summaryrefslogtreecommitdiffstats
path: root/vid-automation/src/test/java
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-12-24 11:04:49 +0200
committerIttay Stern <ittay.stern@att.com>2019-12-24 12:58:05 +0200
commit206d87766f6547934bf4298de326c63c8e31481a (patch)
treeeb72b44309b35bc414bab3a60d0a721d605d8f6c /vid-automation/src/test/java
parent89de17b50dcd1d29fb87acfe518d1ddf43c1408a (diff)
Write async instantiations request-summary to DB
Issue-ID: VID-724 Change-Id: I8b4bb55f6d7d59da321ef7b52802ea8bd957c1c6 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-automation/src/test/java')
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java43
1 files changed, 39 insertions, 4 deletions
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 5e4d83af6..3c9786144 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
@@ -1,5 +1,6 @@
package org.onap.vid.api;
+import static java.util.Arrays.stream;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayWithSize;
@@ -9,6 +10,7 @@ import static vid.automation.test.services.SimulatorApi.registerExpectationFromP
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.util.Map.Entry;
import java.util.function.Predicate;
@@ -21,8 +23,11 @@ import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import vid.automation.test.Constants.Users;
+import vid.automation.test.infra.FeatureTogglingTest;
+import vid.automation.test.infra.Features;
import vid.automation.test.model.User;
import vid.automation.test.services.AsyncJobsService;
import vid.automation.test.services.SimulatorApi.RegistrationStrategy;
@@ -63,6 +68,11 @@ public class InstantiationTemplatesApiTest extends AsyncInstantiationBase {
return new UserCredentials(user.credentials.userId, user.credentials.password, Users.SILVIA_ROBBINS_TYLER_SILVIA, "", "");
}
+ @BeforeMethod
+ public void setUp() {
+ registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), RegistrationStrategy.CLEAR_THEN_SET);
+ }
+
@AfterMethod
protected void dropAllFromNameCounter() {
AsyncJobsService asyncJobsService = new AsyncJobsService();
@@ -87,10 +97,37 @@ public class InstantiationTemplatesApiTest extends AsyncInstantiationBase {
fileAsJsonNode("asyncInstantiation/templates__instance_template.json"));
}
- private JsonNode fileAsJsonNode(String fileName) throws IOException {
+ @Test
+ @FeatureTogglingTest(Features.FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE)
+ public void templateTopology_givenDeploy_getServiceInfoHoldsRequestSummary() throws IOException {
+ ObjectNode request =
+ fileAsJsonNode(CREATE_BULK_OF_MACRO_REQUEST)
+ .put("bulkSize", 1)
+ .put("pause", false);
+
+ postAsyncInstanceRequest(request);
+
+ assertThat(fetchRequestSummary(request.at("/modelInfo/modelVersionId").asText()),
+ jsonEquals(ImmutableMap.of(
+ "vnf", 1L,
+ "vfModule", 2L,
+ "volumeGroup", 1L
+ )));
+ }
+
+ private JsonNode fetchRequestSummary(String serviceModelId) {
+ return stream(restTemplate.getForObject(getTemplateInfoUrl(serviceModelId), JsonNode[].class))
+ .map(it -> it.at("/requestSummary"))
+ .findFirst()
+ .orElseGet(() -> {
+ throw new AssertionError(getTemplateInfoUrl(serviceModelId) + " returned zero results");
+ });
+ }
+
+ private ObjectNode fileAsJsonNode(String fileName) throws IOException {
return objectMapper.readValue(
convertRequest(objectMapper, fileName),
- JsonNode.class);
+ ObjectNode.class);
}
public void templateTopology_givenDeploy_templateTopologyIsEquivalentToBody(JsonNode body) {
@@ -98,8 +135,6 @@ public class InstantiationTemplatesApiTest extends AsyncInstantiationBase {
}
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);