diff options
author | xg353y <xg353y@intl.att.com> | 2019-03-28 10:05:25 +0100 |
---|---|---|
committer | xg353y <xg353y@intl.att.com> | 2019-03-28 10:05:25 +0100 |
commit | a6d09fbe1046057b72247f97ac72a521949409ce (patch) | |
tree | 8542f7b7f3afb888bc6c76189b265716be64c83d /src/test/java/org | |
parent | c62d1b74275b8d5e9d4cef6c308ef16440cfa500 (diff) |
Rework the submit operation
Rework the logic to create/delete ms config policies.
Issue-ID: CLAMP-303
Change-Id: I317e262ab68280a7518a6e31e82e5fcb0a7f94ed
Signed-off-by: xg353y <xg353y@intl.att.com>
Diffstat (limited to 'src/test/java/org')
9 files changed, 53 insertions, 51 deletions
diff --git a/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java b/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java index caab61f18..549c2d117 100644 --- a/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java +++ b/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java @@ -85,7 +85,7 @@ public class DcaeDispatcherServicesTest { @Test public void shouldReturnDcaeOperationSataus() throws IOException { //given - Mockito.when(httpConnectionManager.doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE")) + Mockito.when(httpConnectionManager.doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null)) .thenReturn(STATUS_RESPONSE_PROCESSING); //when String operationStatus = dcaeDispatcherServices.getOperationStatus(DEPLOYMENT_STATUS_URL); @@ -98,7 +98,7 @@ public class DcaeDispatcherServicesTest { public void shouldTryMultipleTimesWhenProcessing() throws IOException, InterruptedException { //given Mockito.when(httpConnectionManager.doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", - null, null, "DCAE")) + null, null, "DCAE", null, null)) .thenReturn(STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_ACTIVE); //when String operationStatus = dcaeDispatcherServices.getOperationStatusWithRetry(DEPLOYMENT_STATUS_URL); @@ -106,7 +106,7 @@ public class DcaeDispatcherServicesTest { //then Assertions.assertThat(operationStatus).isEqualTo("succeeded"); Mockito.verify(httpConnectionManager, Mockito.times(3)) - .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE"); + .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null); } @@ -114,7 +114,7 @@ public class DcaeDispatcherServicesTest { public void shouldTryOnlyAsManyTimesAsConfigured() throws IOException, InterruptedException { //given Mockito.when(httpConnectionManager - .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE")) + .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null)) .thenReturn(STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING); //when @@ -123,7 +123,7 @@ public class DcaeDispatcherServicesTest { //then Assertions.assertThat(operationStatus).isEqualTo("processing"); Mockito.verify(httpConnectionManager, Mockito.times(3)) - .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE"); + .doGeneralHttpQuery(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null); } @@ -140,7 +140,7 @@ public class DcaeDispatcherServicesTest { + "/dcae-deployments/closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId", "PUT", "{\"serviceTypeId\":\"e2ba40f7-bf42-41e7-acd7-48fd07586d90\",\"inputs\":{}}", - "application/json", "DCAE")) + "application/json", "DCAE", null, null)) .thenReturn(DEPLOY_RESPONSE_STRING); JsonObject blueprintInputJson = new JsonObject(); diff --git a/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java b/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java index 42e9c7f63..4db0e5c27 100644 --- a/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java @@ -110,7 +110,7 @@ public class HttpConnectionManagerItCase { @Test public void testHttpGet() throws Exception { String response = httpConnectionManager - .doGeneralHttpQuery("http://localhost:" + this.httpPort + "/designer/index.html", "GET", null, null, "DCAE"); + .doGeneralHttpQuery("http://localhost:" + this.httpPort + "/designer/index.html", "GET", null, null, "DCAE", null, null); assertNotNull(response); // Should be a redirection so 302, so empty assertTrue(response.isEmpty()); @@ -119,7 +119,7 @@ public class HttpConnectionManagerItCase { @Test public void testHttpsGet() throws Exception { String response = httpConnectionManager - .doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index.html", "GET", null, null, "DCAE"); + .doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index.html", "GET", null, null, "DCAE", null, null); assertNotNull(response); // Should contain something assertTrue(!response.isEmpty()); @@ -128,21 +128,21 @@ public class HttpConnectionManagerItCase { @Test(expected = BadRequestException.class) public void testHttpsGet404() throws IOException { httpConnectionManager.doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index1.html", - "GET", null, null, "DCAE"); + "GET", null, null, "DCAE", null, null); fail("Should have raised an BadRequestException"); } @Test(expected = BadRequestException.class) public void testHttpsPost404() throws IOException { httpConnectionManager.doGeneralHttpQuery("https://localhost:" + this.httpsPort + "/designer/index1.html", - "POST", "", "application/json", "DCAE"); + "POST", "", "application/json", "DCAE", null, null); fail("Should have raised an BadRequestException"); } @Test(expected = BadRequestException.class) public void testHttpException() throws IOException { httpConnectionManager.doGeneralHttpQuery("http://localhost:" + this.httpsPort + "/designer/index.html", "GET", - null, null, "DCAE"); + null, null, "DCAE", null, null); fail("Should have raised an BadRequestException"); } } diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java index 551ac1b30..fbe6e63ca 100644 --- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java +++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java @@ -47,6 +47,9 @@ public class BlueprintParserTest { private static final String FIRST_APPP = "first_app"; private static final String SECOND_APPP = "second_app"; private static final String THIRD_APPP = "third_app"; + private static final String MODEL_TYPE1 = "type1"; + private static final String MODEL_TYPE2 = "type2"; + private static final String MODEL_TYPE3 = "type3"; private static String microServiceTheWholeBlueprintValid; private static String microServiceBlueprintOldStyleTCA; @@ -139,7 +142,7 @@ public class BlueprintParserTest { public void getNodeRepresentationFromCompleteYaml() { final JsonObject jsonObject = jsonObjectBlueprintValid; - MicroService expected = new MicroService(SECOND_APPP, FIRST_APPP, ""); + MicroService expected = new MicroService(SECOND_APPP, MODEL_TYPE1, FIRST_APPP, "", SECOND_APPP); Entry<String, JsonElement> entry = jsonObject.entrySet().iterator().next(); MicroService actual = new BlueprintParser().getNodeRepresentation(entry); @@ -148,9 +151,9 @@ public class BlueprintParserTest { @Test public void getMicroServicesFromBlueprintTest() { - MicroService thirdApp = new MicroService(THIRD_APPP, "", ""); - MicroService firstApp = new MicroService(FIRST_APPP, THIRD_APPP, ""); - MicroService secondApp = new MicroService(SECOND_APPP, FIRST_APPP, ""); + MicroService thirdApp = new MicroService(THIRD_APPP, MODEL_TYPE3, "", "", THIRD_APPP); + MicroService firstApp = new MicroService(FIRST_APPP, MODEL_TYPE1, THIRD_APPP, "", FIRST_APPP); + MicroService secondApp = new MicroService(SECOND_APPP, MODEL_TYPE2, FIRST_APPP, "", SECOND_APPP); Set<MicroService> expected = new HashSet<>(Arrays.asList(firstApp, secondApp, thirdApp)); Set<MicroService> actual = new BlueprintParser().getMicroServices(microServiceTheWholeBlueprintValid); @@ -160,7 +163,7 @@ public class BlueprintParserTest { @Test public void fallBackToOneMicroServiceTCATest() { - MicroService tcaMS = new MicroService(BlueprintParser.TCA, "", ""); + MicroService tcaMS = new MicroService(BlueprintParser.TCA, "", "", "", ""); List<MicroService> expected = Collections.singletonList(tcaMS); List<MicroService> actual = new BlueprintParser().fallbackToOneMicroService(microServiceBlueprintOldStyleTCA); @@ -170,7 +173,7 @@ public class BlueprintParserTest { @Test public void fallBackToOneMicroServiceHolmesTest() { - MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, "", ""); + MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, "", "", "", ""); List<MicroService> expected = Collections.singletonList(holmesMS); List<MicroService> actual = new BlueprintParser() diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java index 2ec508799..1eb66eadd 100644 --- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java +++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java @@ -38,10 +38,10 @@ public class ChainGeneratorTest { @Test public void getChainOfMicroServicesTest() { - MicroService ms1 = new MicroService(FIRST_APPP, "", ""); - MicroService ms2 = new MicroService(SECOND_APPP, FIRST_APPP, ""); - MicroService ms3 = new MicroService(THIRD_APPP, SECOND_APPP, ""); - MicroService ms4 = new MicroService(FOURTH_APPP, THIRD_APPP, ""); + MicroService ms1 = new MicroService(FIRST_APPP, "", "", "", ""); + MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, "", ""); + MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, "", ""); + MicroService ms4 = new MicroService(FOURTH_APPP, "", THIRD_APPP, "", ""); List<MicroService> expectedList = Arrays.asList(ms1, ms2, ms3, ms4); Set<MicroService> inputSet = new HashSet<>(expectedList); @@ -52,10 +52,10 @@ public class ChainGeneratorTest { @Test public void getChainOfMicroServicesTwiceNoInputTest() { - MicroService ms1 = new MicroService(FIRST_APPP, "", ""); - MicroService ms2 = new MicroService(SECOND_APPP, "", ""); - MicroService ms3 = new MicroService(THIRD_APPP, SECOND_APPP, ""); - MicroService ms4 = new MicroService(FOURTH_APPP, FIRST_APPP, ""); + MicroService ms1 = new MicroService(FIRST_APPP, "", "", "", ""); + MicroService ms2 = new MicroService(SECOND_APPP, "", "", "", ""); + MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, "", ""); + MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, "", ""); Set<MicroService> inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4)); List<MicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet); @@ -64,10 +64,10 @@ public class ChainGeneratorTest { @Test public void getChainOfMicroServicesBranchingTest() { - MicroService ms1 = new MicroService(FIRST_APPP, "", ""); - MicroService ms2 = new MicroService(SECOND_APPP, FIRST_APPP, ""); - MicroService ms3 = new MicroService(THIRD_APPP, FIRST_APPP, ""); - MicroService ms4 = new MicroService(FOURTH_APPP, FIRST_APPP, ""); + MicroService ms1 = new MicroService(FIRST_APPP, "", "", "", ""); + MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, "", ""); + MicroService ms3 = new MicroService(THIRD_APPP, "", FIRST_APPP, "", ""); + MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, "", ""); Set<MicroService> inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4)); List<MicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet); diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java index 459a701fe..f7d2fe76e 100644 --- a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java +++ b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java @@ -56,8 +56,8 @@ public class ClampGraphBuilderTest { @Test public void clampGraphBuilderCompleteChainTest() { String collector = "VES"; - MicroService ms1 = new MicroService("ms1", "", "ms1_jpa_id"); - MicroService ms2 = new MicroService("ms2", "", "ms2_jpa_id"); + MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id", ""); + MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id", ""); ; String policy = "Policy"; List<MicroService> microServices = Arrays.asList(ms1, ms2); @@ -76,8 +76,8 @@ public class ClampGraphBuilderTest { @Test(expected = InvalidStateException.class) public void clampGraphBuilderNoPolicyGivenTest() { String collector = "VES"; - MicroService ms1 = new MicroService("ms1", "", "ms1_jpa_id"); - MicroService ms2 = new MicroService("ms2", "", "ms2_jpa_id"); + MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id", ""); + MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id", ""); ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter); clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).build(); diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java index fcef5b79e..2578f68ed 100644 --- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java @@ -173,7 +173,6 @@ public class CsarInstallerItCase { assertThat(loop.getSvgRepresentation()).startsWith("<svg "); assertThat(loop.getGlobalPropertiesJson().get("dcaeDeployParameters")).isNotNull(); assertThat(loop.getMicroServicePolicies()).hasSize(1); - assertThat(loop.getOperationalPolicies()).hasSize(1); assertThat(loop.getModelPropertiesJson().get("serviceDetails")).isNotNull(); assertThat(loop.getModelPropertiesJson().get("resourceDetails")).isNotNull(); diff --git a/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java b/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java index c524eec39..9d07415bc 100644 --- a/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java +++ b/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java @@ -83,10 +83,10 @@ public class LoopRepositoriesItCase { return loop; } - private MicroServicePolicy getMicroServicePolicy(String name, String jsonRepresentation, String policyTosca, + private MicroServicePolicy getMicroServicePolicy(String name, String modelType, String jsonRepresentation, String policyTosca, String jsonProperties, boolean shared) { - MicroServicePolicy µService = new MicroServicePolicy(name, policyTosca, shared, - gson.fromJson(jsonRepresentation, JsonObject.class), new HashSet<>()); + MicroServicePolicy µService = new MicroServicePolicy(name, modelType, policyTosca, shared, + gson.fromJson(jsonRepresentation, JsonObject.class), new HashSet<>(), ""); µService.setProperties(new Gson().fromJson(jsonProperties, JsonObject.class)); return µService; } @@ -105,7 +105,7 @@ public class LoopRepositoriesItCase { "123456789", "https://dcaetest.org", "UUID-blueprint"); OperationalPolicy opPolicy = this.getOperationalPolicy("{\"type\":\"GUARD\"}", "GuardOpPolicyTest"); loopTest.addOperationalPolicy(opPolicy); - MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "{\"configtype\":\"json\"}", + MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "", "{\"configtype\":\"json\"}", "YamlContent", "{\"param1\":\"value1\"}", true); loopTest.addMicroServicePolicy(microServicePolicy); LoopLog loopLog = getLoopLog(LogType.INFO, "test message"); diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java index 4011a7867..9a44d41bc 100644 --- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java +++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java @@ -114,7 +114,7 @@ public class LoopServiceTestItCase { JsonObject confJson = JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class); String policyName = "policyName"; String policyTosca = "policyTosca"; - MicroServicePolicy microServicePolicy = new MicroServicePolicy(policyName, policyTosca, false, confJson, null); + MicroServicePolicy microServicePolicy = new MicroServicePolicy(policyName, "", policyTosca, false, confJson, null, ""); //when Loop actualLoop = loopService @@ -141,12 +141,12 @@ public class LoopServiceTestItCase { JsonObject newJsonRepresentation = JsonUtils.GSON.fromJson("{}", JsonObject.class); String secondPolicyName = "secondPolicyName"; String secondPolicyTosca = "secondPolicyTosca"; - MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy(firstPolicyName, "policyTosca", - false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); + MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy(firstPolicyName, "", "policyTosca", + false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, ""); loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy)); - MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy(secondPolicyName, secondPolicyTosca, true, - newJsonRepresentation, null); + MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy(secondPolicyName, "", secondPolicyTosca, true, + newJsonRepresentation, null, ""); //when firstMicroServicePolicy.setProperties(JsonUtils.GSON.fromJson("{\"name1\":\"value1\"}", JsonObject.class)); @@ -178,12 +178,12 @@ public class LoopServiceTestItCase { String firstPolicyName = "firstPolicyName"; String secondPolicyName = "policyName"; String secondPolicyTosca = "secondPolicyTosca"; - MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy(firstPolicyName, "policyTosca", - false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); + MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy(firstPolicyName, "", "policyTosca", + false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, ""); loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy)); - MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy(secondPolicyName, secondPolicyTosca, true, - jsonRepresentation, null); + MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy(secondPolicyName, "", secondPolicyTosca, true, + jsonRepresentation, null, ""); //when Loop actualLoop = loopService diff --git a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java index 92a0e14cf..1c218977d 100644 --- a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java +++ b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java @@ -58,10 +58,10 @@ public class LoopToJsonTest { return loop; } - private MicroServicePolicy getMicroServicePolicy(String name, String jsonRepresentation, String policyTosca, + private MicroServicePolicy getMicroServicePolicy(String name, String modelType, String jsonRepresentation, String policyTosca, String jsonProperties, boolean shared) { - MicroServicePolicy µService = new MicroServicePolicy(name, policyTosca, shared, - gson.fromJson(jsonRepresentation, JsonObject.class), new HashSet<>()); + MicroServicePolicy µService = new MicroServicePolicy(name, modelType, policyTosca, shared, + gson.fromJson(jsonRepresentation, JsonObject.class), new HashSet<>(), ""); µService.setProperties(new Gson().fromJson(jsonProperties, JsonObject.class)); return µService; @@ -81,7 +81,7 @@ public class LoopToJsonTest { "123456789", "https://dcaetest.org", "UUID-blueprint"); OperationalPolicy opPolicy = this.getOperationalPolicy("{\"type\":\"GUARD\"}", "GuardOpPolicyTest"); loopTest.addOperationalPolicy(opPolicy); - MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "{\"configtype\":\"json\"}", + MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "", "{\"configtype\":\"json\"}", "YamlContent", "{\"param1\":\"value1\"}", true); loopTest.addMicroServicePolicy(microServicePolicy); LoopLog loopLog = getLoopLog(LogType.INFO, "test message"); |