Merge "Fix sonar issues in models: sdc to vfc"
authorJorge Hernandez <jorge.hernandez-herrero@att.com>
Mon, 17 Jun 2019 21:13:40 +0000 (21:13 +0000)
committerGerrit Code Review <gerrit@onap.org>
Mon, 17 Jun 2019 21:13:40 +0000 (21:13 +0000)
57 files changed:
models-errors/src/main/java/org/onap/policy/models/errors/concepts/ErrorResponseInfo.java
models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java
models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java
models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java
models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java
models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java
models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java
models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java
models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiCqResponseTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java
models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java
models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java
models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java
models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java
models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java
models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java
models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java
models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java
models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java
models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptor.java
models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java
models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptorTest.java
models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/CdsProcessorGrpcClientTest.java
models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTest.java
models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/params/ControlLoopParamsTest.java
models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageTest.java
models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpMessageUtils.java
models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java
models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java
models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpTest.java
models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java

index ed7104b..70ebbef 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +26,7 @@ package org.onap.policy.models.errors.concepts;
  *
  * @author Liam Fallon (liam.fallon@est.tech)
  */
+@FunctionalInterface
 public interface ErrorResponseInfo {
 
     /**
index b917406..553dfde 100644 (file)
@@ -24,12 +24,10 @@ package org.onap.policy.controlloop.actor.appc;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.time.Instant;
 import java.util.HashMap;
 import java.util.UUID;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -51,6 +49,12 @@ import org.slf4j.LoggerFactory;
 
 public class AppcServiceProviderTest {
 
+    private static final String GENERIC_VNF_ID = "generic-vnf.vnf-id";
+
+    private static final String MODIFY_CONFIG = "ModifyConfig";
+
+    private static final String JSON_OUTPUT = "JSON Output: \n";
+
     private static final Logger logger = LoggerFactory.getLogger(AppcServiceProviderTest.class);
 
     private static final VirtualControlLoopEvent onsetEvent;
@@ -85,7 +89,7 @@ public class AppcServiceProviderTest {
         /* Construct an operation with an APPC actor and ModifyConfig operation. */
         operation = new ControlLoopOperation();
         operation.setActor("APPC");
-        operation.setOperation("ModifyConfig");
+        operation.setOperation(MODIFY_CONFIG);
         operation.setTarget("VNF");
         operation.setEnd(Instant.now());
         operation.setSubRequestId("1");
@@ -97,7 +101,7 @@ public class AppcServiceProviderTest {
         policy.setActor("APPC");
         policy.setTarget(new Target(TargetType.VNF));
         policy.getTarget().setResourceID("Eace933104d443b496b8.nodes.heat.vpg");
-        policy.setRecipe("ModifyConfig");
+        policy.setRecipe(MODIFY_CONFIG);
         policy.setPayload(null);
         policy.setRetry(2);
         policy.setTimeout(300);
@@ -106,14 +110,11 @@ public class AppcServiceProviderTest {
 
     /**
      * Set up before test class.
+     * @throws Exception if the A&AI simulator cannot be started
      */
     @BeforeClass
-    public static void setUpSimulator() {
-        try {
-            Util.buildAaiSim();
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
+    public static void setUpSimulator() throws Exception {
+        Util.buildAaiSim();
     }
 
     /**
@@ -142,12 +143,12 @@ public class AppcServiceProviderTest {
 
         /* An action is required and cannot be null */
         assertNotNull(appcRequest.getAction());
-        assertEquals("ModifyConfig", appcRequest.getAction());
+        assertEquals(MODIFY_CONFIG, appcRequest.getAction());
 
         /* A payload is required and cannot be null */
         assertNotNull(appcRequest.getPayload());
-        assertTrue(appcRequest.getPayload().containsKey("generic-vnf.vnf-id"));
-        assertNotNull(appcRequest.getPayload().get("generic-vnf.vnf-id"));
+        assertTrue(appcRequest.getPayload().containsKey(GENERIC_VNF_ID));
+        assertNotNull(appcRequest.getPayload().get(GENERIC_VNF_ID));
         assertTrue(appcRequest.getPayload().containsKey(KEY1));
         assertTrue(appcRequest.getPayload().containsKey(KEY2));
 
@@ -155,14 +156,14 @@ public class AppcServiceProviderTest {
 
         /* Print out request as json to make sure serialization works */
         String jsonRequest = Serialization.gsonPretty.toJson(appcRequest);
-        logger.debug("JSON Output: \n" + jsonRequest);
+        logger.debug(JSON_OUTPUT + jsonRequest);
 
         /* The JSON string must contain the following fields */
         assertTrue(jsonRequest.contains("CommonHeader"));
         assertTrue(jsonRequest.contains("Action"));
-        assertTrue(jsonRequest.contains("ModifyConfig"));
+        assertTrue(jsonRequest.contains(MODIFY_CONFIG));
         assertTrue(jsonRequest.contains("Payload"));
-        assertTrue(jsonRequest.contains("generic-vnf.vnf-id"));
+        assertTrue(jsonRequest.contains(GENERIC_VNF_ID));
         assertTrue(jsonRequest.contains(KEY1));
         assertTrue(jsonRequest.contains(KEY2));
         assertTrue(jsonRequest.contains(SUBKEY));
@@ -173,7 +174,7 @@ public class AppcServiceProviderTest {
         appcResponse.getStatus().setDescription("AppC success");
         /* Print out request as json to make sure serialization works */
         String jsonResponse = Serialization.gsonPretty.toJson(appcResponse);
-        logger.debug("JSON Output: \n" + jsonResponse);
+        logger.debug(JSON_OUTPUT + jsonResponse);
     }
 
     @Test
@@ -191,32 +192,32 @@ public class AppcServiceProviderTest {
 
         /* An action is required and cannot be null */
         assertNotNull(appcRequest.getAction());
-        assertEquals("ModifyConfig", appcRequest.getAction());
+        assertEquals(MODIFY_CONFIG, appcRequest.getAction());
 
         /* A payload is required and cannot be null */
         assertNotNull(appcRequest.getPayload());
-        assertTrue(appcRequest.getPayload().containsKey("generic-vnf.vnf-id"));
-        assertNotNull(appcRequest.getPayload().get("generic-vnf.vnf-id"));
+        assertTrue(appcRequest.getPayload().containsKey(GENERIC_VNF_ID));
+        assertNotNull(appcRequest.getPayload().get(GENERIC_VNF_ID));
 
         logger.debug("APPC Request: \n" + appcRequest.toString());
 
         /* Print out request as json to make sure serialization works */
         String jsonRequest = Serialization.gsonPretty.toJson(appcRequest);
-        logger.debug("JSON Output: \n" + jsonRequest);
+        logger.debug(JSON_OUTPUT + jsonRequest);
 
         /* The JSON string must contain the following fields */
         assertTrue(jsonRequest.contains("CommonHeader"));
         assertTrue(jsonRequest.contains("Action"));
-        assertTrue(jsonRequest.contains("ModifyConfig"));
+        assertTrue(jsonRequest.contains(MODIFY_CONFIG));
         assertTrue(jsonRequest.contains("Payload"));
-        assertTrue(jsonRequest.contains("generic-vnf.vnf-id"));
+        assertTrue(jsonRequest.contains(GENERIC_VNF_ID));
 
         Response appcResponse = new Response(appcRequest);
         appcResponse.getStatus().setCode(ResponseCode.SUCCESS.getValue());
         appcResponse.getStatus().setDescription("AppC success");
         /* Print out request as json to make sure serialization works */
         String jsonResponse = Serialization.gsonPretty.toJson(appcResponse);
-        logger.debug("JSON Output: \n" + jsonResponse);
+        logger.debug(JSON_OUTPUT + jsonResponse);
     }
 
     @Test
index da95611..7b48387 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * AppcServiceProviderTest
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,17 +24,14 @@ package org.onap.policy.controlloop.actor.appclcm;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
 
 import java.time.Instant;
 import java.util.AbstractMap;
 import java.util.HashMap;
 import java.util.UUID;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.onap.policy.aai.util.AaiException;
 import org.onap.policy.appclcm.LcmCommonHeader;
 import org.onap.policy.appclcm.LcmRequest;
 import org.onap.policy.appclcm.LcmRequestWrapper;
@@ -56,6 +53,16 @@ import org.slf4j.LoggerFactory;
 
 public class AppcLcmActorServiceProviderTest {
 
+    private static final String VNF01 = "vnf01";
+
+    private static final String VNF_ID_KEY = "vnf-id";
+
+    private static final String REJECT = "REJECT";
+
+    private static final String PARTIAL_FAILURE = "PARTIAL FAILURE";
+
+    private static final String FAILURE = "FAILURE";
+
     private static final Logger logger = LoggerFactory.getLogger(AppcLcmActorServiceProviderTest.class);
 
     private static final VirtualControlLoopEvent onsetEvent;
@@ -87,7 +94,7 @@ public class AppcLcmActorServiceProviderTest {
         /* Construct an operation with an APPC actor and restart operation. */
         operation = new ControlLoopOperation();
         operation.setActor("APPC");
-        operation.setOperation("Restart");
+        operation.setOperation(RECIPE_RESTART);
         operation.setTarget("VM");
         operation.setEnd(Instant.now());
         operation.setSubRequestId("1");
@@ -98,7 +105,7 @@ public class AppcLcmActorServiceProviderTest {
         policy.setDescription("Upon getting the trigger event, restart the VM");
         policy.setActor("APPC");
         policy.setTarget(new Target(TargetType.VNF));
-        policy.setRecipe("Restart");
+        policy.setRecipe(RECIPE_RESTART);
         policy.setPayload(null);
         policy.setRetry(2);
         policy.setTimeout(300);
@@ -122,7 +129,7 @@ public class AppcLcmActorServiceProviderTest {
         appcRequest.setAction("restart");
 
         HashMap<String, String> actionIdentifiers = new HashMap<>();
-        actionIdentifiers.put("vnf-id", "trial-vnf-003");
+        actionIdentifiers.put(VNF_ID_KEY, "trial-vnf-003");
 
         appcRequest.setActionIdentifiers(actionIdentifiers);
 
@@ -147,14 +154,11 @@ public class AppcLcmActorServiceProviderTest {
 
     /**
      * Set up before test class.
+     * @throws Exception if an error occurs
      */
     @BeforeClass
-    public static void setUpSimulator() {
-        try {
-            Util.buildAaiSim();
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
+    public static void setUpSimulator() throws Exception {
+        Util.buildAaiSim();
     }
 
     /**
@@ -172,7 +176,7 @@ public class AppcLcmActorServiceProviderTest {
     public void constructRestartRequestTest() {
 
         LcmRequestWrapper dmaapRequest =
-                AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, policy, "vnf01");
+                AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, policy, VNF01);
 
         /* The service provider must return a non null DMAAP request wrapper */
         assertNotNull(dmaapRequest);
@@ -191,12 +195,12 @@ public class AppcLcmActorServiceProviderTest {
 
         /* An action is required and cannot be null */
         assertNotNull(appcRequest.getAction());
-        assertEquals("Restart", appcRequest.getAction());
+        assertEquals(RECIPE_RESTART, appcRequest.getAction());
 
         /* Action Identifiers are required and cannot be null */
         assertNotNull(appcRequest.getActionIdentifiers());
-        assertNotNull(appcRequest.getActionIdentifiers().get("vnf-id"));
-        assertEquals("vnf01", appcRequest.getActionIdentifiers().get("vnf-id"));
+        assertNotNull(appcRequest.getActionIdentifiers().get(VNF_ID_KEY));
+        assertEquals(VNF01, appcRequest.getActionIdentifiers().get(VNF_ID_KEY));
 
         logger.debug("APPC Request: \n" + appcRequest.toString());
     }
@@ -240,35 +244,35 @@ public class AppcLcmActorServiceProviderTest {
 
         /* If APPC rejects, PolicyResult is failure exception */
         dmaapResponse.getBody().getStatus().setCode(300);
-        dmaapResponse.getBody().getStatus().setMessage("REJECT");
+        dmaapResponse.getBody().getStatus().setMessage(REJECT);
         result = AppcLcmActorServiceProvider.processResponse(dmaapResponse);
         assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey());
 
         /* Test multiple reject codes */
         dmaapResponse.getBody().getStatus().setCode(306);
-        dmaapResponse.getBody().getStatus().setMessage("REJECT");
+        dmaapResponse.getBody().getStatus().setMessage(REJECT);
         result = AppcLcmActorServiceProvider.processResponse(dmaapResponse);
         assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey());
 
         dmaapResponse.getBody().getStatus().setCode(313);
-        dmaapResponse.getBody().getStatus().setMessage("REJECT");
+        dmaapResponse.getBody().getStatus().setMessage(REJECT);
         result = AppcLcmActorServiceProvider.processResponse(dmaapResponse);
         assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey());
 
         /* If APPC returns failure, PolicyResult is failure */
         dmaapResponse.getBody().getStatus().setCode(401);
-        dmaapResponse.getBody().getStatus().setMessage("FAILURE");
+        dmaapResponse.getBody().getStatus().setMessage(FAILURE);
         result = AppcLcmActorServiceProvider.processResponse(dmaapResponse);
         assertEquals(PolicyResult.FAILURE, result.getKey());
 
         /* Test multiple failure codes */
         dmaapResponse.getBody().getStatus().setCode(406);
-        dmaapResponse.getBody().getStatus().setMessage("FAILURE");
+        dmaapResponse.getBody().getStatus().setMessage(FAILURE);
         result = AppcLcmActorServiceProvider.processResponse(dmaapResponse);
         assertEquals(PolicyResult.FAILURE, result.getKey());
 
         dmaapResponse.getBody().getStatus().setCode(450);
-        dmaapResponse.getBody().getStatus().setMessage("FAILURE");
+        dmaapResponse.getBody().getStatus().setMessage(FAILURE);
         result = AppcLcmActorServiceProvider.processResponse(dmaapResponse);
         assertEquals(PolicyResult.FAILURE, result.getKey());
 
@@ -280,18 +284,18 @@ public class AppcLcmActorServiceProviderTest {
 
         /* If APPC returns partial failure, PolicyResult is failure exception */
         dmaapResponse.getBody().getStatus().setCode(501);
-        dmaapResponse.getBody().getStatus().setMessage("PARTIAL FAILURE");
+        dmaapResponse.getBody().getStatus().setMessage(PARTIAL_FAILURE);
         result = AppcLcmActorServiceProvider.processResponse(dmaapResponse);
         assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey());
 
         /* Test multiple partial failure codes */
         dmaapResponse.getBody().getStatus().setCode(599);
-        dmaapResponse.getBody().getStatus().setMessage("PARTIAL FAILURE");
+        dmaapResponse.getBody().getStatus().setMessage(PARTIAL_FAILURE);
         result = AppcLcmActorServiceProvider.processResponse(dmaapResponse);
         assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey());
 
         dmaapResponse.getBody().getStatus().setCode(550);
-        dmaapResponse.getBody().getStatus().setMessage("PARTIAL FAILURE");
+        dmaapResponse.getBody().getStatus().setMessage(PARTIAL_FAILURE);
         result = AppcLcmActorServiceProvider.processResponse(dmaapResponse);
         assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey());
 
@@ -302,27 +306,21 @@ public class AppcLcmActorServiceProviderTest {
         assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey());
     }
 
-    /**
+    /*
      * This test ensures that that if the the source entity is also the target entity, the source
      * will be used for the APPC request.
      */
     @Test
-    public void sourceIsTargetTest() {
+    public void sourceIsTargetTest() throws Exception {
         String resourceId = "82194af1-3c2c-485a-8f44-420e22a9eaa4";
-        String targetVnfId = null;
-        try {
-            targetVnfId = AppcLcmActorServiceProvider.vnfNamedQuery(resourceId, "vnf01",
-                    "http://localhost:6666", "AAI", "AAI");
-        } catch (AaiException e) {
-            logger.warn(e.toString());
-            fail("no vnf-id found");
-        }
+        String targetVnfId = AppcLcmActorServiceProvider.vnfNamedQuery(resourceId, VNF01, "http://localhost:6666",
+                        "AAI", "AAI");
         assertNotNull(targetVnfId);
-        assertEquals("vnf01", targetVnfId);
+        assertEquals(VNF01, targetVnfId);
     }
 
-    /**
-     * THis test exercises getters not exercised in other tests.
+    /*
+     * This test exercises getters not exercised in other tests.
      */
     @Test
     public void testMethods() {
@@ -330,8 +328,8 @@ public class AppcLcmActorServiceProviderTest {
 
         assertEquals("APPC", sp.actor());
         assertEquals(4, sp.recipes().size());
-        assertEquals("VM", sp.recipeTargets("Restart").get(0));
-        assertEquals("vm-id", sp.recipePayloads("Restart").get(0));
+        assertEquals("VM", sp.recipeTargets(RECIPE_RESTART).get(0));
+        assertEquals("vm-id", sp.recipePayloads(RECIPE_RESTART).get(0));
     }
 
     @Test
@@ -343,11 +341,11 @@ public class AppcLcmActorServiceProviderTest {
 
         // when
         LcmRequestWrapper migrateRequest =
-            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, migratePolicy, "vnf01");
+            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, migratePolicy, VNF01);
         LcmRequestWrapper rebuildRequest =
-            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, rebuildPolicy, "vnf01");
+            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, rebuildPolicy, VNF01);
         LcmRequestWrapper restartRequest =
-            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, restartPolicy, "vnf01");
+            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, restartPolicy, VNF01);
 
         // then
         assertNull(migrateRequest.getBody().getPayload());
@@ -363,9 +361,9 @@ public class AppcLcmActorServiceProviderTest {
 
         // when
         LcmRequestWrapper noPayloadRequest =
-            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, noPayloadPolicy, "vnf01");
+            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, noPayloadPolicy, VNF01);
         LcmRequestWrapper emptyPayloadRequest =
-            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, emptyPayloadPolicy, "vnf01");
+            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, emptyPayloadPolicy, VNF01);
 
 
         // then
@@ -382,7 +380,7 @@ public class AppcLcmActorServiceProviderTest {
 
         // when
         LcmRequestWrapper dmaapRequest =
-            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, otherPolicy, "vnf01");
+            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, otherPolicy, VNF01);
 
         // then
         assertEquals(dmaapRequest.getBody().getPayload(),
@@ -402,7 +400,7 @@ public class AppcLcmActorServiceProviderTest {
 
         // when
         LcmRequestWrapper dmaapRequest =
-            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, otherPolicy, "vnf01");
+            AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, otherPolicy, VNF01);
 
         // then
         assertEquals(dmaapRequest.getBody().getPayload(),
index c80a38d..26f7336 100644 (file)
@@ -25,11 +25,9 @@ package org.onap.policy.controlloop.actor.sdnc;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
 
 import java.util.Objects;
 import java.util.UUID;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -42,16 +40,15 @@ import org.onap.policy.simulators.Util;
 
 public class SdncActorServiceProviderTest {
 
+    private static final String REROUTE = "Reroute";
+
     /**
-     * Set up for test class.
+     * Set up before test class.
+     * @throws Exception if the A&AI simulator cannot be started
      */
     @BeforeClass
-    public static void setUpSimulator() {
-        try {
-            Util.buildAaiSim();
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
+    public static void setUpSimulator() throws Exception {
+        Util.buildAaiSim();
     }
 
     @AfterClass
@@ -65,7 +62,7 @@ public class SdncActorServiceProviderTest {
         ControlLoopOperation operation = new ControlLoopOperation();
 
         Policy policy = new Policy();
-        policy.setRecipe("Reroute");
+        policy.setRecipe(REROUTE);
 
         SdncActorServiceProvider provider = new SdncActorServiceProvider();
         assertNull(provider.constructRequest(onset, operation, policy));
@@ -84,7 +81,7 @@ public class SdncActorServiceProviderTest {
         onset.getAai().put("service-instance.service-instance-id", "service-instance-01");
         assertNotNull(provider.constructRequest(onset, operation, policy));
 
-        policy.setRecipe("Reroute");
+        policy.setRecipe(REROUTE);
         assertNotNull(provider.constructRequest(onset, operation, policy));
 
         SdncRequest request =
@@ -103,8 +100,8 @@ public class SdncActorServiceProviderTest {
 
         assertEquals("SDNC", sp.actor());
         assertEquals(1, sp.recipes().size());
-        assertEquals("Reroute", sp.recipes().get(0));
-        assertEquals("VM", sp.recipeTargets("Reroute").get(0));
-        assertEquals(0, sp.recipePayloads("Reroute").size());
+        assertEquals(REROUTE, sp.recipes().get(0));
+        assertEquals("VM", sp.recipeTargets(REROUTE).get(0));
+        assertEquals(0, sp.recipePayloads(REROUTE).size());
     }
 }
index 32346bf..4367f54 100644 (file)
@@ -70,7 +70,6 @@ public class SdnrActorServiceProvider implements Actor {
 
     // Strings for recipes
     private static final String RECIPE_MODIFY = "ModifyConfig";
-    private static final String RECIPE_MODIFY_ANR = "ModifyConfigANR";
 
     /* To be used in future releases when pci ModifyConfig is used */
     private static final String SDNR_REQUEST_PARAMS = "request-parameters";
index 265aea3..a917896 100644 (file)
@@ -46,6 +46,8 @@ import org.slf4j.LoggerFactory;
 
 public class SdnrActorServiceProviderTest {
 
+    private static final String MODIFY_CONFIG = "ModifyConfig";
+
     private static final Logger logger = LoggerFactory.getLogger(SdnrActorServiceProviderTest.class);
 
     private static final VirtualControlLoopEvent onsetEvent;
@@ -73,7 +75,7 @@ public class SdnrActorServiceProviderTest {
         /* Construct an operation with an SDNR actor and ModifyConfig operation. */
         operation = new ControlLoopOperation();
         operation.setActor("SDNR");
-        operation.setOperation("ModifyConfig");
+        operation.setOperation(MODIFY_CONFIG);
         operation.setTarget("VNF");
         operation.setEnd(Instant.now());
         operation.setSubRequestId("1");
@@ -85,7 +87,7 @@ public class SdnrActorServiceProviderTest {
         policy.setActor("SDNR");
         policy.setTarget(new Target(TargetType.VNF));
         policy.getTarget().setResourceID("Eace933104d443b496b8.nodes.heat.vpg");
-        policy.setRecipe("ModifyConfig");
+        policy.setRecipe(MODIFY_CONFIG);
         policy.setPayload(null);
         policy.setRetry(2);
         policy.setTimeout(300);
@@ -132,7 +134,7 @@ public class SdnrActorServiceProviderTest {
 
         /* An action is required and cannot be null */
         assertNotNull(sdnrRequest.getAction());
-        assertEquals("ModifyConfig", sdnrRequest.getAction());
+        assertEquals(MODIFY_CONFIG, sdnrRequest.getAction());
 
         /* A payload is required and cannot be null */
         assertNotNull(sdnrRequest.getPayload());
@@ -147,7 +149,7 @@ public class SdnrActorServiceProviderTest {
         /* The JSON string must contain the following fields */
         assertTrue(jsonRequest.contains("CommonHeader"));
         assertTrue(jsonRequest.contains("Action"));
-        assertTrue(jsonRequest.contains("ModifyConfig"));
+        assertTrue(jsonRequest.contains(MODIFY_CONFIG));
         assertTrue(jsonRequest.contains("payload"));
 
         PciResponse sdnrResponse = new PciResponse(sdnrRequest);
@@ -164,7 +166,7 @@ public class SdnrActorServiceProviderTest {
 
         assertEquals("SDNR", sp.actor());
         assertEquals(1, sp.recipes().size());
-        assertEquals("VNF", sp.recipeTargets("ModifyConfig").get(0));
-        assertEquals(2, sp.recipePayloads("ModifyConfig").size());
+        assertEquals("VNF", sp.recipeTargets(MODIFY_CONFIG).get(0));
+        assertEquals(2, sp.recipePayloads(MODIFY_CONFIG).size());
     }
 }
index 2da0a95..8aad5fe 100644 (file)
@@ -57,6 +57,9 @@ import org.slf4j.LoggerFactory;
 public class SoActorServiceProvider implements Actor {
     private static final Logger logger = LoggerFactory.getLogger(SoActorServiceProvider.class);
 
+    private static final String TENANT_NOT_FOUND = "Tenant Item not found in AAI response {}";
+    private static final String CONSTRUCTED_SO_MSG = "Constructed SO request: {}";
+
     // Strings for SO Actor
     private static final String SO_ACTOR = "SO";
 
@@ -160,7 +163,7 @@ public class SoActorServiceProvider implements Actor {
             tenantItem = aaiResponseWrapper.getAaiNqResponse().getInventoryResponseItems().get(0).getItems()
                     .getInventoryResponseItems().get(1);
         } catch (Exception e) {
-            logger.error("Tenant Item not found in AAI response {}",
+            logger.error(TENANT_NOT_FOUND,
                     Serialization.gsonPretty.toJson(aaiResponseWrapper), e);
             return null;
         }
@@ -180,7 +183,7 @@ public class SoActorServiceProvider implements Actor {
         if (RECIPE_VF_MODULE_CREATE.equals(policy.getRecipe())) {
             return constructCreateRequest(aaiResponseWrapper, policy, tenantItem, vnfItem, vnfServiceItem, soModelInfo);
         } else if (RECIPE_VF_MODULE_DELETE.equals(policy.getRecipe())) {
-            return constructDeleteRequest(tenantItem, vnfItem, vnfServiceItem, soModelInfo, policy);
+            return constructDeleteRequest(tenantItem, vnfItem, vnfServiceItem, policy);
         } else {
             return null;
         }
@@ -188,21 +191,23 @@ public class SoActorServiceProvider implements Actor {
 
     private SoModelInfo prepareSoModelInfo(Policy policy) {
 
-        SoModelInfo soModelInfo = new SoModelInfo();
-        if ((policy.getTarget() != null && (policy.getTarget().getModelCustomizationId() != null))
-                && (policy.getTarget().getModelInvariantId() != null) && (policy.getTarget().getModelName() != null)
-                && (policy.getTarget().getModelVersion() != null) && (policy.getTarget().getModelVersionId() != null)) {
-
-            soModelInfo.setModelCustomizationId(policy.getTarget().getModelCustomizationId());
-            soModelInfo.setModelInvariantId(policy.getTarget().getModelInvariantId());
-            soModelInfo.setModelName(policy.getTarget().getModelName());
-            soModelInfo.setModelVersion(policy.getTarget().getModelVersion());
-            soModelInfo.setModelVersionId(policy.getTarget().getModelVersionId());
-            soModelInfo.setModelType("vfModule");
-            return soModelInfo;
-        } else {
+        if (policy.getTarget() == null || policy.getTarget().getModelCustomizationId() == null
+                        || policy.getTarget().getModelInvariantId() == null) {
             return null;
         }
+
+        if (policy.getTarget().getModelName() == null || policy.getTarget().getModelVersion() == null
+                        || policy.getTarget().getModelVersionId() == null) {
+            return null;
+        }
+
+        SoModelInfo soModelInfo = new SoModelInfo();
+        soModelInfo.setModelCustomizationId(policy.getTarget().getModelCustomizationId());
+        soModelInfo.setModelInvariantId(policy.getTarget().getModelInvariantId());
+        soModelInfo.setModelName(policy.getTarget().getModelName());
+        soModelInfo.setModelVersion(policy.getTarget().getModelVersion());
+        soModelInfo.setModelVersionId(policy.getTarget().getModelVersionId());
+        return soModelInfo;
     }
 
     /**
@@ -301,7 +306,7 @@ public class SoActorServiceProvider implements Actor {
         preserveInstanceIds(vnfItem.getGenericVnf().getVnfId(),
                 vnfServiceItem.getServiceInstance().getServiceInstanceId(), null);
         if (logger.isDebugEnabled()) {
-            logger.debug("Constructed SO request: {}", Serialization.gsonPretty.toJson(request));
+            logger.debug(CONSTRUCTED_SO_MSG, Serialization.gsonPretty.toJson(request));
         }
         return request;
     }
@@ -312,11 +317,10 @@ public class SoActorServiceProvider implements Actor {
      * @param tenantItem tenant item from A&AI named-query response
      * @param vnfItem vnf item from A&AI named-query response
      * @param vnfServiceItem vnf service item from A&AI named-query response
-     * @param vfModuleItem vf module item from A&AI named-query response
      * @return SO delete vf-module request
      */
     private SoRequest constructDeleteRequest(AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem vnfItem,
-            AaiNqInventoryResponseItem vnfServiceItem, SoModelInfo vfModuleItem, Policy policy) {
+            AaiNqInventoryResponseItem vnfServiceItem, Policy policy) {
         SoRequest request = new SoRequest();
         request.setOperationType(SoOperationType.DELETE_VF_MODULE);
         request.setRequestDetails(new SoRequestDetails());
@@ -334,7 +338,7 @@ public class SoActorServiceProvider implements Actor {
                 vnfServiceItem.getServiceInstance().getServiceInstanceId(), null);
 
         if (logger.isDebugEnabled()) {
-            logger.debug("Constructed SO request: {}", Serialization.gsonPretty.toJson(request));
+            logger.debug(CONSTRUCTED_SO_MSG, Serialization.gsonPretty.toJson(request));
         }
         return request;
     }
@@ -513,14 +517,14 @@ public class SoActorServiceProvider implements Actor {
         try {
             tenantItem = aaiCqResponse.getDefaultTenant();
         } catch (Exception e) {
-            logger.error("Tenant Item not found in AAI response {}", Serialization.gsonPretty.toJson(aaiCqResponse), e);
+            logger.error(TENANT_NOT_FOUND, Serialization.gsonPretty.toJson(aaiCqResponse), e);
             return null;
         }
 
         try {
             cloudRegionItem = aaiCqResponse.getDefaultCloudRegion();
         } catch (Exception e) {
-            logger.error("Tenant Item not found in AAI response {}", Serialization.gsonPretty.toJson(aaiCqResponse), e);
+            logger.error(TENANT_NOT_FOUND, Serialization.gsonPretty.toJson(aaiCqResponse), e);
             return null;
         }
 
@@ -531,7 +535,7 @@ public class SoActorServiceProvider implements Actor {
             return constructCreateRequestCq(aaiCqResponse, policy, tenantItem, vnfItem, vnfServiceItem, soModelInfo,
                     cloudRegionItem);
         } else if (RECIPE_VF_MODULE_DELETE.equals(policy.getRecipe())) {
-            return constructDeleteRequestCq(tenantItem, vnfItem, vnfServiceItem, soModelInfo, policy, cloudRegionItem);
+            return constructDeleteRequestCq(tenantItem, vnfItem, vnfServiceItem, policy, cloudRegionItem);
         } else {
             return null;
         }
@@ -622,7 +626,7 @@ public class SoActorServiceProvider implements Actor {
         // vfModuleId is not required for the create vf-module
         preserveInstanceIds(vnfItem.getVnfId(), vnfServiceItem.getServiceInstanceId(), null);
         if (logger.isDebugEnabled()) {
-            logger.debug("Constructed SO request: {}", Serialization.gsonPretty.toJson(request));
+            logger.debug(CONSTRUCTED_SO_MSG, Serialization.gsonPretty.toJson(request));
         }
         return request;
     }
@@ -633,13 +637,12 @@ public class SoActorServiceProvider implements Actor {
      * @param tenantItem Tenant from A&AI CQ request
      * @param vnfItem Generic VNF from A&AI CQ request
      * @param vnfServiceItem ServiceInstance from A&AI CQ request
-     * @param vfModuleItem VFModule from A&AI CQ request
      * @param policy policy information
      * @param cloudRegionItem CloudRegion from A&AI CQ request
      * @return SoRequest deleted
      */
     private SoRequest constructDeleteRequestCq(Tenant tenantItem, GenericVnf vnfItem, ServiceInstance vnfServiceItem,
-            SoModelInfo vfModuleItem, Policy policy, CloudRegion cloudRegionItem) {
+            Policy policy, CloudRegion cloudRegionItem) {
         SoRequest request = new SoRequest();
         request.setOperationType(SoOperationType.DELETE_VF_MODULE);
         request.setRequestDetails(new SoRequestDetails());
@@ -656,7 +659,7 @@ public class SoActorServiceProvider implements Actor {
         preserveInstanceIds(vnfItem.getVnfId(), vnfServiceItem.getServiceInstanceId(), null);
 
         if (logger.isDebugEnabled()) {
-            logger.debug("Constructed SO request: {}", Serialization.gsonPretty.toJson(request));
+            logger.debug(CONSTRUCTED_SO_MSG, Serialization.gsonPretty.toJson(request));
         }
         return request;
     }
index 9c26a4c..175d2fe 100644 (file)
@@ -26,7 +26,6 @@ package org.onap.policy.controlloop.actor.so;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
@@ -36,7 +35,6 @@ import java.util.Map;
 import java.util.TreeMap;
 import java.util.UUID;
 import org.apache.commons.io.IOUtils;
-import org.eclipse.persistence.exceptions.JAXBException;
 import org.junit.Test;
 import org.onap.policy.aai.AaiCqResponse;
 import org.onap.policy.aai.AaiNqResponse;
@@ -52,6 +50,8 @@ import org.onap.policy.so.util.Serialization;
 
 public class SoActorServiceProviderTest {
 
+    private static final String C_VALUE = "cvalue";
+    private static final String A_VALUE = "avalue";
     private static final String VF_MODULE_CREATE = "VF Module Create";
     private static final String VF_MODULE_DELETE = "VF Module Delete";
 
@@ -90,9 +90,9 @@ public class SoActorServiceProviderTest {
         request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp);
         assertNotNull(request);
         assertEquals(true, request.getRequestDetails().getRequestParameters().isUsePreload());
-        assertEquals("avalue", request.getRequestDetails().getRequestParameters().getUserParams().get(0).get("akey"));
+        assertEquals(A_VALUE, request.getRequestDetails().getRequestParameters().getUserParams().get(0).get("akey"));
         assertEquals(1, request.getRequestDetails().getConfigurationParameters().size());
-        assertEquals("cvalue", request.getRequestDetails().getConfigurationParameters().get(0).get("ckey"));
+        assertEquals(C_VALUE, request.getRequestDetails().getConfigurationParameters().get(0).get("ckey"));
 
         // payload with config, but no request params
         policy.setPayload(makePayload());
@@ -176,11 +176,7 @@ public class SoActorServiceProviderTest {
 
     @Test
     public void testSendRequest() {
-        try {
-            SoActorServiceProvider.sendRequest(UUID.randomUUID().toString(), null, null, null, null, null);
-        } catch (Exception e) {
-            fail("Test should not throw an exception");
-        }
+        SoActorServiceProvider.sendRequest(UUID.randomUUID().toString(), null, null, null, null, null);
     }
 
     @Test
@@ -232,9 +228,9 @@ public class SoActorServiceProviderTest {
         request = new SoActorServiceProvider().constructRequestCq(onset, operation, policy, aaiCqResp);
         assertNotNull(request);
         assertEquals(true, request.getRequestDetails().getRequestParameters().isUsePreload());
-        assertEquals("avalue", request.getRequestDetails().getRequestParameters().getUserParams().get(0).get("akey"));
+        assertEquals(A_VALUE, request.getRequestDetails().getRequestParameters().getUserParams().get(0).get("akey"));
         assertEquals(1, request.getRequestDetails().getConfigurationParameters().size());
-        assertEquals("cvalue", request.getRequestDetails().getConfigurationParameters().get(0).get("ckey"));
+        assertEquals(C_VALUE, request.getRequestDetails().getConfigurationParameters().get(0).get("ckey"));
 
         // payload with config, but no request params
         policy.setPayload(makePayload());
@@ -282,9 +278,8 @@ public class SoActorServiceProviderTest {
      * @param fileName name of the file containing the JSON response
      * @return output from the AAI vserver named-query
      * @throws IOException if the file cannot be read
-     * @throws JAXBException throws JAXBException
      */
-    private AaiCqResponse loadAaiResponseCq(String fileName) throws IOException, JAXBException {
+    private AaiCqResponse loadAaiResponseCq(String fileName) throws IOException {
         String resp = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8);
         return new AaiCqResponse(resp);
     }
@@ -316,7 +311,7 @@ public class SoActorServiceProviderTest {
         params.setUsePreload(true);
 
         Map<String, String> map = new TreeMap<>();
-        map.put("akey", "avalue");
+        map.put("akey", A_VALUE);
 
         List<Map<String, String>> lst = new LinkedList<>();
         lst.add(map);
@@ -333,7 +328,7 @@ public class SoActorServiceProviderTest {
      */
     private String makeConfigParams() {
         Map<String, String> map = new TreeMap<>();
-        map.put("ckey", "cvalue");
+        map.put("ckey", C_VALUE);
 
         List<Map<String, String>> lst = new LinkedList<>();
         lst.add(map);
index 61cf81d..a41d9e8 100644 (file)
@@ -41,6 +41,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class VfcActorServiceProvider implements Actor {
+    private static final String GENERIC_VNF_ID = "generic-vnf.vnf-id";
+
     private static final Logger logger = LoggerFactory.getLogger(VfcActorServiceProvider.class);
 
     // Strings for VFC Actor
@@ -105,7 +107,7 @@ public class VfcActorServiceProvider implements Actor {
         request.setNsInstanceId(serviceInstance);
         request.setRequestId(onset.getRequestId());
         request.setHealRequest(new VfcHealRequest());
-        request.getHealRequest().setVnfInstanceId(onset.getAai().get("generic-vnf.vnf-id"));
+        request.getHealRequest().setVnfInstanceId(onset.getAai().get(GENERIC_VNF_ID));
         request.getHealRequest().setCause(operation.getMessage());
         request.getHealRequest().setAdditionalParams(new VfcHealAdditionalParams());
 
@@ -127,7 +129,7 @@ public class VfcActorServiceProvider implements Actor {
         AaiGetVnfResponse response = null;
         UUID requestId = event.getRequestId();
         String vnfName = event.getAai().get("generic-vnf.vnf-name");
-        String vnfId = event.getAai().get("generic-vnf.vnf-id");
+        String vnfId = event.getAai().get(GENERIC_VNF_ID);
         try {
             if (vnfName != null) {
                 String url = aaiUrl + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
@@ -176,7 +178,7 @@ public class VfcActorServiceProvider implements Actor {
         request.setNsInstanceId(serviceInstance);
         request.setRequestId(onset.getRequestId());
         request.setHealRequest(new VfcHealRequest());
-        request.getHealRequest().setVnfInstanceId(onset.getAai().get("generic-vnf.vnf-id"));
+        request.getHealRequest().setVnfInstanceId(onset.getAai().get(GENERIC_VNF_ID));
         request.getHealRequest().setCause(operation.getMessage());
         request.getHealRequest().setAdditionalParams(new VfcHealAdditionalParams());
 
index 8d5d5fa..54bb995 100644 (file)
@@ -25,14 +25,12 @@ package org.onap.policy.controlloop.actor.vfc;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.util.Objects;
 import java.util.UUID;
 import org.apache.commons.io.IOUtils;
-import org.eclipse.persistence.exceptions.JAXBException;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -47,16 +45,18 @@ import org.onap.policy.vfc.VfcRequest;
 
 public class VfcActorServiceProviderTest {
 
+    private static final String LOCAL_URL = "http://localhost:6666";
+    private static final String DOROTHY_GALE_1939 = "dorothy.gale.1939";
+    private static final String CQ_RESPONSE_JSON = "aai/AaiCqResponse.json";
+    private static final String RESTART = "Restart";
+
     /**
-     * Set up for test class.
+     * Set up before test class.
+     * @throws Exception if the A&AI simulator cannot be started
      */
     @BeforeClass
-    public static void setUpSimulator() {
-        try {
-            Util.buildAaiSim();
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
+    public static void setUpSimulator() throws Exception {
+        Util.buildAaiSim();
     }
 
     @AfterClass
@@ -74,40 +74,40 @@ public class VfcActorServiceProviderTest {
 
         assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, null, null, null));
 
-        onset.getAai().put("generic-vnf.vnf-id", "dorothy.gale.1939");
+        onset.getAai().put("generic-vnf.vnf-id", DOROTHY_GALE_1939);
         assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, null, null, null));
 
-        assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666",
+        assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL,
                 "AAI", "AAI"));
 
         UUID requestId = UUID.randomUUID();
         onset.setRequestId(requestId);
-        assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666",
+        assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL,
                 "AAI", "AAI"));
 
         onset.getAai().put("generic-vnf.vnf-name", "Dorothy");
-        assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666",
+        assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL,
                 "AAI", null));
 
-        assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666",
+        assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL,
                 "AAI", "AAI"));
 
         onset.getAai().put("service-instance.service-instance-id", "");
-        assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, "http://localhost:6666",
+        assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL,
                 "AAI", "AAI"));
 
         assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(),
-                "http://localhost:6666", "AAI", "AAI"));
+                LOCAL_URL, "AAI", "AAI"));
 
-        policy.setRecipe("Restart");
+        policy.setRecipe(RESTART);
         assertNotNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(),
-                "http://localhost:6666", "AAI", "AAI"));
+                LOCAL_URL, "AAI", "AAI"));
 
         VfcRequest request = VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(),
-                "http://localhost:6666", "AAI", "AAI");
+                LOCAL_URL, "AAI", "AAI");
 
         assertEquals(requestId, Objects.requireNonNull(request).getRequestId());
-        assertEquals("dorothy.gale.1939", request.getHealRequest().getVnfInstanceId());
+        assertEquals(DOROTHY_GALE_1939, request.getHealRequest().getVnfInstanceId());
         assertEquals("restartvm", request.getHealRequest().getAdditionalParams().getAction());
     }
 
@@ -117,13 +117,13 @@ public class VfcActorServiceProviderTest {
 
         assertEquals("VFC", sp.actor());
         assertEquals(1, sp.recipes().size());
-        assertEquals("Restart", sp.recipes().get(0));
-        assertEquals("VM", sp.recipeTargets("Restart").get(0));
-        assertEquals(0, sp.recipePayloads("Restart").size());
+        assertEquals(RESTART, sp.recipes().get(0));
+        assertEquals("VM", sp.recipeTargets(RESTART).get(0));
+        assertEquals(0, sp.recipePayloads(RESTART).size());
     }
 
     @Test
-    public void testConstructRequestCq() throws IOException, JAXBException {
+    public void testConstructRequestCq() throws IOException {
         VirtualControlLoopEvent onset = new VirtualControlLoopEvent();
         ControlLoopOperation operation = new ControlLoopOperation();
 
@@ -132,7 +132,7 @@ public class VfcActorServiceProviderTest {
 
         assertNull(VfcActorServiceProvider.constructRequestCq(onset, operation, policy, null));
 
-        onset.getAai().put("generic-vnf.vnf-id", "dorothy.gale.1939");
+        onset.getAai().put("generic-vnf.vnf-id", DOROTHY_GALE_1939);
         assertNull(VfcActorServiceProvider.constructRequestCq(onset, operation, policy, null));
 
 
@@ -148,17 +148,17 @@ public class VfcActorServiceProviderTest {
         assertNull(VfcActorServiceProvider.constructRequestCq(onset, operation, policy, null));
 
         assertNull(VfcActorServiceProvider.constructRequestCq(onset, operation, policy,
-                loadAaiResponse("aai/AaiCqResponse.json")));
+                loadAaiResponse(CQ_RESPONSE_JSON)));
 
-        policy.setRecipe("Restart");
+        policy.setRecipe(RESTART);
         assertNotNull(VfcActorServiceProvider.constructRequestCq(onset, operation, policy,
-                loadAaiResponse("aai/AaiCqResponse.json")));
+                loadAaiResponse(CQ_RESPONSE_JSON)));
 
         VfcRequest request = VfcActorServiceProvider.constructRequestCq(onset, operation, policy,
-                loadAaiResponse("aai/AaiCqResponse.json"));
+                loadAaiResponse(CQ_RESPONSE_JSON));
 
         assertEquals(requestId, Objects.requireNonNull(request).getRequestId());
-        assertEquals("dorothy.gale.1939", request.getHealRequest().getVnfInstanceId());
+        assertEquals(DOROTHY_GALE_1939, request.getHealRequest().getVnfInstanceId());
         assertEquals("restartvm", request.getHealRequest().getAdditionalParams().getAction());
     }
 
@@ -168,9 +168,8 @@ public class VfcActorServiceProviderTest {
      * @param fileName name of the file containing the JSON response
      * @return output from the AAI vserver named-query
      * @throws IOException if the file cannot be read
-     * @throws JAXBException throws JAXBException
      */
-    private AaiCqResponse loadAaiResponse(String fileName) throws IOException, JAXBException {
+    private AaiCqResponse loadAaiResponse(String fileName) throws IOException {
         String resp = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8);
         return new AaiCqResponse(resp);
     }
index 3354a22..7ab21de 100644 (file)
@@ -4,6 +4,7 @@
  * ================================================================================
  * Copyright (C) 2018 Ericsson. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,6 +30,8 @@ import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
 
 public class ActorServiceProviderTest {
 
+    private static final String DOROTHY = "Dorothy";
+
     @Test
     public void testActorServiceProvider() {
         ActorService actorService = ActorService.getInstance();
@@ -45,10 +48,10 @@ public class ActorServiceProviderTest {
         assertEquals("DummyActor", dummyActor.actor());
 
         assertEquals(2, dummyActor.recipes().size());
-        assertEquals("Dorothy", dummyActor.recipes().get(0));
+        assertEquals(DOROTHY, dummyActor.recipes().get(0));
         assertEquals("Wizard", dummyActor.recipes().get(1));
 
-        assertEquals(2, dummyActor.recipeTargets("Dorothy").size());
-        assertEquals(2, dummyActor.recipePayloads("Dorothy").size());
+        assertEquals(2, dummyActor.recipeTargets(DOROTHY).size());
+        assertEquals(2, dummyActor.recipePayloads(DOROTHY).size());
     }
 }
index 2b51a7b..20998ae 100644 (file)
@@ -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;
     }
index efdba10..8335ce8 100644 (file)
@@ -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());
 
     }
index 7842b07..9a8d7d2 100644 (file)
@@ -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);
     }
index 6932031..9bdc758 100644 (file)
@@ -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();
index e1ac237..ed76f8a 100644 (file)
@@ -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();
index ebc64ef..4837536 100644 (file)
@@ -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();
index e30bcaf..93119c7 100644 (file)
@@ -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());
index 0c487d4..4b4cc6a 100644 (file)
@@ -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();
index 97384db..79f23b6 100644 (file)
@@ -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");
index f43d7c7..ef1dd4e 100644 (file)
@@ -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());
index 2986f6d..a4344d8 100644 (file)
@@ -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();
index 22c1b4b..f304713 100644 (file)
@@ -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();
index a886319..35108a0 100644 (file)
@@ -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();
index 9b3a4af..ba160e2 100644 (file)
@@ -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());
index 459454e..f80fd82 100644 (file)
@@ -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;
index 4dc9b15..45a55c9 100644 (file)
@@ -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();
index 4e03f57..ed4cdb7 100644 (file)
@@ -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();
index c6a04a5..c613a02 100644 (file)
@@ -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
index da169d5..65bde98 100644 (file)
@@ -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();
index ab397cd..8cf8391 100644 (file)
@@ -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");
index b5b1520..54cf473 100644 (file)
@@ -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));
index 3a24d8c..d323690 100644 (file)
@@ -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;
index 4be8a53..c15407d 100644 (file)
@@ -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()));
     }
 
