aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/actors/actor.appc
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-01-20 11:22:27 +0000
committerliamfallon <liam.fallon@ericsson.com>2018-01-21 18:39:46 +0000
commit5f08b93d6642381eb0578ca2048951ac766bc33d (patch)
tree217bc49df6813e661cb46d74f40655252aea6b9c /controlloop/common/actors/actor.appc
parent7b6f0942e355b0405bc47e2e4d276e43c63edde1 (diff)
Fix Tech Debt/JUnit on APPC and APPCLCM actors
Unit test updated to increase coverage on getter methods. Constants added for some string literals to reduce technical debt warnings. Change-Id: I3b175de7c65aa9d342e71adc951d1ee08c9d781b Issue-ID: POLICY-455 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'controlloop/common/actors/actor.appc')
-rw-r--r--controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java21
-rw-r--r--controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java11
2 files changed, 25 insertions, 7 deletions
diff --git a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java
index c0bbfe8f3..929b31982 100644
--- a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java
+++ b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java
@@ -38,16 +38,25 @@ import com.google.common.collect.ImmutableMap;
public class APPCActorServiceProvider implements Actor {
+ // Strings for targets
+ private static final String TARGET_VM = "VM";
+ private static final String TARGET_VNF = "VNF";
- private static final ImmutableList<String> recipes = ImmutableList.of("Restart", "Rebuild", "Migrate", "ModifyConfig");
+ // Strings for recipes
+ private static final String RECIPE_RESTART = "Restart";
+ private static final String RECIPE_REBUILD = "Rebuild";
+ private static final String RECIPE_MIGRATE = "Migrate";
+ private static final String RECIPE_MODIFY = "ModifyConfig";
+
+ private static final ImmutableList<String> recipes = ImmutableList.of(RECIPE_RESTART, RECIPE_REBUILD, RECIPE_MIGRATE, RECIPE_MODIFY);
private static final ImmutableMap<String, List<String>> targets = new ImmutableMap.Builder<String, List<String>>()
- .put("Restart", ImmutableList.of("VM"))
- .put("Rebuild", ImmutableList.of("VM"))
- .put("Migrate", ImmutableList.of("VM"))
- .put("ModifyConfig", ImmutableList.of("VNF"))
+ .put(RECIPE_RESTART, ImmutableList.of(TARGET_VM))
+ .put(RECIPE_REBUILD, ImmutableList.of(TARGET_VM))
+ .put(RECIPE_MIGRATE, ImmutableList.of(TARGET_VM))
+ .put(RECIPE_MODIFY, ImmutableList.of(TARGET_VNF))
.build();
private static final ImmutableMap<String, List<String>> payloads = new ImmutableMap.Builder<String, List<String>>()
- .put("ModifyConfig", ImmutableList.of("generic-vnf.vnf-id"))
+ .put(RECIPE_MODIFY, ImmutableList.of("generic-vnf.vnf-id"))
.build();
@Override
diff --git a/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java b/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java
index 89de717fb..58510ba8c 100644
--- a/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java
+++ b/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java
@@ -127,7 +127,7 @@ public class AppcServiceProviderTest {
/* An action is required and cannot be null */
assertNotNull(appcRequest.getAction());
- assertEquals(appcRequest.getAction(), "ModifyConfig");
+ assertEquals("ModifyConfig", appcRequest.getAction());
/* A payload is required and cannot be null */
assertNotNull(appcRequest.getPayload());
@@ -157,4 +157,13 @@ public class AppcServiceProviderTest {
logger.debug("JSON Output: \n" + jsonResponse);
}
+ @Test
+ public void testMethods() {
+ APPCActorServiceProvider sp = new APPCActorServiceProvider();
+
+ assertEquals("APPC", sp.actor());
+ assertEquals(4, sp.recipes().size());
+ assertEquals("VM", sp.recipeTargets("Restart").get(0));
+ assertEquals(0, sp.recipePayloads("Restart").size());
+ }
}