diff options
Diffstat (limited to 'controlloop/common/actors/actor.appc')
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()); + } } |