aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test/java/org/onap
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2021-04-13 18:49:42 -0400
committerJozsef Csongvai <jozsef.csongvai@bell.ca>2021-08-04 08:47:46 -0400
commit084f025c6374249de06bf99235fd9e5b7987b933 (patch)
tree60f87c4b3cab70d238e6585335974e46cff48633 /bpmn/MSOCommonBPMN/src/test/java/org/onap
parent872613eafe80034cca612bd93294286b3dbed4b1 (diff)
Enable ControllerExecutionBB for service scope
Also make userParams.service optional to support usecases where it is not being passed. Issue-ID: SO-3627 Change-Id: I7e0abfffe54e11935b32f6c6829400de88fb4bd0 Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test/java/org/onap')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnfTest.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsUtilTest.java24
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java7
5 files changed, 38 insertions, 8 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java
index 6de1364a47..42b29ea669 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java
@@ -20,6 +20,7 @@
package org.onap.so.client.cds;
import com.google.gson.JsonParser;
+import java.util.Optional;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
@@ -143,12 +144,12 @@ public abstract class AbstractVnfCDSRequestProviderTest {
return userParams;
}
- protected Service getUserParams() {
+ protected Optional<Service> getUserParams() {
Service service = new Service();
Resources resources = new Resources();
resources.setVnfs(createVnfList());
service.setResources(resources);
- return service;
+ return Optional.of(service);
}
protected List<Vnfs> createVnfList() {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java
index 0273b9dbf6..be100652c0 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java
@@ -28,6 +28,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.UUID;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -67,7 +68,7 @@ public class ConfigureInstanceParamsForVfModuleTest {
resources.setVnfs(createVnfs());
service.setResources(resources);
- when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(service);
+ when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(Optional.of(service));
JsonObject jsonObject = new JsonObject();
configureInstanceParamsForVfModule.populateInstanceParams(jsonObject, new ArrayList<>(), VNF_CUSTOMIZATION_ID,
@@ -85,7 +86,7 @@ public class ConfigureInstanceParamsForVfModuleTest {
resources.setVnfs(createVnfs());
service.setResources(resources);
- when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(service);
+ when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(Optional.of(service));
JsonObject jsonObject = new JsonObject();
// No instance name is passed
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnfTest.java
index 547129e898..6466da59d0 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnfTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnfTest.java
@@ -28,6 +28,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.UUID;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -64,7 +65,7 @@ public class ConfigureInstanceParamsForVnfTest {
Resources resources = new Resources();
resources.setVnfs(createVnfs());
service.setResources(resources);
- when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(service);
+ when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(Optional.of(service));
JsonObject jsonObject = new JsonObject();
configureInstanceParamsForVnf.populateInstanceParams(jsonObject, new ArrayList<>(), VNF_2_CUSTOMIZATION_ID,
@@ -81,7 +82,7 @@ public class ConfigureInstanceParamsForVnfTest {
Resources resources = new Resources();
resources.setVnfs(createVnfs());
service.setResources(resources);
- when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(service);
+ when(extractServiceFromUserParameters.getServiceFromRequestUserParams(any())).thenReturn(Optional.of(service));
JsonObject jsonObject = new JsonObject();
// No instance name is passed
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsUtilTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsUtilTest.java
new file mode 100644
index 0000000000..f7c3e8a192
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsUtilTest.java
@@ -0,0 +1,24 @@
+package org.onap.so.client.cds;
+
+import static org.junit.Assert.assertEquals;
+import com.google.gson.JsonObject;
+import java.util.List;
+import java.util.Map;
+import org.junit.Test;
+
+public class ConfigureInstanceParamsUtilTest {
+
+ @Test
+ public void testApplyParamsToObject() {
+ List<Map<String, String>> instanceParamsList =
+ List.of(Map.of("test-param-1", "value1", "test-param-2", "value2"), Map.of("test-param-3", "value3"));
+ JsonObject jsonObject = new JsonObject();
+
+ ConfigureInstanceParamsUtil.applyParamsToObject(instanceParamsList, jsonObject);
+
+ assertEquals("value1", jsonObject.get("test-param-1").getAsString());
+ assertEquals("value2", jsonObject.get("test-param-2").getAsString());
+ assertEquals("value3", jsonObject.get("test-param-3").getAsString());
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java
index 70ce3a1eed..c860d0fc5e 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java
@@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,13 +36,15 @@ public class ServiceCDSRequestProviderTest extends AbstractVnfCDSRequestProvider
@InjectMocks
private ServiceCDSRequestProvider serviceCDSRequestProvider;
+ @Mock
+ private ConfigureInstanceParamsForService configureInstanceParamsForService;
+
@Test
public void testRequestPayloadForCreateService() throws Exception {
// given
setScopeAndAction(SERVICE_SCOPE, SERVICE_ACTION);
ServiceInstance instance = createServiceInstance();
- doReturn(instance).when(extractPojosForBB).extractByKey(buildingBlockExecution,
- ResourceKey.SERVICE_INSTANCE_ID);
+ buildingBlockExecution.getGeneralBuildingBlock().setServiceInstance(instance);
// when
serviceCDSRequestProvider.setExecutionObject(buildingBlockExecution);