Merge "Reverting tenant_meta_data Json property"
authorByung-Woo Jun <byung-woo.jun@est.tech>
Thu, 17 Jun 2021 10:15:50 +0000 (10:15 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 17 Jun 2021 10:15:50 +0000 (10:15 +0000)
asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
asdc-controller/src/test/resources/download/service-pnfservice.csar
asdc-controller/src/test/resources/download/service-vnfservice.csar
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICommonTasksTest.java [new file with mode: 0644]
so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessNetwork.java
so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java
so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro1.java
so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro2.java
so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro3.java
so-simulator/src/main/java/org/onap/so/simulator/scenarios/sdnc/grapi/QueryVFModuleGR.java

index da7aad4..bc4434a 100644 (file)
@@ -1471,13 +1471,30 @@ public class ToscaResourceInstaller {
                 generateNamingValue = "true".equalsIgnoreCase(generateNaming);
             }
             service.setOnapGeneratedNaming(generateNamingValue);
-            service.setBlueprintName(serviceMetadata.getValue(CDS_MODEL_NAME));
-            service.setBlueprintVersion(serviceMetadata.getValue(CDS_MODEL_VERSION));
-            service.setSkipPostInstConf(Boolean.valueOf(serviceMetadata.getValue(SKIP_POST_INST_CONF)));
-            service.setControllerActor(serviceMetadata.getValue(CONTROLLER_ACTOR));
-        }
-
 
+            List<Input> serviceInputs = toscaResourceStructure.getSdcCsarHelper().getServiceInputs();
+            logger.debug("serviceInputs: {} " + serviceInputs);
+            if (!serviceInputs.isEmpty()) {
+                serviceInputs.forEach(input -> {
+                    if (CDS_MODEL_NAME.equalsIgnoreCase(input.getName())) {
+                        String value = input.getDefault() != null ? input.getDefault().toString() : null;
+                        service.setBlueprintName(value);
+                    }
+                    if (CDS_MODEL_VERSION.equalsIgnoreCase(input.getName())) {
+                        String value = input.getDefault() != null ? input.getDefault().toString() : null;
+                        service.setBlueprintVersion(value);
+                    }
+                    if (CONTROLLER_ACTOR.equalsIgnoreCase(input.getName())) {
+                        String value = input.getDefault() != null ? input.getDefault().toString() : null;
+                        service.setControllerActor(value);
+                    }
+                    if (SKIP_POST_INST_CONF.equalsIgnoreCase(input.getName())) {
+                        String value = input.getDefault() != null ? input.getDefault().toString() : "false";
+                        service.setSkipPostInstConf(Boolean.valueOf(value));
+                    }
+                });
+            }
+        }
         toscaResourceStructure.setCatalogService(service);
         return service;
     }