index 5ff71e0..ad8fc1f 100644 (file)
  * ============LICENSE_END=========================================================
  */
 
-/*-
- * ============LICENSE_START=======================================================
- * appc
- * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
 package org.onap.policy.appc;
 
 import static org.junit.Assert.assertEquals;
@@ -58,6 +37,10 @@ import org.junit.Test;
 
 public class CommonHeaderTest {
 
+    private static final String KANSAS = "Kansas";
+    private static final String DOROTHY = "Dorothy";
+    private static final String CAN_I_GO_HOME = "Can I go home?";
+
     @Test
     public void testCommonHeader() {
         CommonHeader commonHeader = new CommonHeader();
@@ -65,15 +48,15 @@ public class CommonHeaderTest {
         assertNotNull(new CommonHeader(commonHeader));
         assertNotEquals(0, commonHeader.hashCode());
 
-        commonHeader.setApiVer("Kansas");
-        assertEquals("Kansas", commonHeader.getApiVer());
+        commonHeader.setApiVer(KANSAS);
+        assertEquals(KANSAS, commonHeader.getApiVer());
 
         List<Map<String, String>> flagSet = new ArrayList<>();
         commonHeader.setFlags(flagSet);
         assertEquals(flagSet, commonHeader.getFlags());
 
-        commonHeader.setOriginatorId("Dorothy");
-        assertEquals("Dorothy", commonHeader.getOriginatorId());
+        commonHeader.setOriginatorId(DOROTHY);
+        assertEquals(DOROTHY, commonHeader.getOriginatorId());
 
         UUID requestId = UUID.randomUUID();
         commonHeader.setRequestId(requestId);
@@ -83,8 +66,8 @@ public class CommonHeaderTest {
         commonHeader.setRequestTrack(requestTrackSet);
         assertEquals(requestTrackSet, commonHeader.getRequestTrack());
 
-        commonHeader.setSubRequestId("Can I go home?");
-        assertEquals("Can I go home?", commonHeader.getSubRequestId());
+        commonHeader.setSubRequestId(CAN_I_GO_HOME);
+        assertEquals(CAN_I_GO_HOME, commonHeader.getSubRequestId());
 
         Instant timestamp = Instant.now();
         commonHeader.setTimeStamp(timestamp);
@@ -118,9 +101,9 @@ public class CommonHeaderTest {
         assertFalse(commonHeader.equals(copiedCommonHeader));
         copiedCommonHeader.setApiVer(null);
         assertTrue(commonHeader.equals(copiedCommonHeader));
-        commonHeader.setApiVer("Kansas");
+        commonHeader.setApiVer(KANSAS);
         assertFalse(commonHeader.equals(copiedCommonHeader));
-        copiedCommonHeader.setApiVer("Kansas");
+        copiedCommonHeader.setApiVer(KANSAS);
         assertTrue(commonHeader.equals(copiedCommonHeader));
 
         commonHeader.setFlags(null);
@@ -136,9 +119,9 @@ public class CommonHeaderTest {
         assertFalse(commonHeader.equals(copiedCommonHeader));
         copiedCommonHeader.setOriginatorId(null);
         assertTrue(commonHeader.equals(copiedCommonHeader));
-        commonHeader.setOriginatorId("Dorothy");
+        commonHeader.setOriginatorId(DOROTHY);
         assertFalse(commonHeader.equals(copiedCommonHeader));
-        copiedCommonHeader.setOriginatorId("Dorothy");
+        copiedCommonHeader.setOriginatorId(DOROTHY);
         assertTrue(commonHeader.equals(copiedCommonHeader));
 
         commonHeader.setRequestId(null);
@@ -163,9 +146,9 @@ public class CommonHeaderTest {
         assertFalse(commonHeader.equals(copiedCommonHeader));
         copiedCommonHeader.setSubRequestId(null);
         assertTrue(commonHeader.equals(copiedCommonHeader));
-        commonHeader.setSubRequestId("Can I go home?");
+        commonHeader.setSubRequestId(CAN_I_GO_HOME);
         assertFalse(commonHeader.equals(copiedCommonHeader));
-        copiedCommonHeader.setSubRequestId("Can I go home?");
+        copiedCommonHeader.setSubRequestId(CAN_I_GO_HOME);
         assertTrue(commonHeader.equals(copiedCommonHeader));
 
         commonHeader.setTimeStamp(null);
index 0f461d2..560a7d8 100644 (file)
@@ -34,6 +34,9 @@ import org.junit.Test;
 
 public class RequestTest {
 
+    private static final String WIZARD = "Wizard";
+    private static final String GO_TO_OZ = "Go to Oz";
+
     @Test
     public void testRequest() {
         Request request = new Request();
@@ -45,11 +48,11 @@ public class RequestTest {
         request.setCommonHeader(commonHeader);
         assertEquals(commonHeader, request.getCommonHeader());
 
-        request.setAction("Go to Oz");
-        assertEquals("Go to Oz", request.getAction());
+        request.setAction(GO_TO_OZ);
+        assertEquals(GO_TO_OZ, request.getAction());
 
-        request.setObjectId("Wizard");
-        assertEquals("Wizard", request.getObjectId());
+        request.setObjectId(WIZARD);
+        assertEquals(WIZARD, request.getObjectId());
 
         request.setTargetId("Oz");
         assertEquals("Oz", request.getTargetId());
@@ -90,18 +93,18 @@ public class RequestTest {
         assertFalse(request.equals(copiedRequest));
         copiedRequest.setAction(null);
         assertTrue(request.equals(copiedRequest));
-        request.setAction("Go to Oz");
+        request.setAction(GO_TO_OZ);
         assertFalse(request.equals(copiedRequest));
-        copiedRequest.setAction("Go to Oz");
+        copiedRequest.setAction(GO_TO_OZ);
         assertTrue(request.equals(copiedRequest));
 
         request.setObjectId(null);
         assertFalse(request.equals(copiedRequest));
         copiedRequest.setObjectId(null);
         assertTrue(request.equals(copiedRequest));
-        request.setObjectId("Wizard");
+        request.setObjectId(WIZARD);
         assertFalse(request.equals(copiedRequest));
-        copiedRequest.setObjectId("Wizard");
+        copiedRequest.setObjectId(WIZARD);
         assertTrue(request.equals(copiedRequest));
 
         request.setTargetId(null);
index 561c949..2541f9b 100644 (file)
@@ -31,6 +31,9 @@ import org.junit.Test;
 
 public class ResponseStatusTest {
 
+    private static final String THERE_S_NO_PLACE_LIKE_HOME = "There's no place like home";
+    private static final String THE_WONDERFUL_LAND_OF_OZ = "The wonderful land of Oz";
+
     @Test
     public void testResonseStatus() {
         ResponseStatus status = new ResponseStatus();
@@ -40,11 +43,11 @@ public class ResponseStatusTest {
         status.setCode(1234);
         assertEquals(1234, status.getCode());
 
-        status.setDescription("The wonderful land of Oz");
-        assertEquals("The wonderful land of Oz", status.getDescription());
+        status.setDescription(THE_WONDERFUL_LAND_OF_OZ);
+        assertEquals(THE_WONDERFUL_LAND_OF_OZ, status.getDescription());
 
-        status.setValue("There's no place like home");
-        assertEquals("There's no place like home", status.getValue());
+        status.setValue(THERE_S_NO_PLACE_LIKE_HOME);
+        assertEquals(THERE_S_NO_PLACE_LIKE_HOME, status.getValue());
         assertNotEquals(0, status.hashCode());
 
         assertEquals("ResponseStatus [Code=1234, Value=There's no pla", status.toString().substring(0, 47));
@@ -72,18 +75,18 @@ public class ResponseStatusTest {
         assertFalse(status.equals(copiedStatus));
         copiedStatus.setDescription(null);
         assertTrue(status.equals(copiedStatus));
-        status.setDescription("The wonderful land of Oz");
+        status.setDescription(THE_WONDERFUL_LAND_OF_OZ);
         assertFalse(status.equals(copiedStatus));
-        copiedStatus.setDescription("The wonderful land of Oz");
+        copiedStatus.setDescription(THE_WONDERFUL_LAND_OF_OZ);
         assertTrue(status.equals(copiedStatus));
 
         status.setValue(null);
         assertFalse(status.equals(copiedStatus));
         copiedStatus.setValue(null);
         assertTrue(status.equals(copiedStatus));
-        status.setValue("There's no place like home");
+        status.setValue(THERE_S_NO_PLACE_LIKE_HOME);
         assertFalse(status.equals(copiedStatus));
-        copiedStatus.setValue("There's no place like home");
+        copiedStatus.setValue(THERE_S_NO_PLACE_LIKE_HOME);
         assertTrue(status.equals(copiedStatus));
     }
 }
index 0ca6239..0ee79cf 100644 (file)
@@ -35,6 +35,12 @@ import org.slf4j.LoggerFactory;
 
 public class AppcLcmTest {
 
+    private static final String VNF_ID_KEY = "vnf-id";
+
+    private static final String RESTART = "restart";
+
+    private static final String CORRELATION_ID = "664be3d2-6c12-4f4b-a3e7-c349acced200";
+
     private static final Logger logger = LoggerFactory.getLogger(AppcLcmTest.class);
 
     private static LcmRequestWrapper dmaapRequest;
@@ -45,29 +51,29 @@ public class AppcLcmTest {
          * Construct an APPCLCM Request to be Serialized
          */
         dmaapRequest = new LcmRequestWrapper();
