2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * Copyright © 2017 Amdocs
\r
7 * ================================================================================
\r
8 * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * you may not use this file except in compliance with the License.
\r
10 * You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing, software
\r
15 * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * See the License for the specific language governing permissions and
\r
18 * limitations under the License.
\r
19 * ============LICENSE_END=========================================================
\r
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
23 package org.onap.aai.datarouter.entity;
\r
25 import org.junit.Assert;
\r
26 import org.junit.Test;
\r
27 import org.onap.aai.datarouter.util.CrossEntityReference;
\r
29 import java.io.IOException;
\r
30 import java.security.NoSuchAlgorithmException;
\r
31 import java.util.ArrayList;
\r
32 import java.util.HashMap;
\r
33 import java.util.List;
\r
34 import java.util.Map;
\r
36 public class AaiEventEntityTest {
\r
39 public void testAddCrossEntityReferenceValue(){
\r
40 AaiEventEntity eventEntity = new AaiEventEntity();
\r
41 Assert.assertTrue(eventEntity.crossEntityReferenceCollection.size()==0);
\r
42 eventEntity.addCrossEntityReferenceValue("reference-1");
\r
43 Assert.assertTrue(eventEntity.crossEntityReferenceCollection.size()==1);
\r
47 public void testOtherMethods(){
\r
48 AaiEventEntity eventEntity = new AaiEventEntity();
\r
49 eventEntity.setEntityType("type-1");
\r
50 Assert.assertEquals(eventEntity.getEntityType(), "type-1");
\r
52 eventEntity.setSearchTagCollection(new ArrayList<String>());
\r
53 Assert.assertTrue(eventEntity.getSearchTagCollection().size()==0);
\r
55 eventEntity.setSearchTags("tag-1");
\r
56 Assert.assertEquals(eventEntity.getSearchTags(), "tag-1");
\r
58 eventEntity.setSearchTagIDs("tagid-1");
\r
59 Assert.assertEquals(eventEntity.getSearchTagIDs(), "tagid-1");
\r
61 eventEntity.setId("id-1");
\r
62 Assert.assertEquals(eventEntity.getId(), "id-1");
\r
64 eventEntity.setSearchTagIdCollection(new ArrayList<String>());
\r
65 Assert.assertTrue(eventEntity.getSearchTagIdCollection().size()==0);
\r
67 eventEntity.setLastmodTimestamp("2017-28-12");
\r
68 Assert.assertEquals(eventEntity.getLastmodTimestamp(), "2017-28-12");
\r
70 eventEntity.setLink("link-1");
\r
71 Assert.assertEquals(eventEntity.getLink(), "link-1");
\r
73 eventEntity.setCrossReferenceEntityValues("cross-entity");
\r
74 Assert.assertEquals(eventEntity.getCrossReferenceEntityValues(), "cross-entity");
\r
76 Assert.assertNotNull(eventEntity.toString());
\r
80 public void testAggregationEntity(){
\r
81 AggregationEntity entity = new AggregationEntity();
\r
82 entity.setLastmodTimestamp("2017-28-12");
\r
83 Assert.assertEquals(entity.getLastmodTimestamp(), "2017-28-12");
\r
85 entity.addAttributeKeyValuePair("key1", "value1");
\r
87 Map<String, Object> entityMap = new HashMap<String, Object>();
\r
88 entityMap.put("relationship", "relationship-value");
\r
89 entityMap.put("relationship-list", new ArrayList<String>());
\r
90 entity.copyAttributeKeyValuePair(entityMap);
\r
92 Assert.assertTrue(entity.attributes.containsKey("relationship"));
\r
93 Assert.assertFalse(entity.attributes.containsKey("relationship-list"));
\r
95 entity.setId("id-1");
\r
96 entity.setLink("link-1");
\r
97 Assert.assertNotNull(entity.toString());
\r
101 public void testOxmEntityDescriptor(){
\r
102 OxmEntityDescriptor descriptor = new OxmEntityDescriptor();
\r
103 descriptor.setEntityName("entity-1");
\r
104 Assert.assertEquals(descriptor.getEntityName(), "entity-1");
\r
106 descriptor.setPrimaryKeyAttributeName(new ArrayList<String>());
\r
107 Assert.assertTrue(descriptor.getPrimaryKeyAttributeName().size()==0);
\r
109 Assert.assertFalse(descriptor.hasSearchableAttributes());
\r
111 List<String> searchableAttr = new ArrayList<String>();
\r
112 searchableAttr.add("search");
\r
113 descriptor.setSearchableAttributes(searchableAttr);
\r
114 Assert.assertTrue(descriptor.getSearchableAttributes().size()==1);
\r
116 Assert.assertTrue(descriptor.hasSearchableAttributes());
\r
118 CrossEntityReference ref = new CrossEntityReference();
\r
119 descriptor.setCrossEntityReference(ref);
\r
120 Assert.assertEquals(descriptor.getCrossEntityReference(), ref);
\r
122 descriptor.setSuggestableEntity(true);
\r
123 Assert.assertTrue(descriptor.isSuggestableEntity());
\r
125 Assert.assertNotNull(descriptor.toString());
\r
129 public void testPolicyResponse(){
\r
130 PolicyResponse response = new PolicyResponse(PolicyResponse.ResponseType.SUCCESS, "response-data");
\r
132 Assert.assertEquals(response.getResponseType(), PolicyResponse.ResponseType.SUCCESS);
\r
133 Assert.assertEquals(response.getResponseData(), "response-data");
\r
135 response.setHttpResponseCode(200);
\r
136 Assert.assertTrue(response.getHttpResponseCode() == 200);
\r
138 Assert.assertNotNull(response.toString());
\r
142 public void testTopographicalEntity() throws NoSuchAlgorithmException, IOException {
\r
143 TopographicalEntity entity = new TopographicalEntity();
\r
144 String retStr = entity.generateUniqueShaDigest("entity", "name-1", "value-1");
\r
145 Assert.assertNotNull(retStr);
\r
147 entity.setEntityType("type-1");
\r
148 Assert.assertEquals(entity.getEntityType(),"type-1");
\r
149 entity.setEntityPrimaryKeyName("key-1");
\r
150 Assert.assertEquals(entity.getEntityPrimaryKeyName(), "key-1");
\r
151 entity.setEntityPrimaryKeyValue("value-1");
\r
152 Assert.assertEquals(entity.getEntityPrimaryKeyValue(),"value-1");
\r
153 entity.setLatitude("37.0902");
\r
154 Assert.assertEquals(entity.getLatitude(),"37.0902");
\r
155 entity.setLongitude("95.7129");
\r
156 Assert.assertEquals(entity.getLongitude(),"95.7129");
\r
157 entity.setId("id-1");
\r
158 Assert.assertEquals(entity.getId(),"id-1");
\r
159 entity.setSelfLink("link-1");
\r
160 Assert.assertEquals(entity.getSelfLink(),"link-1");
\r
162 Assert.assertNotNull(TopographicalEntity.getSerialversionuid());
\r
163 Assert.assertNotNull(entity.getAsJson());
\r
164 Assert.assertNotNull(entity.toString());
\r