diff options
author | Jim Hahn <jrh3@att.com> | 2019-06-13 10:39:55 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-06-17 10:50:16 -0400 |
commit | d37c71292d9cbdd892f328d63f49a8027b1f13c4 (patch) | |
tree | 615a8af45285d1032a02af1214c76b938c58044d /models-interactions/model-impl/aai/src | |
parent | f59ec395bf1e41df894f884e70ff3185280668c0 (diff) |
Fix simple sonar issues in models
Added @FunctionalInterface where needed.
Replaced anonymous classes with lambda expressions.
Replaced duplicate strings with a constant.
Removed unused BeforeClass & AfterClass test methods.
Removed some trailing spaces.
Fixed:
aai
actor.appc
actor.appclcm
actor.sdnc
actor.sdnr
actor.so
actor.vfc
actorServiceProvider
appc
appclcm
cds
events
Change-Id: I0e21cbb10db6d1217bbd0e00e6dd4fac3eb84e31
Issue-ID: POLICY-1791
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-impl/aai/src')
23 files changed, 172 insertions, 272 deletions
diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java index 2b51a7bde..20998ae0c 100644 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java @@ -45,6 +45,8 @@ public final class AaiManager { /** The Constant logger. */ private static final Logger logger = LoggerFactory.getLogger(AaiManager.class); + private static final String APPLICATION_JSON = "application/json"; + /** The rest manager. */ // The REST manager used for processing REST calls for this AAI manager private final RestManager restManager; @@ -77,7 +79,7 @@ public final class AaiManager { return null; } else { JSONObject responseObj = new JSONObject(getResponse); - JSONArray resultsArray = new JSONArray(); + JSONArray resultsArray; if (responseObj.has("result-data")) { resultsArray = (JSONArray) responseObj.get("result-data"); } else { @@ -138,7 +140,7 @@ public final class AaiManager { url = url + CQ_URL; Pair<Integer, String> httpDetails = - this.restManager.put(url, username, password, headers, "application/json", requestJson); + this.restManager.put(url, username, password, headers, APPLICATION_JSON, requestJson); logger.debug("RestManager.put after"); if (httpDetails == null) { @@ -232,7 +234,7 @@ public final class AaiManager { String requestJson = Serialization.gsonPretty.toJson(request); NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, requestJson); Pair<Integer, String> httpDetails = - restManager.post(url, username, password, headers, "application/json", requestJson); + restManager.post(url, username, password, headers, APPLICATION_JSON, requestJson); logger.debug("RestManager.post after"); if (httpDetails == null) { @@ -360,7 +362,7 @@ public final class AaiManager { headers.put("X-FromAppId", "POLICY"); headers.put("X-TransactionId", requestId.toString()); - headers.put("Accept", "application/json"); + headers.put("Accept", APPLICATION_JSON); return headers; } diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiCqResponseTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiCqResponseTest.java index efdba10a3..8335ce80b 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiCqResponseTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiCqResponseTest.java @@ -40,6 +40,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AaiCqResponseTest { + private static final String ETE_VFMODULE = "Vfmodule_Ete_vFWCLvFWSNK_7ba1fbde_0"; + private static final String ETE_VNF = "Ete_vFWCLvFWSNK_7ba1fbde_0"; private static final Logger LOGGER = LoggerFactory.getLogger(AaiCqResponseTest.class); private static final String CQ_RESPONSE_SAMPLE = "src/test/resources/org/onap/policy/aai/AaiCqResponseFull.json"; @@ -168,7 +170,7 @@ public class AaiCqResponseTest { aaiCqResponse = new AaiCqResponse(responseString); GenericVnf genVnf = aaiCqResponse.getDefaultGenericVnf(); assertNotNull(genVnf); - assertEquals("Ete_vFWCLvFWSNK_7ba1fbde_0", genVnf.getVnfName()); + assertEquals(ETE_VNF, genVnf.getVnfName()); LOGGER.info(genVnf.getVnfName()); } @@ -181,7 +183,7 @@ public class AaiCqResponseTest { AaiCqResponse aaiCqResponse; aaiCqResponse = new AaiCqResponse(responseString); - GenericVnf genVnf = aaiCqResponse.getGenericVnfByVnfName("Ete_vFWCLvFWSNK_7ba1fbde_0"); + GenericVnf genVnf = aaiCqResponse.getGenericVnfByVnfName(ETE_VNF); assertNotNull(genVnf); assertEquals("f17face5-69cb-4c88-9e0b-7426db7edddd", genVnf.getVnfId()); LOGGER.info(genVnf.getVnfId()); @@ -214,7 +216,7 @@ public class AaiCqResponseTest { GenericVnf genVnf = aaiCqResponse.getGenericVnfByVfModuleModelInvariantId("e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e"); assertNotNull(genVnf); - assertEquals("Ete_vFWCLvFWSNK_7ba1fbde_0", genVnf.getVnfName()); + assertEquals(ETE_VNF, genVnf.getVnfName()); LOGGER.info(genVnf.getVnfName()); } @@ -245,9 +247,9 @@ public class AaiCqResponseTest { AaiCqResponse aaiCqResponse; aaiCqResponse = new AaiCqResponse(responseString); - VfModule vfModule = aaiCqResponse.getVfModuleByVfModuleName("Vfmodule_Ete_vFWCLvFWSNK_7ba1fbde_0"); + VfModule vfModule = aaiCqResponse.getVfModuleByVfModuleName(ETE_VFMODULE); assertNotNull(vfModule); - assertEquals("Vfmodule_Ete_vFWCLvFWSNK_7ba1fbde_0", vfModule.getVfModuleName()); + assertEquals(ETE_VFMODULE, vfModule.getVfModuleName()); LOGGER.info(vfModule.getVfModuleName()); @@ -263,7 +265,7 @@ public class AaiCqResponseTest { aaiCqResponse = new AaiCqResponse(responseString); VfModule vfModule = aaiCqResponse.getVfModuleByVfModelInvariantId("e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e"); assertNotNull(vfModule); - assertEquals("Vfmodule_Ete_vFWCLvFWSNK_7ba1fbde_0", vfModule.getVfModuleName()); + assertEquals(ETE_VFMODULE, vfModule.getVfModuleName()); LOGGER.info(vfModule.getVfModuleName()); @@ -279,7 +281,7 @@ public class AaiCqResponseTest { aaiCqResponse = new AaiCqResponse(responseString); VfModule vfModule = aaiCqResponse.getDefaultVfModule(); assertNotNull(vfModule); - assertEquals("Vfmodule_Ete_vFWCLvFWSNK_7ba1fbde_0", vfModule.getVfModuleName()); + assertEquals(ETE_VFMODULE, vfModule.getVfModuleName()); LOGGER.info(vfModule.getVfModuleName()); } @@ -293,7 +295,7 @@ public class AaiCqResponseTest { aaiCqResponse = new AaiCqResponse(responseString); Vserver vserver = aaiCqResponse.getVserver(); assertNotNull(vserver); - assertEquals("Ete_vFWCLvFWSNK_7ba1fbde_0", vserver.getVserverName()); + assertEquals(ETE_VNF, vserver.getVserverName()); LOGGER.info(vserver.getVserverName()); } diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java index 7842b076c..9a8d7d260 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java @@ -44,6 +44,12 @@ import org.onap.policy.rest.RestManager; import org.onap.policy.rest.RestManager.Pair; public class AaiManagerTest { + private static final String VSERVER_NAME = "vserverName"; + private static final String CQ_QUERY_URL = "http://testing.cq.query"; + private static final String WITCH = "Witch"; + private static final String DOROTHY = "Dorothy"; + private static final String SOME_URL = "http://somewhere.over.the.rainbow"; + private static final String ANOTHER_URL = "http://somewhere.under.the.rainbow"; RestManager restManagerMock; UUID aaiNqRequestUuid = UUID.randomUUID(); Pair<Integer, String> httpResponseOk; @@ -92,14 +98,14 @@ public class AaiManagerTest { UUID vserverNameRequestId = UUID.randomUUID(); - when(restManagerMock.put(startsWith("http://testing.cq.query"), eq("Foo"), eq("Bar"), anyMap(), anyString(), + when(restManagerMock.put(startsWith(CQ_QUERY_URL), eq("Foo"), eq("Bar"), anyMap(), anyString(), anyString())).thenReturn(httpCqResponseOk); - when(restManagerMock.get(startsWith("http://testing.cq.query"), eq("Foo"), eq("Bar"), anyMap())) + when(restManagerMock.get(startsWith(CQ_QUERY_URL), eq("Foo"), eq("Bar"), anyMap())) .thenReturn(httpTenantResponseOk); AaiCqResponse aaiCqResponse = - aaiManager.getCustomQueryResponse("http://testing.cq.query", "Foo", "Bar", vserverNameRequestId, "Foo"); + aaiManager.getCustomQueryResponse(CQ_QUERY_URL, "Foo", "Bar", vserverNameRequestId, "Foo"); assertNotNull(aaiCqResponse); when(restManagerMock.put(eq(""), eq("Foo"), eq("Bar"), anyMap(), anyString(), anyString())) @@ -146,30 +152,30 @@ public class AaiManagerTest { AaiNqRequest aaiNqRequest = new AaiNqRequest(); aaiNqRequest.setQueryParameters(aaiNqQueryParameters); - when(restManagerMock.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Gale"), anyMap(), + when(restManagerMock.post(startsWith(SOME_URL), eq(DOROTHY), eq("Gale"), anyMap(), anyString(), anyString())).thenReturn(httpResponseOk); - AaiNqResponse aaiNqOkResponse = aaiManager.postQuery("http://somewhere.over.the.rainbow", "Dorothy", "Gale", + AaiNqResponse aaiNqOkResponse = aaiManager.postQuery(SOME_URL, DOROTHY, "Gale", aaiNqRequest, aaiNqRequestUuid); assertNotNull(aaiNqOkResponse); - when(restManagerMock.post(isNull(), eq("Dorothy"), anyString(), anyMap(), anyString(), anyString())) + when(restManagerMock.post(isNull(), eq(DOROTHY), anyString(), anyMap(), anyString(), anyString())) .thenReturn(null); - AaiNqResponse aaiNqNullResponse = aaiManager.postQuery(null, "Dorothy", "Gale", null, aaiNqRequestUuid); + AaiNqResponse aaiNqNullResponse = aaiManager.postQuery(null, DOROTHY, "Gale", null, aaiNqRequestUuid); assertNull(aaiNqNullResponse); - when(restManagerMock.post(startsWith("http://somewhere.over.the.rainbow"), eq("Witch"), eq("West"), anyMap(), + when(restManagerMock.post(startsWith(SOME_URL), eq(WITCH), eq("West"), anyMap(), anyString(), anyString())).thenReturn(httpResponseErr0); - AaiNqResponse aaiNqNotOkResponse0 = aaiManager.postQuery("http://somewhere.over.the.rainbow", "Witch", "West", + AaiNqResponse aaiNqNotOkResponse0 = aaiManager.postQuery(SOME_URL, WITCH, "West", aaiNqRequest, aaiNqRequestUuid); assertNull(aaiNqNotOkResponse0); - when(restManagerMock.post(startsWith("http://somewhere.under.the.rainbow"), eq("Witch"), eq("West"), anyMap(), + when(restManagerMock.post(startsWith(ANOTHER_URL), eq(WITCH), eq("West"), anyMap(), anyString(), anyString())).thenReturn(httpResponseErr1); - AaiNqResponse aaiNqNotOkResponse1 = aaiManager.postQuery("http://somewhere.under.the.rainbow", "Witch", "West", + AaiNqResponse aaiNqNotOkResponse1 = aaiManager.postQuery(ANOTHER_URL, WITCH, "West", aaiNqRequest, aaiNqRequestUuid); assertNull(aaiNqNotOkResponse1); } @@ -181,22 +187,22 @@ public class AaiManagerTest { UUID vserverNameRequestId = UUID.randomUUID(); - when(restManagerMock.get(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Gale"), anyMap())) + when(restManagerMock.get(startsWith(SOME_URL), eq(DOROTHY), eq("Gale"), anyMap())) .thenReturn(httpResponseOk); - AaiGetVserverResponse vserverResponse = aaiManager.getQueryByVserverName("http://somewhere.over.the.rainbow", - "Dorothy", "Gale", vserverNameRequestId, "vserverName"); + AaiGetVserverResponse vserverResponse = aaiManager.getQueryByVserverName(SOME_URL, + DOROTHY, "Gale", vserverNameRequestId, VSERVER_NAME); assertNotNull(vserverResponse); AaiGetVserverResponse vserverNullResponse = - aaiManager.getQueryByVserverName(null, "Dorothy", "Gale", vserverNameRequestId, "vserverName"); + aaiManager.getQueryByVserverName(null, DOROTHY, "Gale", vserverNameRequestId, VSERVER_NAME); assertNull(vserverNullResponse); - when(restManagerMock.get(startsWith("http://somewhere.under.the.rainbow"), eq("Witch"), eq("West"), anyMap())) + when(restManagerMock.get(startsWith(ANOTHER_URL), eq(WITCH), eq("West"), anyMap())) .thenReturn(httpResponseErr0); AaiGetVserverResponse vserverNotOkResponse0 = aaiManager.getQueryByVserverName( - "http://somewhere.under.the.rainbow", "Witch", "West", vserverNameRequestId, "vserverName"); + ANOTHER_URL, WITCH, "West", vserverNameRequestId, VSERVER_NAME); assertNull(vserverNotOkResponse0); } @@ -207,10 +213,10 @@ public class AaiManagerTest { UUID vserverNameRequestId = UUID.randomUUID(); - when(restManagerMock.get(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Gale"), anyMap())) + when(restManagerMock.get(startsWith(SOME_URL), eq(DOROTHY), eq("Gale"), anyMap())) .thenReturn(httpResponseOk); - AaiGetVnfResponse vnfResponse = aaiManager.getQueryByVnfId("http://somewhere.over.the.rainbow", "Dorothy", + AaiGetVnfResponse vnfResponse = aaiManager.getQueryByVnfId(SOME_URL, DOROTHY, "Gale", vserverNameRequestId, "vnfID"); assertNotNull(vnfResponse); } @@ -222,10 +228,10 @@ public class AaiManagerTest { UUID vserverNameRequestId = UUID.randomUUID(); - when(restManagerMock.get(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Gale"), anyMap())) + when(restManagerMock.get(startsWith(SOME_URL), eq(DOROTHY), eq("Gale"), anyMap())) .thenReturn(httpResponseOk); - AaiGetVnfResponse vnfResponse = aaiManager.getQueryByVnfId("http://somewhere.over.the.rainbow", "Dorothy", + AaiGetVnfResponse vnfResponse = aaiManager.getQueryByVnfId(SOME_URL, DOROTHY, "Gale", vserverNameRequestId, "vnfName"); assertNotNull(vnfResponse); } diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java index 6932031db..9bdc758ed 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java @@ -24,18 +24,10 @@ package org.onap.policy.aai; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; public class AaiNqCloudRegionTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { AaiNqCloudRegion aaiNqCloudRegion = new AaiNqCloudRegion(); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java index e1ac2379c..ed76f8a12 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java @@ -23,18 +23,10 @@ package org.onap.policy.aai; import static org.junit.Assert.assertNotNull; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; public class AaiNqExtraPropertiesTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { AaiNqExtraProperties aaiNqExtraProperties = new AaiNqExtraProperties(); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java index ebc64efc9..483753679 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java @@ -24,18 +24,10 @@ package org.onap.policy.aai; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; public class AaiNqExtraPropertyTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { AaiNqExtraProperty aaiNqExtraProperty = new AaiNqExtraProperty(); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java index e30bcaf86..93119c73e 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java @@ -24,17 +24,12 @@ package org.onap.policy.aai; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; public class AaiNqGenericVnfTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} + private static final String VERSION_ID = "98f410f6-4c63-447b-97d2-42508437cec0"; + private static final String INVARIANT_ID = "653d2caa-7e47-4614-95b3-26c8d82755b8"; @Test public void test() { @@ -44,12 +39,12 @@ public class AaiNqGenericVnfTest { aaiNqGenericVnf.setIpv4Loopback0Address("aa"); aaiNqGenericVnf.setIpv4OamAddress("oamAddress"); aaiNqGenericVnf.setIsClosedLoopDisabled(false); - aaiNqGenericVnf.setModelInvariantId("653d2caa-7e47-4614-95b3-26c8d82755b8"); - aaiNqGenericVnf.setModelVersionId("98f410f6-4c63-447b-97d2-42508437cec0"); + aaiNqGenericVnf.setModelInvariantId(INVARIANT_ID); + aaiNqGenericVnf.setModelVersionId(VERSION_ID); aaiNqGenericVnf.setModelCustomizationId("SomeCustomizationId"); aaiNqGenericVnf.setOperationalState("active"); - aaiNqGenericVnf.setPersonaModelId("653d2caa-7e47-4614-95b3-26c8d82755b8"); - aaiNqGenericVnf.setPersonaModelVersion("98f410f6-4c63-447b-97d2-42508437cec0"); + aaiNqGenericVnf.setPersonaModelId(INVARIANT_ID); + aaiNqGenericVnf.setPersonaModelVersion(VERSION_ID); aaiNqGenericVnf.setProvStatus("complete"); aaiNqGenericVnf.setResourceVersion("1505056714553"); aaiNqGenericVnf.setServiceId("e8cb8968-5411-478b-906a-f28747de72cd"); @@ -64,12 +59,12 @@ public class AaiNqGenericVnfTest { assertEquals("aa", aaiNqGenericVnf.getIpv4Loopback0Address()); assertEquals("oamAddress", aaiNqGenericVnf.getIpv4OamAddress()); assertEquals(false, aaiNqGenericVnf.getIsClosedLoopDisabled()); - assertEquals("653d2caa-7e47-4614-95b3-26c8d82755b8", aaiNqGenericVnf.getModelInvariantId()); - assertEquals("98f410f6-4c63-447b-97d2-42508437cec0", aaiNqGenericVnf.getModelVersionId()); + assertEquals(INVARIANT_ID, aaiNqGenericVnf.getModelInvariantId()); + assertEquals(VERSION_ID, aaiNqGenericVnf.getModelVersionId()); assertEquals("SomeCustomizationId", aaiNqGenericVnf.getModelCustomizationId()); assertEquals("active", aaiNqGenericVnf.getOperationalState()); - assertEquals("653d2caa-7e47-4614-95b3-26c8d82755b8", aaiNqGenericVnf.getPersonaModelId()); - assertEquals("98f410f6-4c63-447b-97d2-42508437cec0", aaiNqGenericVnf.getPersonaModelVersion()); + assertEquals(INVARIANT_ID, aaiNqGenericVnf.getPersonaModelId()); + assertEquals(VERSION_ID, aaiNqGenericVnf.getPersonaModelVersion()); assertEquals("complete", aaiNqGenericVnf.getProvStatus()); assertEquals("1505056714553", aaiNqGenericVnf.getResourceVersion()); assertEquals("e8cb8968-5411-478b-906a-f28747de72cd", aaiNqGenericVnf.getServiceId()); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java index 0c487d437..4b4cc6a6a 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java @@ -23,18 +23,10 @@ package org.onap.policy.aai; import static org.junit.Assert.assertNotNull; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; public class AaiNqInstanceFiltersTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { AaiNqInstanceFilters aaiNqInstanceFilters = new AaiNqInstanceFilters(); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java index 97384db76..79f23b629 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java @@ -24,27 +24,27 @@ package org.onap.policy.aai; import static org.junit.Assert.assertNotNull; import java.util.LinkedList; - -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.util.Serialization; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AaiNqInventoryResponseItemTest { + private static final String WIDGET = "widget"; + private static final String SERVICE_INSTANCE = "service-instance"; + private static final String MODEL_VERSION_KEY = "model.model-version"; + private static final String MODEL_TYPE_KEY = "model.model-type"; + private static final String MODEL_NAME_KEY = "model.model-name"; + private static final String MODEL_ID_KEY = "model.model-id"; + private static final String PERSONA_MODEL_ID2 = "ef86f9c5-2165-44f3-8fc3-96018b609ea5"; + private static final String PERSONA_MODEL_ID = "82194af1-3c2c-485a-8f44-420e22a9eaa4"; + private static final String RESOURCE_VERSION = "1485366450"; private static final Logger logger = LoggerFactory.getLogger(AaiNqInventoryResponseItemTest.class); - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { AaiNqInventoryResponseItem aaiNqInventoryResponseItem = new AaiNqInventoryResponseItem(); - aaiNqInventoryResponseItem.setModelName("service-instance"); + aaiNqInventoryResponseItem.setModelName(SERVICE_INSTANCE); AaiNqCloudRegion aaiNqCloudRegion = new AaiNqCloudRegion(); aaiNqCloudRegion.setCloudOwner("OWNER"); aaiNqCloudRegion.setCloudRegionId("REGIONID"); @@ -54,11 +54,11 @@ public class AaiNqInventoryResponseItemTest { aaiNqInventoryResponseItem.setCloudRegion(aaiNqCloudRegion); AaiNqExtraProperties aaiNqExtraProperties = new AaiNqExtraProperties(); aaiNqExtraProperties.setExtraProperty(new LinkedList<>()); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty("model.model-name", "generic-vnf")); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty(MODEL_NAME_KEY, "generic-vnf")); + aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); + aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); aaiNqExtraProperties.getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); + .add(new AaiNqExtraProperty(MODEL_ID_KEY, "acc6edd8-a8d4-4b93-afaa-0994068be14c")); aaiNqExtraProperties.getExtraProperty() .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); aaiNqInventoryResponseItem.setExtraProperties(aaiNqExtraProperties); @@ -74,29 +74,29 @@ public class AaiNqInventoryResponseItemTest { aaiNqGenericVnf.setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); aaiNqGenericVnf.setInMaint(false); aaiNqGenericVnf.setIsClosedLoopDisabled(false); - aaiNqGenericVnf.setResourceVersion("1485366450"); + aaiNqGenericVnf.setResourceVersion(RESOURCE_VERSION); aaiNqGenericVnf.setEncrypedAccessFlag(true); aaiNqGenericVnf.setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); aaiNqGenericVnf.setPersonaModelVersion("1.0"); aaiNqInventoryResponseItem.setGenericVnf(aaiNqGenericVnf); AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); - serviceItem.setModelName("service-instance"); + serviceItem.setModelName(SERVICE_INSTANCE); serviceItem.setServiceInstance(new AaiNqServiceInstance()); serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); - serviceItem.getServiceInstance().setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); + serviceItem.getServiceInstance().setPersonaModelId(PERSONA_MODEL_ID); serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); serviceItem.getServiceInstance().setResourceVersion("1485366092"); serviceItem.setExtraProperties(new AaiNqExtraProperties()); serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "service-instance")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, SERVICE_INSTANCE)); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + .add(new AaiNqExtraProperty(MODEL_ID_KEY, PERSONA_MODEL_ID)); serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "46b92144-923a-4d20-b85a-3cbd847668a9")); AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); vfModuleItem.setModelName("vf-module"); @@ -106,21 +106,21 @@ public class AaiNqInventoryResponseItemTest { vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); vfModuleItem.getVfModule().setIsBaseVfModule(true); - vfModuleItem.getVfModule().setResourceVersion("1485366450"); - vfModuleItem.getVfModule().setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); + vfModuleItem.getVfModule().setResourceVersion(RESOURCE_VERSION); + vfModuleItem.getVfModule().setPersonaModelId(PERSONA_MODEL_ID2); vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "vf-module")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "vf-module")); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); + .add(new AaiNqExtraProperty(MODEL_ID_KEY, PERSONA_MODEL_ID2)); vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "c00563ae-812b-4e62-8330-7c4d0f47088a")); AaiNqInventoryResponseItems aaiNqInventoryResponseItems = new AaiNqInventoryResponseItems(); aaiNqInventoryResponseItems.getInventoryResponseItems().add(serviceItem); @@ -130,7 +130,7 @@ public class AaiNqInventoryResponseItemTest { AaiNqServiceInstance serviceInstance = new AaiNqServiceInstance(); serviceInstance.setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); serviceInstance.setServiceInstanceName("dhv-test-service-instance-name1"); - serviceInstance.setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); + serviceInstance.setPersonaModelId(PERSONA_MODEL_ID); serviceInstance.setPersonaModelVersion("1.0"); serviceInstance.setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); serviceInstance.setResourceVersion("1485366092"); @@ -146,8 +146,8 @@ public class AaiNqInventoryResponseItemTest { aaiNqVfModule.setHeatStackId("example-heat-stack-id-val-86300"); aaiNqVfModule.setOrchestrationStatus("example-orchestration-status-val-56523"); aaiNqVfModule.setIsBaseVfModule(true); - aaiNqVfModule.setResourceVersion("1485366450"); - aaiNqVfModule.setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); + aaiNqVfModule.setResourceVersion(RESOURCE_VERSION); + aaiNqVfModule.setPersonaModelId(PERSONA_MODEL_ID2); aaiNqVfModule.setPersonaModelVersion("1.0"); aaiNqVfModule.setWidgetModelId("example-widget-model-id-val-92571"); aaiNqVfModule.setWidgetModelVersion("example-widget-model-version-val-83317"); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java index f43d7c777..ef1dd4e09 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java @@ -25,28 +25,25 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.LinkedList; - -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.util.Serialization; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AaiNqInventoryResponseItemsTest { + private static final String WIDGET = "widget"; + private static final String SERVICE_INSTANCE = "service-instance"; + private static final String MODEL_VERSION_KEY = "model.model-version"; + private static final String MODEL_TYPE_KEY = "model.model-type"; + private static final String MODEL_NAME_KEY = "model.model-name"; + private static final String MODEL_ID_KEY = "model.model-id"; private static final Logger logger = LoggerFactory.getLogger(AaiNqInventoryResponseItemsTest.class); - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); - serviceItem.setModelName("service-instance"); - assertEquals("service-instance", serviceItem.getModelName()); + serviceItem.setModelName(SERVICE_INSTANCE); + assertEquals(SERVICE_INSTANCE, serviceItem.getModelName()); serviceItem.setServiceInstance(new AaiNqServiceInstance()); serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); @@ -57,13 +54,13 @@ public class AaiNqInventoryResponseItemsTest { serviceItem.getServiceInstance().setResourceVersion("1485366092"); serviceItem.setExtraProperties(new AaiNqExtraProperties()); serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "service-instance")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, SERVICE_INSTANCE)); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + .add(new AaiNqExtraProperty(MODEL_ID_KEY, "82194af1-3c2c-485a-8f44-420e22a9eaa4")); serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "46b92144-923a-4d20-b85a-3cbd847668a9")); AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); vfModuleItem.setModelName("vf-module"); @@ -81,13 +78,13 @@ public class AaiNqInventoryResponseItemsTest { vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "vf-module")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "vf-module")); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); + .add(new AaiNqExtraProperty(MODEL_ID_KEY, "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "c00563ae-812b-4e62-8330-7c4d0f47088a")); AaiNqInventoryResponseItem genericVnfItem = new AaiNqInventoryResponseItem(); genericVnfItem.setModelName("generic-vnf"); @@ -110,13 +107,13 @@ public class AaiNqInventoryResponseItemsTest { genericVnfItem.setExtraProperties(new AaiNqExtraProperties()); genericVnfItem.getExtraProperties().setExtraProperty(new LinkedList<>()); genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "generic-vnf")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "generic-vnf")); genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-type", "widget")); + .add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-version", "1.0")); + .add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); + .add(new AaiNqExtraProperty(MODEL_ID_KEY, "acc6edd8-a8d4-4b93-afaa-0994068be14c")); genericVnfItem.getExtraProperties().getExtraProperty() .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); genericVnfItem.setItems(new AaiNqInventoryResponseItems()); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java index 2986f6db6..a4344d8e6 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java @@ -25,19 +25,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.UUID; - -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; public class AaiNqNamedQueryTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java index 22c1b4bbf..f304713f9 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java @@ -25,19 +25,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.UUID; - -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; public class AaiNqQueryParametersTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { AaiNqQueryParameters aaiNqQueryParameters = new AaiNqQueryParameters(); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java index a8863197e..35108a03a 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java @@ -25,9 +25,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.UUID; - -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.util.Serialization; import org.slf4j.Logger; @@ -36,12 +33,6 @@ import org.slf4j.LoggerFactory; public class AaiNqRequestTest { private static final Logger logger = LoggerFactory.getLogger(AaiNqRequestTest.class); - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { AaiNqRequest aaiNqRequest = new AaiNqRequest(); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java index 9b3a4afee..ba160e2c7 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java @@ -29,6 +29,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AaiNqResponseTest { + private static final String WIDGET = "widget"; + private static final String MODEL_VERSION_KEY = "model.model-version"; + private static final String MODEL_TYPE_KEY = "model.model-type"; + private static final String MODEL_NAME_KEY = "model.model-name"; + private static final String MODEL_ID_KEY = "model.model-id"; private static final Logger logger = LoggerFactory.getLogger(AaiNqResponseTest.class); @Test @@ -53,13 +58,13 @@ public class AaiNqResponseTest { serviceItem.getServiceInstance().setResourceVersion("1485366092"); serviceItem.setExtraProperties(new AaiNqExtraProperties()); serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "service-instance")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "service-instance")); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + .add(new AaiNqExtraProperty(MODEL_ID_KEY, "82194af1-3c2c-485a-8f44-420e22a9eaa4")); serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "46b92144-923a-4d20-b85a-3cbd847668a9")); AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); vfModuleItem.setModelName("vf-module"); @@ -77,13 +82,13 @@ public class AaiNqResponseTest { vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "vf-module")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "vf-module")); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); + .add(new AaiNqExtraProperty(MODEL_ID_KEY, "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "c00563ae-812b-4e62-8330-7c4d0f47088a")); AaiNqInventoryResponseItem genericVnfItem = new AaiNqInventoryResponseItem(); genericVnfItem.setModelName("generic-vnf"); @@ -106,13 +111,13 @@ public class AaiNqResponseTest { genericVnfItem.setExtraProperties(new AaiNqExtraProperties()); genericVnfItem.getExtraProperties().setExtraProperty(new LinkedList<>()); genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "generic-vnf")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "generic-vnf")); genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-type", "widget")); + .add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-version", "1.0")); + .add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); + .add(new AaiNqExtraProperty(MODEL_ID_KEY, "acc6edd8-a8d4-4b93-afaa-0994068be14c")); genericVnfItem.getExtraProperties().getExtraProperty() .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); genericVnfItem.setItems(new AaiNqInventoryResponseItems()); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java index 459454e3a..f80fd82bd 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java @@ -37,6 +37,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AaiNqResponseWrapperTest { + private static final String WIDGET = "widget"; + private static final String MODEL_VERSION_KEY = "model.model-version"; + private static final String MODEL_TYPE_KEY = "model.model-type"; + private static final String MODEL_NAME_KEY = "model.model-name"; + private static final String MODEL_ID_KEY = "model.model-id"; + private static final String VERSION_JSON = "AaiNqResponseWrapper-Vserver.json"; + private static final String NO_NAMES_JSON = "AaiNqResponseWrapper-NoNames.json"; private static final Logger logger = LoggerFactory.getLogger(AaiNqResponseWrapperTest.class); @Test @@ -52,13 +59,13 @@ public class AaiNqResponseWrapperTest { serviceItem.getServiceInstance().setResourceVersion("1485366092"); serviceItem.setExtraProperties(new AaiNqExtraProperties()); serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "service-instance")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "service-instance")); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); + serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); + .add(new AaiNqExtraProperty(MODEL_ID_KEY, "82194af1-3c2c-485a-8f44-420e22a9eaa4")); serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "46b92144-923a-4d20-b85a-3cbd847668a9")); AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); vfModuleItem.setModelName("vf-module"); @@ -76,13 +83,13 @@ public class AaiNqResponseWrapperTest { vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "vf-module")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "vf-module")); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); + vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); + .add(new AaiNqExtraProperty(MODEL_ID_KEY, "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "c00563ae-812b-4e62-8330-7c4d0f47088a")); AaiNqInventoryResponseItem genericVnfItem = new AaiNqInventoryResponseItem(); genericVnfItem.setModelName("generic-vnf"); @@ -105,13 +112,13 @@ public class AaiNqResponseWrapperTest { genericVnfItem.setExtraProperties(new AaiNqExtraProperties()); genericVnfItem.getExtraProperties().setExtraProperty(new LinkedList<>()); genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "generic-vnf")); + .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "generic-vnf")); genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-type", "widget")); + .add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-version", "1.0")); + .add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); + .add(new AaiNqExtraProperty(MODEL_ID_KEY, "acc6edd8-a8d4-4b93-afaa-0994068be14c")); genericVnfItem.getExtraProperties().getExtraProperty() .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); genericVnfItem.setItems(new AaiNqInventoryResponseItems()); @@ -175,13 +182,13 @@ public class AaiNqResponseWrapperTest { // null item resp = new AaiNqResponseWrapper(); assertEquals(0, resp.countVfModules()); - + // no names - resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoNames.json")); + resp.setAaiNqResponse(load(NO_NAMES_JSON)); assertEquals(0, resp.countVfModules()); // has VF modules - resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json")); + resp.setAaiNqResponse(load(VERSION_JSON)); assertEquals(3, resp.countVfModules()); } @@ -192,13 +199,13 @@ public class AaiNqResponseWrapperTest { // null item resp = new AaiNqResponseWrapper(); assertEquals(null, resp.genVfModuleName()); - + // no names - resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoNames.json")); + resp.setAaiNqResponse(load(NO_NAMES_JSON)); assertEquals(null, resp.genVfModuleName()); // has VF modules - resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json")); + resp.setAaiNqResponse(load(VERSION_JSON)); assertEquals("my-module-abc_124", resp.genVfModuleName()); } @@ -220,25 +227,25 @@ public class AaiNqResponseWrapperTest { resp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0) .getItems().setInventoryResponseItems(null); assertTrue(resp.getVfModuleItems(false).isEmpty()); - + // no modules resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoModules.json")); assertTrue(resp.getVfModuleItems(false).isEmpty()); - + // no names - resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoNames.json")); + resp.setAaiNqResponse(load(NO_NAMES_JSON)); List<AaiNqInventoryResponseItem> lst; lst = resp.getVfModuleItems(false); assertEquals(0, lst.size()); // base VF modules - resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json")); + resp.setAaiNqResponse(load(VERSION_JSON)); lst = resp.getVfModuleItems(true); assertEquals(1, lst.size()); assertEquals("Vfmodule_vLBMS-0809-1", lst.get(0).getVfModule().getVfModuleName()); - + // non base VF modules - resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json")); + resp.setAaiNqResponse(load(VERSION_JSON)); lst = resp.getVfModuleItems(false); assertEquals(3, lst.size()); int index; diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java index 4dc9b15e4..45a55c99b 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java @@ -24,8 +24,6 @@ package org.onap.policy.aai; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.util.Serialization; import org.slf4j.Logger; @@ -34,12 +32,6 @@ import org.slf4j.LoggerFactory; public class AaiNqServiceInstanceTest { private static final Logger logger = LoggerFactory.getLogger(AaiNqServiceInstanceTest.class); - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { AaiNqServiceInstance aaiNqServiceInstance = new AaiNqServiceInstance(); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java index 4e03f57fc..ed4cdb705 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java @@ -24,8 +24,6 @@ package org.onap.policy.aai; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.util.Serialization; import org.slf4j.Logger; @@ -34,12 +32,6 @@ import org.slf4j.LoggerFactory; public class AaiNqTenantTest { private static final Logger logger = LoggerFactory.getLogger(AaiNqTenantTest.class); - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { AaiNqTenant aaiNqTenant = new AaiNqTenant(); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java index c6a04a5eb..c613a0223 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java @@ -27,8 +27,6 @@ import static org.junit.Assert.assertNotNull; import java.io.File; import java.nio.file.Files; import java.util.List; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.util.Serialization; import org.slf4j.Logger; @@ -37,13 +35,6 @@ import org.slf4j.LoggerFactory; public class AaiNqVServerTest { private static final Logger logger = LoggerFactory.getLogger(AaiNqVServerTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() throws Exception { // deserialize json and verify fields are populated properly diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java index da169d589..65bde98c2 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java @@ -24,8 +24,6 @@ package org.onap.policy.aai; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.util.Serialization; import org.slf4j.Logger; @@ -34,13 +32,6 @@ import org.slf4j.LoggerFactory; public class AaiNqVfModuleTest { private static final Logger logger = LoggerFactory.getLogger(AaiNqVfModuleTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { AaiNqVfModule aaiNqVfModule = new AaiNqVfModule(); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java index ab397cd95..8cf839110 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java @@ -27,27 +27,20 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.util.Serialization; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class PnfInstanceTest { + private static final String PNF_NAME_TEST = "pnf-name-test"; private static final Logger logger = LoggerFactory.getLogger(PnfInstanceTest.class); - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { PnfInstance pnfInstance = new PnfInstance(); pnfInstance.setPnfInstanceName("pnf-instance-name-test"); - pnfInstance.setPnfName("pnf-name-test"); + pnfInstance.setPnfName(PNF_NAME_TEST); pnfInstance.setPnfType(PnfType.ENODEB); pnfInstance.setPnfSerial("pnf-serial-test"); assertNotNull(pnfInstance); @@ -59,7 +52,7 @@ public class PnfInstanceTest { PnfInstance pnfInstanceClone = new PnfInstance(pnfInstance); assertNotNull(pnfInstanceClone); - assertEquals("pnf-name-test", pnfInstanceClone.getPnfName()); + assertEquals(PNF_NAME_TEST, pnfInstanceClone.getPnfName()); assertEquals(PnfType.ENODEB, pnfInstanceClone.getPnfType()); assertEquals("pnf-serial-test", pnfInstanceClone.getPnfSerial()); @@ -69,7 +62,7 @@ public class PnfInstanceTest { assertNotEquals(0, new Pnf().hashCode()); PnfInstance pnfInstanceOther0 = new PnfInstance(); - pnfInstanceOther0.setPnfName("pnf-name-test"); + pnfInstanceOther0.setPnfName(PNF_NAME_TEST); PnfInstance pnfInstanceOther1 = new PnfInstance(pnfInstance); pnfInstanceOther1.setPnfName("pnf-name-test-diff"); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java index b5b152089..54cf4735b 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java @@ -27,33 +27,26 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.util.Serialization; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class PnfTest { + private static final String PNF_NAME_TEST = "pnf-name-test"; private static final Logger logger = LoggerFactory.getLogger(PnfTest.class); - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { Pnf pnf = new Pnf(); - pnf.setPnfName("pnf-name-test"); + pnf.setPnfName(PNF_NAME_TEST); pnf.setPnfType(PnfType.ENODEB); assertNotNull(pnf); Pnf pnfClone = new Pnf(pnf); assertNotNull(pnfClone); - assertEquals("pnf-name-test", pnfClone.getPnfName()); + assertEquals(PNF_NAME_TEST, pnfClone.getPnfName()); assertEquals(PnfType.ENODEB, pnfClone.getPnfType()); assertEquals("PNF [PNFName=pnf-name-test, PNFType=eNodeB]", pnfClone.toString()); @@ -61,7 +54,7 @@ public class PnfTest { assertNotEquals(0, new Pnf().hashCode()); Pnf pnfOther = new Pnf(); - pnfOther.setPnfName("pnf-name-test"); + pnfOther.setPnfName(PNF_NAME_TEST); assertTrue(pnf.equals(pnf)); assertFalse(pnf.equals(null)); diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java index 3a24d8c46..d3236904d 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java @@ -23,8 +23,6 @@ package org.onap.policy.aai; import static org.junit.Assert.assertNotNull; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.util.Serialization; import org.slf4j.Logger; @@ -33,13 +31,6 @@ import org.slf4j.LoggerFactory; public class PnfTypeTest { private static final Logger logger = LoggerFactory.getLogger(PnfTypeTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - @Test public void test() { PnfType pnfType = PnfType.ENODEB; diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java index 4be8a53f6..c15407dd0 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java @@ -29,12 +29,14 @@ import org.junit.Test; public class AaiExceptionTest { + private static final String MESSAGE = "message"; + @Test public void test() { assertNotNull(new AaiException()); - assertNotNull(new AaiException("message")); - assertNotNull(new AaiException("message", new IOException())); - assertNotNull(new AaiException("message", new IOException(), true, false)); + assertNotNull(new AaiException(MESSAGE)); + assertNotNull(new AaiException(MESSAGE, new IOException())); + assertNotNull(new AaiException(MESSAGE, new IOException(), true, false)); assertNotNull(new AaiException(new IOException())); } |