index e488211..bf327f5 100644 (file)
@@ -36,6 +36,7 @@ import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -571,6 +572,36 @@ public class ToscaResourceInstallerTest extends BaseTest {
         doReturn(namingPolicy).when(metadata).getValue("namingPolicy");
         doReturn(ecompGeneratedNaming).when(metadata).getValue("ecompGeneratedNaming");
 
+        ISdcCsarHelper iSdcCsarHelper = mock(ISdcCsarHelper.class);
+        List<Input> serviceInputs = new ArrayList<Input>();
+
+        LinkedHashMap<String, Object> value = new LinkedHashMap<String, Object>();
+        value.put("controller_actor", "SO-REF-DATA");
+        value.put("type", "string");
+        Input input = new Input("controller_actor", value, null);
+        serviceInputs.add(0, input);
+
+        value = new LinkedHashMap<String, Object>();
+        value.put("cds_model_version", "v1.4.0");
+        value.put("type", "string");
+        input = new Input("cds_model_version", value, null);
+        serviceInputs.add(1, input);
+
+        value = new LinkedHashMap<String, Object>();
+        value.put("cds_model_name", "Blueprint140");
+        value.put("type", "string");
+        input = new Input("cds_model_name", value, null);
+        serviceInputs.add(2, input);
+
+        value = new LinkedHashMap<String, Object>();
+        value.put("skip_post_instantiation_configuration", "false");
+        value.put("type", "boolean");
+        input = new Input("skip_post_instantiation_configuration", value, null);
+        serviceInputs.add(3, input);
+
+        doReturn(iSdcCsarHelper).when(toscaResourceStructure).getSdcCsarHelper();
+        doReturn(serviceInputs).when(iSdcCsarHelper).getServiceInputs();
+
         Service service = toscaInstaller.createService(toscaResourceStructure, resourceStructure);
 
         assertNotNull(service);
index 89d24a1..a026c7a 100644 (file)
Binary files a/asdc-controller/src/test/resources/download/service-pnfservice.csar and b/asdc-controller/src/test/resources/download/service-pnfservice.csar differ
index 25d2ebd..1dcfb59 100644 (file)
Binary files a/asdc-controller/src/test/resources/download/service-vnfservice.csar and b/asdc-controller/src/test/resources/download/service-vnfservice.csar differ
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICommonTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICommonTasksTest.java
new file mode 100644 (file)
index 0000000..f2687ef
--- /dev/null
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Modifications Copyright (c) 2021 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.aai.tasks;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.Optional;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.exception.ExceptionBuilder;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AAICommonTasksTest {
+
+    private static final String SERVICE_TYPE = "testService";
+
+    @Mock
+    private ExtractPojosForBB extractPojosForBBMock;
+    @Mock
+    private ExceptionBuilder exceptionBuilder;
+    @InjectMocks
+    private AAICommonTasks testedObject;
+
+    private ServiceInstance serviceInstance;
+    private BuildingBlockExecution buildingBlockExecution;
+
+    @Before
+    public void setup() {
+        serviceInstance = new ServiceInstance();
+        buildingBlockExecution = new DelegateExecutionImpl(new DelegateExecutionFake());
+    }
+
+    @Test
+    public void getServiceType_success() throws Exception {
+        // given
+        ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+        modelInfoServiceInstance.setServiceType(SERVICE_TYPE);
+        serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+        when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.SERVICE_INSTANCE_ID))
+                .thenReturn(serviceInstance);
+        // when
+        Optional<String> resultOpt = testedObject.getServiceType(buildingBlockExecution);
+        // then
+        assertThat(resultOpt).isNotEmpty();
+        String result = resultOpt.get();
+        assertThat(result).isEqualTo(SERVICE_TYPE);
+    }
+
+    @Test
+    public void getServiceType_emptyWhenServiceInstanceModelIsNull() throws Exception {
+        // given
+        when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.SERVICE_INSTANCE_ID))
+                .thenReturn(serviceInstance);
+        // when
+        Optional<String> result = testedObject.getServiceType(buildingBlockExecution);
+        // then
+        assertThat(result).isEmpty();
+    }
+
+    @Test
+    public void getServiceType_exceptionHandling() throws Exception {
+        // given
+        BBObjectNotFoundException exception = new BBObjectNotFoundException();
+        when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.SERVICE_INSTANCE_ID))
+                .thenThrow(exception);
+        // when
+        testedObject.getServiceType(buildingBlockExecution);
+        // then
+        verify(exceptionBuilder).buildAndThrowWorkflowException(buildingBlockExecution, 7000, exception);
+    }
+}
index b42441b..f7e8293 100644 (file)
@@ -1,5 +1,8 @@
 package org.onap.so.simulator.actions.aai;
 
+import com.consol.citrus.actions.AbstractTestAction;
+import com.consol.citrus.context.TestContext;
+import java.security.SecureRandom;
 import org.onap.aai.domain.yang.L3Network;
 import org.onap.aaiclient.client.aai.AAIResourcesClient;
 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
