aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-06-13 10:39:55 -0400
committerJim Hahn <jrh3@att.com>2019-06-17 10:50:16 -0400
commitd37c71292d9cbdd892f328d63f49a8027b1f13c4 (patch)
tree615a8af45285d1032a02af1214c76b938c58044d /models-interactions/model-actors
parentf59ec395bf1e41df894f884e70ff3185280668c0 (diff)
Fix simple sonar issues in models
Added @FunctionalInterface where needed. Replaced anonymous classes with lambda expressions. Replaced duplicate strings with a constant. Removed unused BeforeClass & AfterClass test methods. Removed some trailing spaces. Fixed: aai actor.appc actor.appclcm actor.sdnc actor.sdnr actor.so actor.vfc actorServiceProvider appc appclcm cds events Change-Id: I0e21cbb10db6d1217bbd0e00e6dd4fac3eb84e31 Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors')
-rw-r--r--models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java49
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java94
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java25
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java1
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java14
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java55
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java25
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java8
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java63
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java9
10 files changed, 171 insertions, 172 deletions
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java
index b917406cd..553dfde9b 100644
--- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java
@@ -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
diff --git a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java
index da95611d4..7b48387a4 100644
--- a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java
@@ -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(),
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java
index c80a38d77..26f7336d6 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java
@@ -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());
}
}
diff --git a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java
index 32346bfa2..4367f54c5 100644
--- a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java
@@ -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";
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java
index 265aea341..a9178961a 100644
--- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java
@@ -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());
}
}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
index 2da0a95af..8aad5feb3 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
@@ -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;
}
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java
index 9c26a4cd1..175d2fe0c 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java
@@ -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);
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
index 61cf81da9..a41d9e82d 100644
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
@@ -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());
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java
index 8d5d5fae0..54bb995d2 100644
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java
@@ -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);
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java
index 3354a2268..7ab21dece 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java
@@ -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());
}
}