-        dmaapRequest.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1");
-        dmaapRequest.setRpcName("restart");
+        dmaapRequest.setCorrelationId(CORRELATION_ID + "-" + "1");
+        dmaapRequest.setRpcName(RESTART);
         dmaapRequest.setType("request");
 
         dmaapResponse = new LcmResponseWrapper();
-        dmaapResponse.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1");
-        dmaapResponse.setRpcName("restart");
+        dmaapResponse.setCorrelationId(CORRELATION_ID + "-" + "1");
+        dmaapResponse.setRpcName(RESTART);
         dmaapResponse.setType("response");
 
         LcmRequest appcRequest = new LcmRequest();
 
-        appcRequest.setAction("restart");
+        appcRequest.setAction(RESTART);
 
         HashMap<String, String> actionIdentifiers = new HashMap<>();
-        actionIdentifiers.put("vnf-id", "trial-vnf-003");
+        actionIdentifiers.put(VNF_ID_KEY, "trial-vnf-003");
         actionIdentifiers.put("vserver-id", "08f6c1f9-99e7-49f3-a662-c62b9f200d79");
 
         appcRequest.setActionIdentifiers(actionIdentifiers);
 
         LcmCommonHeader commonHeader = new LcmCommonHeader();
-        commonHeader.setRequestId(UUID.fromString("664be3d2-6c12-4f4b-a3e7-c349acced200"));
+        commonHeader.setRequestId(UUID.fromString(CORRELATION_ID));
         commonHeader.setSubRequestId("1");
