From e2801985291583854dcedcad69c858c81c64d3de Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Tue, 17 Dec 2019 11:48:12 +0200 Subject: Templates: Test deployment of a Cypress *edited* template templates__instance_from_template__set_without_modify.json is currently a plain copy of original template, but this will be changed later on Issue-ID: VID-724 Change-Id: Ib527fc33b684b0886c7aa407d5ba90be65fad159 Signed-off-by: Ittay Stern --- .../vid/api/InstantiationTemplatesApiTest.java | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'vid-automation/src/test/java/org/onap') diff --git a/vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java index ab59f087d..721c9ead6 100644 --- a/vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java +++ b/vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java @@ -22,7 +22,6 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import vid.automation.test.Constants; import vid.automation.test.Constants.Users; import vid.automation.test.model.User; import vid.automation.test.services.AsyncJobsService; @@ -77,18 +76,34 @@ public class InstantiationTemplatesApiTest extends AsyncInstantiationBase { @Test public void templateTopology_givenDeployFromCypressE2E_getTemplateTopologyDataIsEquivalent() throws IOException { - templateTopology_givenDeploy_templateTopologyIsEquivalent(objectMapper.readValue( - convertRequest(objectMapper, "asyncInstantiation/templates__instance_template.json"), - JsonNode.class)); + templateTopology_givenDeploy_templateTopologyIsEquivalentToBody( + fileAsJsonNode("asyncInstantiation/templates__instance_template.json")); } - public void templateTopology_givenDeploy_templateTopologyIsEquivalent(JsonNode body) { + @Test + public void templateTopology_givenDeployFromEditedTemplateCypressE2E_getTemplateTopologyDataIsEquivalentToOriginalTemplate() throws IOException { + templateTopology_givenDeploy_templateTopologyIsEquivalent( + fileAsJsonNode("asyncInstantiation/templates__instance_from_template__set_without_modify.json"), + fileAsJsonNode("asyncInstantiation/templates__instance_template.json")); + } + + private JsonNode fileAsJsonNode(String fileName) throws IOException { + return objectMapper.readValue( + convertRequest(objectMapper, fileName), + JsonNode.class); + } + + public void templateTopology_givenDeploy_templateTopologyIsEquivalentToBody(JsonNode body) { + templateTopology_givenDeploy_templateTopologyIsEquivalent(body, body); + } + + public void templateTopology_givenDeploy_templateTopologyIsEquivalent(JsonNode body, JsonNode expectedTemplateTopology) { registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), RegistrationStrategy.CLEAR_THEN_SET); String uuid1 = postAsyncInstanceRequest(body); JsonNode templateTopology1 = restTemplate.getForObject(templateTopologyUri(uuid1), JsonNode.class); - assertThat(cleanupTemplate(templateTopology1), jsonEquals(cleanupTemplate(body))); + assertThat(cleanupTemplate(templateTopology1), jsonEquals(cleanupTemplate(expectedTemplateTopology))); } private JsonNode cleanupTemplate(JsonNode templateTopology) { -- cgit 1.2.3-korg