diff options
Diffstat (limited to 'models-interactions/model-actors/actor.so/src/test')
-rw-r--r-- | models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java | 123 |
1 files changed, 0 insertions, 123 deletions
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 175d2fe0c..b46ac52fb 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 @@ -37,8 +37,6 @@ import java.util.UUID; import org.apache.commons.io.IOUtils; import org.junit.Test; import org.onap.policy.aai.AaiCqResponse; -import org.onap.policy.aai.AaiNqResponse; -import org.onap.policy.aai.AaiNqResponseWrapper; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.policy.Policy; @@ -55,113 +53,6 @@ public class SoActorServiceProviderTest { private static final String VF_MODULE_CREATE = "VF Module Create"; private static final String VF_MODULE_DELETE = "VF Module Delete"; - @Test - public void testConstructRequest() throws Exception { - VirtualControlLoopEvent onset = new VirtualControlLoopEvent(); - final ControlLoopOperation operation = new ControlLoopOperation(); - final AaiNqResponseWrapper aaiNqResp = loadAaiResponse(onset, "aai/AaiNqResponse-Full.json"); - - final UUID requestId = UUID.randomUUID(); - onset.setRequestId(requestId); - - Policy policy = new Policy(); - policy.setActor("Dorothy"); - policy.setRecipe("GoToOz"); - - instantiateTarget(policy); - - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - - policy.setActor("SO"); - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - - policy.setRecipe(VF_MODULE_CREATE); - - // empty policy payload - SoRequest request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(request); - - assertEquals("my_module_3", request.getRequestDetails().getRequestInfo().getInstanceName()); - assertEquals("policy", request.getRequestDetails().getRequestInfo().getRequestorId()); - assertEquals("RegionOne", request.getRequestDetails().getCloudConfiguration().getLcpCloudRegionId()); - - // non-empty policy payload - policy.setPayload(makePayload()); - request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(request); - assertEquals(true, request.getRequestDetails().getRequestParameters().isUsePreload()); - assertEquals(A_VALUE, request.getRequestDetails().getRequestParameters().getUserParams().get(0).get("akey")); - assertEquals(1, request.getRequestDetails().getConfigurationParameters().size()); - assertEquals(C_VALUE, request.getRequestDetails().getConfigurationParameters().get(0).get("ckey")); - - // payload with config, but no request params - policy.setPayload(makePayload()); - policy.getPayload().remove(SoActorServiceProvider.REQ_PARAM_NM); - request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(request); - assertNull(request.getRequestDetails().getRequestParameters()); - assertNotNull(request.getRequestDetails().getConfigurationParameters()); - - // payload with request, but no config params - policy.setPayload(makePayload()); - policy.getPayload().remove(SoActorServiceProvider.CONFIG_PARAM_NM); - request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(request); - assertNotNull(request.getRequestDetails().getRequestParameters()); - assertNull(request.getRequestDetails().getConfigurationParameters()); - - // null response - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, null)); - - // response has no base VF module - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, - loadAaiResponse(onset, "aai/AaiNqResponse-NoBase.json"))); - - policy.setTarget(null); - - // response has no non-base VF modules (other than the "dummy") - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, - loadAaiResponse(onset, "aai/AaiNqResponse-NoNonBase.json"))); - - instantiateTarget(policy); - policy.setRecipe(VF_MODULE_DELETE); - SoRequest deleteRequest = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(deleteRequest); - assertEquals(SoOperationType.DELETE_VF_MODULE, deleteRequest.getOperationType()); - - /* - * NOTE: The remaining tests must be done in order - */ - - policy.setRecipe(VF_MODULE_CREATE); - - // null tenant - aaiNqResp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems() - .remove(1); - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - - // null service item - aaiNqResp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0) - .setItems(null); - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - - // null response - aaiNqResp.setAaiNqResponse(null); - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - } - - private void instantiateTarget(Policy policy) { - - Target target = new Target(); - target.setModelCustomizationId("3e2d67ad-3495-4732-82f6-b0b872791fff"); - target.setModelInvariantId("90b793b5-b8ae-4c36-b10b-4b6372859d3a"); - target.setModelName("SproutScalingVf..scaling_sprout..module-1"); - target.setModelVersion("1"); - target.setModelVersionId("2210154d-e61a-4d7f-8fb9-0face1aee3f8"); - - policy.setTarget(target); - } - private void instantiateTargetCq(Policy policy) { Target target = new Target(); @@ -336,18 +227,4 @@ public class SoActorServiceProviderTest { return Serialization.gsonPretty.toJson(lst); } - /** - * Reads an AAI vserver named-query response from a file. - * - * @param onset the ONSET event - * @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 - */ - private AaiNqResponseWrapper loadAaiResponse(VirtualControlLoopEvent onset, String fileName) throws IOException { - String resp = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8); - AaiNqResponse aaiNqResponse = Serialization.gsonPretty.fromJson(resp, AaiNqResponse.class); - - return new AaiNqResponseWrapper(onset.getRequestId(), aaiNqResponse); - } } |