-        commonHeader.setOriginatorId("664be3d2-6c12-4f4b-a3e7-c349acced200");
+        commonHeader.setOriginatorId(CORRELATION_ID);
 
         appcRequest.setCommonHeader(commonHeader);
 
@@ -111,7 +117,7 @@ public class AppcLcmTest {
          * action-identifiers should exist and contain a vnf-id
          */
         assertTrue(jsonRequest.contains("action-identifiers"));
-        assertTrue(jsonRequest.contains("vnf-id"));
+        assertTrue(jsonRequest.contains(VNF_ID_KEY));
 
         /*
          * The action sub-tag should exist
@@ -132,19 +138,19 @@ public class AppcLcmTest {
         /*
          * Use the serializer to convert the json string into a java object
          */
-        LcmRequestWrapper dmaapRequest = Serialization.gson.fromJson(jsonRequest, LcmRequestWrapper.class);
-        assertNotNull(dmaapRequest);
+        LcmRequestWrapper req = Serialization.gson.fromJson(jsonRequest, LcmRequestWrapper.class);
+        assertNotNull(req);
 
         /*
          * The type of the DMAAP wrapper should be request
          */
-        assertEquals("request", dmaapRequest.getType());
+        assertEquals("request", req.getType());
 
         /*
          * The DMAAP wrapper must have a body as that is the true APPC request
          */
-        assertNotNull(dmaapRequest.getBody());
-        LcmRequest appcRequest = dmaapRequest.getBody();
+        assertNotNull(req.getBody());
+        LcmRequest appcRequest = req.getBody();
         assertNotNull(appcRequest);
 
         /*
@@ -156,13 +162,13 @@ public class AppcLcmTest {
          * The action should not be null and should be set to restart
          */
         assertNotNull(appcRequest.getAction());
-        assertEquals("restart", appcRequest.getAction());
+        assertEquals(RESTART, appcRequest.getAction());
 
         /*
          * The action-identifiers should not be null and should contain a vnf-id
          */
         assertNotNull(appcRequest.getActionIdentifiers());
-        assertNotNull(appcRequest.getActionIdentifiers().get("vnf-id"));
+        assertNotNull(appcRequest.getActionIdentifiers().get(VNF_ID_KEY));
 
         logger.debug("Request as a Java Object: \n" + appcRequest.toString() + "\n\n");
     }
