+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ */\r
+package org.onap.aai.datarouter.entity;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.aai.datarouter.util.CrossEntityReference;\r
+\r
+import java.io.IOException;\r
+import java.security.NoSuchAlgorithmException;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+public class AaiEventEntityTest {\r
+\r
+ @Test\r
+ public void testAddCrossEntityReferenceValue(){\r
+ AaiEventEntity eventEntity = new AaiEventEntity();\r
+ Assert.assertTrue(eventEntity.crossEntityReferenceCollection.size()==0);\r
+ eventEntity.addCrossEntityReferenceValue("reference-1");\r
+ Assert.assertTrue(eventEntity.crossEntityReferenceCollection.size()==1);\r
+ }\r
+\r
+ @Test\r
+ public void testOtherMethods(){\r
+ AaiEventEntity eventEntity = new AaiEventEntity();\r
+ eventEntity.setEntityType("type-1");\r
+ Assert.assertEquals(eventEntity.getEntityType(), "type-1");\r
+\r
+ eventEntity.setSearchTagCollection(new ArrayList<String>());\r
+ Assert.assertTrue(eventEntity.getSearchTagCollection().size()==0);\r
+\r
+ eventEntity.setSearchTags("tag-1");\r
+ Assert.assertEquals(eventEntity.getSearchTags(), "tag-1");\r
+\r
+ eventEntity.setSearchTagIDs("tagid-1");\r
+ Assert.assertEquals(eventEntity.getSearchTagIDs(), "tagid-1");\r
+\r
+ eventEntity.setId("id-1");\r
+ Assert.assertEquals(eventEntity.getId(), "id-1");\r
+\r
+ eventEntity.setSearchTagIdCollection(new ArrayList<String>());\r
+ Assert.assertTrue(eventEntity.getSearchTagIdCollection().size()==0);\r
+\r
+ eventEntity.setLastmodTimestamp("2017-28-12");\r
+ Assert.assertEquals(eventEntity.getLastmodTimestamp(), "2017-28-12");\r
+\r
+ eventEntity.setLink("link-1");\r
+ Assert.assertEquals(eventEntity.getLink(), "link-1");\r
+\r
+ eventEntity.setCrossReferenceEntityValues("cross-entity");\r
+ Assert.assertEquals(eventEntity.getCrossReferenceEntityValues(), "cross-entity");\r
+\r
+ Assert.assertNotNull(eventEntity.toString());\r
+ }\r
+\r
+ @Test\r
+ public void testAggregationEntity(){\r
+ AggregationEntity entity = new AggregationEntity();\r
+ entity.setLastmodTimestamp("2017-28-12");\r
+ Assert.assertEquals(entity.getLastmodTimestamp(), "2017-28-12");\r
+\r
+ entity.addAttributeKeyValuePair("key1", "value1");\r
+\r
+ Map<String, Object> entityMap = new HashMap<String, Object>();\r
+ entityMap.put("relationship", "relationship-value");\r
+ entityMap.put("relationship-list", new ArrayList<String>());\r
+ entity.copyAttributeKeyValuePair(entityMap);\r
+\r
+ Assert.assertTrue(entity.attributes.containsKey("relationship"));\r
+ Assert.assertFalse(entity.attributes.containsKey("relationship-list"));\r
+\r
+ entity.setId("id-1");\r
+ entity.setLink("link-1");\r
+ Assert.assertNotNull(entity.toString());\r
+ }\r
+\r
+ @Test\r
+ public void testOxmEntityDescriptor(){\r
+ OxmEntityDescriptor descriptor = new OxmEntityDescriptor();\r
+ descriptor.setEntityName("entity-1");\r
+ Assert.assertEquals(descriptor.getEntityName(), "entity-1");\r
+\r
+ descriptor.setPrimaryKeyAttributeName(new ArrayList<String>());\r
+ Assert.assertTrue(descriptor.getPrimaryKeyAttributeName().size()==0);\r
+\r
+ Assert.assertFalse(descriptor.hasSearchableAttributes());\r
+\r
+ List<String> searchableAttr = new ArrayList<String>();\r
+ searchableAttr.add("search");\r
+ descriptor.setSearchableAttributes(searchableAttr);\r
+ Assert.assertTrue(descriptor.getSearchableAttributes().size()==1);\r
+\r
+ Assert.assertTrue(descriptor.hasSearchableAttributes());\r
+\r
+ CrossEntityReference ref = new CrossEntityReference();\r
+ descriptor.setCrossEntityReference(ref);\r
+ Assert.assertEquals(descriptor.getCrossEntityReference(), ref);\r
+\r
+ descriptor.setSuggestableEntity(true);\r
+ Assert.assertTrue(descriptor.isSuggestableEntity());\r
+\r
+ Assert.assertNotNull(descriptor.toString());\r
+ }\r
+\r
+ @Test\r
+ public void testPolicyResponse(){\r
+ PolicyResponse response = new PolicyResponse(PolicyResponse.ResponseType.SUCCESS, "response-data");\r
+\r
+ Assert.assertEquals(response.getResponseType(), PolicyResponse.ResponseType.SUCCESS);\r
+ Assert.assertEquals(response.getResponseData(), "response-data");\r
+\r
+ response.setHttpResponseCode(200);\r
+ Assert.assertTrue(response.getHttpResponseCode() == 200);\r
+\r
+ Assert.assertNotNull(response.toString());\r
+ }\r
+\r
+ @Test\r
+ public void testTopographicalEntity() throws NoSuchAlgorithmException, IOException {\r
+ TopographicalEntity entity = new TopographicalEntity();\r
+ String retStr = entity.generateUniqueShaDigest("entity", "name-1", "value-1");\r
+ Assert.assertNotNull(retStr);\r
+\r
+ entity.setEntityType("type-1");\r
+ Assert.assertEquals(entity.getEntityType(),"type-1");\r
+ entity.setEntityPrimaryKeyName("key-1");\r
+ Assert.assertEquals(entity.getEntityPrimaryKeyName(), "key-1");\r
+ entity.setEntityPrimaryKeyValue("value-1");\r
+ Assert.assertEquals(entity.getEntityPrimaryKeyValue(),"value-1");\r
+ entity.setLatitude("37.0902");\r
+ Assert.assertEquals(entity.getLatitude(),"37.0902");\r
+ entity.setLongitude("95.7129");\r
+ Assert.assertEquals(entity.getLongitude(),"95.7129");\r
+ entity.setId("id-1");\r
+ Assert.assertEquals(entity.getId(),"id-1");\r
+ entity.setSelfLink("link-1");\r
+ Assert.assertEquals(entity.getSelfLink(),"link-1");\r
+\r
+ Assert.assertNotNull(TopographicalEntity.getSerialversionuid());\r
+ Assert.assertNotNull(entity.getAsJson());\r
+ Assert.assertNotNull(entity.toString());\r
+ }\r
+}\r