2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
\r
6 * Copyright © 2017-2018 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 package org.onap.aai.datarouter.entity;
\r
23 import org.junit.Assert;
\r
24 import org.junit.Test;
\r
25 import org.onap.aai.datarouter.util.CrossEntityReference;
\r
27 import java.io.IOException;
\r
28 import java.security.NoSuchAlgorithmException;
\r
29 import java.util.ArrayList;
\r
30 import java.util.HashMap;
\r
31 import java.util.List;
\r
32 import java.util.Map;
\r
34 public class AaiEventEntityTest {
\r
37 public void testAddCrossEntityReferenceValue(){
\r
38 AaiEventEntity eventEntity = new AaiEventEntity();
\r
39 Assert.assertTrue(eventEntity.crossEntityReferenceCollection.size()==0);
\r
40 eventEntity.addCrossEntityReferenceValue("reference-1");
\r
41 Assert.assertTrue(eventEntity.crossEntityReferenceCollection.size()==1);
\r
45 public void testOtherMethods(){
\r
46 AaiEventEntity eventEntity = new AaiEventEntity();
\r
47 eventEntity.setEntityType("type-1");
\r
48 Assert.assertEquals(eventEntity.getEntityType(), "type-1");
\r
50 eventEntity.setSearchTagCollection(new ArrayList<String>());
\r
51 Assert.assertTrue(eventEntity.getSearchTagCollection().size()==0);
\r
53 eventEntity.setSearchTags("tag-1");
\r
54 Assert.assertEquals(eventEntity.getSearchTags(), "tag-1");
\r
56 eventEntity.setSearchTagIDs("tagid-1");
\r
57 Assert.assertEquals(eventEntity.getSearchTagIDs(), "tagid-1");
\r
59 eventEntity.setId("id-1");
\r
60 Assert.assertEquals(eventEntity.getId(), "id-1");
\r
62 eventEntity.setSearchTagIdCollection(new ArrayList<String>());
\r
63 Assert.assertTrue(eventEntity.getSearchTagIdCollection().size()==0);
\r
65 eventEntity.setLastmodTimestamp("2017-28-12");
\r
66 Assert.assertEquals(eventEntity.getLastmodTimestamp(), "2017-28-12");
\r
68 eventEntity.setLink("link-1");
\r
69 Assert.assertEquals(eventEntity.getLink(), "link-1");
\r
71 eventEntity.setCrossReferenceEntityValues("cross-entity");
\r
72 Assert.assertEquals(eventEntity.getCrossReferenceEntityValues(), "cross-entity");
\r
74 Assert.assertNotNull(eventEntity.toString());
\r
78 public void testAggregationEntity(){
\r
79 AggregationEntity entity = new AggregationEntity();
\r
80 entity.setLastmodTimestamp("2017-28-12");
\r
81 Assert.assertEquals(entity.getLastmodTimestamp(), "2017-28-12");
\r
83 entity.addAttributeKeyValuePair("key1", "value1");
\r
85 Map<String, Object> entityMap = new HashMap<String, Object>();
\r
86 entityMap.put("relationship", "relationship-value");
\r
87 entityMap.put("relationship-list", new ArrayList<String>());
\r
88 entity.copyAttributeKeyValuePair(entityMap);
\r
90 Assert.assertTrue(entity.attributes.containsKey("relationship"));
\r
91 Assert.assertFalse(entity.attributes.containsKey("relationship-list"));
\r
93 entity.setId("id-1");
\r
94 entity.setLink("link-1");
\r
95 Assert.assertNotNull(entity.toString());
\r
99 public void testOxmEntityDescriptor(){
\r
100 OxmEntityDescriptor descriptor = new OxmEntityDescriptor();
\r
101 descriptor.setEntityName("entity-1");
\r
102 Assert.assertEquals(descriptor.getEntityName(), "entity-1");
\r
104 descriptor.setPrimaryKeyAttributeName(new ArrayList<String>());
\r
105 Assert.assertTrue(descriptor.getPrimaryKeyAttributeName().size()==0);
\r
107 Assert.assertFalse(descriptor.hasSearchableAttributes());
\r
109 List<String> searchableAttr = new ArrayList<String>();
\r
110 searchableAttr.add("search");
\r
111 descriptor.setSearchableAttributes(searchableAttr);
\r
112 Assert.assertTrue(descriptor.getSearchableAttributes().size()==1);
\r
114 Assert.assertTrue(descriptor.hasSearchableAttributes());
\r
116 CrossEntityReference ref = new CrossEntityReference();
\r
117 descriptor.setCrossEntityReference(ref);
\r
118 Assert.assertEquals(descriptor.getCrossEntityReference(), ref);
\r
120 descriptor.setSuggestableEntity(true);
\r
121 Assert.assertTrue(descriptor.isSuggestableEntity());
\r
123 Assert.assertNotNull(descriptor.toString());
\r
127 public void testPolicyResponse(){
\r
128 PolicyResponse response = new PolicyResponse(PolicyResponse.ResponseType.SUCCESS, "response-data");
\r
130 Assert.assertEquals(response.getResponseType(), PolicyResponse.ResponseType.SUCCESS);
\r
131 Assert.assertEquals(response.getResponseData(), "response-data");
\r
133 response.setHttpResponseCode(200);
\r
134 Assert.assertTrue(response.getHttpResponseCode() == 200);
\r
136 Assert.assertNotNull(response.toString());
\r
140 public void testTopographicalEntity() throws NoSuchAlgorithmException, IOException {
\r
141 TopographicalEntity entity = new TopographicalEntity();
\r
142 String retStr = entity.generateUniqueShaDigest("entity", "name-1", "value-1");
\r
143 Assert.assertNotNull(retStr);
\r
145 entity.setEntityType("type-1");
\r
146 Assert.assertEquals(entity.getEntityType(),"type-1");
\r
147 entity.setEntityPrimaryKeyName("key-1");
\r
148 Assert.assertEquals(entity.getEntityPrimaryKeyName(), "key-1");
\r
149 entity.setEntityPrimaryKeyValue("value-1");
\r
150 Assert.assertEquals(entity.getEntityPrimaryKeyValue(),"value-1");
\r
151 entity.setLatitude("37.0902");
\r
152 Assert.assertEquals(entity.getLatitude(),"37.0902");
\r
153 entity.setLongitude("95.7129");
\r
154 Assert.assertEquals(entity.getLongitude(),"95.7129");
\r
155 entity.setId("id-1");
\r
156 Assert.assertEquals(entity.getId(),"id-1");
\r
157 entity.setSelfLink("link-1");
\r
158 Assert.assertEquals(entity.getSelfLink(),"link-1");
\r
160 Assert.assertNotNull(TopographicalEntity.getSerialversionuid());
\r
161 Assert.assertNotNull(entity.getAsJson());
\r
162 Assert.assertNotNull(entity.toString());
\r