@@ -7,8 +10,6 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import com.consol.citrus.actions.AbstractTestAction;
-import com.consol.citrus.context.TestContext;
 
 
 public class ProcessNetwork extends AbstractTestAction {
@@ -17,7 +18,7 @@ public class ProcessNetwork extends AbstractTestAction {
     public void doExecute(TestContext context) {
         final Logger logger = LoggerFactory.getLogger(ProcessNetwork.class);
         try {
-            int random = (int) (Math.random() * 50 + 1);
+            int random = (new SecureRandom()).nextInt(50) + 1;
 
             AAIResourcesClient aaiResourceClient = new AAIResourcesClient();
 
index 383e1bf..4989e99 100644 (file)
@@ -14,19 +14,21 @@ import com.consol.citrus.context.TestContext;
 
 public class ProcessVnfc extends AbstractTestAction {
 
+    private static final String VNF_SERVER_1_NAME = "ssc_server_1";
+
     @Override
     public void doExecute(TestContext context) {
 
         final Logger logger = LoggerFactory.getLogger(ProcessVnfc.class);
         try {
             logger.debug("running ProcessVnfc scenario");
-            logger.debug("requestAction: " + context.getVariable("requestAction"));
-            logger.debug("serviceAction: " + context.getVariable("serviceAction"));
-            logger.debug("cloudOwner: " + context.getVariable("cloudOwner"));
-            logger.debug("cloundRegion: " + context.getVariable("cloudRegion"));
-            logger.debug("tenant: " + context.getVariable("tenant"));
-            logger.debug("vfModuleId: " + context.getVariable("vfModuleId"));
-            logger.debug("vnfId: " + context.getVariable("vnfId"));
+            logger.debug("requestAction: {}", context.getVariable("requestAction"));
+            logger.debug("serviceAction: {}", context.getVariable("serviceAction"));
+            logger.debug("cloudOwner: {}", context.getVariable("cloudOwner"));
+            logger.debug("cloundRegion: {}", context.getVariable("cloudRegion"));
+            logger.debug("tenant: {}", context.getVariable("tenant"));
+            logger.debug("vfModuleId: {}", context.getVariable("vfModuleId"));
+            logger.debug("vnfId: {}", context.getVariable("vnfId"));
 
             AAIResourcesClient aaiResourceClient = new AAIResourcesClient();
 
@@ -34,9 +36,9 @@ public class ProcessVnfc extends AbstractTestAction {
                     && context.getVariable("serviceAction").equals("assign")) {
 
                 AAIResourceUri vnfcURI =
-                        AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc("ssc_server_1"));
+                        AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(VNF_SERVER_1_NAME));
                 Vnfc vnfc = new Vnfc();
-                vnfc.setVnfcName("ssc_server_1");
+                vnfc.setVnfcName(VNF_SERVER_1_NAME);
                 vnfc.setNfcNamingCode("oamfw");
                 vnfc.setNfcFunction("EPC-OAM-FIREWALL");
                 vnfc.setProvStatus("PREPROV");
@@ -53,8 +55,8 @@ public class ProcessVnfc extends AbstractTestAction {
 
                 if (aaiResourceClient.exists(vnfcURI)) {
                     Optional<VfModule> vfModule = aaiResourceClient.get(vfModuleURI).asBean(VfModule.class);
-                    if (vfModule.get().getVfModuleName().contains("macro")) {
-                        String vnfcName = "ssc_server_1" + vfModule.get().getVfModuleName()
+                    if (vfModule.isPresent() && vfModule.get().getVfModuleName().contains("macro")) {
+                        String vnfcName = VNF_SERVER_1_NAME + vfModule.get().getVfModuleName()
                                 .substring(vfModule.get().getVfModuleName().length() - 1);
                         vnfc.setVnfcName(vnfcName);
                         vnfcURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfcName));
index 29a9aff..140ac3c 100644 (file)
@@ -1,22 +1,24 @@
 package org.onap.so.simulator.scenarios.openstack.macro;
 
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
 import com.consol.citrus.endpoint.resolver.DynamicEndpointUriResolver;
 import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
 import com.consol.citrus.simulator.scenario.Scenario;
 import com.consol.citrus.simulator.scenario.ScenarioDesigner;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 
 /**
- * This scenario is used by the following test cases: Resume Service Instance Macro 3 Modules 1 To Complete
+ * This scenario is used by the following test cases: Resume Service Instance Macro 3 Modules 1 To Complete.
  *
  */
 @Scenario("Openstack-QueryStackByID-Macro1")
 @RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_1/*", method = RequestMethod.GET)
 public class QueryStackByIdMacro1 extends AbstractSimulatorScenario {
 
+    private static final String FILE_STACK_CREATED_PATH = "openstack/gr_api/Stack_Created.json";
+    private static final String FILE_STACK_DELETED_PATH = "openstack/gr_api/Stack_Deleted.json";
 
     @Override
     public void run(ScenarioDesigner scenario) {
@@ -31,38 +33,31 @@ public class QueryStackByIdMacro1 extends AbstractSimulatorScenario {
 
         scenario.variable("stackName", "macro_module_1");
 
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
 
         // Create (module_2)
         scenario.http().receive().get();
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
 
         // Create (module_3)
         scenario.http().receive().get();
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
 
         // Create (module_2 recreate)
         scenario.http().receive().get();
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
 
         // Delete
         scenario.http().receive().get();
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
 
         // Delete
         scenario.http().receive().get();
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
 
         // Poll
         scenario.http().receive().get();
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
     }
 
 }
index 15f0b61..05d87cd 100644 (file)
@@ -1,22 +1,24 @@
 package org.onap.so.simulator.scenarios.openstack.macro;
 
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
 import com.consol.citrus.endpoint.resolver.DynamicEndpointUriResolver;
 import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
 import com.consol.citrus.simulator.scenario.Scenario;
 import com.consol.citrus.simulator.scenario.ScenarioDesigner;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 
 /**
- * This scenario is used by the following test cases: Resume Service Instance Macro 3 Modules 1 To Complete
+ * This scenario is used by the following test cases: Resume Service Instance Macro 3 Modules 1 To Complete.
  *
  */
 @Scenario("Openstack-QueryStackByID-Macro2")
 @RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_2/*", method = RequestMethod.GET)
 public class QueryStackByIdMacro2 extends AbstractSimulatorScenario {
 
+    private static final String FILE_STACK_CREATED_PATH = "openstack/gr_api/Stack_Created.json";
+    private static final String FILE_STACK_DELETED_PATH = "openstack/gr_api/Stack_Deleted.json";
 
     @Override
     public void run(ScenarioDesigner scenario) {
@@ -31,22 +33,18 @@ public class QueryStackByIdMacro2 extends AbstractSimulatorScenario {
 
         scenario.variable("stackName", "macro_module_2");
 
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
 
         // Delete
         scenario.http().receive().get();
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
 
         scenario.http().receive().get();
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
 
         // Poll
         scenario.http().receive().get();
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
     }
 
 }
index b7808dc..15a6fa3 100644 (file)
@@ -1,22 +1,24 @@
 package org.onap.so.simulator.scenarios.openstack.macro;
 
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
 import com.consol.citrus.endpoint.resolver.DynamicEndpointUriResolver;
 import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
 import com.consol.citrus.simulator.scenario.Scenario;
 import com.consol.citrus.simulator.scenario.ScenarioDesigner;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 
 /**
- * This scenario is used by the following test cases: Resume Service Instance Macro 3 Modules 1 To Complete
+ * This scenario is used by the following test cases: Resume Service Instance Macro 3 Modules 1 To Complete.
  *
  */
 @Scenario("Openstack-QueryStackByID-Macro3")
 @RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_3/*", method = RequestMethod.GET)
 public class QueryStackByIdMacro3 extends AbstractSimulatorScenario {
 
+    private static final String FILE_STACK_CREATED_PATH = "openstack/gr_api/Stack_Created.json";
+    private static final String FILE_STACK_DELETED_PATH = "openstack/gr_api/Stack_Deleted.json";
 
     @Override
     public void run(ScenarioDesigner scenario) {
@@ -31,22 +33,18 @@ public class QueryStackByIdMacro3 extends AbstractSimulatorScenario {
         scenario.variable("stackName", "macro_module_3");
 
         // Poll
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
 
         // Delete
         scenario.http().receive().get();
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
 
         scenario.http().receive().get();
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
 
         // Poll
         scenario.http().receive().get();
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+        scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
 
     }
 
index 4e6b151..6e5122f 100644 (file)
@@ -1,12 +1,13 @@
 package org.onap.so.simulator.scenarios.sdnc.grapi;
 
+import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
+import com.consol.citrus.simulator.scenario.Scenario;
+import com.consol.citrus.simulator.scenario.ScenarioDesigner;
+import java.security.SecureRandom;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
-import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
-import com.consol.citrus.simulator.scenario.Scenario;
-import com.consol.citrus.simulator.scenario.ScenarioDesigner;
 
 @Scenario("SDNC-GRAPI-QueryVFModule")
 @RequestMapping(
@@ -17,7 +18,7 @@ public class QueryVFModuleGR extends AbstractSimulatorScenario {
     @Override
     public void run(ScenarioDesigner scenario) {
         scenario.http().receive().get();
-        int random = (int) (Math.random() * 50 + 1);
+        int random = (new SecureRandom()).nextInt(50) + 1;
 
         scenario.variable("vfModuleName", "vfModuleName" + random);