@@ -202,19 +208,19 @@ public class AppcLcmTest {
         /*
          * Use the serializer to convert the json string into a java object
          */
-        LcmResponseWrapper dmaapResponse = Serialization.gson.fromJson(jsonResponse, LcmResponseWrapper.class);
-        assertNotNull(dmaapResponse);
+        LcmResponseWrapper resp = Serialization.gson.fromJson(jsonResponse, LcmResponseWrapper.class);
+        assertNotNull(resp);
 
         /*
          * The type of the DMAAP wrapper should be response
          */
-        assertEquals("response", dmaapResponse.getType());
+        assertEquals("response", resp.getType());
 
         /*
          * The DMAAP wrapper must have a body as that is the true APPC response
          */
-        assertNotNull(dmaapResponse.getBody());
-        LcmResponse appcResponse = dmaapResponse.getBody();
+        assertNotNull(resp.getBody());
+        LcmResponse appcResponse = resp.getBody();
         assertNotNull(appcResponse);
 
         /*
index 7825e7f..32a4954 100644 (file)
@@ -36,6 +36,10 @@ import org.junit.Test;
 
 public class LcmCommonHeaderTest {
 
+    private static final String KANSAS = "Kansas";
+    private static final String DOROTHY = "Dorothy";
+    private static final String CAN_I_GO_HOME = "Can I go home?";
+
     @Test
     public void testLcmCommonHeader() {
         LcmCommonHeader commonHeader = new LcmCommonHeader();
@@ -43,22 +47,22 @@ public class LcmCommonHeaderTest {
         assertNotNull(new LcmCommonHeader(commonHeader));
         assertNotEquals(0, commonHeader.hashCode());
 
-        commonHeader.setApiVer("Kansas");
-        assertEquals("Kansas", commonHeader.getApiVer());
+        commonHeader.setApiVer(KANSAS);
+        assertEquals(KANSAS, commonHeader.getApiVer());
 
         Map<String, String> flagMap = new HashMap<>();
         commonHeader.setFlags(flagMap);
         assertEquals(flagMap, commonHeader.getFlags());
 
-        commonHeader.setOriginatorId("Dorothy");
-        assertEquals("Dorothy", commonHeader.getOriginatorId());
+        commonHeader.setOriginatorId(DOROTHY);
+        assertEquals(DOROTHY, commonHeader.getOriginatorId());
 
         UUID requestId = UUID.randomUUID();
         commonHeader.setRequestId(requestId);
         assertEquals(requestId, commonHeader.getRequestId());
 
-        commonHeader.setSubRequestId("Can I go home?");
-        assertEquals("Can I go home?", commonHeader.getSubRequestId());
+        commonHeader.setSubRequestId(CAN_I_GO_HOME);
+        assertEquals(CAN_I_GO_HOME, commonHeader.getSubRequestId());
 
         Instant timestamp = Instant.now();
         commonHeader.setTimeStamp(timestamp);
@@ -91,9 +95,9 @@ public class LcmCommonHeaderTest {
         assertFalse(commonHeader.equals(copiedLcmCommonHeader));
         copiedLcmCommonHeader.setApiVer(null);
         assertTrue(commonHeader.equals(copiedLcmCommonHeader));
-        commonHeader.setApiVer("Kansas");
+        commonHeader.setApiVer(KANSAS);
         assertFalse(commonHeader.equals(copiedLcmCommonHeader));
-        copiedLcmCommonHeader.setApiVer("Kansas");
+        copiedLcmCommonHeader.setApiVer(KANSAS);
         assertTrue(commonHeader.equals(copiedLcmCommonHeader));
 
         commonHeader.setFlags(null);
@@ -109,9 +113,9 @@ public class LcmCommonHeaderTest {
         assertFalse(commonHeader.equals(copiedLcmCommonHeader));
         copiedLcmCommonHeader.setOriginatorId(null);
         assertTrue(commonHeader.equals(copiedLcmCommonHeader));
-        commonHeader.setOriginatorId("Dorothy");
+        commonHeader.setOriginatorId(DOROTHY);
         assertFalse(commonHeader.equals(copiedLcmCommonHeader));
-        copiedLcmCommonHeader.setOriginatorId("Dorothy");
+        copiedLcmCommonHeader.setOriginatorId(DOROTHY);
         assertTrue(commonHeader.equals(copiedLcmCommonHeader));
 
         commonHeader.setRequestId(null);
@@ -127,9 +131,9 @@ public class LcmCommonHeaderTest {
         assertFalse(commonHeader.equals(copiedLcmCommonHeader));
         copiedLcmCommonHeader.setSubRequestId(null);
         assertTrue(commonHeader.equals(copiedLcmCommonHeader));
-        commonHeader.setSubRequestId("Can I go home?");
+        commonHeader.setSubRequestId(CAN_I_GO_HOME);
         assertFalse(commonHeader.equals(copiedLcmCommonHeader));
-        copiedLcmCommonHeader.setSubRequestId("Can I go home?");
+        copiedLcmCommonHeader.setSubRequestId(CAN_I_GO_HOME);
         assertTrue(commonHeader.equals(copiedLcmCommonHeader));
 
         commonHeader.setTimeStamp(null);
index 4b392f8..4066293 100644 (file)
@@ -34,6 +34,9 @@ import org.junit.Test;
 
 public class LcmRequestTest {
 
+    private static final String THE_EMERALD_CITY = "The Emerald City";
+    private static final String GO_TO_OZ = "Go to Oz";
+
     @Test
     public void testLcmRequest() {
         LcmRequest request = new LcmRequest();
@@ -45,8 +48,8 @@ public class LcmRequestTest {
         request.setCommonHeader(commonHeader);
         assertEquals(commonHeader, request.getCommonHeader());
 
-        request.setAction("Go to Oz");
-        assertEquals("Go to Oz", request.getAction());
+        request.setAction(GO_TO_OZ);
+        assertEquals(GO_TO_OZ, request.getAction());
 
         Map<String, String> actionIdentifiers = new HashMap<>();
         actionIdentifiers.put("North", "Good Witch");
@@ -55,8 +58,8 @@ public class LcmRequestTest {
         request.setActionIdentifiers(actionIdentifiers);
         assertEquals(actionIdentifiers, request.getActionIdentifiers());
 
-        request.setPayload("The Emerald City");
-        assertEquals("The Emerald City", request.getPayload());
+        request.setPayload(THE_EMERALD_CITY);
+        assertEquals(THE_EMERALD_CITY, request.getPayload());
 
         assertNotEquals(0, request.hashCode());
 
@@ -86,9 +89,9 @@ public class LcmRequestTest {
         assertFalse(request.equals(copiedLcmRequest));
         copiedLcmRequest.setAction(null);
         assertTrue(request.equals(copiedLcmRequest));
-        request.setAction("Go to Oz");
+        request.setAction(GO_TO_OZ);
         assertFalse(request.equals(copiedLcmRequest));
-        copiedLcmRequest.setAction("Go to Oz");
+        copiedLcmRequest.setAction(GO_TO_OZ);
         assertTrue(request.equals(copiedLcmRequest));
 
         request.setActionIdentifiers(null);
@@ -104,9 +107,9 @@ public class LcmRequestTest {
         assertFalse(request.equals(copiedLcmRequest));
         copiedLcmRequest.setPayload(null);
         assertTrue(request.equals(copiedLcmRequest));
-        request.setPayload("The Emerald City");
+        request.setPayload(THE_EMERALD_CITY);
         assertFalse(request.equals(copiedLcmRequest));
-        copiedLcmRequest.setPayload("The Emerald City");
+        copiedLcmRequest.setPayload(THE_EMERALD_CITY);
         assertTrue(request.equals(copiedLcmRequest));
     }
 }
index b022aa1..a4d1bc6 100644 (file)
@@ -31,6 +31,8 @@ import org.junit.Test;
 
 public class LcmResponseStatusTest {
 
+    private static final String THE_WONDERFUL_LAND_OF_OZ = "The wonderful land of Oz";
+
     @Test
     public void testResonseStatus() {
         LcmResponseStatus status = new LcmResponseStatus();
@@ -40,8 +42,8 @@ public class LcmResponseStatusTest {
         status.setCode(1234);
         assertEquals(1234, status.getCode());
 
-        status.setMessage("The wonderful land of Oz");
-        assertEquals("The wonderful land of Oz", status.getMessage());
+        status.setMessage(THE_WONDERFUL_LAND_OF_OZ);
+        assertEquals(THE_WONDERFUL_LAND_OF_OZ, status.getMessage());
 
         assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0, 47));
 
@@ -67,9 +69,9 @@ public class LcmResponseStatusTest {
         assertFalse(status.equals(copiedStatus));
         copiedStatus.setMessage(null);
         assertTrue(status.equals(copiedStatus));
-        status.setMessage("The wonderful land of Oz");
+        status.setMessage(THE_WONDERFUL_LAND_OF_OZ);
         assertFalse(status.equals(copiedStatus));
-        copiedStatus.setMessage("The wonderful land of Oz");
+        copiedStatus.setMessage(THE_WONDERFUL_LAND_OF_OZ);
         assertTrue(status.equals(copiedStatus));
     }
 }
index 18fdc8c..7d005cd 100644 (file)
@@ -31,26 +31,32 @@ import org.junit.Test;
 
 public class LcmWrapperTest {
 
+    private static final String YELLOW_BRICK_ROAD = "YellowBrickRoad";
+    private static final String TORNADO = "Tornado";
+    private static final String THE_EMERALD_CITY = "The Emerald City";
+    private static final String MUNCHKIN = "Munchkin";
+    private static final String VERSION19 = "19.3.9";
+
     @Test
     public void testLcmWrapper() {
         LcmWrapper wrapper = new LcmWrapper();
         assertNotNull(wrapper);
         assertNotEquals(0, wrapper.hashCode());
 
-        wrapper.setVersion("19.3.9");
-        assertEquals("19.3.9", wrapper.getVersion());
+        wrapper.setVersion(VERSION19);
+        assertEquals(VERSION19, wrapper.getVersion());
 
-        wrapper.setCambriaPartition("The Emerald City");
-        assertEquals("The Emerald City", wrapper.getCambriaPartition());
+        wrapper.setCambriaPartition(THE_EMERALD_CITY);
+        assertEquals(THE_EMERALD_CITY, wrapper.getCambriaPartition());
 
-        wrapper.setRpcName("Tornado");
-        assertEquals("Tornado", wrapper.getRpcName());
+        wrapper.setRpcName(TORNADO);
+        assertEquals(TORNADO, wrapper.getRpcName());
 
-        wrapper.setCorrelationId("YellowBrickRoad");
-        assertEquals("YellowBrickRoad", wrapper.getCorrelationId());
+        wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
+        assertEquals(YELLOW_BRICK_ROAD, wrapper.getCorrelationId());
 
-        wrapper.setType("Munchkin");
-        assertEquals("Munchkin", wrapper.getType());
+        wrapper.setType(MUNCHKIN);
+        assertEquals(MUNCHKIN, wrapper.getType());
 
         assertNotEquals(0, wrapper.hashCode());
 
@@ -72,45 +78,45 @@ public class LcmWrapperTest {
         assertFalse(wrapper.equals(copiedLcmWrapper));
         copiedLcmWrapper.setVersion(null);
         assertTrue(wrapper.equals(copiedLcmWrapper));
-        wrapper.setVersion("19.3.9");
+        wrapper.setVersion(VERSION19);
         assertFalse(wrapper.equals(copiedLcmWrapper));
-        copiedLcmWrapper.setVersion("19.3.9");
+        copiedLcmWrapper.setVersion(VERSION19);
         assertTrue(wrapper.equals(copiedLcmWrapper));
 
         wrapper.setCambriaPartition(null);
         assertFalse(wrapper.equals(copiedLcmWrapper));
         copiedLcmWrapper.setCambriaPartition(null);
         assertTrue(wrapper.equals(copiedLcmWrapper));
-        wrapper.setCambriaPartition("The Emerald City");
+        wrapper.setCambriaPartition(THE_EMERALD_CITY);
         assertFalse(wrapper.equals(copiedLcmWrapper));
-        copiedLcmWrapper.setCambriaPartition("The Emerald City");
+        copiedLcmWrapper.setCambriaPartition(THE_EMERALD_CITY);
         assertTrue(wrapper.equals(copiedLcmWrapper));
 
         wrapper.setRpcName(null);
         assertFalse(wrapper.equals(copiedLcmWrapper));
         copiedLcmWrapper.setRpcName(null);
         assertTrue(wrapper.equals(copiedLcmWrapper));
-        wrapper.setRpcName("Tornado");
+        wrapper.setRpcName(TORNADO);
         assertFalse(wrapper.equals(copiedLcmWrapper));
-        copiedLcmWrapper.setRpcName("Tornado");
+        copiedLcmWrapper.setRpcName(TORNADO);
         assertTrue(wrapper.equals(copiedLcmWrapper));
 
         wrapper.setCorrelationId(null);
         assertFalse(wrapper.equals(copiedLcmWrapper));
         copiedLcmWrapper.setCorrelationId(null);
         assertTrue(wrapper.equals(copiedLcmWrapper));
-        wrapper.setCorrelationId("YellowBrickRoad");
+        wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
         assertFalse(wrapper.equals(copiedLcmWrapper));
-        copiedLcmWrapper.setCorrelationId("YellowBrickRoad");
+        copiedLcmWrapper.setCorrelationId(YELLOW_BRICK_ROAD);
         assertTrue(wrapper.equals(copiedLcmWrapper));
 
         wrapper.setType(null);
         assertFalse(wrapper.equals(copiedLcmWrapper));
         copiedLcmWrapper.setType(null);
         assertTrue(wrapper.equals(copiedLcmWrapper));
-        wrapper.setType("Munchkin");
+        wrapper.setType(MUNCHKIN);
         assertFalse(wrapper.equals(copiedLcmWrapper));
-        copiedLcmWrapper.setType("Munchkin");
+        copiedLcmWrapper.setType(MUNCHKIN);
         assertTrue(wrapper.equals(copiedLcmWrapper));
     }
 }
index 3957fe5..17eefd2 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2019 Bell Canada.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,12 +50,12 @@ public class BasicAuthClientHeaderInterceptor implements ClientInterceptor {
     }
 
     @Override
-    public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> method,
+    public <Q, P> ClientCall<Q, P> interceptCall(MethodDescriptor<Q, P> method,
         CallOptions callOptions, Channel channel) {
         Key<String> authHeader = Key.of(BASIC_AUTH_HEADER_KEY, Metadata.ASCII_STRING_MARSHALLER);
-        return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(channel.newCall(method, callOptions)) {
+        return new ForwardingClientCall.SimpleForwardingClientCall<Q, P>(channel.newCall(method, callOptions)) {
             @Override
-            public void start(Listener<RespT> responseListener, Metadata headers) {
+            public void start(Listener<P> responseListener, Metadata headers) {
                 headers.put(authHeader, props.getBasicAuth());
                 super.start(responseListener, headers);
             }
index 94a336b..2e91981 100644 (file)
@@ -39,7 +39,6 @@ public class CdsServerProperties implements ParameterGroup {
     private static final int MIN_USER_PORT = 1024;
     private static final int MAX_USER_PORT = 65535;
 
-    private static final String INVALID_PROP = "Invalid CDS property: ";
     private static final String SERVER_PROPERTIES_TYPE = "CDS gRPC Server Properties";
 
     // CDS carrier properties
index 3b6ad7d..fedf470 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2019 Bell Canada.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -127,9 +128,8 @@ public class BasicAuthClientHeaderInterceptorTest {
     private static class TestServerInterceptor implements ServerInterceptor {
 
         @Override
-        public <ReqT, RespT> Listener<ReqT> interceptCall(final ServerCall<ReqT, RespT> serverCall,
-            final Metadata metadata,
-            final ServerCallHandler<ReqT, RespT> serverCallHandler) {
+        public <Q, P> Listener<Q> interceptCall(final ServerCall<Q, P> serverCall,
+                        final Metadata metadata, final ServerCallHandler<Q, P> serverCallHandler) {
             return serverCallHandler.startCall(serverCall, metadata);
         }
     }
index b9a9a84..17b4dc5 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2019 Bell Canada.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,9 +20,8 @@
 package org.onap.policy.cds.client;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
@@ -128,13 +128,13 @@ public class CdsProcessorGrpcClientTest {
 
     @Test
     public void testCdsProcessorGrpcClientConstructor() {
-        new CdsProcessorGrpcClient(listener, props);
+        new CdsProcessorGrpcClient(listener, props).close();
     }
 
     @Test(expected = IllegalStateException.class)
     public void testCdsProcessorGrpcClientConstructorFailure() {
         props.setHost(null);
-        new CdsProcessorGrpcClient(listener, props);
+        new CdsProcessorGrpcClient(listener, props).close();
     }
 
     @Test
index 0c1070e..2ad0972 100644 (file)
@@ -61,7 +61,7 @@ public class ControlLoopNotificationTest {
         assertEquals("from", notification.getFrom());
 
         notification.setHistory(Collections.emptyList());
-        assertTrue(notification.getHistory().size() == 0);
+        assertTrue(notification.getHistory().isEmpty());
 
         notification.setMessage("message");
         assertEquals("message", notification.getMessage());
index bf23e57..fd17f78 100644 (file)
@@ -21,8 +21,8 @@
 
 package org.onap.policy.controlloop.params;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 
@@ -41,11 +41,11 @@ public class ControlLoopParamsTest {
 
         ControlLoopParams params2 = new ControlLoopParams(params);
 
-        assertTrue(params2.getClosedLoopControlName().equals("name"));
-        assertTrue(params2.getControlLoopYaml().equals("yaml"));
-        assertTrue(params2.getPolicyName().equals("name"));
-        assertTrue(params2.getPolicyScope().equals("scope"));
-        assertTrue(params2.getPolicyVersion().equals("1"));
+        assertEquals("name", params2.getClosedLoopControlName());
+        assertEquals("yaml", params2.getControlLoopYaml());
+        assertEquals("name", params2.getPolicyName());
+        assertEquals("scope", params2.getPolicyScope());
+        assertEquals("1", params2.getPolicyVersion());
 
     }
 }
index efdf5f2..9dafc41 100644 (file)
@@ -96,7 +96,7 @@ public class PdpProvider {
             throws PfModelException {
 
         for (PdpGroup pdpGroup : pdpGroups) {
-            JpaPdpGroup jpaPdpGroup = new JpaPdpGroup();;
+            JpaPdpGroup jpaPdpGroup = new JpaPdpGroup();
             jpaPdpGroup.fromAuthorative(pdpGroup);
 
             PfValidationResult validationResult = jpaPdpGroup.validate(new PfValidationResult());
@@ -133,7 +133,7 @@ public class PdpProvider {
             throws PfModelException {
 
         for (PdpGroup pdpGroup : pdpGroups) {
-            JpaPdpGroup jpaPdpGroup = new JpaPdpGroup();;
+            JpaPdpGroup jpaPdpGroup = new JpaPdpGroup();
             jpaPdpGroup.fromAuthorative(pdpGroup);
 
             PfValidationResult validationResult = jpaPdpGroup.validate(new PfValidationResult());
index 89ee5b9..808bfe7 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -42,6 +43,20 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi
  * @author Liam Fallon (liam.fallon@est.tech)
  */
 public class PdpGroupFilterTest {
+    private static final String POLICY_TYPE3 = "policy.type.3";
+    private static final String POLICY_TYPE2 = "policy.type.2";
+    private static final String POLICY_TYPE1 = "policy.type.1";
+    private static final String POLICY_TYPE0 = "policy.type.0";
+    private static final String POLICY3 = "Policy3";
+    private static final String POLICY2 = "Policy2";
+    private static final String POLICY1 = "Policy1";
+    private static final String POLICY0 = "Policy0";
+    private static final String NON_EXISTANT = "Nonexistant";
+    private static final String VERSION9 = "9.9.9";
+    private static final String VERSION7 = "7.8.9";
+    private static final String VERSION4 = "4.5.6";
+    private static final String VERSION1 = "1.2.3";
+    private static final String VERSION0 = "0.1.2";
     private List<PdpGroup> pdpGroupList;
 
     /**
@@ -161,43 +176,43 @@ public class PdpGroupFilterTest {
     public void testFilterPolicyType() {
         List<ToscaPolicyTypeIdentifier> identifierList = new ArrayList<>();
 
-        identifierList.add(new ToscaPolicyTypeIdentifier("Nonexistant", "1.2.3"));
+        identifierList.add(new ToscaPolicyTypeIdentifier(NON_EXISTANT, VERSION1));
         PdpGroupFilter filter =
                 PdpGroupFilter.builder().policyTypeList(identifierList).build();
         List<PdpGroup> filteredList = filter.filter(pdpGroupList);
         assertEquals(0, filteredList.size());
         identifierList.clear();
 
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3"));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1));
         filter = PdpGroupFilter.builder().policyTypeList(identifierList).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(4, filteredList.size());
         identifierList.clear();
 
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.1", "4.5.6"));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4));
         filter = PdpGroupFilter.builder().policyTypeList(identifierList).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(4, filteredList.size());
         identifierList.clear();
 
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.2", "7.8.9"));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE2, VERSION7));
         filter = PdpGroupFilter.builder().policyTypeList(identifierList).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(2, filteredList.size());
         identifierList.clear();
 
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.3", "0.1.2"));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE3, VERSION0));
         filter = PdpGroupFilter.builder().policyTypeList(identifierList).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(2, filteredList.size());
         identifierList.clear();
 
-        identifierList.add(new ToscaPolicyTypeIdentifier("Nonexistant", "1.2.3"));
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "9.9.9"));
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3"));
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.1", "4.5.6"));
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.2", "7.8.9"));
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.3", "0.1.2"));
+        identifierList.add(new ToscaPolicyTypeIdentifier(NON_EXISTANT, VERSION1));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION9));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE2, VERSION7));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE3, VERSION0));
         filter = PdpGroupFilter.builder().policyTypeList(identifierList).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(5, filteredList.size());
@@ -207,30 +222,30 @@ public class PdpGroupFilterTest {
         assertEquals(0, filteredList.size());
 
         identifierList.clear();
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3"));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1));
         filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(2, filteredList.size());
 
         identifierList.clear();
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3"));
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.1", "4.5.6"));
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.2", "7.8.9"));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE2, VERSION7));
         filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(1, filteredList.size());
 
         identifierList.clear();
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3"));
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.1", "4.5.6"));
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.3", "0.1.2"));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE3, VERSION0));
         filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(1, filteredList.size());
 
         identifierList.clear();
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.1", "4.5.6"));
-        identifierList.add(new ToscaPolicyTypeIdentifier("policy.type.3", "0.1.2"));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4));
+        identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE3, VERSION0));
         filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(1, filteredList.size());
@@ -240,49 +255,49 @@ public class PdpGroupFilterTest {
     public void testFilterPolicy() {
         List<ToscaPolicyIdentifier> identifierList = new ArrayList<>();
 
-        identifierList.add(new ToscaPolicyIdentifier("Nonexistant", "1.2.3"));
+        identifierList.add(new ToscaPolicyIdentifier(NON_EXISTANT, VERSION1));
         PdpGroupFilter filter =
                 PdpGroupFilter.builder().policyList(identifierList).build();
         List<PdpGroup> filteredList = filter.filter(pdpGroupList);
         assertEquals(0, filteredList.size());
         identifierList.clear();
 
-        identifierList.add(new ToscaPolicyIdentifier("Policy0", "9.9.9"));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION9));
         filter = PdpGroupFilter.builder().policyList(identifierList).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(0, filteredList.size());
         identifierList.clear();
 
-        identifierList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6"));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION4));
         filter = PdpGroupFilter.builder().policyList(identifierList).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(4, filteredList.size());
         identifierList.clear();
 
-        identifierList.add(new ToscaPolicyIdentifier("Policy1", "4.5.6"));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY1, VERSION4));
         filter = PdpGroupFilter.builder().policyList(identifierList).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(1, filteredList.size());
         identifierList.clear();
 
-        identifierList.add(new ToscaPolicyIdentifier("Policy2", "4.5.6"));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY2, VERSION4));
         filter = PdpGroupFilter.builder().policyList(identifierList).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(2, filteredList.size());
         identifierList.clear();
 
-        identifierList.add(new ToscaPolicyIdentifier("Policy3", "1.2.3"));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY3, VERSION1));
         filter = PdpGroupFilter.builder().policyList(identifierList).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(1, filteredList.size());
         identifierList.clear();
 
-        identifierList.add(new ToscaPolicyIdentifier("Nonexistant", "1.2.3"));
-        identifierList.add(new ToscaPolicyIdentifier("Policy0", "9.9.9"));
-        identifierList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6"));
-        identifierList.add(new ToscaPolicyIdentifier("Policy1", "4.5.6"));
-        identifierList.add(new ToscaPolicyIdentifier("Policy2", "4.5.6"));
-        identifierList.add(new ToscaPolicyIdentifier("Policy3", "1.2.3"));
+        identifierList.add(new ToscaPolicyIdentifier(NON_EXISTANT, VERSION1));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION9));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION4));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY1, VERSION4));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY2, VERSION4));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY3, VERSION1));
         filter = PdpGroupFilter.builder().policyList(identifierList).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(5, filteredList.size());
@@ -292,27 +307,27 @@ public class PdpGroupFilterTest {
         assertEquals(0, filteredList.size());
 
         identifierList.clear();
-        identifierList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6"));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION4));
         filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(3, filteredList.size());
 
         identifierList.clear();
-        identifierList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6"));
-        identifierList.add(new ToscaPolicyIdentifier("Policy1", "4.5.6"));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION4));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY1, VERSION4));
         filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(1, filteredList.size());
 
         identifierList.clear();
-        identifierList.add(new ToscaPolicyIdentifier("Policy2", "4.5.6"));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY2, VERSION4));
         filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(1, filteredList.size());
 
         identifierList.clear();
-        identifierList.add(new ToscaPolicyIdentifier("Policy2", "4.5.6"));
-        identifierList.add(new ToscaPolicyIdentifier("Policy3", "1.2.3"));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY2, VERSION4));
+        identifierList.add(new ToscaPolicyIdentifier(POLICY3, VERSION1));
         filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build();
         filteredList = filter.filter(pdpGroupList);
         assertEquals(1, filteredList.size());
index a717dc2..a282b7d 100644 (file)
@@ -43,6 +43,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi
  * Test methods not tested by {@link ModelsTest}.
  */
 public class PdpGroupTest {
+    private static final String VERSION = "1.2.3";
     private static final String NAME = "my-name";
     private static final String PDP_TYPE1 = "type-1";
     private static final String PDP_TYPE2 = "type-2";
@@ -61,7 +62,7 @@ public class PdpGroupTest {
         // verify with all values
         orig.setDescription("my-descript");
         orig.setName(NAME);
-        orig.setVersion("1.2.3");
+        orig.setVersion(VERSION);
         orig.setDescription("my-description");
         orig.setPdpGroupState(PdpState.SAFE);
 
@@ -100,11 +101,11 @@ public class PdpGroupTest {
     public void testCompareTo() {
         PdpGroup pdpGroup0 = new PdpGroup();
         pdpGroup0.setName("Name0");
-        pdpGroup0.setVersion("1.2.3");
+        pdpGroup0.setVersion(VERSION);
 
         PdpGroup pdpGroup1 = new PdpGroup();
         pdpGroup1.setName("Name0");
-        pdpGroup1.setVersion("1.2.3");
+        pdpGroup1.setVersion(VERSION);
 
         assertEquals(0, pdpGroup0.compareTo(pdpGroup1));
 
index 10f3131..9047a7a 100644 (file)
@@ -30,6 +30,7 @@ import org.junit.Test;
 import org.onap.policy.models.pdp.enums.PdpMessageType;
 
 public class PdpMessageTest {
+    private static final String PDP_GROUP_STRING = " pdp group ";
     private static final String PDP_NAME = "pdpA";
     private static final String PDP_GROUP = "groupA";
     private static final String PDP_SUBGROUP = "subgroupA";
@@ -67,7 +68,7 @@ public class PdpMessageTest {
 
                 for (String pdpGroup : new String[] {null, PDP_GROUP, DIFFERENT}) {
                     for (String pdpSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) {
-                        assertTrue("name msg " + message + " pdp group " + pdpGroup + "/" + pdpSubgroup,
+                        assertTrue("name msg " + message + PDP_GROUP_STRING + pdpGroup + "/" + pdpSubgroup,
                                         message.appliesTo(PDP_NAME, pdpGroup, pdpSubgroup));
                     }
                 }
@@ -83,7 +84,7 @@ public class PdpMessageTest {
 
                 for (String pdpGroup : new String[] {null, PDP_GROUP, DIFFERENT}) {
                     for (String pdpSubgroup : new String[] {null, PDP_SUBGROUP, DIFFERENT}) {
-                        assertFalse("name msg " + message + " pdp group " + pdpGroup + "/" + pdpSubgroup,
+                        assertFalse("name msg " + message + PDP_GROUP_STRING + pdpGroup + "/" + pdpSubgroup,
                                         message.appliesTo(DIFFERENT, pdpGroup, pdpSubgroup));
                     }
                 }
@@ -110,7 +111,7 @@ public class PdpMessageTest {
                 message = makeMessage(null, msgGroup, msgSubgroup);
 
                 for (String pdpGroup : new String[] {null, DIFFERENT}) {
-                    assertFalse("group msg " + message + " pdp group " + pdpGroup,
+                    assertFalse("group msg " + message + PDP_GROUP_STRING + pdpGroup,
                                     message.appliesTo(PDP_NAME, pdpGroup, PDP_SUBGROUP));
                 }
             }
index ee7e15b..a308ab0 100644 (file)
@@ -25,6 +25,10 @@ package org.onap.policy.models.pdp.concepts;
  */
 public class PdpMessageUtils {
 
+    private PdpMessageUtils() {
+
+    }
+
     public static String removeVariableFields(String text) {
         return text.replaceAll("requestId=[^,]*", "requestId=xxx").replaceAll("timestampMs=[^,]*", "timestampMs=nnn");
     }
index c0545fa..a2f502b 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,6 +48,10 @@ import org.onap.policy.models.pdp.testconcepts.DummyJpaPdpSubgroupChild;
  */
 public class JpaPdpGroupTest {
 
+    private static final String NULL_KEY_ERROR = "key is marked @NonNull but is null";
+    private static final String PDP_GROUP0 = "PDPGroup0";
+    private static final String VERSION = "1.0.0";
+
     @Test
     public void testJpaPdpGroup() {
         assertThatThrownBy(() -> {
@@ -55,7 +60,7 @@ public class JpaPdpGroupTest {
 
         assertThatThrownBy(() -> {
             new JpaPdpGroup((PfConceptKey) null);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdpGroup((PdpGroup) null);
@@ -67,7 +72,7 @@ public class JpaPdpGroupTest {
 
         assertThatThrownBy(() -> {
             new JpaPdpGroup(null, null, null);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdpGroup(new PfConceptKey(), null, null);
@@ -79,31 +84,31 @@ public class JpaPdpGroupTest {
 
         assertThatThrownBy(() -> {
             new JpaPdpGroup(null, PdpState.PASSIVE, null);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdpGroup(null, PdpState.PASSIVE, new ArrayList<>());
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdpGroup(null, null, new ArrayList<>());
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertNotNull(new JpaPdpGroup((new PfConceptKey())));
         assertNotNull(new JpaPdpGroup((new JpaPdpGroup())));
 
         PdpGroup testPdpGroup = new PdpGroup();
-        testPdpGroup.setName("PDPGroup0");
+        testPdpGroup.setName(PDP_GROUP0);
         testPdpGroup.setPdpSubgroups(new ArrayList<>());
         JpaPdpGroup testJpaPdpGroup = new JpaPdpGroup();
         testJpaPdpGroup.setKey(null);
 
         testJpaPdpGroup.setKey(new PfConceptKey());
 
-        testPdpGroup.setVersion("1.0.0");
+        testPdpGroup.setVersion(VERSION);
         testJpaPdpGroup.fromAuthorative(testPdpGroup);
 
-        assertEquals("PDPGroup0", testJpaPdpGroup.getKey().getName());
+        assertEquals(PDP_GROUP0, testJpaPdpGroup.getKey().getName());
         testJpaPdpGroup.setKey(PfConceptKey.getNullKey());
         testJpaPdpGroup.fromAuthorative(testPdpGroup);
 
@@ -111,19 +116,19 @@ public class JpaPdpGroupTest {
             testJpaPdpGroup.fromAuthorative(null);
         }).hasMessage("pdpGroup is marked @NonNull but is null");
 
-        testJpaPdpGroup.setKey(new PfConceptKey("PDPGroup0", "1.0.0"));
+        testJpaPdpGroup.setKey(new PfConceptKey(PDP_GROUP0, VERSION));
         testJpaPdpGroup.fromAuthorative(testPdpGroup);
 
         assertThatThrownBy(() -> {
             testJpaPdpGroup.copyTo(null);
         }).hasMessage("target is marked @NonNull but is null");
 
-        assertEquals("PDPGroup0", testJpaPdpGroup.getKey().getName());
-        assertEquals("PDPGroup0", new JpaPdpGroup(testPdpGroup).getKey().getName());
-        assertEquals("PDPGroup0", ((PfConceptKey) new JpaPdpGroup(testPdpGroup).getKeys().get(0)).getName());
+        assertEquals(PDP_GROUP0, testJpaPdpGroup.getKey().getName());
+        assertEquals(PDP_GROUP0, new JpaPdpGroup(testPdpGroup).getKey().getName());
+        assertEquals(PDP_GROUP0, ((PfConceptKey) new JpaPdpGroup(testPdpGroup).getKeys().get(0)).getName());
 
         testJpaPdpGroup.clean();
-        assertEquals("PDPGroup0", testJpaPdpGroup.getKey().getName());
+        assertEquals(PDP_GROUP0, testJpaPdpGroup.getKey().getName());
 
         assertThatThrownBy(() -> {
             testJpaPdpGroup.validate(null);
@@ -135,7 +140,7 @@ public class JpaPdpGroupTest {
 
         testJpaPdpGroup.setKey(PfConceptKey.getNullKey());
         assertFalse(testJpaPdpGroup.validate(new PfValidationResult()).isOk());
-        testJpaPdpGroup.setKey(new PfConceptKey("PdpGroup0", "1.0.0"));
+        testJpaPdpGroup.setKey(new PfConceptKey("PdpGroup0", VERSION));
         assertTrue(testJpaPdpGroup.validate(new PfValidationResult()).isOk());
 
         testJpaPdpGroup.setDescription("   ");
index d066d9b..981f40f 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,6 +47,9 @@ import org.onap.policy.models.pdp.testconcepts.DummyJpaPdpSubgroupChild;
  */
 public class JpaPdpSubGroupTest {
 
+    private static final String NULL_KEY_ERROR = "key is marked @NonNull but is null";
+    private static final String PDP_A = "PDP-A";
+
     @Test
     public void testJpaPdpSubGroup() {
         assertThatThrownBy(() -> {
@@ -54,7 +58,7 @@ public class JpaPdpSubGroupTest {
 
         assertThatThrownBy(() -> {
             new JpaPdpSubGroup((PfReferenceKey) null);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdpSubGroup((PdpSubGroup) null);
@@ -62,7 +66,7 @@ public class JpaPdpSubGroupTest {
 
         assertThatThrownBy(() -> {
             new JpaPdpSubGroup(null, null, null, null);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdpSubGroup(new PfReferenceKey(), null, null, null);
@@ -74,19 +78,19 @@ public class JpaPdpSubGroupTest {
 
         assertThatThrownBy(() -> {
             new JpaPdpSubGroup(null, new ArrayList<>(), null, null);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdpSubGroup(null, new ArrayList<>(), new ArrayList<>(), null);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdpSubGroup(null, null, new ArrayList<>(), null);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdpSubGroup(null, null, null, new ArrayList<>());
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdpSubGroup(new PfReferenceKey(), null, null, new ArrayList<>());
@@ -98,24 +102,24 @@ public class JpaPdpSubGroupTest {
 
         assertThatThrownBy(() -> {
             new JpaPdpSubGroup(null, new ArrayList<>(), null, new ArrayList<>());
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdpSubGroup(null, new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdpSubGroup(null, null, new ArrayList<>(), null);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertNotNull(new JpaPdpSubGroup((new PfReferenceKey())));
 
         PdpSubGroup testPdpSubgroup = new PdpSubGroup();
-        testPdpSubgroup.setPdpType("PDP-A");
+        testPdpSubgroup.setPdpType(PDP_A);
         JpaPdpSubGroup testJpaPdpSubGroup = new JpaPdpSubGroup();
         testJpaPdpSubGroup.setKey(null);
         testJpaPdpSubGroup.fromAuthorative(testPdpSubgroup);
-        assertEquals("PDP-A", testJpaPdpSubGroup.getKey().getLocalName());
+        assertEquals(PDP_A, testJpaPdpSubGroup.getKey().getLocalName());
         testJpaPdpSubGroup.setKey(PfReferenceKey.getNullKey());
         testJpaPdpSubGroup.fromAuthorative(testPdpSubgroup);
 
@@ -127,12 +131,12 @@ public class JpaPdpSubGroupTest {
             testJpaPdpSubGroup.copyTo(null);
         }).hasMessage("target is marked @NonNull but is null");
 
-        assertEquals("PDP-A", testJpaPdpSubGroup.getKey().getLocalName());
-        assertEquals("PDP-A", new JpaPdpSubGroup(testPdpSubgroup).getKey().getLocalName());
-        assertEquals("PDP-A", ((PfReferenceKey) new JpaPdpSubGroup(testPdpSubgroup).getKeys().get(0)).getLocalName());
+        assertEquals(PDP_A, testJpaPdpSubGroup.getKey().getLocalName());
+        assertEquals(PDP_A, new JpaPdpSubGroup(testPdpSubgroup).getKey().getLocalName());
+        assertEquals(PDP_A, ((PfReferenceKey) new JpaPdpSubGroup(testPdpSubgroup).getKeys().get(0)).getLocalName());
 
         testJpaPdpSubGroup.clean();
-        assertEquals("PDP-A", testJpaPdpSubGroup.getKey().getLocalName());
+        assertEquals(PDP_A, testJpaPdpSubGroup.getKey().getLocalName());
 
         assertThatThrownBy(() -> {
             testJpaPdpSubGroup.validate(null);
index ebdf31c..5ffba10 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,7 +34,6 @@ import org.onap.policy.models.base.PfValidationResult;
 import org.onap.policy.models.pdp.concepts.Pdp;
 import org.onap.policy.models.pdp.enums.PdpHealthStatus;
 import org.onap.policy.models.pdp.enums.PdpState;
-import org.onap.policy.models.pdp.persistence.concepts.JpaPdp;
 import org.onap.policy.models.pdp.testconcepts.DummyJpaPdpChild;
 
 /**
@@ -43,6 +43,9 @@ import org.onap.policy.models.pdp.testconcepts.DummyJpaPdpChild;
  */
 public class JpaPdpTest {
 
+    private static final String NULL_KEY_ERROR = "key is marked @NonNull but is null";
+    private static final String PDP1 = "ThePDP";
+
     @Test
     public void testJpaPdp() {
         assertThatThrownBy(() -> {
@@ -51,11 +54,11 @@ public class JpaPdpTest {
 
         assertThatThrownBy(() -> {
             new JpaPdp((PfReferenceKey) null);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdp(null, null, null);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdp(new PfReferenceKey(), null, null);
@@ -67,15 +70,15 @@ public class JpaPdpTest {
 
         assertThatThrownBy(() -> {
             new JpaPdp(null, PdpState.ACTIVE, null);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdp(null, PdpState.ACTIVE, PdpHealthStatus.UNKNOWN);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdp(null, null, PdpHealthStatus.UNKNOWN);
-        }).hasMessage("key is marked @NonNull but is null");
+        }).hasMessage(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> {
             new JpaPdp((Pdp) null);
@@ -84,11 +87,11 @@ public class JpaPdpTest {
         assertNotNull(new JpaPdp((new PfReferenceKey())));
 
         Pdp testPdp = new Pdp();
-        testPdp.setInstanceId("ThePDP");
+        testPdp.setInstanceId(PDP1);
         JpaPdp testJpaPdp = new JpaPdp();
         testJpaPdp.setKey(null);
         testJpaPdp.fromAuthorative(testPdp);
-        assertEquals("ThePDP", testJpaPdp.getKey().getLocalName());
+        assertEquals(PDP1, testJpaPdp.getKey().getLocalName());
         testJpaPdp.setKey(PfReferenceKey.getNullKey());
         testJpaPdp.fromAuthorative(testPdp);
 
@@ -100,12 +103,12 @@ public class JpaPdpTest {
             testJpaPdp.copyTo(null);
         }).hasMessage("target is marked @NonNull but is null");
 
-        assertEquals("ThePDP", testJpaPdp.getKey().getLocalName());
-        assertEquals("ThePDP", new JpaPdp(testPdp).getKey().getLocalName());
-        assertEquals("ThePDP", ((PfReferenceKey) new JpaPdp(testPdp).getKeys().get(0)).getLocalName());
+        assertEquals(PDP1, testJpaPdp.getKey().getLocalName());
+        assertEquals(PDP1, new JpaPdp(testPdp).getKey().getLocalName());
+        assertEquals(PDP1, ((PfReferenceKey) new JpaPdp(testPdp).getKeys().get(0)).getLocalName());
 
         testJpaPdp.clean();
-        assertEquals("ThePDP", testJpaPdp.getKey().getLocalName());
+        assertEquals(PDP1, testJpaPdp.getKey().getLocalName());
 
         testJpaPdp.setMessage("   A Message   ");
         testJpaPdp.clean();
index f0af69e..4314b81 100644 (file)
@@ -29,7 +29,6 @@ import static org.junit.Assert.assertTrue;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
-
 import org.eclipse.persistence.config.PersistenceUnitProperties;
 import org.junit.After;
 import org.junit.Before;
@@ -49,7 +48,6 @@ import org.onap.policy.models.pdp.concepts.PdpStatistics;
 import org.onap.policy.models.pdp.concepts.PdpSubGroup;
 import org.onap.policy.models.pdp.enums.PdpHealthStatus;
 import org.onap.policy.models.pdp.enums.PdpState;
-import org.onap.policy.models.pdp.persistence.provider.PdpProvider;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
 import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider;
@@ -99,7 +97,7 @@ public class PdpProviderTest {
     }
 
     @After
-    public void teardown() throws Exception {
+    public void teardown() {
         pfDao.close();
     }