aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test/java')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/AllIntegrationTestSuites.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java94
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java28
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/FileUtil.java85
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/IntegrationTestSuite.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java18
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/UnitTestSuite.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java128
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java321
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java997
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java1192
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java365
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java1285
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java76
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java112
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java70
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java137
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java84
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java348
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java174
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java412
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java124
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java251
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTaskTest.java239
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java122
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java96
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java169
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java466
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java120
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java86
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/audit/AuditTasksTest.java67
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java24
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtilsTest.java61
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java70
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java191
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtilsTest.java111
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java130
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java284
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollectionTest.java152
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkTest.java90
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java262
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtilsTest.java160
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java941
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java140
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnfTest.java80
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java146
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java87
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java63
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java169
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java191
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java122
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java201
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java187
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java241
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java203
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java156
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java57
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java812
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java45
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java201
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java623
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java97
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java2786
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java110
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasksTest.java121
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java1119
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java381
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java633
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java348
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java333
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestPropertiesTest.java36
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java604
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java1637
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java155
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java134
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java146
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java142
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java132
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java82
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java135
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java147
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java671
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java63
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java211
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java328
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java143
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVpnBindingResourcesTest.java142
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java109
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NetworkAdapterResourcesTest.java327
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java70
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java239
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java192
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java155
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java244
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java52
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResourcesTest.java189
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResourcesTest.java142
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/policy/CommonObjectMapperProviderTest.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java54
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java28
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java742
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java339
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java89
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java547
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java190
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java98
114 files changed, 14689 insertions, 13849 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/AllIntegrationTestSuites.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/AllIntegrationTestSuites.java
index 23fcddfe8a..c5cdae4425 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/AllIntegrationTestSuites.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/AllIntegrationTestSuites.java
@@ -21,12 +21,11 @@
package org.onap.so;
import org.junit.runner.RunWith;
-
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
@RunWith(WildcardPatternSuite.class)
@SuiteClasses({"**/SniroHomingV2IT.class"})
-public class AllIntegrationTestSuites{
+public class AllIntegrationTestSuites {
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java
index aefe4c64bf..3bb8fb70f2 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java
@@ -21,7 +21,6 @@ package org.onap.so;
import java.io.IOException;
import java.io.InputStream;
-
import org.junit.Before;
import org.junit.runner.RunWith;
import org.onap.so.bpmn.buildingblock.SniroHomingV2;
@@ -40,7 +39,6 @@ import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
-
import com.github.tomakehurst.wiremock.WireMockServer;
@RunWith(SpringRunner.class)
@@ -50,60 +48,60 @@ import com.github.tomakehurst.wiremock.WireMockServer;
@AutoConfigureWireMock(port = 0)
public abstract class BaseIntegrationTest extends TestDataSetup {
- @Value("${wiremock.server.port}")
- protected String wireMockPort;
+ @Value("${wiremock.server.port}")
+ protected String wireMockPort;
+
+ @SpyBean
+ protected SDNCClient SPY_sdncClient;
+
+ @SpyBean
+ protected SDNOHealthCheckResources MOCK_sdnoHealthCheckResources;
- @SpyBean
- protected SDNCClient SPY_sdncClient;
+ @SpyBean
+ protected SniroHomingV2 sniroHoming;
- @SpyBean
- protected SDNOHealthCheckResources MOCK_sdnoHealthCheckResources;
+ @SpyBean
+ protected SniroClient sniroClient;
- @SpyBean
- protected SniroHomingV2 sniroHoming;
+ @MockBean
+ protected ApplicationControllerAction appCClient;
- @SpyBean
- protected SniroClient sniroClient;
+ @MockBean
+ protected CatalogDbClient catalogDbClient;
- @MockBean
- protected ApplicationControllerAction appCClient;
+ @Autowired
+ protected WireMockServer wireMockServer;
- @MockBean
- protected CatalogDbClient catalogDbClient;
-
- @Autowired
- protected WireMockServer wireMockServer;
+ @Before
+ public void baseTestBefore() {
+ wireMockServer.resetAll();
+ }
- @Before
- public void baseTestBefore() {
- wireMockServer.resetAll();
- }
- public String readResourceFile(String fileName) {
- InputStream stream;
- try {
- stream = getResourceAsStream(fileName);
- byte[] bytes;
- bytes = new byte[stream.available()];
- if(stream.read(bytes) > 0) {
- stream.close();
- return new String(bytes);
- } else {
- stream.close();
- return "";
- }
- } catch (IOException e) {
- return "";
- }
- }
+ public String readResourceFile(String fileName) {
+ InputStream stream;
+ try {
+ stream = getResourceAsStream(fileName);
+ byte[] bytes;
+ bytes = new byte[stream.available()];
+ if (stream.read(bytes) > 0) {
+ stream.close();
+ return new String(bytes);
+ } else {
+ stream.close();
+ return "";
+ }
+ } catch (IOException e) {
+ return "";
+ }
+ }
- private InputStream getResourceAsStream(String resourceName) throws IOException {
- InputStream stream =
- FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
- if (stream == null) {
- throw new IOException("Can't access resource '" + resourceName + "'");
- }
- return stream;
- }
+ private InputStream getResourceAsStream(String resourceName) throws IOException {
+ InputStream stream = FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
+ if (stream == null) {
+ throw new IOException("Can't access resource '" + resourceName + "'");
+ }
+ return stream;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
index fb08e5e830..62d9ecee44 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
@@ -19,6 +19,7 @@
*/
package org.onap.so;
+
import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
@@ -35,30 +36,25 @@ public class EmbeddedMariaDbConfig {
@Bean
MariaDB4jSpringService mariaDB4jSpringService() {
- MariaDB4jSpringService service = new MariaDB4jSpringService();
-
-
- service.getConfiguration().addArg("--lower_case_table_names=1");
+ MariaDB4jSpringService service = new MariaDB4jSpringService();
+
+
+ service.getConfiguration().addArg("--lower_case_table_names=1");
return service;
}
@Bean
DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService,
- @Value("${mariaDB4j.databaseName}") String databaseName,
- @Value("${spring.datasource.username}") String datasourceUsername,
- @Value("${spring.datasource.password}") String datasourcePassword,
- @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
- //Create our database with default root user and no password
+ @Value("${mariaDB4j.databaseName}") String databaseName,
+ @Value("${spring.datasource.username}") String datasourceUsername,
+ @Value("${spring.datasource.password}") String datasourcePassword,
+ @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
+ // Create our database with default root user and no password
mariaDB4jSpringService.getDB().createDB(databaseName);
DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration();
- return DataSourceBuilder
- .create()
- .username(datasourceUsername)
- .password(datasourcePassword)
- .url(config.getURL(databaseName))
- .driverClassName(datasourceDriver)
- .build();
+ return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword)
+ .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build();
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/FileUtil.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/FileUtil.java
index 366c9c11a9..24927b0d1c 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/FileUtil.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/FileUtil.java
@@ -34,51 +34,50 @@ import org.slf4j.LoggerFactory;
* </p>
*
* @author
- * @version ONAP Sep 15, 2017
+ * @version ONAP Sep 15, 2017
*/
public class FileUtil {
private static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
-
- /**
- * Read the specified resource file and return the contents as a String.
- *
- * @param fileName Name of the resource file
- * @return the contents of the resource file as a String
- * @throws IOException if there is a problem reading the file
- */
- public static String readResourceFile(String fileName) {
- InputStream stream;
- try {
- stream = getResourceAsStream(fileName);
- byte[] bytes;
- bytes = new byte[stream.available()];
- if(stream.read(bytes) > 0) {
- stream.close();
- return new String(bytes);
- } else {
- stream.close();
- return "";
- }
- } catch (IOException e) {
- logger.debug("Exception:", e);
- return "";
- }
- }
-
- /**
- * Get an InputStream for the resource specified.
- *
- * @param resourceName Name of resource for which to get InputStream.
- * @return an InputStream for the resource specified.
- * @throws IOException If we can't get the InputStream for whatever reason.
- */
- private static InputStream getResourceAsStream(String resourceName) throws IOException {
- InputStream stream =
- FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
- if (stream == null) {
- throw new IOException("Can't access resource '" + resourceName + "'");
- }
- return stream;
- }
+
+ /**
+ * Read the specified resource file and return the contents as a String.
+ *
+ * @param fileName Name of the resource file
+ * @return the contents of the resource file as a String
+ * @throws IOException if there is a problem reading the file
+ */
+ public static String readResourceFile(String fileName) {
+ InputStream stream;
+ try {
+ stream = getResourceAsStream(fileName);
+ byte[] bytes;
+ bytes = new byte[stream.available()];
+ if (stream.read(bytes) > 0) {
+ stream.close();
+ return new String(bytes);
+ } else {
+ stream.close();
+ return "";
+ }
+ } catch (IOException e) {
+ logger.debug("Exception:", e);
+ return "";
+ }
+ }
+
+ /**
+ * Get an InputStream for the resource specified.
+ *
+ * @param resourceName Name of resource for which to get InputStream.
+ * @return an InputStream for the resource specified.
+ * @throws IOException If we can't get the InputStream for whatever reason.
+ */
+ private static InputStream getResourceAsStream(String resourceName) throws IOException {
+ InputStream stream = FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
+ if (stream == null) {
+ throw new IOException("Can't access resource '" + resourceName + "'");
+ }
+ return stream;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/IntegrationTestSuite.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/IntegrationTestSuite.java
index 0eddeb1649..50bbc1845f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/IntegrationTestSuite.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/IntegrationTestSuite.java
@@ -21,7 +21,6 @@
package org.onap.so;
import org.junit.runner.RunWith;
-
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java
index 87153144c8..2e27b346ea 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java
@@ -31,14 +31,14 @@ import org.springframework.context.annotation.Profile;
@SpringBootApplication
@Profile("test")
-@ComponentScan(basePackages = {"org.onap.so"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = {
- @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
+@ComponentScan(basePackages = {"org.onap.so"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class,
+ excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
public class TestApplication {
- public static void main(String... args) {
- SpringApplication.run(TestApplication.class, args);
- System.getProperties().setProperty("mso.db", "MARIADB");
- System.getProperties().setProperty("server.name", "Springboot");
-
-
- }
+ public static void main(String... args) {
+ SpringApplication.run(TestApplication.class, args);
+ System.getProperties().setProperty("mso.db", "MARIADB");
+ System.getProperties().setProperty("server.name", "Springboot");
+
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/UnitTestSuite.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/UnitTestSuite.java
index 82ad6582c5..890c81daeb 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/UnitTestSuite.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/UnitTestSuite.java
@@ -22,7 +22,6 @@ package org.onap.so;
import org.junit.runner.RunWith;
-
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
index 6dc0b1861d..b40e43b959 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
@@ -58,96 +58,96 @@ import org.springframework.core.env.Environment;
@RunWith(MockitoJUnitRunner.Silent.class)
public abstract class BaseTaskTest extends TestDataSetup {
- @Mock
- protected AAIVolumeGroupResources aaiVolumeGroupResources;
+ @Mock
+ protected AAIVolumeGroupResources aaiVolumeGroupResources;
- @Mock
- protected AAIServiceInstanceResources aaiServiceInstanceResources;
+ @Mock
+ protected AAIServiceInstanceResources aaiServiceInstanceResources;
- @Mock
- protected AAIVnfResources aaiVnfResources;
+ @Mock
+ protected AAIVnfResources aaiVnfResources;
- @Mock
- protected AAIVfModuleResources aaiVfModuleResources;
+ @Mock
+ protected AAIVfModuleResources aaiVfModuleResources;
- @Mock
- protected AAIVpnBindingResources aaiVpnBindingResources;
+ @Mock
+ protected AAIVpnBindingResources aaiVpnBindingResources;
- @Mock
- protected AAINetworkResources aaiNetworkResources;
+ @Mock
+ protected AAINetworkResources aaiNetworkResources;
- @Mock
- protected AAICollectionResources aaiCollectionResources;
+ @Mock
+ protected AAICollectionResources aaiCollectionResources;
- @Mock
- protected NetworkAdapterResources networkAdapterResources;
+ @Mock
+ protected NetworkAdapterResources networkAdapterResources;
- @Mock
- protected VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
+ @Mock
+ protected VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
- @Mock
- protected VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
+ @Mock
+ protected VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
- @Mock
- protected SDNCVnfResources sdncVnfResources;
+ @Mock
+ protected SDNCVnfResources sdncVnfResources;
- @Mock
- protected SDNCNetworkResources sdncNetworkResources;
+ @Mock
+ protected SDNCNetworkResources sdncNetworkResources;
- @Mock
- protected SDNCVfModuleResources sdncVfModuleResources;
+ @Mock
+ protected SDNCVfModuleResources sdncVfModuleResources;
- @Mock
- protected SDNCServiceInstanceResources sdncServiceInstanceResources;
+ @Mock
+ protected SDNCServiceInstanceResources sdncServiceInstanceResources;
- @Mock
- protected AssignNetworkBBUtils assignNetworkBBUtils;
+ @Mock
+ protected AssignNetworkBBUtils assignNetworkBBUtils;
- @Mock
- protected NetworkAdapterObjectMapper networkAdapterObjectMapper;
+ @Mock
+ protected NetworkAdapterObjectMapper networkAdapterObjectMapper;
- @Mock
- protected AAIInstanceGroupResources aaiInstanceGroupResources;
-
- @Mock
- protected NamingServiceResources namingServiceResources;
+ @Mock
+ protected AAIInstanceGroupResources aaiInstanceGroupResources;
- @Mock
- protected ApplicationControllerAction appCClient;
+ @Mock
+ protected NamingServiceResources namingServiceResources;
- @Mock
- protected CatalogDbClient catalogDbClient;
+ @Mock
+ protected ApplicationControllerAction appCClient;
- @Mock
- protected RequestsDbClient requestsDbClient;
+ @Mock
+ protected CatalogDbClient catalogDbClient;
- @Mock
- protected BBInputSetupUtils bbSetupUtils;
+ @Mock
+ protected RequestsDbClient requestsDbClient;
- @Mock
- protected BBInputSetup bbInputSetup;
+ @Mock
+ protected BBInputSetupUtils bbSetupUtils;
- @Mock
- protected AAIConfigurationResources aaiConfigurationResources;
+ @Mock
+ protected BBInputSetup bbInputSetup;
- @Mock
- protected AAIObjectMapper MOCK_aaiObjectMapper;
+ @Mock
+ protected AAIConfigurationResources aaiConfigurationResources;
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
+ @Mock
+ protected AAIObjectMapper MOCK_aaiObjectMapper;
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
- @Mock
- protected ExtractPojosForBB extractPojosForBB;
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
- @Mock
- protected ExceptionBuilder exceptionUtil;
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
- @Mock
- protected WorkflowActionExtractResourcesAAI workflowActionUtils;
-
- @Mock
- protected Environment env;
+ @Mock
+ protected ExceptionBuilder exceptionUtil;
+
+ @Mock
+ protected WorkflowActionExtractResourcesAAI workflowActionUtils;
+
+ @Mock
+ protected Environment env;
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java
index a91ef66a29..95689e49cd 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java
@@ -28,9 +28,7 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.io.IOException;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -56,154 +54,173 @@ import org.springframework.beans.factory.annotation.Autowired;
public class AAIFlagTasksTest extends BaseTaskTest {
- @InjectMocks
- private AAIFlagTasks aaiFlagTasks = new AAIFlagTasks();
-
- private GenericVnf genericVnf;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- genericVnf = setGenericVnf();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- when(extractPojosForBB.extractByKey(any(),any())).thenReturn(genericVnf);
- }
-
- @Test
- public void checkVnfInMaintTestTrue() throws Exception {
- doThrow(new BpmnError("VNF is in maintenance in A&AI")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doReturn(false).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
- doReturn(true).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
- try {
- aaiFlagTasks.checkVnfInMaintFlag(execution);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkInMaintFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), eq("VNF is in maintenance in A&AI"));
- }
- }
-
- @Test
- public void checkVnfInMaintTestFalse() throws Exception {
- doReturn(false).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
- aaiFlagTasks.checkVnfInMaintFlag(execution);
- verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), any(int.class), any(String.class));
- }
-
- @Test
- public void checkVnfInMaintFlagExceptionTest() {
-
- doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(RuntimeException.class).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
- try {
- aaiFlagTasks.checkVnfInMaintFlag(execution);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkInMaintFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
-
- }
-
- @Test
- public void modifyVnfInMaintFlagTest() throws Exception {
- doNothing().when(aaiVnfResources).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
- aaiFlagTasks.modifyVnfInMaintFlag(execution, true);
- verify(aaiVnfResources, times(1)).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
- }
-
- @Test
- public void modifyVnfInMaintFlagExceptionTest() {
-
- doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(isA(GenericVnf.class));
- try {
- aaiFlagTasks.modifyVnfInMaintFlag(execution, true);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkInMaintFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
- }
-
- @Test
- public void checkVnfClosedLoopDisabledTestTrue() throws Exception {
- doThrow(new BpmnError("VNF Closed Loop Disabled in A&AI")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doReturn(false).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
- try {
- aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), eq("VNF Closed Loop Disabled in A&AI"));
- }
- }
-
- @Test
- public void checkVnfClosedLoopDisabledTestFalse() throws Exception {
- doReturn(false).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
- aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
- verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), any(int.class), any(String.class));
- }
-
- @Test
- public void checkVnfClosedLoopDisabledFlagExceptionTest() {
-
- doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(RuntimeException.class).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
- try {
- aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
- }
-
- @Test
- public void modifyVnfClosedLoopDisabledFlagTest() throws Exception {
- doNothing().when(aaiVnfResources).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
- aaiFlagTasks.modifyVnfClosedLoopDisabledFlag(execution, true);
- verify(aaiVnfResources, times(1)).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
- }
-
- @Test
- public void modifyVnfClosedLoopDisabledFlagExceptionTest() {
-
- doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(isA(GenericVnf.class));
- try {
- aaiFlagTasks.modifyVnfClosedLoopDisabledFlag(execution, true);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
- }
-
-
- @Test
- public void checkVnfPserversLockedFlagTestTrue() throws Exception {
- doThrow(new BpmnError("VNF PServers in Locked in A&AI")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doReturn(true).when(aaiVnfResources).checkVnfPserversLockedFlag(isA(String.class));
- try {
- aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkVnfPserversLockedFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), eq("VNF PServers in Locked in A&AI"));
- }
- }
-
- @Test
- public void checkVnfPserversLockedFlagTestFalse() throws Exception {
- doReturn(false).when(aaiVnfResources).checkVnfPserversLockedFlag(isA(String.class));
- aaiFlagTasks.checkVnfPserversLockedFlag(execution);
- verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), any(int.class), any(String.class));
- }
-
- @Test
- public void checkVnfPserversLockedFlagExceptionTest() throws IOException {
-
- doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(RuntimeException.class).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
- try {
- aaiFlagTasks.checkVnfPserversLockedFlag(execution);
- } catch (Exception e) {
- verify(aaiVnfResources, times(1)).checkVnfPserversLockedFlag(any(String.class));
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
- }
+ @InjectMocks
+ private AAIFlagTasks aaiFlagTasks = new AAIFlagTasks();
+
+ private GenericVnf genericVnf;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ genericVnf = setGenericVnf();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ when(extractPojosForBB.extractByKey(any(), any())).thenReturn(genericVnf);
+ }
+
+ @Test
+ public void checkVnfInMaintTestTrue() throws Exception {
+ doThrow(new BpmnError("VNF is in maintenance in A&AI")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doReturn(false).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
+ doReturn(true).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
+ try {
+ aaiFlagTasks.checkVnfInMaintFlag(execution);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkInMaintFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ eq("VNF is in maintenance in A&AI"));
+ }
+ }
+
+ @Test
+ public void checkVnfInMaintTestFalse() throws Exception {
+ doReturn(false).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
+ aaiFlagTasks.checkVnfInMaintFlag(execution);
+ verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class),
+ any(int.class), any(String.class));
+ }
+
+ @Test
+ public void checkVnfInMaintFlagExceptionTest() {
+
+ doThrow(new BpmnError("Unknown Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(RuntimeException.class).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
+ try {
+ aaiFlagTasks.checkVnfInMaintFlag(execution);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkInMaintFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+
+ }
+
+ @Test
+ public void modifyVnfInMaintFlagTest() throws Exception {
+ doNothing().when(aaiVnfResources).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
+ aaiFlagTasks.modifyVnfInMaintFlag(execution, true);
+ verify(aaiVnfResources, times(1)).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
+ }
+
+ @Test
+ public void modifyVnfInMaintFlagExceptionTest() {
+
+ doThrow(new BpmnError("Unknown Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(isA(GenericVnf.class));
+ try {
+ aaiFlagTasks.modifyVnfInMaintFlag(execution, true);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkInMaintFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+ }
+
+ @Test
+ public void checkVnfClosedLoopDisabledTestTrue() throws Exception {
+ doThrow(new BpmnError("VNF Closed Loop Disabled in A&AI")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doReturn(false).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
+ try {
+ aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ eq("VNF Closed Loop Disabled in A&AI"));
+ }
+ }
+
+ @Test
+ public void checkVnfClosedLoopDisabledTestFalse() throws Exception {
+ doReturn(false).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
+ aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
+ verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class),
+ any(int.class), any(String.class));
+ }
+
+ @Test
+ public void checkVnfClosedLoopDisabledFlagExceptionTest() {
+
+ doThrow(new BpmnError("Unknown Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(RuntimeException.class).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
+ try {
+ aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+ }
+
+ @Test
+ public void modifyVnfClosedLoopDisabledFlagTest() throws Exception {
+ doNothing().when(aaiVnfResources).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
+ aaiFlagTasks.modifyVnfClosedLoopDisabledFlag(execution, true);
+ verify(aaiVnfResources, times(1)).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
+ }
+
+ @Test
+ public void modifyVnfClosedLoopDisabledFlagExceptionTest() {
+
+ doThrow(new BpmnError("Unknown Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(isA(GenericVnf.class));
+ try {
+ aaiFlagTasks.modifyVnfClosedLoopDisabledFlag(execution, true);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+ }
+
+
+ @Test
+ public void checkVnfPserversLockedFlagTestTrue() throws Exception {
+ doThrow(new BpmnError("VNF PServers in Locked in A&AI")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doReturn(true).when(aaiVnfResources).checkVnfPserversLockedFlag(isA(String.class));
+ try {
+ aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkVnfPserversLockedFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ eq("VNF PServers in Locked in A&AI"));
+ }
+ }
+
+ @Test
+ public void checkVnfPserversLockedFlagTestFalse() throws Exception {
+ doReturn(false).when(aaiVnfResources).checkVnfPserversLockedFlag(isA(String.class));
+ aaiFlagTasks.checkVnfPserversLockedFlag(execution);
+ verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class),
+ any(int.class), any(String.class));
+ }
+
+ @Test
+ public void checkVnfPserversLockedFlagExceptionTest() throws IOException {
+
+ doThrow(new BpmnError("Unknown Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(RuntimeException.class).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
+ try {
+ aaiFlagTasks.checkVnfPserversLockedFlag(execution);
+ } catch (Exception e) {
+ verify(aaiVnfResources, times(1)).checkVnfPserversLockedFlag(any(String.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
index 8bbb6c7f46..ff6426d351 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
@@ -21,14 +21,12 @@ package org.onap.so.bpmn.common.data;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl;
import org.junit.Before;
@@ -75,540 +73,543 @@ import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-public class TestDataSetup{
- private int collectionCounter;
- private int configurationCounter;
- private int customerCounter;
- private int genericVnfCounter;
- private int instanceGroupCounter;
- private int l3NetworkCounter;
- private int owningEntityCounter;
- private int pnfCounter;
- private int projectCounter;
- private int serviceInstanceCounter;
- private int serviceProxyCounter;
- private int serviceSubscriptionCounter;
- private int vfModuleCounter;
- private int volumeGroupCounter;
- private int vpnBindingCounter;
- private int vpnBondingLinkCounter;
-
- protected BuildingBlockExecution execution;
-
- protected GeneralBuildingBlock gBBInput;
-
- protected HashMap<ResourceKey, String> lookupKeyMap;
-
- protected ExtractPojosForBB extractPojosForBB = new ExtractPojosForBB();
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- protected DelegateExecution delegateExecution;
-
- @Before
- public void buildingBlockTestDataSetupBefore() {
- collectionCounter = 0;
- configurationCounter = 0;
- customerCounter = 0;
- genericVnfCounter = 0;
- instanceGroupCounter = 0;
- l3NetworkCounter = 0;
- owningEntityCounter = 0;
- pnfCounter = 0;
- projectCounter = 0;
- serviceInstanceCounter = 0;
- serviceProxyCounter = 0;
- serviceSubscriptionCounter = 0;
- vfModuleCounter = 0;
- volumeGroupCounter = 0;
- vpnBindingCounter = 0;
- vpnBondingLinkCounter = 0;
-
- execution = new DelegateExecutionImpl(new ExecutionImpl());
- execution.setVariable("testProcessKey", "testProcessKeyValue");
-
- gBBInput = new GeneralBuildingBlock();
- execution.setVariable("gBBInput", gBBInput);
-
- lookupKeyMap = new HashMap<ResourceKey, String>();
- execution.setVariable("lookupKeyMap", lookupKeyMap);
-
- ExecutionImpl mockExecutionImpl = mock(ExecutionImpl.class);
- doReturn("test").when(mockExecutionImpl).getProcessInstanceId();
-
- ExecutionImpl executionImpl = new ExecutionImpl();
- executionImpl.setProcessInstance(mockExecutionImpl);
-
- delegateExecution = (DelegateExecution) executionImpl;
- delegateExecution.setVariable("testProcessKey", "testProcessKeyValue");
- }
-
- public Map<String, String> buildUserInput() {
- Map<String, String> userInput = new HashMap<>();
- userInput.put("testUserInputKey", "testUserInputValue");
-
- return userInput;
- }
-
- public Map<String, String> setUserInput() {
- Map<String, String> userInput = buildUserInput();
-
- gBBInput.setUserInput(userInput);
-
- return userInput;
- }
-
- public RequestContext buildRequestContext() {
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId(UUID.randomUUID().toString());
- requestContext.setProductFamilyId("testProductFamilyId");
- requestContext.setRequestorId("testRequestorId");
-
- requestContext.setUserParams(new HashMap<>());
-
- Map<String,Object> dataMap = new HashMap<>();
- dataMap.put("vpnId","testVpnId");
- dataMap.put("vpnRegion","testVpnRegion");
- dataMap.put("vpnRt","testVpnRt");
- dataMap.put("vpnName","vpnName");
+public class TestDataSetup {
+ private int collectionCounter;
+ private int configurationCounter;
+ private int customerCounter;
+ private int genericVnfCounter;
+ private int instanceGroupCounter;
+ private int l3NetworkCounter;
+ private int owningEntityCounter;
+ private int pnfCounter;
+ private int projectCounter;
+ private int serviceInstanceCounter;
+ private int serviceProxyCounter;
+ private int serviceSubscriptionCounter;
+ private int vfModuleCounter;
+ private int volumeGroupCounter;
+ private int vpnBindingCounter;
+ private int vpnBondingLinkCounter;
+
+ protected BuildingBlockExecution execution;
+
+ protected GeneralBuildingBlock gBBInput;
+
+ protected HashMap<ResourceKey, String> lookupKeyMap;
+
+ protected ExtractPojosForBB extractPojosForBB = new ExtractPojosForBB();
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ protected DelegateExecution delegateExecution;
+
+ @Before
+ public void buildingBlockTestDataSetupBefore() {
+ collectionCounter = 0;
+ configurationCounter = 0;
+ customerCounter = 0;
+ genericVnfCounter = 0;
+ instanceGroupCounter = 0;
+ l3NetworkCounter = 0;
+ owningEntityCounter = 0;
+ pnfCounter = 0;
+ projectCounter = 0;
+ serviceInstanceCounter = 0;
+ serviceProxyCounter = 0;
+ serviceSubscriptionCounter = 0;
+ vfModuleCounter = 0;
+ volumeGroupCounter = 0;
+ vpnBindingCounter = 0;
+ vpnBondingLinkCounter = 0;
+
+ execution = new DelegateExecutionImpl(new ExecutionImpl());
+ execution.setVariable("testProcessKey", "testProcessKeyValue");
+
+ gBBInput = new GeneralBuildingBlock();
+ execution.setVariable("gBBInput", gBBInput);
+
+ lookupKeyMap = new HashMap<ResourceKey, String>();
+ execution.setVariable("lookupKeyMap", lookupKeyMap);
+
+ ExecutionImpl mockExecutionImpl = mock(ExecutionImpl.class);
+ doReturn("test").when(mockExecutionImpl).getProcessInstanceId();
+
+ ExecutionImpl executionImpl = new ExecutionImpl();
+ executionImpl.setProcessInstance(mockExecutionImpl);
+
+ delegateExecution = (DelegateExecution) executionImpl;
+ delegateExecution.setVariable("testProcessKey", "testProcessKeyValue");
+ }
+
+ public Map<String, String> buildUserInput() {
+ Map<String, String> userInput = new HashMap<>();
+ userInput.put("testUserInputKey", "testUserInputValue");
+
+ return userInput;
+ }
+
+ public Map<String, String> setUserInput() {
+ Map<String, String> userInput = buildUserInput();
+
+ gBBInput.setUserInput(userInput);
+
+ return userInput;
+ }
+
+ public RequestContext buildRequestContext() {
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId(UUID.randomUUID().toString());
+ requestContext.setProductFamilyId("testProductFamilyId");
+ requestContext.setRequestorId("testRequestorId");
+
+ requestContext.setUserParams(new HashMap<>());
+
+ Map<String, Object> dataMap = new HashMap<>();
+ dataMap.put("vpnId", "testVpnId");
+ dataMap.put("vpnRegion", "testVpnRegion");
+ dataMap.put("vpnRt", "testVpnRt");
+ dataMap.put("vpnName", "vpnName");
dataMap.put("vpnRegion", Arrays.asList(new String[] {"USA", "EMEA", "APAC"}));
- HashMap<String,Object> userParams = new HashMap<>();
- userParams.put("vpnData",dataMap);
+ HashMap<String, Object> userParams = new HashMap<>();
+ userParams.put("vpnData", dataMap);
+
+ List<Map<String, Object>> userParamsList = new ArrayList<>();
+ userParamsList.add(userParams);
- List<Map<String,Object>> userParamsList = new ArrayList<>();
- userParamsList.add(userParams);
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUserParams(userParamsList);
+ requestContext.setRequestParameters(requestParameters);
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setUserParams(userParamsList);
- requestContext.setRequestParameters(requestParameters);
+ return requestContext;
+ }
- return requestContext;
- }
+ public RequestContext setRequestContext() {
+ RequestContext requestContext = buildRequestContext();
- public RequestContext setRequestContext() {
- RequestContext requestContext = buildRequestContext();
+ gBBInput.setRequestContext(requestContext);
- gBBInput.setRequestContext(requestContext);
+ return requestContext;
+ }
- return requestContext;
- }
+ public CloudRegion buildCloudRegion() {
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("testLcpCloudRegionId");
+ cloudRegion.setTenantId("testTenantId");
+ cloudRegion.setCloudOwner("testCloudOwner");
- public CloudRegion buildCloudRegion() {
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("testLcpCloudRegionId");
- cloudRegion.setTenantId("testTenantId");
- cloudRegion.setCloudOwner("testCloudOwner");
+ return cloudRegion;
+ }
- return cloudRegion;
- }
+ public CloudRegion setCloudRegion() {
+ CloudRegion cloudRegion = buildCloudRegion();
- public CloudRegion setCloudRegion() {
- CloudRegion cloudRegion = buildCloudRegion();
+ gBBInput.setCloudRegion(cloudRegion);
- gBBInput.setCloudRegion(cloudRegion);
+ return cloudRegion;
+ }
- return cloudRegion;
- }
+ public OrchestrationContext buildOrchestrationContext() {
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
- public OrchestrationContext buildOrchestrationContext() {
- OrchestrationContext orchestrationContext = new OrchestrationContext();
+ return orchestrationContext;
+ }
- return orchestrationContext;
- }
+ public OrchestrationContext setOrchestrationContext() {
+ OrchestrationContext orchestrationContext = buildOrchestrationContext();
- public OrchestrationContext setOrchestrationContext() {
- OrchestrationContext orchestrationContext = buildOrchestrationContext();
+ gBBInput.setOrchContext(orchestrationContext);
- gBBInput.setOrchContext(orchestrationContext);
+ return orchestrationContext;
+ }
- return orchestrationContext;
- }
+ public Collection buildCollection() {
+ collectionCounter++;
- public Collection buildCollection() {
- collectionCounter++;
+ Collection collection = new Collection();
+ collection.setId("testId" + collectionCounter);
+ collection.setInstanceGroup(buildInstanceGroup());
- Collection collection = new Collection();
- collection.setId("testId" + collectionCounter);
- collection.setInstanceGroup(buildInstanceGroup());
+ return collection;
+ }
- return collection;
- }
+ public Configuration buildConfiguration() {
+ configurationCounter++;
- public Configuration buildConfiguration() {
- configurationCounter++;
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("testConfigurationId" + configurationCounter);
+ configuration.setConfigurationName("testConfigurationName" + configurationCounter);
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("testConfigurationId" + configurationCounter);
- configuration.setConfigurationName("testConfigurationName" + configurationCounter);
+ ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
+ modelInfoConfiguration.setModelVersionId("testModelVersionId" + configurationCounter);
+ modelInfoConfiguration.setModelInvariantId("testModelInvariantId" + configurationCounter);
+ modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter);
- ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
- modelInfoConfiguration.setModelVersionId("testModelVersionId" + configurationCounter);
- modelInfoConfiguration.setModelInvariantId("testModelInvariantId" + configurationCounter);
- modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter);
+ configuration.setModelInfoConfiguration(modelInfoConfiguration);
- configuration.setModelInfoConfiguration(modelInfoConfiguration);
+ return configuration;
+ }
- return configuration;
- }
+ public OwningEntity buildOwningEntity() {
+ owningEntityCounter++;
- public OwningEntity buildOwningEntity() {
- owningEntityCounter++;
+ OwningEntity owningEntity = new OwningEntity();
+ owningEntity.setOwningEntityId("testOwningEntityId" + owningEntityCounter);
+ owningEntity.setOwningEntityName("testOwningEntityName" + owningEntityCounter);
- OwningEntity owningEntity = new OwningEntity();
- owningEntity.setOwningEntityId("testOwningEntityId" + owningEntityCounter);
- owningEntity.setOwningEntityName("testOwningEntityName" + owningEntityCounter);
+ return owningEntity;
+ }
- return owningEntity;
- }
+ public Project buildProject() {
+ projectCounter++;
- public Project buildProject() {
- projectCounter++;
+ Project project = new Project();
+ project.setProjectName("testProjectName1 , testProjectName2 , testProjectName3" + projectCounter);
- Project project = new Project();
- project.setProjectName("testProjectName1 , testProjectName2 , testProjectName3" + projectCounter);
+ return project;
+ }
- return project;
- }
+ public ServiceSubscription buildServiceSubscription() {
+ serviceSubscriptionCounter++;
- public ServiceSubscription buildServiceSubscription() {
- serviceSubscriptionCounter++;
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setTempUbSubAccountId("testTempUbSubAccountId" + serviceSubscriptionCounter);
+ serviceSubscription.setServiceType("testServiceType" + serviceSubscriptionCounter);
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setTempUbSubAccountId("testTempUbSubAccountId" + serviceSubscriptionCounter);
- serviceSubscription.setServiceType("testServiceType" + serviceSubscriptionCounter);
+ return serviceSubscription;
+ }
- return serviceSubscription;
- }
+ public Customer buildCustomer() {
+ customerCounter++;
- public Customer buildCustomer() {
- customerCounter++;
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("testGlobalCustomerId" + customerCounter);
+ customer.setSubscriberType("testSubscriberType" + customerCounter);
- Customer customer = new Customer();
- customer.setGlobalCustomerId("testGlobalCustomerId" + customerCounter);
- customer.setSubscriberType("testSubscriberType" + customerCounter);
+ customer.setServiceSubscription(buildServiceSubscription());
- customer.setServiceSubscription(buildServiceSubscription());
+ return customer;
+ }
- return customer;
- }
+ public ServiceInstance buildServiceInstance() {
+ serviceInstanceCounter++;
- public ServiceInstance buildServiceInstance() {
- serviceInstanceCounter++;
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("testServiceInstanceId" + serviceInstanceCounter);
+ serviceInstance.setServiceInstanceName("testServiceInstanceName" + serviceInstanceCounter);
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("testServiceInstanceId" + serviceInstanceCounter);
- serviceInstance.setServiceInstanceName("testServiceInstanceName" + serviceInstanceCounter);
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("testModelInvariantUUID" + serviceInstanceCounter);
+ modelInfoServiceInstance.setModelUuid("testModelUUID" + serviceInstanceCounter);
+ modelInfoServiceInstance.setModelVersion("testModelVersion" + serviceInstanceCounter);
+ modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter);
+ modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter);
+ modelInfoServiceInstance.setServiceRole("testServiceRole" + serviceInstanceCounter);
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("testModelInvariantUUID" + serviceInstanceCounter);
- modelInfoServiceInstance.setModelUuid("testModelUUID" + serviceInstanceCounter);
- modelInfoServiceInstance.setModelVersion("testModelVersion" + serviceInstanceCounter);
- modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter);
- modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter);
- modelInfoServiceInstance.setServiceRole("testServiceRole" + serviceInstanceCounter);
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ serviceInstance.setProject(buildProject());
- serviceInstance.setProject(buildProject());
+ serviceInstance.setOwningEntity(buildOwningEntity());
- serviceInstance.setOwningEntity(buildOwningEntity());
+ serviceInstance.setCollection(buildCollection());
- serviceInstance.setCollection(buildCollection());
+ serviceInstance.getConfigurations().add(buildConfiguration());
- serviceInstance.getConfigurations().add(buildConfiguration());
+ return serviceInstance;
+ }
- return serviceInstance;
- }
+ public ServiceInstance setServiceInstance() {
+ ServiceInstance serviceInstance = buildServiceInstance();
- public ServiceInstance setServiceInstance() {
- ServiceInstance serviceInstance = buildServiceInstance();
+ if (gBBInput.getCustomer() == null) {
+ gBBInput.setCustomer(buildCustomer());
+ }
+ gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance);
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
- if(gBBInput.getCustomer() == null) {
- gBBInput.setCustomer(buildCustomer());
- }
- gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance);
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
+ return serviceInstance;
+ }
- return serviceInstance;
- }
+ public Customer setCustomer() {
+ if (gBBInput.getCustomer() != null)
+ return gBBInput.getCustomer();
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("testGlobalCustomerId");
+ customer.setSubscriberType("testSubscriberType");
- public Customer setCustomer() {
- if(gBBInput.getCustomer() != null) return gBBInput.getCustomer();
- Customer customer = new Customer();
- customer.setGlobalCustomerId("testGlobalCustomerId");
- customer.setSubscriberType("testSubscriberType");
+ customer.setServiceSubscription(buildServiceSubscription());
- customer.setServiceSubscription(buildServiceSubscription());
+ gBBInput.setCustomer(customer);
- gBBInput.setCustomer(customer);
+ return customer;
+ }
- return customer;
- }
+ public Collection setCollection() {
+ Collection collection = new Collection();
+ collection.setId("testId");
- public Collection setCollection() {
- Collection collection = new Collection();
- collection.setId("testId");
+ ServiceInstance serviceInstance = null;
- ServiceInstance serviceInstance = null;
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ serviceInstance.setCollection(collection);
- serviceInstance.setCollection(collection);
+ return collection;
+ }
- return collection;
- }
+ public InstanceGroup setInstanceGroup() {
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroup.setId("testId");
+ instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction");
- public InstanceGroup setInstanceGroup() {
- InstanceGroup instanceGroup = new InstanceGroup();
- instanceGroup.setId("testId");
- instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction");
+ Collection collection = null;
- Collection collection = null;
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ collection = serviceInstance.getCollection();
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- collection = serviceInstance.getCollection();
+ if (collection == null) {
+ collection = setCollection();
+ }
+ } catch (BBObjectNotFoundException e) {
+ collection = setCollection();
+ }
- if (collection == null) {
- collection = setCollection();
- }
- } catch(BBObjectNotFoundException e) {
- collection = setCollection();
- }
+ collection.setInstanceGroup(instanceGroup);
- collection.setInstanceGroup(instanceGroup);
-
- return instanceGroup;
- }
+ return instanceGroup;
+ }
- public InstanceGroup setInstanceGroupVnf() {
- InstanceGroup instanceGroup = buildInstanceGroup();
+ public InstanceGroup setInstanceGroupVnf() {
+ InstanceGroup instanceGroup = buildInstanceGroup();
- ServiceInstance serviceInstance = null;
+ ServiceInstance serviceInstance = null;
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- serviceInstance.getInstanceGroups().add(instanceGroup);
- lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroup.getId());
+ serviceInstance.getInstanceGroups().add(instanceGroup);
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroup.getId());
- return instanceGroup;
- }
+ return instanceGroup;
+ }
- public VpnBinding buildVpnBinding() {
- vpnBindingCounter++;
+ public VpnBinding buildVpnBinding() {
+ vpnBindingCounter++;
- VpnBinding vpnBinding = new VpnBinding();
- vpnBinding.setVpnId("testVpnId" + vpnBindingCounter);
- vpnBinding.setVpnName("testVpnName" + vpnBindingCounter);
- vpnBinding.setCustomerVpnId("testCustomerVpnId" + vpnBindingCounter);
+ VpnBinding vpnBinding = new VpnBinding();
+ vpnBinding.setVpnId("testVpnId" + vpnBindingCounter);
+ vpnBinding.setVpnName("testVpnName" + vpnBindingCounter);
+ vpnBinding.setCustomerVpnId("testCustomerVpnId" + vpnBindingCounter);
- return vpnBinding;
- }
+ return vpnBinding;
+ }
- public VpnBinding setVpnBinding() {
- VpnBinding vpnBinding = buildVpnBinding();
+ public VpnBinding setVpnBinding() {
+ VpnBinding vpnBinding = buildVpnBinding();
- Customer customer = gBBInput.getCustomer();
+ Customer customer = gBBInput.getCustomer();
- if(customer == null){
- customer = buildCustomer();
- }
+ if (customer == null) {
+ customer = buildCustomer();
+ }
- customer.getVpnBindings().add(vpnBinding);
- lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
+ customer.getVpnBindings().add(vpnBinding);
+ lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
- return vpnBinding;
- }
+ return vpnBinding;
+ }
- public InstanceGroup buildInstanceGroup() {
- instanceGroupCounter++;
+ public InstanceGroup buildInstanceGroup() {
+ instanceGroupCounter++;
- InstanceGroup instanceGroup = new InstanceGroup();
- instanceGroup.setId("testId" + instanceGroupCounter);
- instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction" + instanceGroupCounter);
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroup.setId("testId" + instanceGroupCounter);
+ instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction" + instanceGroupCounter);
- return instanceGroup;
- }
+ return instanceGroup;
+ }
- public L3Network buildL3Network() {
- l3NetworkCounter++;
+ public L3Network buildL3Network() {
+ l3NetworkCounter++;
- L3Network network = new L3Network();
- network.setNetworkId("testNetworkId" + l3NetworkCounter);
- network.setNetworkName("testNetworkName" + l3NetworkCounter);
- network.setNetworkType("testNetworkType" + l3NetworkCounter);
+ L3Network network = new L3Network();
+ network.setNetworkId("testNetworkId" + l3NetworkCounter);
+ network.setNetworkName("testNetworkName" + l3NetworkCounter);
+ network.setNetworkType("testNetworkType" + l3NetworkCounter);
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter);
- modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter);
- modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter);
- modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter);
- network.setModelInfoNetwork(modelInfoNetwork);
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter);
+ modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter);
+ modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter);
+ modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter);
+ network.setModelInfoNetwork(modelInfoNetwork);
- return network;
- }
+ return network;
+ }
- public L3Network setL3Network() {
- L3Network network = buildL3Network();
+ public L3Network setL3Network() {
+ L3Network network = buildL3Network();
- ServiceInstance serviceInstance = null;
+ ServiceInstance serviceInstance = null;
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- serviceInstance.getNetworks().add(network);
- lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
+ serviceInstance.getNetworks().add(network);
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
- return network;
- }
+ return network;
+ }
- public GenericVnf buildGenericVnf() {
- genericVnfCounter++;
+ public GenericVnf buildGenericVnf() {
+ genericVnfCounter++;
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("testVnfId" + genericVnfCounter);
- genericVnf.setVnfName("testVnfName" + genericVnfCounter);
- genericVnf.setVnfType("testVnfType" + genericVnfCounter);
- genericVnf.setIpv4OamAddress("10.222.22.2");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("testVnfId" + genericVnfCounter);
+ genericVnf.setVnfName("testVnfName" + genericVnfCounter);
+ genericVnf.setVnfType("testVnfType" + genericVnfCounter);
+ genericVnf.setIpv4OamAddress("10.222.22.2");
- Platform platform = new Platform();
- platform.setPlatformName(" testPlatformName, testPlatformName2 , testPlatformName3 , testPlatformName4");
- genericVnf.setPlatform(platform);
+ Platform platform = new Platform();
+ platform.setPlatformName(" testPlatformName, testPlatformName2 , testPlatformName3 , testPlatformName4");
+ genericVnf.setPlatform(platform);
- LineOfBusiness lob = new LineOfBusiness();
- lob.setLineOfBusinessName(" testLineOfBusinessName , testLineOfBusinessName2, testLineOfBusinessName3, testLineOfBusinessName4");
- genericVnf.setLineOfBusiness(lob);
+ LineOfBusiness lob = new LineOfBusiness();
+ lob.setLineOfBusinessName(
+ " testLineOfBusinessName , testLineOfBusinessName2, testLineOfBusinessName3, testLineOfBusinessName4");
+ genericVnf.setLineOfBusiness(lob);
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter);
- modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter);
- modelInfoGenericVnf.setModelInvariantUuid("testModelInvariantUUID" + genericVnfCounter);
- modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter);
- modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter);
- modelInfoGenericVnf.setModelInstanceName("testInstanceName" + genericVnfCounter);
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter);
+ modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter);
+ modelInfoGenericVnf.setModelInvariantUuid("testModelInvariantUUID" + genericVnfCounter);
+ modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter);
+ modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter);
+ modelInfoGenericVnf.setModelInstanceName("testInstanceName" + genericVnfCounter);
- genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+ genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
- License license = new License();
- List<String> array = new ArrayList<String>();
- array.add("testPoolUuid");
- license.setEntitlementPoolUuids(array);
- genericVnf.setLicense(license);
+ License license = new License();
+ List<String> array = new ArrayList<String>();
+ array.add("testPoolUuid");
+ license.setEntitlementPoolUuids(array);
+ genericVnf.setLicense(license);
- return genericVnf;
- }
+ return genericVnf;
+ }
- public GenericVnf setGenericVnf() {
- GenericVnf genericVnf = buildGenericVnf();
+ public GenericVnf setGenericVnf() {
+ GenericVnf genericVnf = buildGenericVnf();
- ServiceInstance serviceInstance = null;
+ ServiceInstance serviceInstance = null;
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- serviceInstance.getVnfs().add(genericVnf);
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId());
+ serviceInstance.getVnfs().add(genericVnf);
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId());
- return genericVnf;
- }
+ return genericVnf;
+ }
- public VfModule buildVfModule() {
- vfModuleCounter++;
+ public VfModule buildVfModule() {
+ vfModuleCounter++;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter);
- vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter);
- vfModule.setModuleIndex(0);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter);
- modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter);
- modelInfoVfModule.setModelUUID("testModelUUID" + vfModuleCounter);
- modelInfoVfModule.setModelName("testModelName" + vfModuleCounter);
- modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter);
- vfModule.setModelInfoVfModule(modelInfoVfModule);
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter);
+ vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter);
+ vfModule.setModuleIndex(0);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter);
+ modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter);
+ modelInfoVfModule.setModelUUID("testModelUUID" + vfModuleCounter);
+ modelInfoVfModule.setModelName("testModelName" + vfModuleCounter);
+ modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter);
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
- return vfModule;
- }
+ return vfModule;
+ }
- public VfModule setVfModule() {
- return setVfModule(true);
- }
-
- public VfModule setVfModule(boolean addToGenericVnf) {
- VfModule vfModule = buildVfModule();
+ public VfModule setVfModule() {
+ return setVfModule(true);
+ }
- GenericVnf genericVnf = null;
+ public VfModule setVfModule(boolean addToGenericVnf) {
+ VfModule vfModule = buildVfModule();
- try {
- genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- } catch(BBObjectNotFoundException e) {
- genericVnf = setGenericVnf();
- }
+ GenericVnf genericVnf = null;
- if (addToGenericVnf) {
- genericVnf.getVfModules().add(vfModule);
- }
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId());
+ try {
+ genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ } catch (BBObjectNotFoundException e) {
+ genericVnf = setGenericVnf();
+ }
- return vfModule;
- }
+ if (addToGenericVnf) {
+ genericVnf.getVfModules().add(vfModule);
+ }
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId());
- public VolumeGroup buildVolumeGroup() {
- volumeGroupCounter++;
+ return vfModule;
+ }
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("testVolumeGroupId" + volumeGroupCounter);
- volumeGroup.setVolumeGroupName("testVolumeGroupName" + volumeGroupCounter);
- volumeGroup.setHeatStackId("testHeatStackId" + volumeGroupCounter);
+ public VolumeGroup buildVolumeGroup() {
+ volumeGroupCounter++;
- return volumeGroup;
- }
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("testVolumeGroupId" + volumeGroupCounter);
+ volumeGroup.setVolumeGroupName("testVolumeGroupName" + volumeGroupCounter);
+ volumeGroup.setHeatStackId("testHeatStackId" + volumeGroupCounter);
- public VolumeGroup setVolumeGroup() {
- VolumeGroup volumeGroup = buildVolumeGroup();
+ return volumeGroup;
+ }
- GenericVnf genericVnf = null;
+ public VolumeGroup setVolumeGroup() {
+ VolumeGroup volumeGroup = buildVolumeGroup();
- try {
- genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- } catch(BBObjectNotFoundException e) {
- genericVnf = setGenericVnf();
- }
+ GenericVnf genericVnf = null;
- genericVnf.getVolumeGroups().add(volumeGroup);
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId());
+ try {
+ genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ } catch (BBObjectNotFoundException e) {
+ genericVnf = setGenericVnf();
+ }
- return volumeGroup;
- }
+ genericVnf.getVolumeGroups().add(volumeGroup);
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId());
- public Pnf buildPnf() {
- pnfCounter++;
+ return volumeGroup;
+ }
- Pnf pnf = new Pnf();
- pnf.setPnfId("testPnfId" + pnfCounter);
- pnf.setPnfName("testPnfName" + pnfCounter);
+ public Pnf buildPnf() {
+ pnfCounter++;
- return pnf;
- }
+ Pnf pnf = new Pnf();
+ pnf.setPnfId("testPnfId" + pnfCounter);
+ pnf.setPnfName("testPnfName" + pnfCounter);
- public ServiceProxy buildServiceProxy() {
- serviceProxyCounter++;
+ return pnf;
+ }
+
+ public ServiceProxy buildServiceProxy() {
+ serviceProxyCounter++;
ServiceProxy serviceProxy = new ServiceProxy();
serviceProxy.setServiceInstance(buildServiceInstance());
@@ -623,115 +624,115 @@ public class TestDataSetup{
serviceProxy.getServiceInstance().getPnfs().add(secondaryPnf);
return serviceProxy;
- }
+ }
- public VpnBondingLink buildVpnBondingLink() {
- vpnBondingLinkCounter++;
+ public VpnBondingLink buildVpnBondingLink() {
+ vpnBondingLinkCounter++;
- VpnBondingLink vpnBondingLink = new VpnBondingLink();
- vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter);
+ VpnBondingLink vpnBondingLink = new VpnBondingLink();
+ vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter);
- Configuration vnrConfiguration = buildConfiguration();
- vnrConfiguration.setNetwork(buildL3Network());
- vpnBondingLink.setVnrConfiguration(vnrConfiguration);
+ Configuration vnrConfiguration = buildConfiguration();
+ vnrConfiguration.setNetwork(buildL3Network());
+ vpnBondingLink.setVnrConfiguration(vnrConfiguration);
- vpnBondingLink.setVrfConfiguration(buildConfiguration());
+ vpnBondingLink.setVrfConfiguration(buildConfiguration());
vpnBondingLink.setInfrastructureServiceProxy(buildServiceProxy());
vpnBondingLink.setTransportServiceProxy(buildServiceProxy());
- return vpnBondingLink;
- }
-
- public VpnBondingLink setVpnBondingLink() {
- VpnBondingLink vpnBondingLink = buildVpnBondingLink();
-
- ServiceInstance serviceInstance = null;
+ return vpnBondingLink;
+ }
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ public VpnBondingLink setVpnBondingLink() {
+ VpnBondingLink vpnBondingLink = buildVpnBondingLink();
- serviceInstance.getVpnBondingLinks().add(vpnBondingLink);
- lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId());
+ ServiceInstance serviceInstance = null;
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- return vpnBondingLink;
- }
+ serviceInstance.getVpnBondingLinks().add(vpnBondingLink);
+ lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId());
- public Customer setAvpnCustomer() {
- Customer customer = buildCustomer();
- gBBInput.setCustomer(customer);
+ return vpnBondingLink;
+ }
- return customer;
- }
+ public Customer setAvpnCustomer() {
+ Customer customer = buildCustomer();
- public ServiceProxy setServiceProxy(String uniqueIdentifier, String type) {
- ServiceProxy serviceProxy = new ServiceProxy();
- serviceProxy.setId("testProxyId" + uniqueIdentifier);
- serviceProxy.setType(type);
+ gBBInput.setCustomer(customer);
- ModelInfoServiceProxy modelInfo = new ModelInfoServiceProxy();
- modelInfo.setModelInvariantUuid("testProxyModelInvariantUuid" + uniqueIdentifier);
- modelInfo.setModelName("testProxyModelName" + uniqueIdentifier);
- modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier);
- modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier);
- modelInfo.setModelInstanceName("testProxyInstanceName" + uniqueIdentifier);
+ return customer;
+ }
- serviceProxy.setModelInfoServiceProxy(modelInfo);
-
- return serviceProxy;
- }
-
- public AllottedResource setAllottedResource(String uniqueIdentifier) {
- AllottedResource ar = new AllottedResource();
- ar.setId("testAllottedResourceId" + uniqueIdentifier);
-
- ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource();
- modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier);
- modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier);
- modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
- modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
- modelInfo.setModelInstanceName("testAllottedModelInstanceName" + uniqueIdentifier);
-
- ar.setModelInfoAllottedResource(modelInfo);
+ public ServiceProxy setServiceProxy(String uniqueIdentifier, String type) {
+ ServiceProxy serviceProxy = new ServiceProxy();
+ serviceProxy.setId("testProxyId" + uniqueIdentifier);
+ serviceProxy.setType(type);
- return ar;
- }
+ ModelInfoServiceProxy modelInfo = new ModelInfoServiceProxy();
+ modelInfo.setModelInvariantUuid("testProxyModelInvariantUuid" + uniqueIdentifier);
+ modelInfo.setModelName("testProxyModelName" + uniqueIdentifier);
+ modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier);
+ modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier);
+ modelInfo.setModelInstanceName("testProxyInstanceName" + uniqueIdentifier);
- public Configuration setConfiguration () {
- Configuration config = new Configuration();
- config.setConfigurationId("testConfigurationId");
- List<Configuration> configurations = new ArrayList<>();
- configurations.add(config);
- ServiceInstance serviceInstance = new ServiceInstance();
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "testConfigurationId");
- serviceInstance.setConfigurations(configurations);
- return config;
- }
+ serviceProxy.setModelInfoServiceProxy(modelInfo);
- public Subnet buildSubnet() {
+ return serviceProxy;
+ }
+
+ public AllottedResource setAllottedResource(String uniqueIdentifier) {
+ AllottedResource ar = new AllottedResource();
+ ar.setId("testAllottedResourceId" + uniqueIdentifier);
+
+ ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource();
+ modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier);
+ modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier);
+ modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
+ modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
+ modelInfo.setModelInstanceName("testAllottedModelInstanceName" + uniqueIdentifier);
+
+ ar.setModelInfoAllottedResource(modelInfo);
+
+ return ar;
+ }
+
+ public Configuration setConfiguration() {
+ Configuration config = new Configuration();
+ config.setConfigurationId("testConfigurationId");
+ List<Configuration> configurations = new ArrayList<>();
+ configurations.add(config);
+ ServiceInstance serviceInstance = new ServiceInstance();
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "testConfigurationId");
+ serviceInstance.setConfigurations(configurations);
+ return config;
+ }
+
+ public Subnet buildSubnet() {
Subnet subnet = new Subnet();
subnet.setSubnetId("testSubnetId");
subnet.setOrchestrationStatus(OrchestrationStatus.PENDING);
subnet.setNeutronSubnetId("testNeutronSubnetId");
- return subnet;
- }
-
- public NetworkPolicy buildNetworkPolicy() {
- NetworkPolicy networkPolicy = new NetworkPolicy();
- networkPolicy.setNetworkPolicyId("testNetworkPolicyId");
- networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn");
- networkPolicy.setHeatStackId("testHeatStackId");
- return networkPolicy;
- }
+ return subnet;
+ }
+
+ public NetworkPolicy buildNetworkPolicy() {
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ networkPolicy.setNetworkPolicyId("testNetworkPolicyId");
+ networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn");
+ networkPolicy.setHeatStackId("testHeatStackId");
+ return networkPolicy;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
index 5c1caccc2d..b054cc17bb 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
@@ -30,12 +30,10 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.TreeSet;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Rule;
@@ -67,589 +65,631 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
-public class AAICreateTasksTest extends BaseTaskTest{
-
- @InjectMocks
- private AAICreateTasks aaiCreateTasks = new AAICreateTasks();
-
-
- private ServiceInstance serviceInstance;
- private L3Network network;
- private GenericVnf genericVnf;
- private VolumeGroup volumeGroup;
- private CloudRegion cloudRegion;
- private VfModule vfModule;
- private Customer customer;
- private Configuration configuration;
- private InstanceGroup instanceGroup;
-
- @Captor
- ArgumentCaptor<NetworkPolicy> networkPolicyCaptor;
-
- @Rule
- public final ExpectedException exception = ExpectedException.none();
-
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- network = setL3Network();
- genericVnf = setGenericVnf();
- volumeGroup = setVolumeGroup();
- cloudRegion = setCloudRegion();
- vfModule = setVfModule();
- configuration = setConfiguration();
- instanceGroup = setInstanceGroupVnf();
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID))).thenReturn(configuration);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID))).thenReturn(instanceGroup);
-
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
-
- }
-
- @Test
- public void createServiceInstanceTest() throws Exception {
- doNothing().when(aaiServiceInstanceResources).createServiceInstance(serviceInstance, customer);
- aaiCreateTasks.createServiceInstance(execution);
- verify(aaiServiceInstanceResources, times(1)).createServiceInstance(serviceInstance, customer);
- }
-
- @Test
- public void createServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "notfound");
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).createServiceInstance(serviceInstance, customer);
- aaiCreateTasks.createServiceInstance(execution);
- }
-
- @Test
- public void createVolumeGroupTest() throws Exception {
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
- doNothing().when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion);
- doNothing().when(aaiVolumeGroupResources).connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
-
- aaiCreateTasks.createVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).createVolumeGroup(volumeGroup, cloudRegion);
- verify(aaiVolumeGroupResources, times(1)).connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
- verify(aaiVolumeGroupResources, times(1)).connectVolumeGroupToTenant(volumeGroup, cloudRegion);
- }
-
- @Test
- public void createVolumeGroupExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
- doThrow(RuntimeException.class).when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion);
-
- aaiCreateTasks.createVolumeGroup(execution);
- }
-
- @Test
- public void createProjectTest() throws Exception {
- doNothing().when(aaiServiceInstanceResources).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- aaiCreateTasks.createProject(execution);
- verify(aaiServiceInstanceResources, times(1)).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- }
-
- @Test
- public void createPlatformTest() throws Exception {
- doNothing().when(aaiVnfResources).createPlatformandConnectVnf(genericVnf.getPlatform(), genericVnf);
- aaiCreateTasks.createPlatform(execution);
- ArgumentCaptor<Platform> platformCaptor = ArgumentCaptor.forClass(Platform.class);
- ArgumentCaptor<GenericVnf> genericVnf = ArgumentCaptor.forClass(GenericVnf.class);
- Mockito.verify(aaiVnfResources,times(4)).createPlatformandConnectVnf(platformCaptor.capture(),genericVnf.capture());
-
- List<Platform> capturedPlatforms = platformCaptor.getAllValues();
- assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName".equals(item.getPlatformName())));
- assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName2".equals(item.getPlatformName())));
- assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName3".equals(item.getPlatformName())));
- assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName4".equals(item.getPlatformName())));
- }
-
- @Test
- public void createLineOfBusinessTest() throws Exception {
- doNothing().when(aaiVnfResources).createLineOfBusinessandConnectVnf(genericVnf.getLineOfBusiness(), genericVnf);
- aaiCreateTasks.createLineOfBusiness(execution);
-
- ArgumentCaptor<LineOfBusiness> lobCaptor = ArgumentCaptor.forClass(LineOfBusiness.class);
- ArgumentCaptor<GenericVnf> genericVnf = ArgumentCaptor.forClass(GenericVnf.class);
- Mockito.verify(aaiVnfResources,times(4)).createLineOfBusinessandConnectVnf(lobCaptor.capture(),genericVnf.capture());
-
- List<LineOfBusiness> capturedLOB = lobCaptor.getAllValues();
- assertTrue(capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName".equals(item.getLineOfBusinessName())));
- assertTrue(capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName2".equals(item.getLineOfBusinessName())));
- assertTrue(capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName3".equals(item.getLineOfBusinessName())));
- assertTrue(capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName4".equals(item.getLineOfBusinessName())));
-
- }
-
- @Test
- public void splitCDL_Test() throws Exception {
- List<String> strings = aaiCreateTasks.splitCDL("Test");
- assertEquals(strings.get(0),"Test");
-
- List<String> strings2 = aaiCreateTasks.splitCDL("");
- assertEquals(strings2.get(0),"");
- }
-
- @Test
- public void createProjectExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "notfound");
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- aaiCreateTasks.createProject(execution);
- }
-
- @Test
- public void createProjectNullProjectNameTest() throws Exception {
- serviceInstance.getProject().setProjectName(null);
- doNothing().when(aaiServiceInstanceResources).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- aaiCreateTasks.createProject(execution);
- verify(aaiServiceInstanceResources, times(0)).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- }
-
- @Test
- public void createProjectEmptyProjectNameTest() throws Exception {
- serviceInstance.getProject().setProjectName("");
- doNothing().when(aaiServiceInstanceResources).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- aaiCreateTasks.createProject(execution);
- verify(aaiServiceInstanceResources, times(0)).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
- }
-
- @Test
- public void createOwningEntityTest() throws Exception {
- doReturn(true).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
- doNothing().when(aaiServiceInstanceResources).connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(),serviceInstance);
- aaiCreateTasks.createOwningEntity(execution);
- verify(aaiServiceInstanceResources, times(1)).existsOwningEntity(serviceInstance.getOwningEntity());
- verify(aaiServiceInstanceResources, times(1)).connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
- }
-
- @Test
- public void createOwningEntityNotExistsOwningEntityTest() throws Exception {
- doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
- doNothing().when(aaiServiceInstanceResources).createOwningEntityandConnectServiceInstance(serviceInstance.getOwningEntity(),serviceInstance);
- aaiCreateTasks.createOwningEntity(execution);
- verify(aaiServiceInstanceResources, times(1)).existsOwningEntity(serviceInstance.getOwningEntity());
- verify(aaiServiceInstanceResources, times(1)).createOwningEntityandConnectServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
- }
-
- @Test
- public void createOwningEntityNullOwningEntityIdTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- serviceInstance.getOwningEntity().setOwningEntityId(null);
-
- aaiCreateTasks.createOwningEntity(execution);
- }
-
- @Test
- public void createOwningEntityEmptyOwningEntityIdTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- serviceInstance.getOwningEntity().setOwningEntityId("");
-
- aaiCreateTasks.createOwningEntity(execution);
- }
-
- @Test
- public void createOwningEntityNullOwningEntityNameTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- serviceInstance.getOwningEntity().setOwningEntityName(null);
-
- doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
-
- aaiCreateTasks.createOwningEntity(execution);
- }
-
- @Test
- public void createOwningEntityEmptyOwningEntityNameTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- serviceInstance.getOwningEntity().setOwningEntityName("");
-
- doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
-
- aaiCreateTasks.createOwningEntity(execution);
- }
-
- @Test
- public void createOwningEntityExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doReturn(true).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
-
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
-
- aaiCreateTasks.createOwningEntity(execution);
- }
-
- @Test
- public void createVnfTest() throws Exception {
- doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
- aaiCreateTasks.createVnf(execution);
- verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
- }
-
- @Test
- public void createVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "notfound");
- doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
- doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
- aaiCreateTasks.createVnf(execution);
- verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
- }
-
-
- @Test
- public void createVfModuleTest() throws Exception {
-
- VfModule newVfModule = setVfModule(false);
- newVfModule.setModuleIndex(null);
- newVfModule.getModelInfoVfModule().setModelInvariantUUID("testModelInvariantUUID1");
- doNothing().when(aaiVfModuleResources).createVfModule(newVfModule, genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(newVfModule);
-
- assertEquals(null, newVfModule.getModuleIndex());
- aaiCreateTasks.createVfModule(execution);
- assertEquals(1, newVfModule.getModuleIndex().intValue());
- verify(aaiVfModuleResources, times(1)).createVfModule(newVfModule, genericVnf);
- }
-
- @Test
- public void createServiceSubscriptionTest(){
- doNothing().when(aaiServiceInstanceResources).createServiceSubscription(customer);
- aaiCreateTasks.createServiceSubscription(execution);
- verify(aaiServiceInstanceResources, times(1)).createServiceSubscription(customer);
- }
-
- @Test
- public void createServiceSubscriptionTestExceptionHandling(){
+public class AAICreateTasksTest extends BaseTaskTest {
+
+ @InjectMocks
+ private AAICreateTasks aaiCreateTasks = new AAICreateTasks();
+
+
+ private ServiceInstance serviceInstance;
+ private L3Network network;
+ private GenericVnf genericVnf;
+ private VolumeGroup volumeGroup;
+ private CloudRegion cloudRegion;
+ private VfModule vfModule;
+ private Customer customer;
+ private Configuration configuration;
+ private InstanceGroup instanceGroup;
+
+ @Captor
+ ArgumentCaptor<NetworkPolicy> networkPolicyCaptor;
+
+ @Rule
+ public final ExpectedException exception = ExpectedException.none();
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ network = setL3Network();
+ genericVnf = setGenericVnf();
+ volumeGroup = setVolumeGroup();
+ cloudRegion = setCloudRegion();
+ vfModule = setVfModule();
+ configuration = setConfiguration();
+ instanceGroup = setInstanceGroupVnf();
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID)))
+ .thenReturn(configuration);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
+ .thenReturn(instanceGroup);
+
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+
+ }
+
+ @Test
+ public void createServiceInstanceTest() throws Exception {
+ doNothing().when(aaiServiceInstanceResources).createServiceInstance(serviceInstance, customer);
+ aaiCreateTasks.createServiceInstance(execution);
+ verify(aaiServiceInstanceResources, times(1)).createServiceInstance(serviceInstance, customer);
+ }
+
+ @Test
+ public void createServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "notfound");
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).createServiceInstance(serviceInstance,
+ customer);
+ aaiCreateTasks.createServiceInstance(execution);
+ }
+
+ @Test
+ public void createVolumeGroupTest() throws Exception {
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+
+ doNothing().when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion);
+ doNothing().when(aaiVolumeGroupResources).connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
+
+ aaiCreateTasks.createVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).createVolumeGroup(volumeGroup, cloudRegion);
+ verify(aaiVolumeGroupResources, times(1)).connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
+ verify(aaiVolumeGroupResources, times(1)).connectVolumeGroupToTenant(volumeGroup, cloudRegion);
+ }
+
+ @Test
+ public void createVolumeGroupExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion);
+
+ aaiCreateTasks.createVolumeGroup(execution);
+ }
+
+ @Test
+ public void createProjectTest() throws Exception {
+ doNothing().when(aaiServiceInstanceResources)
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ aaiCreateTasks.createProject(execution);
+ verify(aaiServiceInstanceResources, times(1))
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ }
+
+ @Test
+ public void createPlatformTest() throws Exception {
+ doNothing().when(aaiVnfResources).createPlatformandConnectVnf(genericVnf.getPlatform(), genericVnf);
+ aaiCreateTasks.createPlatform(execution);
+ ArgumentCaptor<Platform> platformCaptor = ArgumentCaptor.forClass(Platform.class);
+ ArgumentCaptor<GenericVnf> genericVnf = ArgumentCaptor.forClass(GenericVnf.class);
+ Mockito.verify(aaiVnfResources, times(4)).createPlatformandConnectVnf(platformCaptor.capture(),
+ genericVnf.capture());
+
+ List<Platform> capturedPlatforms = platformCaptor.getAllValues();
+ assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName".equals(item.getPlatformName())));
+ assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName2".equals(item.getPlatformName())));
+ assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName3".equals(item.getPlatformName())));
+ assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName4".equals(item.getPlatformName())));
+ }
+
+ @Test
+ public void createLineOfBusinessTest() throws Exception {
+ doNothing().when(aaiVnfResources).createLineOfBusinessandConnectVnf(genericVnf.getLineOfBusiness(), genericVnf);
+ aaiCreateTasks.createLineOfBusiness(execution);
+
+ ArgumentCaptor<LineOfBusiness> lobCaptor = ArgumentCaptor.forClass(LineOfBusiness.class);
+ ArgumentCaptor<GenericVnf> genericVnf = ArgumentCaptor.forClass(GenericVnf.class);
+ Mockito.verify(aaiVnfResources, times(4)).createLineOfBusinessandConnectVnf(lobCaptor.capture(),
+ genericVnf.capture());
+
+ List<LineOfBusiness> capturedLOB = lobCaptor.getAllValues();
+ assertTrue(
+ capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName".equals(item.getLineOfBusinessName())));
+ assertTrue(
+ capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName2".equals(item.getLineOfBusinessName())));
+ assertTrue(
+ capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName3".equals(item.getLineOfBusinessName())));
+ assertTrue(
+ capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName4".equals(item.getLineOfBusinessName())));
+
+ }
+
+ @Test
+ public void splitCDL_Test() throws Exception {
+ List<String> strings = aaiCreateTasks.splitCDL("Test");
+ assertEquals(strings.get(0), "Test");
+
+ List<String> strings2 = aaiCreateTasks.splitCDL("");
+ assertEquals(strings2.get(0), "");
+ }
+
+ @Test
+ public void createProjectExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "notfound");
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources)
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ aaiCreateTasks.createProject(execution);
+ }
+
+ @Test
+ public void createProjectNullProjectNameTest() throws Exception {
+ serviceInstance.getProject().setProjectName(null);
+ doNothing().when(aaiServiceInstanceResources)
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ aaiCreateTasks.createProject(execution);
+ verify(aaiServiceInstanceResources, times(0))
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ }
+
+ @Test
+ public void createProjectEmptyProjectNameTest() throws Exception {
+ serviceInstance.getProject().setProjectName("");
+ doNothing().when(aaiServiceInstanceResources)
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ aaiCreateTasks.createProject(execution);
+ verify(aaiServiceInstanceResources, times(0))
+ .createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ }
+
+ @Test
+ public void createOwningEntityTest() throws Exception {
+ doReturn(true).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
+ doNothing().when(aaiServiceInstanceResources)
+ .connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
+ aaiCreateTasks.createOwningEntity(execution);
+ verify(aaiServiceInstanceResources, times(1)).existsOwningEntity(serviceInstance.getOwningEntity());
+ verify(aaiServiceInstanceResources, times(1))
+ .connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
+ }
+
+ @Test
+ public void createOwningEntityNotExistsOwningEntityTest() throws Exception {
+ doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
+ doNothing().when(aaiServiceInstanceResources)
+ .createOwningEntityandConnectServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
+ aaiCreateTasks.createOwningEntity(execution);
+ verify(aaiServiceInstanceResources, times(1)).existsOwningEntity(serviceInstance.getOwningEntity());
+ verify(aaiServiceInstanceResources, times(1))
+ .createOwningEntityandConnectServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
+ }
+
+ @Test
+ public void createOwningEntityNullOwningEntityIdTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ serviceInstance.getOwningEntity().setOwningEntityId(null);
+
+ aaiCreateTasks.createOwningEntity(execution);
+ }
+
+ @Test
+ public void createOwningEntityEmptyOwningEntityIdTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ serviceInstance.getOwningEntity().setOwningEntityId("");
+
+ aaiCreateTasks.createOwningEntity(execution);
+ }
+
+ @Test
+ public void createOwningEntityNullOwningEntityNameTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ serviceInstance.getOwningEntity().setOwningEntityName(null);
+
+ doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
+
+ aaiCreateTasks.createOwningEntity(execution);
+ }
+
+ @Test
+ public void createOwningEntityEmptyOwningEntityNameTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ serviceInstance.getOwningEntity().setOwningEntityName("");
+
+ doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
+
+ aaiCreateTasks.createOwningEntity(execution);
+ }
+
+ @Test
+ public void createOwningEntityExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doReturn(true).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
+
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources)
+ .connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
+
+ aaiCreateTasks.createOwningEntity(execution);
+ }
+
+ @Test
+ public void createVnfTest() throws Exception {
+ doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
+ aaiCreateTasks.createVnf(execution);
+ verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
+ }
+
+ @Test
+ public void createVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "notfound");
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
+ doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
+ aaiCreateTasks.createVnf(execution);
+ verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
+ }
+
+
+ @Test
+ public void createVfModuleTest() throws Exception {
+
+ VfModule newVfModule = setVfModule(false);
+ newVfModule.setModuleIndex(null);
+ newVfModule.getModelInfoVfModule().setModelInvariantUUID("testModelInvariantUUID1");
+ doNothing().when(aaiVfModuleResources).createVfModule(newVfModule, genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID)))
+ .thenReturn(newVfModule);
+
+ assertEquals(null, newVfModule.getModuleIndex());
+ aaiCreateTasks.createVfModule(execution);
+ assertEquals(1, newVfModule.getModuleIndex().intValue());
+ verify(aaiVfModuleResources, times(1)).createVfModule(newVfModule, genericVnf);
+ }
+
+ @Test
+ public void createServiceSubscriptionTest() {
+ doNothing().when(aaiServiceInstanceResources).createServiceSubscription(customer);
+ aaiCreateTasks.createServiceSubscription(execution);
+ verify(aaiServiceInstanceResources, times(1)).createServiceSubscription(customer);
+ }
+
+ @Test
+ public void createServiceSubscriptionTestExceptionHandling() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiServiceInstanceResources).createServiceSubscription(customer);
aaiCreateTasks.createServiceSubscription(execution);
}
@Test
- public void createServiceSubscriptionTestCustomerIsNull(){
+ public void createServiceSubscriptionTestCustomerIsNull() {
expectedException.expect(BpmnError.class);
gBBInput.setCustomer(null);
aaiCreateTasks.createServiceSubscription(execution);
}
- @Test
- public void createVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiVfModuleResources).createVfModule(vfModule, genericVnf);
- aaiCreateTasks.createVfModule(execution);
- }
-
- @Test
- public void connectVfModuleToVolumeGroupTest() throws Exception {
- doNothing().when(aaiVfModuleResources).connectVfModuleToVolumeGroup(genericVnf, vfModule, volumeGroup, cloudRegion);
- aaiCreateTasks.connectVfModuleToVolumeGroup(execution);
- verify(aaiVfModuleResources, times(1)).connectVfModuleToVolumeGroup(genericVnf, vfModule, volumeGroup, cloudRegion);
- }
-
- @Test
- public void createNetworkTest() throws Exception {
- network.getModelInfoNetwork().setNeutronNetworkType("PROVIDER");
-
- doNothing().when(aaiNetworkResources).createNetworkConnectToServiceInstance(network,serviceInstance);
- aaiCreateTasks.createNetwork(execution);
- verify(aaiNetworkResources, times(1)).createNetworkConnectToServiceInstance(network, serviceInstance);
- }
-
- @Test
- public void createNetworkExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "notfound");
- doThrow(RuntimeException.class).when(aaiNetworkResources).createNetworkConnectToServiceInstance(network,serviceInstance);
- aaiCreateTasks.createNetwork(execution);
- }
-
- @Test
- public void createCustomerTest() throws Exception {
- doNothing().when(aaiVpnBindingResources).createCustomer(customer);
-
- aaiCreateTasks.createCustomer(execution);
-
- verify(aaiVpnBindingResources, times(1)).createCustomer(customer);
- }
-
- @Test
- public void createCustomerExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiVpnBindingResources).createCustomer(customer);
-
- aaiCreateTasks.createCustomer(execution);
- }
-
- @Test
- public void createNetworkCollectionTest() throws Exception {
- doNothing().when(aaiNetworkResources).createNetworkCollection(serviceInstance.getCollection());
- execution.setVariable("networkCollectionName", "testNetworkCollectionName");
- aaiCreateTasks.createNetworkCollection(execution);
- verify(aaiNetworkResources, times(1)).createNetworkCollection(serviceInstance.getCollection());
- }
-
- @Test
- public void createNetworkCollectionInstanceGroupTest() throws Exception {
- doNothing().when(aaiNetworkResources).createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
- aaiCreateTasks.createNetworkCollectionInstanceGroup(execution);
- verify(aaiNetworkResources, times(1)).createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
- }
-
- @Test
- public void connectNetworkToNetworkCollectionServiceInstanceTest() throws Exception {
- doNothing().when(aaiNetworkResources).connectNetworkToNetworkCollectionServiceInstance(network, serviceInstance);
- aaiCreateTasks.connectNetworkToNetworkCollectionServiceInstance(execution);
- verify(aaiNetworkResources, times(1)).connectNetworkToNetworkCollectionServiceInstance(network, serviceInstance);
- }
-
- @Test
- public void connectNetworkToNetworkCollectionInstanceGroupTest() throws Exception {
- doNothing().when(aaiNetworkResources).connectNetworkToNetworkCollectionInstanceGroup(network, serviceInstance.getCollection().getInstanceGroup());
- aaiCreateTasks.connectNetworkToNetworkCollectionInstanceGroup(execution);
- verify(aaiNetworkResources, times(1)).connectNetworkToNetworkCollectionInstanceGroup(network, serviceInstance.getCollection().getInstanceGroup());
- }
-
- @Test
- public void connectNetworkToNullNetworkCollectionInstanceGroupTest() throws Exception {
- //reset test data to have no network collection instance group
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("testServiceInstanceId");
- L3Network network = new L3Network();
- network.setNetworkId("testNetworkId");
- serviceInstance.getNetworks().add(network);
- lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
- gBBInput.setServiceInstance(serviceInstance);
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(serviceInstance);
- //verify connection call was not executednetwork
- exception.expect(BpmnError.class);
- aaiCreateTasks.connectNetworkToNetworkCollectionInstanceGroup(execution);
- verify(aaiNetworkResources, never()).connectNetworkToNetworkCollectionInstanceGroup(network, null);
- }
-
- @Test
- public void connectNetworkToCloudRegionTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiNetworkResources).connectNetworkToCloudRegion(network, gBBInput.getCloudRegion());
- aaiCreateTasks.connectNetworkToCloudRegion(execution);
- verify(aaiNetworkResources, times(1)).connectNetworkToCloudRegion(network, gBBInput.getCloudRegion());
- }
-
- @Test
- public void connectNetworkToTenantTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiNetworkResources).connectNetworkToTenant(network, gBBInput.getCloudRegion());
- aaiCreateTasks.connectNetworkToTenant(execution);
- verify(aaiNetworkResources, times(1)).connectNetworkToTenant(network, gBBInput.getCloudRegion());
- }
-
- @Test
- public void createConfigurationTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiConfigurationResources).createConfiguration(configuration);
- aaiCreateTasks.createConfiguration(execution);
- verify(aaiConfigurationResources, times(1)).createConfiguration(configuration);
- }
-
- @Test
- public void connectVnfToCloudRegionTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
- aaiCreateTasks.connectVnfToCloudRegion(execution);
- verify(aaiVnfResources, times(1)).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
- }
-
- @Test
- public void connectNoneToVnfToCloudRegionTest() throws Exception {
- String[] arr = new String[1];
- arr[0] = "test25Region2";
- doReturn(arr).when(env).getProperty("mso.bpmn.cloudRegionIdsToSkipAddingVnfEdgesTo", String[].class);
- gBBInput = execution.getGeneralBuildingBlock();
- gBBInput.getCloudRegion().setLcpCloudRegionId("test25Region2");
- doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
- aaiCreateTasks.connectVnfToCloudRegion(execution);
- verify(aaiVnfResources, times(0)).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
- }
-
- @Test
- public void connectVnfTenantTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiVnfResources).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
- aaiCreateTasks.connectVnfToTenant(execution);
- verify(aaiVnfResources, times(1)).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
- }
-
- @Test
- public void createInstanceGroupVnfTest() throws Exception {
- doNothing().when(aaiInstanceGroupResources).createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
- aaiCreateTasks.createInstanceGroupVnf(execution);
- verify(aaiInstanceGroupResources, times(1)).createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
- }
-
- @Test
- public void createInstanceGroupVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiInstanceGroupResources).createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
- aaiCreateTasks.createInstanceGroupVnf(execution);
- }
-
- @Test
- public void createNetworkPolicyNeedToCreateAllTest() throws Exception {
- execution.setVariable("heatStackId", "testHeatStackId");
- execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,ED456");
- Optional<NetworkPolicy> networkPolicy = Optional.empty();
- doReturn(networkPolicy).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
- doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class));
- aaiCreateTasks.createNetworkPolicies(execution);
- verify(aaiNetworkResources, times(2)).createNetworkPolicy(networkPolicyCaptor.capture());
- assertEquals("ABC123", networkPolicyCaptor.getAllValues().get(0).getNetworkPolicyFqdn());
- assertEquals("ED456", networkPolicyCaptor.getAllValues().get(1).getNetworkPolicyFqdn());
- assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(0).getHeatStackId());
- assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(1).getHeatStackId());
- }
-
- @Test
- public void createNetworkPolicyNeedToCreateNoneTest() throws Exception {
- execution.setVariable("heatStackId", "testHeatStackId");
- execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
- NetworkPolicy networkPolicy = new NetworkPolicy();
- doReturn(Optional.of(networkPolicy)).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
- doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class));
- aaiCreateTasks.createNetworkPolicies(execution);
- verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class));
- }
-
- @Test
- public void createNetworkPolicyNoNetworkPoliciesTest() throws Exception {
- execution.setVariable("heatStackId", "testHeatStackId");
- aaiCreateTasks.createNetworkPolicies(execution);
- verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class));
- }
-
- @Test
- public void createVfModuleGetLowestIndexTest() throws Exception {
- GenericVnf vnf = new GenericVnf();
- ModelInfoGenericVnf vnfInfo = new ModelInfoGenericVnf();
- vnf.setModelInfoGenericVnf(vnfInfo);
- vnfInfo.setModelInvariantUuid("my-uuid");
-
- ModelInfoVfModule infoA = new ModelInfoVfModule();
- infoA.setIsBaseBoolean(false);
- infoA.setModelInvariantUUID("A");
-
- ModelInfoVfModule infoB = new ModelInfoVfModule();
- infoB.setIsBaseBoolean(false);
- infoB.setModelInvariantUUID("B");
-
- ModelInfoVfModule infoC = new ModelInfoVfModule();
- infoC.setIsBaseBoolean(false);
- infoC.setModelInvariantUUID("C");
-
- VfModule newVfModuleA = new VfModule();
- newVfModuleA.setVfModuleId("a");
- VfModule newVfModuleB = new VfModule();
- newVfModuleB.setVfModuleId("b");
- VfModule newVfModuleC = new VfModule();
- newVfModuleC.setVfModuleId("c");
-
- VfModule vfModule = new VfModule();
- vnf.getVfModules().add(vfModule);
- vfModule.setVfModuleId("1");
-
- VfModule vfModule2 = new VfModule();
- vnf.getVfModules().add(vfModule2);
- vfModule2.setVfModuleId("2");
-
- VfModule vfModule3 = new VfModule();
- vnf.getVfModules().add(vfModule3);
- vfModule3.setVfModuleId("3");
-
- VfModule vfModule4 = new VfModule();
- vnf.getVfModules().add(vfModule4);
- vfModule4.setVfModuleId("4");
-
- VfModule vfModule5 = new VfModule();
- vnf.getVfModules().add(vfModule5);
- vfModule5.setVfModuleId("5");
-
- //modules are included in the vnf already
- vnf.getVfModules().add(newVfModuleA);
- vnf.getVfModules().add(newVfModuleB);
- vnf.getVfModules().add(newVfModuleC);
-
- //A
- newVfModuleA.setModelInfoVfModule(infoA);
- vfModule.setModelInfoVfModule(infoA);
- vfModule2.setModelInfoVfModule(infoA);
- vfModule3.setModelInfoVfModule(infoA);
-
- //B
-
- newVfModuleB.setModelInfoVfModule(infoB);
- vfModule4.setModelInfoVfModule(infoB);
- vfModule5.setModelInfoVfModule(infoB);
-
- //C
- newVfModuleC.setModelInfoVfModule(infoC);
-
-
- //A
- vfModule.setModuleIndex(2);
- vfModule2.setModuleIndex(0);
- vfModule3.setModuleIndex(3);
-
- //B
- vfModule4.setModuleIndex(null);
- vfModule5.setModuleIndex(1);
-
- assertEquals(1, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleA));
-
- assertEquals(2, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleB));
-
- assertEquals(0, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleC));
-
- }
-
- @Test
- public void calculateUnusedIndexTest() {
-
- TreeSet<Integer> a = new TreeSet<>(Arrays.asList(0,1,3));
- TreeSet<Integer> b = new TreeSet<>(Arrays.asList(0,1,8));
- TreeSet<Integer> c = new TreeSet<>(Arrays.asList(0,2,4));
- assertEquals(2, aaiCreateTasks.calculateUnusedIndex(a, 0));
- assertEquals(5, aaiCreateTasks.calculateUnusedIndex(a, 2));
-
- assertEquals(4, aaiCreateTasks.calculateUnusedIndex(b, 2));
- assertEquals(3, aaiCreateTasks.calculateUnusedIndex(b, 1));
-
- assertEquals(5, aaiCreateTasks.calculateUnusedIndex(c, 2));
- assertEquals(9, aaiCreateTasks.calculateUnusedIndex(c, 6));
- assertEquals(1, aaiCreateTasks.calculateUnusedIndex(c, 0));
-
- }
+ @Test
+ public void createVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).createVfModule(vfModule, genericVnf);
+ aaiCreateTasks.createVfModule(execution);
+ }
+
+ @Test
+ public void connectVfModuleToVolumeGroupTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).connectVfModuleToVolumeGroup(genericVnf, vfModule, volumeGroup,
+ cloudRegion);
+ aaiCreateTasks.connectVfModuleToVolumeGroup(execution);
+ verify(aaiVfModuleResources, times(1)).connectVfModuleToVolumeGroup(genericVnf, vfModule, volumeGroup,
+ cloudRegion);
+ }
+
+ @Test
+ public void createNetworkTest() throws Exception {
+ network.getModelInfoNetwork().setNeutronNetworkType("PROVIDER");
+
+ doNothing().when(aaiNetworkResources).createNetworkConnectToServiceInstance(network, serviceInstance);
+ aaiCreateTasks.createNetwork(execution);
+ verify(aaiNetworkResources, times(1)).createNetworkConnectToServiceInstance(network, serviceInstance);
+ }
+
+ @Test
+ public void createNetworkExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "notfound");
+ doThrow(RuntimeException.class).when(aaiNetworkResources).createNetworkConnectToServiceInstance(network,
+ serviceInstance);
+ aaiCreateTasks.createNetwork(execution);
+ }
+
+ @Test
+ public void createCustomerTest() throws Exception {
+ doNothing().when(aaiVpnBindingResources).createCustomer(customer);
+
+ aaiCreateTasks.createCustomer(execution);
+
+ verify(aaiVpnBindingResources, times(1)).createCustomer(customer);
+ }
+
+ @Test
+ public void createCustomerExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiVpnBindingResources).createCustomer(customer);
+
+ aaiCreateTasks.createCustomer(execution);
+ }
+
+ @Test
+ public void createNetworkCollectionTest() throws Exception {
+ doNothing().when(aaiNetworkResources).createNetworkCollection(serviceInstance.getCollection());
+ execution.setVariable("networkCollectionName", "testNetworkCollectionName");
+ aaiCreateTasks.createNetworkCollection(execution);
+ verify(aaiNetworkResources, times(1)).createNetworkCollection(serviceInstance.getCollection());
+ }
+
+ @Test
+ public void createNetworkCollectionInstanceGroupTest() throws Exception {
+ doNothing().when(aaiNetworkResources)
+ .createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
+ aaiCreateTasks.createNetworkCollectionInstanceGroup(execution);
+ verify(aaiNetworkResources, times(1))
+ .createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
+ }
+
+ @Test
+ public void connectNetworkToNetworkCollectionServiceInstanceTest() throws Exception {
+ doNothing().when(aaiNetworkResources).connectNetworkToNetworkCollectionServiceInstance(network,
+ serviceInstance);
+ aaiCreateTasks.connectNetworkToNetworkCollectionServiceInstance(execution);
+ verify(aaiNetworkResources, times(1)).connectNetworkToNetworkCollectionServiceInstance(network,
+ serviceInstance);
+ }
+
+ @Test
+ public void connectNetworkToNetworkCollectionInstanceGroupTest() throws Exception {
+ doNothing().when(aaiNetworkResources).connectNetworkToNetworkCollectionInstanceGroup(network,
+ serviceInstance.getCollection().getInstanceGroup());
+ aaiCreateTasks.connectNetworkToNetworkCollectionInstanceGroup(execution);
+ verify(aaiNetworkResources, times(1)).connectNetworkToNetworkCollectionInstanceGroup(network,
+ serviceInstance.getCollection().getInstanceGroup());
+ }
+
+ @Test
+ public void connectNetworkToNullNetworkCollectionInstanceGroupTest() throws Exception {
+ // reset test data to have no network collection instance group
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("testServiceInstanceId");
+ L3Network network = new L3Network();
+ network.setNetworkId("testNetworkId");
+ serviceInstance.getNetworks().add(network);
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
+ gBBInput.setServiceInstance(serviceInstance);
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID)))
+ .thenReturn(serviceInstance);
+ // verify connection call was not executednetwork
+ exception.expect(BpmnError.class);
+ aaiCreateTasks.connectNetworkToNetworkCollectionInstanceGroup(execution);
+ verify(aaiNetworkResources, never()).connectNetworkToNetworkCollectionInstanceGroup(network, null);
+ }
+
+ @Test
+ public void connectNetworkToCloudRegionTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiNetworkResources).connectNetworkToCloudRegion(network, gBBInput.getCloudRegion());
+ aaiCreateTasks.connectNetworkToCloudRegion(execution);
+ verify(aaiNetworkResources, times(1)).connectNetworkToCloudRegion(network, gBBInput.getCloudRegion());
+ }
+
+ @Test
+ public void connectNetworkToTenantTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiNetworkResources).connectNetworkToTenant(network, gBBInput.getCloudRegion());
+ aaiCreateTasks.connectNetworkToTenant(execution);
+ verify(aaiNetworkResources, times(1)).connectNetworkToTenant(network, gBBInput.getCloudRegion());
+ }
+
+ @Test
+ public void createConfigurationTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiConfigurationResources).createConfiguration(configuration);
+ aaiCreateTasks.createConfiguration(execution);
+ verify(aaiConfigurationResources, times(1)).createConfiguration(configuration);
+ }
+
+ @Test
+ public void connectVnfToCloudRegionTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
+ aaiCreateTasks.connectVnfToCloudRegion(execution);
+ verify(aaiVnfResources, times(1)).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
+ }
+
+ @Test
+ public void connectNoneToVnfToCloudRegionTest() throws Exception {
+ String[] arr = new String[1];
+ arr[0] = "test25Region2";
+ doReturn(arr).when(env).getProperty("mso.bpmn.cloudRegionIdsToSkipAddingVnfEdgesTo", String[].class);
+ gBBInput = execution.getGeneralBuildingBlock();
+ gBBInput.getCloudRegion().setLcpCloudRegionId("test25Region2");
+ doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
+ aaiCreateTasks.connectVnfToCloudRegion(execution);
+ verify(aaiVnfResources, times(0)).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
+ }
+
+ @Test
+ public void connectVnfTenantTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiVnfResources).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
+ aaiCreateTasks.connectVnfToTenant(execution);
+ verify(aaiVnfResources, times(1)).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
+ }
+
+ @Test
+ public void createInstanceGroupVnfTest() throws Exception {
+ doNothing().when(aaiInstanceGroupResources).createInstanceGroupandConnectServiceInstance(instanceGroup,
+ serviceInstance);
+ aaiCreateTasks.createInstanceGroupVnf(execution);
+ verify(aaiInstanceGroupResources, times(1)).createInstanceGroupandConnectServiceInstance(instanceGroup,
+ serviceInstance);
+ }
+
+ @Test
+ public void createInstanceGroupVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiInstanceGroupResources)
+ .createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
+ aaiCreateTasks.createInstanceGroupVnf(execution);
+ }
+
+ @Test
+ public void createNetworkPolicyNeedToCreateAllTest() throws Exception {
+ execution.setVariable("heatStackId", "testHeatStackId");
+ execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,ED456");
+ Optional<NetworkPolicy> networkPolicy = Optional.empty();
+ doReturn(networkPolicy).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
+ doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class));
+ aaiCreateTasks.createNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(2)).createNetworkPolicy(networkPolicyCaptor.capture());
+ assertEquals("ABC123", networkPolicyCaptor.getAllValues().get(0).getNetworkPolicyFqdn());
+ assertEquals("ED456", networkPolicyCaptor.getAllValues().get(1).getNetworkPolicyFqdn());
+ assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(0).getHeatStackId());
+ assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(1).getHeatStackId());
+ }
+
+ @Test
+ public void createNetworkPolicyNeedToCreateNoneTest() throws Exception {
+ execution.setVariable("heatStackId", "testHeatStackId");
+ execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ doReturn(Optional.of(networkPolicy)).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
+ doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class));
+ aaiCreateTasks.createNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class));
+ }
+
+ @Test
+ public void createNetworkPolicyNoNetworkPoliciesTest() throws Exception {
+ execution.setVariable("heatStackId", "testHeatStackId");
+ aaiCreateTasks.createNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class));
+ }
+
+ @Test
+ public void createVfModuleGetLowestIndexTest() throws Exception {
+ GenericVnf vnf = new GenericVnf();
+ ModelInfoGenericVnf vnfInfo = new ModelInfoGenericVnf();
+ vnf.setModelInfoGenericVnf(vnfInfo);
+ vnfInfo.setModelInvariantUuid("my-uuid");
+
+ ModelInfoVfModule infoA = new ModelInfoVfModule();
+ infoA.setIsBaseBoolean(false);
+ infoA.setModelInvariantUUID("A");
+
+ ModelInfoVfModule infoB = new ModelInfoVfModule();
+ infoB.setIsBaseBoolean(false);
+ infoB.setModelInvariantUUID("B");
+
+ ModelInfoVfModule infoC = new ModelInfoVfModule();
+ infoC.setIsBaseBoolean(false);
+ infoC.setModelInvariantUUID("C");
+
+ VfModule newVfModuleA = new VfModule();
+ newVfModuleA.setVfModuleId("a");
+ VfModule newVfModuleB = new VfModule();
+ newVfModuleB.setVfModuleId("b");
+ VfModule newVfModuleC = new VfModule();
+ newVfModuleC.setVfModuleId("c");
+
+ VfModule vfModule = new VfModule();
+ vnf.getVfModules().add(vfModule);
+ vfModule.setVfModuleId("1");
+
+ VfModule vfModule2 = new VfModule();
+ vnf.getVfModules().add(vfModule2);
+ vfModule2.setVfModuleId("2");
+
+ VfModule vfModule3 = new VfModule();
+ vnf.getVfModules().add(vfModule3);
+ vfModule3.setVfModuleId("3");
+
+ VfModule vfModule4 = new VfModule();
+ vnf.getVfModules().add(vfModule4);
+ vfModule4.setVfModuleId("4");
+
+ VfModule vfModule5 = new VfModule();
+ vnf.getVfModules().add(vfModule5);
+ vfModule5.setVfModuleId("5");
+
+ // modules are included in the vnf already
+ vnf.getVfModules().add(newVfModuleA);
+ vnf.getVfModules().add(newVfModuleB);
+ vnf.getVfModules().add(newVfModuleC);
+
+ // A
+ newVfModuleA.setModelInfoVfModule(infoA);
+ vfModule.setModelInfoVfModule(infoA);
+ vfModule2.setModelInfoVfModule(infoA);
+ vfModule3.setModelInfoVfModule(infoA);
+
+ // B
+
+ newVfModuleB.setModelInfoVfModule(infoB);
+ vfModule4.setModelInfoVfModule(infoB);
+ vfModule5.setModelInfoVfModule(infoB);
+
+ // C
+ newVfModuleC.setModelInfoVfModule(infoC);
+
+
+ // A
+ vfModule.setModuleIndex(2);
+ vfModule2.setModuleIndex(0);
+ vfModule3.setModuleIndex(3);
+
+ // B
+ vfModule4.setModuleIndex(null);
+ vfModule5.setModuleIndex(1);
+
+ assertEquals(1, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleA));
+
+ assertEquals(2, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleB));
+
+ assertEquals(0, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleC));
+
+ }
+
+ @Test
+ public void calculateUnusedIndexTest() {
+
+ TreeSet<Integer> a = new TreeSet<>(Arrays.asList(0, 1, 3));
+ TreeSet<Integer> b = new TreeSet<>(Arrays.asList(0, 1, 8));
+ TreeSet<Integer> c = new TreeSet<>(Arrays.asList(0, 2, 4));
+ assertEquals(2, aaiCreateTasks.calculateUnusedIndex(a, 0));
+ assertEquals(5, aaiCreateTasks.calculateUnusedIndex(a, 2));
+
+ assertEquals(4, aaiCreateTasks.calculateUnusedIndex(b, 2));
+ assertEquals(3, aaiCreateTasks.calculateUnusedIndex(b, 1));
+
+ assertEquals(5, aaiCreateTasks.calculateUnusedIndex(c, 2));
+ assertEquals(9, aaiCreateTasks.calculateUnusedIndex(c, 6));
+ assertEquals(1, aaiCreateTasks.calculateUnusedIndex(c, 0));
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
index 826f888818..855d935ae1 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
@@ -29,11 +29,9 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Optional;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -60,180 +58,191 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
public class AAIDeleteTasksTest extends BaseTaskTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
-
- @InjectMocks
- private AAIDeleteTasks aaiDeleteTasks = new AAIDeleteTasks();
-
- private L3Network network;
- private ServiceInstance serviceInstance;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private VolumeGroup volumeGroup;
- private CloudRegion cloudRegion;
- private Configuration configuration;
- private InstanceGroup instanceGroup;
-
- @Captor
- ArgumentCaptor<String> stringCaptor;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- network = setL3Network();
- volumeGroup = setVolumeGroup();
- cloudRegion = setCloudRegion();
- configuration = setConfiguration();
- instanceGroup = setInstanceGroupVnf();
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID))).thenReturn(configuration);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID))).thenReturn(instanceGroup);
-
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- }
-
- @Test
- public void deleteVfModuleTest() throws Exception {
-
- doNothing().when(aaiVfModuleResources).deleteVfModule(vfModule, genericVnf);
-
- aaiDeleteTasks.deleteVfModule(execution);
- verify(aaiVfModuleResources, times(1)).deleteVfModule(vfModule, genericVnf);
- }
-
- @Test
- public void deleteVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVfModuleResources).deleteVfModule(vfModule, genericVnf);
- aaiDeleteTasks.deleteVfModule(execution);
- }
-
- @Test
- public void deleteServiceInstanceTest() throws Exception {
- doNothing().when(aaiServiceInstanceResources).deleteServiceInstance(serviceInstance);
-
- aaiDeleteTasks.deleteServiceInstance(execution);
-
- verify(aaiServiceInstanceResources, times(1)).deleteServiceInstance(serviceInstance);
- }
-
- @Test
- public void deleteServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).deleteServiceInstance(serviceInstance);
-
- aaiDeleteTasks.deleteServiceInstance(execution);
- }
-
- @Test
- public void deleteVnfTest() throws Exception {
- doNothing().when(aaiVnfResources).deleteVnf(genericVnf);
- aaiDeleteTasks.deleteVnf(execution);
- verify(aaiVnfResources, times(1)).deleteVnf(genericVnf);
- }
-
- @Test
- public void deleteVnfTestException() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVnfResources).deleteVnf(genericVnf);
-
- aaiDeleteTasks.deleteVnf(execution);
- verify(aaiVnfResources, times(1)).deleteVnf(genericVnf);
- }
-
- @Test
- public void deleteNetworkTest() throws Exception {
- doNothing().when(aaiNetworkResources).deleteNetwork(network);
- aaiDeleteTasks.deleteNetwork(execution);
- verify(aaiNetworkResources, times(1)).deleteNetwork(network);
- }
-
- @Test
- public void deleteCollectionTest() throws Exception {
- doNothing().when(aaiNetworkResources).deleteCollection(serviceInstance.getCollection());
- aaiDeleteTasks.deleteCollection(execution);
- verify(aaiNetworkResources, times(1)).deleteCollection(serviceInstance.getCollection());
- }
-
- @Test
- public void deleteInstanceGroupTest() throws Exception {
- doNothing().when(aaiNetworkResources).deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
- aaiDeleteTasks.deleteInstanceGroup(execution);
- verify(aaiNetworkResources, times(1)).deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
- }
-
- @Test
- public void deleteVolumeGroupTest() {
- doNothing().when(aaiVolumeGroupResources).deleteVolumeGroup(volumeGroup, cloudRegion);
-
- aaiDeleteTasks.deleteVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).deleteVolumeGroup(volumeGroup, cloudRegion);
- }
-
- @Test
- public void deleteVolumeGroupExceptionTest() {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiVolumeGroupResources).deleteVolumeGroup(volumeGroup, cloudRegion);
-
- aaiDeleteTasks.deleteVolumeGroup(execution);
- }
-
- @Test
- public void deleteConfigurationTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiConfigurationResources).deleteConfiguration(configuration);
- aaiDeleteTasks.deleteConfiguration(execution);
- verify(aaiConfigurationResources, times(1)).deleteConfiguration(configuration);
- }
-
- @Test
- public void deleteInstanceGroupVnfTest() throws Exception {
- doNothing().when(aaiInstanceGroupResources).deleteInstanceGroup(instanceGroup);
- aaiDeleteTasks.deleteInstanceGroupVnf(execution);
- verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(instanceGroup);
- }
-
- @Test
- public void deleteNetworkPolicyNeedToDeleteAllTest() throws Exception {
- execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,DEF456");
- final String content0 = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete0.json")));
- AAIResultWrapper aaiResultWrapper0 = new AAIResultWrapper(content0);
- NetworkPolicies networkPolicies0 = aaiResultWrapper0.asBean(NetworkPolicies.class).get();
- final String content1 = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete1.json")));
- AAIResultWrapper aaiResultWrapper1 = new AAIResultWrapper(content1);
- NetworkPolicies networkPolicies1 = aaiResultWrapper1.asBean(NetworkPolicies.class).get();
-
- doReturn(Optional.of(networkPolicies0),Optional.of(networkPolicies1)).when(aaiNetworkResources).getNetworkPolicies(any(AAIResourceUri.class));
- doNothing().when(aaiNetworkResources).deleteNetworkPolicy(any(String.class));
- aaiDeleteTasks.deleteNetworkPolicies(execution);
- verify(aaiNetworkResources, times(2)).deleteNetworkPolicy(stringCaptor.capture());
- assertEquals("testNetworkPolicyId0", stringCaptor.getAllValues().get(0));
- assertEquals("testNetworkPolicyId1", stringCaptor.getAllValues().get(1));
- }
-
- @Test
- public void deleteNetworkPolicyNeedToDeleteNoneTest() throws Exception {
- execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
- Optional<NetworkPolicies> networkPolicies = Optional.empty();
- doReturn(networkPolicies).when(aaiNetworkResources).getNetworkPolicies(any(AAIResourceUri.class));
- aaiDeleteTasks.deleteNetworkPolicies(execution);
- verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class));
- }
-
- @Test
- public void deleteNetworkPolicyNoNetworkPoliciesTest() throws Exception {
- aaiDeleteTasks.deleteNetworkPolicies(execution);
- verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class));
- }
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
+
+ @InjectMocks
+ private AAIDeleteTasks aaiDeleteTasks = new AAIDeleteTasks();
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private VolumeGroup volumeGroup;
+ private CloudRegion cloudRegion;
+ private Configuration configuration;
+ private InstanceGroup instanceGroup;
+
+ @Captor
+ ArgumentCaptor<String> stringCaptor;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ network = setL3Network();
+ volumeGroup = setVolumeGroup();
+ cloudRegion = setCloudRegion();
+ configuration = setConfiguration();
+ instanceGroup = setInstanceGroupVnf();
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID)))
+ .thenReturn(configuration);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
+ .thenReturn(instanceGroup);
+
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ }
+
+ @Test
+ public void deleteVfModuleTest() throws Exception {
+
+ doNothing().when(aaiVfModuleResources).deleteVfModule(vfModule, genericVnf);
+
+ aaiDeleteTasks.deleteVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).deleteVfModule(vfModule, genericVnf);
+ }
+
+ @Test
+ public void deleteVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).deleteVfModule(vfModule, genericVnf);
+ aaiDeleteTasks.deleteVfModule(execution);
+ }
+
+ @Test
+ public void deleteServiceInstanceTest() throws Exception {
+ doNothing().when(aaiServiceInstanceResources).deleteServiceInstance(serviceInstance);
+
+ aaiDeleteTasks.deleteServiceInstance(execution);
+
+ verify(aaiServiceInstanceResources, times(1)).deleteServiceInstance(serviceInstance);
+ }
+
+ @Test
+ public void deleteServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).deleteServiceInstance(serviceInstance);
+
+ aaiDeleteTasks.deleteServiceInstance(execution);
+ }
+
+ @Test
+ public void deleteVnfTest() throws Exception {
+ doNothing().when(aaiVnfResources).deleteVnf(genericVnf);
+ aaiDeleteTasks.deleteVnf(execution);
+ verify(aaiVnfResources, times(1)).deleteVnf(genericVnf);
+ }
+
+ @Test
+ public void deleteVnfTestException() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVnfResources).deleteVnf(genericVnf);
+
+ aaiDeleteTasks.deleteVnf(execution);
+ verify(aaiVnfResources, times(1)).deleteVnf(genericVnf);
+ }
+
+ @Test
+ public void deleteNetworkTest() throws Exception {
+ doNothing().when(aaiNetworkResources).deleteNetwork(network);
+ aaiDeleteTasks.deleteNetwork(execution);
+ verify(aaiNetworkResources, times(1)).deleteNetwork(network);
+ }
+
+ @Test
+ public void deleteCollectionTest() throws Exception {
+ doNothing().when(aaiNetworkResources).deleteCollection(serviceInstance.getCollection());
+ aaiDeleteTasks.deleteCollection(execution);
+ verify(aaiNetworkResources, times(1)).deleteCollection(serviceInstance.getCollection());
+ }
+
+ @Test
+ public void deleteInstanceGroupTest() throws Exception {
+ doNothing().when(aaiNetworkResources)
+ .deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
+ aaiDeleteTasks.deleteInstanceGroup(execution);
+ verify(aaiNetworkResources, times(1))
+ .deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
+ }
+
+ @Test
+ public void deleteVolumeGroupTest() {
+ doNothing().when(aaiVolumeGroupResources).deleteVolumeGroup(volumeGroup, cloudRegion);
+
+ aaiDeleteTasks.deleteVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).deleteVolumeGroup(volumeGroup, cloudRegion);
+ }
+
+ @Test
+ public void deleteVolumeGroupExceptionTest() {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).deleteVolumeGroup(volumeGroup, cloudRegion);
+
+ aaiDeleteTasks.deleteVolumeGroup(execution);
+ }
+
+ @Test
+ public void deleteConfigurationTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiConfigurationResources).deleteConfiguration(configuration);
+ aaiDeleteTasks.deleteConfiguration(execution);
+ verify(aaiConfigurationResources, times(1)).deleteConfiguration(configuration);
+ }
+
+ @Test
+ public void deleteInstanceGroupVnfTest() throws Exception {
+ doNothing().when(aaiInstanceGroupResources).deleteInstanceGroup(instanceGroup);
+ aaiDeleteTasks.deleteInstanceGroupVnf(execution);
+ verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(instanceGroup);
+ }
+
+ @Test
+ public void deleteNetworkPolicyNeedToDeleteAllTest() throws Exception {
+ execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,DEF456");
+ final String content0 = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete0.json")));
+ AAIResultWrapper aaiResultWrapper0 = new AAIResultWrapper(content0);
+ NetworkPolicies networkPolicies0 = aaiResultWrapper0.asBean(NetworkPolicies.class).get();
+ final String content1 = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPoliciesForDelete1.json")));
+ AAIResultWrapper aaiResultWrapper1 = new AAIResultWrapper(content1);
+ NetworkPolicies networkPolicies1 = aaiResultWrapper1.asBean(NetworkPolicies.class).get();
+
+ doReturn(Optional.of(networkPolicies0), Optional.of(networkPolicies1)).when(aaiNetworkResources)
+ .getNetworkPolicies(any(AAIResourceUri.class));
+ doNothing().when(aaiNetworkResources).deleteNetworkPolicy(any(String.class));
+ aaiDeleteTasks.deleteNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(2)).deleteNetworkPolicy(stringCaptor.capture());
+ assertEquals("testNetworkPolicyId0", stringCaptor.getAllValues().get(0));
+ assertEquals("testNetworkPolicyId1", stringCaptor.getAllValues().get(1));
+ }
+
+ @Test
+ public void deleteNetworkPolicyNeedToDeleteNoneTest() throws Exception {
+ execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
+ Optional<NetworkPolicies> networkPolicies = Optional.empty();
+ doReturn(networkPolicies).when(aaiNetworkResources).getNetworkPolicies(any(AAIResourceUri.class));
+ aaiDeleteTasks.deleteNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class));
+ }
+
+ @Test
+ public void deleteNetworkPolicyNoNetworkPoliciesTest() throws Exception {
+ aaiDeleteTasks.deleteNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
index 05af58040a..7109ac8826 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
@@ -32,9 +32,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.HashMap;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.hamcrest.Matchers;
import org.junit.Before;
@@ -59,613 +57,678 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-public class AAIUpdateTasksTest extends BaseTaskTest{
-
- @InjectMocks
- private AAIUpdateTasks aaiUpdateTasks = new AAIUpdateTasks();
-
- private L3Network network;
- private ServiceInstance serviceInstance;
- private VfModule vfModule;
- private GenericVnf genericVnf;
- private VolumeGroup volumeGroup;
- private CloudRegion cloudRegion;
- private Configuration configuration;
- private Subnet subnet;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- volumeGroup = setVolumeGroup();
- cloudRegion = setCloudRegion();
- network = setL3Network();
- configuration = setConfiguration();
- subnet = buildSubnet();
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID))).thenReturn(configuration);
-
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- }
-
- @Test
- public void updateOrchestrationStatusAssignedServiceTest() throws Exception {
- doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
-
- verify(aaiServiceInstanceResources, times(1)).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
- }
-
- @Test
- public void updateOrchestrationStatusAssignedServiceExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
- }
-
- @Test
- public void updateOrchestrationStatusActiveServiceTest() throws Exception {
- doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
-
- verify(aaiServiceInstanceResources, times(1)).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
- }
-
- @Test
- public void updateOrchestrationStatusActiveServiceExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
- }
-
- @Test
- public void updateOrchestrationStatusAssignedVnfTest() throws Exception {
- doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
-
- verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
- }
-
- @Test
- public void updateOrchestrationStatusAssignedVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
- }
-
- @Test
- public void updateOrchestrationStatusActiveVnfTest() throws Exception {
- doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
-
- verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
- }
-
- @Test
- public void updateOrchestrationStatusActiveVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
- }
-
- @Test
- public void updateOrchestrationStatusAssignVfModuleTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution);
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- assertEquals("", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateOrchestrationStatusAssignVfModuleExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution);
- }
-
- @Test
- public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleNoMultiStageTest() throws Exception {
- execution.setVariable("aLaCarte", true);
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("false");
- genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- assertEquals("", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleMultiStageButNotAlacarteTest() throws Exception {
- execution.setVariable("aLaCarte", false);
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- assertEquals("", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleWithMultiStageTest() throws Exception {
- execution.setVariable("aLaCarte", true);
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
- aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
- assertEquals("", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleExceptionTest() throws Exception {
- execution.setVariable("aLaCarte", true);
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
- }
-
- @Test
- public void updateOrchestrationStatusCreatedVfModuleTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
- aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution);
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
- }
-
- @Test
- public void updateOrchestrationStatusCreatedVfModuleExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution);
- }
-
- @Test
- public void updateOrchestrationStatusPendingActivatefModuleTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
-
- aaiUpdateTasks.updateOrchestrationStatusPendingActivationVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
- }
-
- @Test
- public void updateOrchestrationStatusPendingActivatefModuleExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateOrchestrationStatusPendingActivationVfModule(execution);
- }
-
- @Test
- public void updateOrchestrationStatusDectivateVfModuleTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
-
- aaiUpdateTasks.updateOrchestrationStatusDeactivateVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
- }
-
- @Test
- public void updateOrchestrationStatusDectivateVfModuleExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateOrchestrationStatusDeactivateVfModule(execution);
- }
-
- @Test
- public void updateHeatStackIdVfModuleTest() throws Exception {
- execution.setVariable("heatStackId", "newHeatStackId");
- doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
-
- aaiUpdateTasks.updateHeatStackIdVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf);
- assertEquals("newHeatStackId", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateHeatStackIdVfModuleToNullTest() throws Exception {
- execution.setVariable("heatStackId", null);
- doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
-
- aaiUpdateTasks.updateHeatStackIdVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf);
- assertEquals(vfModule.getHeatStackId(), "");
- }
-
- @Test
- public void updateHeatStackIdVfModuleExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateHeatStackIdVfModule(execution);
- }
-
- @Test
- public void updateOrchestrationStatusActiveVolumeGroupTest() throws Exception {
- doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActiveVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
- }
-
- @Test
- public void updateOrchestrationStatusActiveVolumeGroupExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
- aaiUpdateTasks.updateOrchestrationStatusActiveVolumeGroup(execution);
- }
-
- @Test
- public void updateOrchestrationStatusCreatedVolumeGroupTest() throws Exception {
- doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
-
- aaiUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
- }
-
- @Test
- public void updateOrchestrationStatusCreatedVolumeGroupExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
- aaiUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(execution);
- }
-
- @Test
- public void test_updateOrchestrationStatusAssignedVolumeGroup() throws Exception {
- doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
- assertEquals("", volumeGroup.getHeatStackId());
- }
-
- @Test
- public void test_updateOrchestrationStatusAssignedVolumeGroup_exception() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
- aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution);
- }
- @Test
- public void updateHeatStackIdVolumeGroupTest() throws Exception {
- execution.setVariable("heatStackId", "newHeatStackId");
- doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
-
- aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
- assertEquals("newHeatStackId", volumeGroup.getHeatStackId());
- }
- @Test
- public void updateHeatStackIdVolumeGroupToNullTest() throws Exception {
- execution.setVariable("heatStackId", null);
- doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
-
- aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
-
- verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
- assertEquals(volumeGroup.getHeatStackId(), "");
- }
-
- @Test
- public void updateHeatStackIdVolumeGroupExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
- aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
- }
-
- @Test
- public void updateNetworkExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
-
- aaiUpdateTasks.updateNetwork(execution, OrchestrationStatus.ACTIVE);
- }
-
- @Test
- public void updateOstatusActivedNetworkCollectionTest() throws Exception {
- doNothing().when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
- aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
- verify(aaiCollectionResources, times(1)).updateCollection(serviceInstance.getCollection());
- }
-
- @Test
- public void updateOstatusActiveNetworkColectionExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
- aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
- }
-
- @Test
- public void updateOrchestrationStatusActivateVfModuleTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActivateVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
- }
-
- @Test
- public void updateOrchestrationStatusActivateVfModuleExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
-
- expectedException.expect(BpmnError.class);
-
- aaiUpdateTasks.updateOrchestrationStatusActivateVfModule(execution);
- }
-
- @Test
- public void updateNetworkCreatedTest() throws Exception {
- CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
- createNetworkResponse.setNetworkFqdn("testNetworkFqdn");
- createNetworkResponse.setNetworkStackId("testNetworkStackId");
- HashMap<String, String> subnetMap = new HashMap<>();
- subnetMap.put("testSubnetId", "testNeutronSubnetId");
- createNetworkResponse.setSubnetMap(subnetMap);
-
- network.getSubnets().add(subnet);
-
- execution.setVariable("createNetworkResponse", createNetworkResponse);
-
- doNothing().when(aaiNetworkResources).updateNetwork(network);
- doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
-
- aaiUpdateTasks.updateNetworkCreated(execution);
- verify(aaiNetworkResources, times(1)).updateNetwork(network);
- verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet);
-
- assertEquals(createNetworkResponse.getNetworkFqdn(), network.getContrailNetworkFqdn());
- assertEquals(OrchestrationStatus.CREATED, network.getOrchestrationStatus());
- assertEquals(createNetworkResponse.getNetworkStackId(), network.getHeatStackId());
- assertEquals(createNetworkResponse.getNeutronNetworkId(), network.getNeutronNetworkId());
- String neutronSubnetId = createNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue();
- assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId());
- }
-
- @Test
- public void updateNetworkUpdatedTest() throws Exception {
- UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse();
- updateNetworkResponse.setNeutronNetworkId("testNeutronNetworkId");
- HashMap<String, String> subnetMap = new HashMap<>();
- subnetMap.put("testSubnetId", "testNeutronSubnetId");
- updateNetworkResponse.setSubnetMap(subnetMap);
-
- network.getSubnets().add(subnet);
-
- execution.setVariable("updateNetworkResponse", updateNetworkResponse);
-
- doNothing().when(aaiNetworkResources).updateNetwork(network);
- doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
-
- aaiUpdateTasks.updateNetworkUpdated(execution);
- verify(aaiNetworkResources, times(1)).updateNetwork(network);
- verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet);
-
- String neutronSubnetId = updateNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue();
- assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId());
- }
-
- @Test
- public void updateOrchestrationStatusNetworkTest() {
- AAIUpdateTasks spy = Mockito.spy(new AAIUpdateTasks());
- doNothing().when(spy).updateNetwork(eq(execution), any());
- spy.updateOrchestrationStatusActiveNetwork(execution);
- verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ACTIVE);
- spy.updateOrchestrationStatusAssignedNetwork(execution);
- verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ASSIGNED);
- spy.updateOrchestrationStatusCreatedNetwork(execution);
- verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.CREATED);
- }
-
- @Test
- public void updateNetworkAAITest() {
-
- L3Network spy = spy(new L3Network());
- L3Network shallowCopy = mock(L3Network.class);
- Subnet mockSubnet = mock(Subnet.class);
- Subnet shallowCopySubnet = mock(Subnet.class);
- when(mockSubnet.shallowCopyId()).thenReturn(shallowCopySubnet);
- doReturn(shallowCopy).when(spy).shallowCopyId();
-
- doNothing().when(aaiNetworkResources).updateNetwork(network);
- doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
-
- spy.getSubnets().add(mockSubnet);
- aaiUpdateTasks.updateNetworkAAI(spy, OrchestrationStatus.CREATED);
-
- verify(shallowCopy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
- verify(spy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
- verify(shallowCopySubnet, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
- }
- @Test
- public void updateNetworkCreatedkExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
- aaiUpdateTasks.updateNetworkCreated(execution);
- }
-
- @Test
- public void updateObjectNetworkTest() {
- doNothing().when(aaiNetworkResources).updateNetwork(network);
-
- aaiUpdateTasks.updateObjectNetwork(execution);
-
- verify(aaiNetworkResources, times(1)).updateNetwork(network);
- }
-
- @Test
- public void updateObjectNetworkExceptionText() {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
-
- aaiUpdateTasks.updateObjectNetwork(execution);
- }
-
- @Test
- public void test_updateServiceInstance() {
- doNothing().when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
- aaiUpdateTasks.updateServiceInstance(execution);
- verify(aaiServiceInstanceResources, times(1)).updateServiceInstance(serviceInstance);
- }
-
- @Test
- public void test_updateServiceInstance_exception() {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
- aaiUpdateTasks.updateServiceInstance(execution);
- }
-
- @Test
- public void updateObjectVnfTest() {
- doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
-
- aaiUpdateTasks.updateObjectVnf(execution);
-
- verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
- }
-
- @Test
- public void updateObjectVnfExceptionTest() {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(genericVnf);
- aaiUpdateTasks.updateObjectVnf(execution);
- }
-
- @Test
- public void updateOrchestrationStatusDeleteVfModuleTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusDeleteVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
- assertEquals("", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateModelVfModuleTest() {
- doNothing().when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
- aaiUpdateTasks.updateModelVfModule(execution);
- verify(aaiVfModuleResources, times(1)).changeAssignVfModule(vfModule, genericVnf);
- }
-
- @Test
- public void updateModelVfModuleExceptionTest() {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
- aaiUpdateTasks.updateModelVfModule(execution);
- }
-
- @Test
- public void updateOrchestrationStatusDeactivateFabricConfigurationTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED);
-
- aaiUpdateTasks.updateOrchestrationStatusDeactivateFabricConfiguration(execution);
-
- verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED);
- }
- @Test
- public void updateOrchestrationStatusActivateFabricConfigurationTest() throws Exception {
- gBBInput = execution.getGeneralBuildingBlock();
- doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
-
- aaiUpdateTasks.updateOrchestrationStatusActivateFabricConfiguration(execution);
-
- verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
- }
- @Test
- public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception {
- execution.setVariable("contrailServiceInstanceFqdn", "newContrailServiceInstanceFqdn");
- doNothing().when(aaiVfModuleResources).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
-
- aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution);
-
- verify(aaiVfModuleResources, times(1)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
- assertEquals("newContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn());
- }
- @Test
- public void updateContrailServiceInstanceFqdnVfModuleNoUpdateTest() throws Exception {
- aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution);
- verify(aaiVfModuleResources, times(0)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
- }
- @Test
- public void updateIpv4OamAddressVnfTest() throws Exception {
- execution.setVariable("oamManagementV4Address", "newIpv4OamAddress");
- doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
-
- aaiUpdateTasks.updateIpv4OamAddressVnf(execution);
-
- verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
- assertEquals("newIpv4OamAddress", genericVnf.getIpv4OamAddress());
- }
- @Test
- public void updateIpv4OamAddressVnfNoUpdateTest() throws Exception {
- aaiUpdateTasks.updateIpv4OamAddressVnf(execution);
- verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
- }
- @Test
- public void updateManagementV6AddressVnfTest() throws Exception {
- execution.setVariable("oamManagementV6Address", "newManagementV6Address");
- doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
-
- aaiUpdateTasks.updateManagementV6AddressVnf(execution);
-
- verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
- assertEquals("newManagementV6Address", genericVnf.getManagementV6Address());
- }
- @Test
- public void updateManagementV6AddressVnfNoUpdateTest() throws Exception {
- aaiUpdateTasks.updateManagementV6AddressVnf(execution);
- verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
- }
-
- @Test
- public void updateOrchestrationStatusVnfConfigureTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURE);
-
- aaiUpdateTasks.updateOrchestrationStausConfigDeployConfigureVnf(execution);
- }
- @Test
- public void updateOrchestrationStatusVnfConfiguredTest() throws Exception {
- doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CONFIGURED);
-
- aaiUpdateTasks.updateOrchestrationStausConfigDeployConfiguredVnf(execution);
- }
+public class AAIUpdateTasksTest extends BaseTaskTest {
+
+ @InjectMocks
+ private AAIUpdateTasks aaiUpdateTasks = new AAIUpdateTasks();
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private VfModule vfModule;
+ private GenericVnf genericVnf;
+ private VolumeGroup volumeGroup;
+ private CloudRegion cloudRegion;
+ private Configuration configuration;
+ private Subnet subnet;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ volumeGroup = setVolumeGroup();
+ cloudRegion = setCloudRegion();
+ network = setL3Network();
+ configuration = setConfiguration();
+ subnet = buildSubnet();
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID)))
+ .thenReturn(configuration);
+
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedServiceTest() throws Exception {
+ doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance,
+ OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
+
+ verify(aaiServiceInstanceResources, times(1)).updateOrchestrationStatusServiceInstance(serviceInstance,
+ OrchestrationStatus.ASSIGNED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedServiceExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources)
+ .updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActiveServiceTest() throws Exception {
+ doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance,
+ OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
+
+ verify(aaiServiceInstanceResources, times(1)).updateOrchestrationStatusServiceInstance(serviceInstance,
+ OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActiveServiceExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources)
+ .updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedVnfTest() throws Exception {
+ doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
+
+ verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf,
+ OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActiveVnfTest() throws Exception {
+ doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
+
+ verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActiveVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf,
+ OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignVfModuleTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ assertEquals("", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignVfModuleExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
+ genericVnf, OrchestrationStatus.ASSIGNED);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleNoMultiStageTest() throws Exception {
+ execution.setVariable("aLaCarte", true);
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("false");
+ genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ assertEquals("", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleMultiStageButNotAlacarteTest()
+ throws Exception {
+ execution.setVariable("aLaCarte", false);
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ assertEquals("", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleWithMultiStageTest() throws Exception {
+ execution.setVariable("aLaCarte", true);
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.PENDING_ACTIVATION);
+ aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.PENDING_ACTIVATION);
+ assertEquals("", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleExceptionTest() throws Exception {
+ execution.setVariable("aLaCarte", true);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
+ genericVnf, OrchestrationStatus.ASSIGNED);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusCreatedVfModuleTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.CREATED);
+ aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.CREATED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusCreatedVfModuleExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
+ genericVnf, OrchestrationStatus.CREATED);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusPendingActivatefModuleTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.PENDING_ACTIVATION);
+
+ aaiUpdateTasks.updateOrchestrationStatusPendingActivationVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.PENDING_ACTIVATION);
+ }
+
+ @Test
+ public void updateOrchestrationStatusPendingActivatefModuleExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
+ genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateOrchestrationStatusPendingActivationVfModule(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusDectivateVfModuleTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.CREATED);
+
+ aaiUpdateTasks.updateOrchestrationStatusDeactivateVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.CREATED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusDectivateVfModuleExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
+ genericVnf, OrchestrationStatus.CREATED);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateOrchestrationStatusDeactivateVfModule(execution);
+ }
+
+ @Test
+ public void updateHeatStackIdVfModuleTest() throws Exception {
+ execution.setVariable("heatStackId", "newHeatStackId");
+ doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
+
+ aaiUpdateTasks.updateHeatStackIdVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf);
+ assertEquals("newHeatStackId", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateHeatStackIdVfModuleToNullTest() throws Exception {
+ execution.setVariable("heatStackId", null);
+ doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
+
+ aaiUpdateTasks.updateHeatStackIdVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf);
+ assertEquals(vfModule.getHeatStackId(), "");
+ }
+
+ @Test
+ public void updateHeatStackIdVfModuleExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateHeatStackIdVfModule(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActiveVolumeGroupTest() throws Exception {
+ doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActiveVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActiveVolumeGroupExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup,
+ cloudRegion, OrchestrationStatus.ACTIVE);
+ aaiUpdateTasks.updateOrchestrationStatusActiveVolumeGroup(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusCreatedVolumeGroupTest() throws Exception {
+ doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.CREATED);
+
+ aaiUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.CREATED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusCreatedVolumeGroupExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup,
+ cloudRegion, OrchestrationStatus.CREATED);
+ aaiUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(execution);
+ }
+
+ @Test
+ public void test_updateOrchestrationStatusAssignedVolumeGroup() throws Exception {
+ doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.ASSIGNED);
+ assertEquals("", volumeGroup.getHeatStackId());
+ }
+
+ @Test
+ public void test_updateOrchestrationStatusAssignedVolumeGroup_exception() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup,
+ cloudRegion, OrchestrationStatus.ASSIGNED);
+ aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution);
+ }
+
+ @Test
+ public void updateHeatStackIdVolumeGroupTest() throws Exception {
+ execution.setVariable("heatStackId", "newHeatStackId");
+ doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
+
+ aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
+ assertEquals("newHeatStackId", volumeGroup.getHeatStackId());
+ }
+
+ @Test
+ public void updateHeatStackIdVolumeGroupToNullTest() throws Exception {
+ execution.setVariable("heatStackId", null);
+ doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
+
+ aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
+
+ verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
+ assertEquals(volumeGroup.getHeatStackId(), "");
+ }
+
+ @Test
+ public void updateHeatStackIdVolumeGroupExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup,
+ cloudRegion);
+ aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
+ }
+
+ @Test
+ public void updateNetworkExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
+
+ aaiUpdateTasks.updateNetwork(execution, OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateOstatusActivedNetworkCollectionTest() throws Exception {
+ doNothing().when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
+ aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
+ verify(aaiCollectionResources, times(1)).updateCollection(serviceInstance.getCollection());
+ }
+
+ @Test
+ public void updateOstatusActiveNetworkColectionExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
+ aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActivateVfModuleTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActivateVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActivateVfModuleExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
+ genericVnf, OrchestrationStatus.ACTIVE);
+
+ expectedException.expect(BpmnError.class);
+
+ aaiUpdateTasks.updateOrchestrationStatusActivateVfModule(execution);
+ }
+
+ @Test
+ public void updateNetworkCreatedTest() throws Exception {
+ CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
+ createNetworkResponse.setNetworkFqdn("testNetworkFqdn");
+ createNetworkResponse.setNetworkStackId("testNetworkStackId");
+ HashMap<String, String> subnetMap = new HashMap<>();
+ subnetMap.put("testSubnetId", "testNeutronSubnetId");
+ createNetworkResponse.setSubnetMap(subnetMap);
+
+ network.getSubnets().add(subnet);
+
+ execution.setVariable("createNetworkResponse", createNetworkResponse);
+
+ doNothing().when(aaiNetworkResources).updateNetwork(network);
+ doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
+
+ aaiUpdateTasks.updateNetworkCreated(execution);
+ verify(aaiNetworkResources, times(1)).updateNetwork(network);
+ verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet);
+
+ assertEquals(createNetworkResponse.getNetworkFqdn(), network.getContrailNetworkFqdn());
+ assertEquals(OrchestrationStatus.CREATED, network.getOrchestrationStatus());
+ assertEquals(createNetworkResponse.getNetworkStackId(), network.getHeatStackId());
+ assertEquals(createNetworkResponse.getNeutronNetworkId(), network.getNeutronNetworkId());
+ String neutronSubnetId = createNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue();
+ assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId());
+ }
+
+ @Test
+ public void updateNetworkUpdatedTest() throws Exception {
+ UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse();
+ updateNetworkResponse.setNeutronNetworkId("testNeutronNetworkId");
+ HashMap<String, String> subnetMap = new HashMap<>();
+ subnetMap.put("testSubnetId", "testNeutronSubnetId");
+ updateNetworkResponse.setSubnetMap(subnetMap);
+
+ network.getSubnets().add(subnet);
+
+ execution.setVariable("updateNetworkResponse", updateNetworkResponse);
+
+ doNothing().when(aaiNetworkResources).updateNetwork(network);
+ doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
+
+ aaiUpdateTasks.updateNetworkUpdated(execution);
+ verify(aaiNetworkResources, times(1)).updateNetwork(network);
+ verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet);
+
+ String neutronSubnetId = updateNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue();
+ assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId());
+ }
+
+ @Test
+ public void updateOrchestrationStatusNetworkTest() {
+ AAIUpdateTasks spy = Mockito.spy(new AAIUpdateTasks());
+ doNothing().when(spy).updateNetwork(eq(execution), any());
+ spy.updateOrchestrationStatusActiveNetwork(execution);
+ verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ACTIVE);
+ spy.updateOrchestrationStatusAssignedNetwork(execution);
+ verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ASSIGNED);
+ spy.updateOrchestrationStatusCreatedNetwork(execution);
+ verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.CREATED);
+ }
+
+ @Test
+ public void updateNetworkAAITest() {
+
+ L3Network spy = spy(new L3Network());
+ L3Network shallowCopy = mock(L3Network.class);
+ Subnet mockSubnet = mock(Subnet.class);
+ Subnet shallowCopySubnet = mock(Subnet.class);
+ when(mockSubnet.shallowCopyId()).thenReturn(shallowCopySubnet);
+ doReturn(shallowCopy).when(spy).shallowCopyId();
+
+ doNothing().when(aaiNetworkResources).updateNetwork(network);
+ doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
+
+ spy.getSubnets().add(mockSubnet);
+ aaiUpdateTasks.updateNetworkAAI(spy, OrchestrationStatus.CREATED);
+
+ verify(shallowCopy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
+ verify(spy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
+ verify(shallowCopySubnet, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
+ }
+
+ @Test
+ public void updateNetworkCreatedkExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
+ aaiUpdateTasks.updateNetworkCreated(execution);
+ }
+
+ @Test
+ public void updateObjectNetworkTest() {
+ doNothing().when(aaiNetworkResources).updateNetwork(network);
+
+ aaiUpdateTasks.updateObjectNetwork(execution);
+
+ verify(aaiNetworkResources, times(1)).updateNetwork(network);
+ }
+
+ @Test
+ public void updateObjectNetworkExceptionText() {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
+
+ aaiUpdateTasks.updateObjectNetwork(execution);
+ }
+
+ @Test
+ public void test_updateServiceInstance() {
+ doNothing().when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
+ aaiUpdateTasks.updateServiceInstance(execution);
+ verify(aaiServiceInstanceResources, times(1)).updateServiceInstance(serviceInstance);
+ }
+
+ @Test
+ public void test_updateServiceInstance_exception() {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
+ aaiUpdateTasks.updateServiceInstance(execution);
+ }
+
+ @Test
+ public void updateObjectVnfTest() {
+ doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
+
+ aaiUpdateTasks.updateObjectVnf(execution);
+
+ verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
+ }
+
+ @Test
+ public void updateObjectVnfExceptionTest() {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(genericVnf);
+ aaiUpdateTasks.updateObjectVnf(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusDeleteVfModuleTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusDeleteVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.ASSIGNED);
+ assertEquals("", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateModelVfModuleTest() {
+ doNothing().when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
+ aaiUpdateTasks.updateModelVfModule(execution);
+ verify(aaiVfModuleResources, times(1)).changeAssignVfModule(vfModule, genericVnf);
+ }
+
+ @Test
+ public void updateModelVfModuleExceptionTest() {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
+ aaiUpdateTasks.updateModelVfModule(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusDeactivateFabricConfigurationTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration,
+ OrchestrationStatus.ASSIGNED);
+
+ aaiUpdateTasks.updateOrchestrationStatusDeactivateFabricConfiguration(execution);
+
+ verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration,
+ OrchestrationStatus.ASSIGNED);
+ }
+
+ @Test
+ public void updateOrchestrationStatusActivateFabricConfigurationTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration,
+ OrchestrationStatus.ACTIVE);
+
+ aaiUpdateTasks.updateOrchestrationStatusActivateFabricConfiguration(execution);
+
+ verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration,
+ OrchestrationStatus.ACTIVE);
+ }
+
+ @Test
+ public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception {
+ execution.setVariable("contrailServiceInstanceFqdn", "newContrailServiceInstanceFqdn");
+ doNothing().when(aaiVfModuleResources).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
+
+ aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
+ assertEquals("newContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn());
+ }
+
+ @Test
+ public void updateContrailServiceInstanceFqdnVfModuleNoUpdateTest() throws Exception {
+ aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution);
+ verify(aaiVfModuleResources, times(0)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
+ }
+
+ @Test
+ public void updateIpv4OamAddressVnfTest() throws Exception {
+ execution.setVariable("oamManagementV4Address", "newIpv4OamAddress");
+ doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
+
+ aaiUpdateTasks.updateIpv4OamAddressVnf(execution);
+
+ verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
+ assertEquals("newIpv4OamAddress", genericVnf.getIpv4OamAddress());
+ }
+
+ @Test
+ public void updateIpv4OamAddressVnfNoUpdateTest() throws Exception {
+ aaiUpdateTasks.updateIpv4OamAddressVnf(execution);
+ verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
+ }
+
+ @Test
+ public void updateManagementV6AddressVnfTest() throws Exception {
+ execution.setVariable("oamManagementV6Address", "newManagementV6Address");
+ doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
+
+ aaiUpdateTasks.updateManagementV6AddressVnf(execution);
+
+ verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
+ assertEquals("newManagementV6Address", genericVnf.getManagementV6Address());
+ }
+
+ @Test
+ public void updateManagementV6AddressVnfNoUpdateTest() throws Exception {
+ aaiUpdateTasks.updateManagementV6AddressVnf(execution);
+ verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
+ }
+
+ @Test
+ public void updateOrchestrationStatusVnfConfigureTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.CONFIGURE);
+
+ aaiUpdateTasks.updateOrchestrationStausConfigDeployConfigureVnf(execution);
+ }
+
+ @Test
+ public void updateOrchestrationStatusVnfConfiguredTest() throws Exception {
+ doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
+ OrchestrationStatus.CONFIGURED);
+
+ aaiUpdateTasks.updateOrchestrationStausConfigDeployConfiguredVnf(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java
index ee7a9ad952..56ff813e73 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java
@@ -22,14 +22,11 @@ package org.onap.so.bpmn.infrastructure.activity;
import static org.junit.Assert.assertEquals;
-
import java.nio.file.Files;
import java.nio.file.Paths;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
-
import org.junit.Test;
import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
@@ -38,40 +35,41 @@ import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.springframework.beans.factory.annotation.Autowired;
public class ExecuteActivityTest extends BaseTaskTest {
- @InjectMocks
- protected ExecuteActivity executeActivity = new ExecuteActivity();
-
- private DelegateExecution execution;
-
- @Before
- public void before() throws Exception {
- execution = new DelegateExecutionFake();
- execution.setVariable("vnfType", "testVnfType");
- execution.setVariable("requestAction", "testRequestAction");
- execution.setVariable("mso-request-id", "testMsoRequestId");
- execution.setVariable("vnfId", "testVnfId");
- execution.setVariable("serviceInstanceId", "testServiceInstanceId");
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- }
-
- @Test
- public void buildBuildingBlock_Test(){
- BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
- assertEquals(bb.getBpmnFlowName(), "testActivityName");
- assertEquals(bb.getKey(), "");
- }
-
- @Test
- public void executeBuildingBlock_Test() throws Exception {
- BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
- ExecuteBuildingBlock ebb = executeActivity.buildExecuteBuildingBlock(execution, "testMsoRequestId", bb);
- assertEquals(ebb.getVnfType(), "testVnfType");
- assertEquals(ebb.getRequestAction(), "testRequestAction");
- assertEquals(ebb.getRequestId(), "testMsoRequestId");
- assertEquals(ebb.getWorkflowResourceIds().getVnfId(), "testVnfId");
- assertEquals(ebb.getWorkflowResourceIds().getServiceInstanceId(), "testServiceInstanceId");
- assertEquals(ebb.getBuildingBlock(), bb);
- }
-
+ @InjectMocks
+ protected ExecuteActivity executeActivity = new ExecuteActivity();
+
+ private DelegateExecution execution;
+
+ @Before
+ public void before() throws Exception {
+ execution = new DelegateExecutionFake();
+ execution.setVariable("vnfType", "testVnfType");
+ execution.setVariable("requestAction", "testRequestAction");
+ execution.setVariable("mso-request-id", "testMsoRequestId");
+ execution.setVariable("vnfId", "testVnfId");
+ execution.setVariable("serviceInstanceId", "testServiceInstanceId");
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ }
+
+ @Test
+ public void buildBuildingBlock_Test() {
+ BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
+ assertEquals(bb.getBpmnFlowName(), "testActivityName");
+ assertEquals(bb.getKey(), "");
+ }
+
+ @Test
+ public void executeBuildingBlock_Test() throws Exception {
+ BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
+ ExecuteBuildingBlock ebb = executeActivity.buildExecuteBuildingBlock(execution, "testMsoRequestId", bb);
+ assertEquals(ebb.getVnfType(), "testVnfType");
+ assertEquals(ebb.getRequestAction(), "testRequestAction");
+ assertEquals(ebb.getRequestId(), "testMsoRequestId");
+ assertEquals(ebb.getWorkflowResourceIds().getVnfId(), "testVnfId");
+ assertEquals(ebb.getWorkflowResourceIds().getServiceInstanceId(), "testServiceInstanceId");
+ assertEquals(ebb.getBuildingBlock(), bb);
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java
index 72f6a08ee7..00dfd4e236 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java
@@ -27,10 +27,8 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.Map;
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -47,61 +45,69 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.client.exception.BBObjectNotFoundException;
-public class NetworkAdapterCreateTasksTest extends BaseTaskTest{
- @InjectMocks
- private NetworkAdapterCreateTasks networkAdapterCreateTasks = new NetworkAdapterCreateTasks();
+public class NetworkAdapterCreateTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private NetworkAdapterCreateTasks networkAdapterCreateTasks = new NetworkAdapterCreateTasks();
+
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+ private L3Network l3Network;
+ private Map<String, String> userInput;
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ l3Network = setL3Network();
+ userInput = setUserInput();
+ userInput.put("userInputKey1", "userInputValue1");
+ requestContext = setRequestContext();
+ cloudRegion = setCloudRegion();
+ orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(l3Network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
- private ServiceInstance serviceInstance;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
- private L3Network l3Network;
- private Map<String, String> userInput;
- private Customer customer;
+ }
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- l3Network = setL3Network();
- userInput = setUserInput();
- userInput.put("userInputKey1", "userInputValue1");
- requestContext = setRequestContext();
- cloudRegion = setCloudRegion();
- orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
+ @Test
+ public void createNetworkTest() throws Exception {
+ String cloudRegionPo = "cloudRegionPo";
+ CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
+ execution.setVariable("cloudRegionPo", cloudRegionPo);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(l3Network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
-
- }
-
- @Test
- public void createNetworkTest() throws Exception {
- String cloudRegionPo = "cloudRegionPo";
- CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
- execution.setVariable("cloudRegionPo", cloudRegionPo);
+ doReturn(createNetworkRequest).when(networkAdapterObjectMapper).createNetworkRequestMapper(
+ isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class),
+ isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class),
+ isA(Customer.class));
+ networkAdapterCreateTasks.createNetwork(execution);
+ verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
+ assertEquals(createNetworkRequest, execution.getVariable("networkAdapterRequest"));
+ }
- doReturn(createNetworkRequest).when(networkAdapterObjectMapper).createNetworkRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(Customer.class));
- networkAdapterCreateTasks.createNetwork(execution);
- verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
- assertEquals(createNetworkRequest, execution.getVariable("networkAdapterRequest"));
- }
-
- @Test
- public void rollbackCreateNetworkTest() throws Exception {
- CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
- createNetworkResponse.setNetworkStackId("networkStackId");
- createNetworkResponse.setNetworkCreated(true);
- execution.setVariable("createNetworkResponse", createNetworkResponse);
- Optional<CreateNetworkResponse> oCreateNetworkResponse = Optional.of(createNetworkResponse);
+ @Test
+ public void rollbackCreateNetworkTest() throws Exception {
+ CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
+ createNetworkResponse.setNetworkStackId("networkStackId");
+ createNetworkResponse.setNetworkCreated(true);
+ execution.setVariable("createNetworkResponse", createNetworkResponse);
+ Optional<CreateNetworkResponse> oCreateNetworkResponse = Optional.of(createNetworkResponse);
- String cloudRegionPo = "cloudRegionPo";
- execution.setVariable("cloudRegionPo", cloudRegionPo);
+ String cloudRegionPo = "cloudRegionPo";
+ execution.setVariable("cloudRegionPo", cloudRegionPo);
- doReturn(oCreateNetworkResponse).when(networkAdapterResources).rollbackCreateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
- networkAdapterCreateTasks.rollbackCreateNetwork(execution);
- verify(networkAdapterResources, times(1)).rollbackCreateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
- }
+ doReturn(oCreateNetworkResponse).when(networkAdapterResources).rollbackCreateNetwork(requestContext,
+ cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo,
+ createNetworkResponse);
+ networkAdapterCreateTasks.rollbackCreateNetwork(execution);
+ verify(networkAdapterResources, times(1)).rollbackCreateNetwork(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java
index ceb4796443..eb481651f0 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java
@@ -27,9 +27,7 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.io.UnsupportedEncodingException;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -48,44 +46,48 @@ import org.onap.so.client.adapter.network.NetworkAdapterClientException;
import org.onap.so.client.exception.BBObjectNotFoundException;
-public class NetworkAdapterDeleteTasksTest extends BaseTaskTest{
-
- @InjectMocks
- private NetworkAdapterDeleteTasks networkAdapterDeleteTasks = new NetworkAdapterDeleteTasks();
+public class NetworkAdapterDeleteTasksTest extends BaseTaskTest {
+
+ @InjectMocks
+ private NetworkAdapterDeleteTasks networkAdapterDeleteTasks = new NetworkAdapterDeleteTasks();
- private ServiceInstance serviceInstance;
- private L3Network l3Network;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
+ private ServiceInstance serviceInstance;
+ private L3Network l3Network;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- l3Network = setL3Network();
- requestContext = setRequestContext();
- cloudRegion = setCloudRegion();
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ l3Network = setL3Network();
+ requestContext = setRequestContext();
+ cloudRegion = setCloudRegion();
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(l3Network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- }
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(l3Network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ }
- @Test
- public void test_deleteNetwork() throws UnsupportedEncodingException, NetworkAdapterClientException {
- DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
- doReturn(deleteNetworkRequest).when(networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
+ @Test
+ public void test_deleteNetwork() throws UnsupportedEncodingException, NetworkAdapterClientException {
+ DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
+ doReturn(deleteNetworkRequest).when(networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext,
+ cloudRegion, serviceInstance, l3Network);
- networkAdapterDeleteTasks.deleteNetwork(execution);
- verify(networkAdapterObjectMapper, times(1)).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
- }
+ networkAdapterDeleteTasks.deleteNetwork(execution);
+ verify(networkAdapterObjectMapper, times(1)).deleteNetworkRequestMapper(requestContext, cloudRegion,
+ serviceInstance, l3Network);
+ }
- @Test
- public void test_deleteNetwork_exception() throws UnsupportedEncodingException, NetworkAdapterClientException {
- expectedException.expect(BpmnError.class);
+ @Test
+ public void test_deleteNetwork_exception() throws UnsupportedEncodingException, NetworkAdapterClientException {
+ expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(networkAdapterObjectMapper).
- deleteNetworkRequestMapper(any(RequestContext.class), any(CloudRegion.class), any(ServiceInstance.class), eq(l3Network));
- networkAdapterDeleteTasks.deleteNetwork(execution);
- }
+ doThrow(RuntimeException.class).when(networkAdapterObjectMapper).deleteNetworkRequestMapper(
+ any(RequestContext.class), any(CloudRegion.class), any(ServiceInstance.class), eq(l3Network));
+ networkAdapterDeleteTasks.deleteNetwork(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
index c11dc822b4..d0cee42178 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
@@ -23,15 +23,12 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-
import javax.xml.bind.JAXBException;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
import org.junit.Test;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
@@ -42,7 +39,6 @@ import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.exception.MapperException;
-
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -55,69 +51,74 @@ import static org.mockito.Mockito.verify;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
public class NetworkAdapterRestV1Test extends BaseTaskTest {
-
- @InjectMocks
- NetworkAdapterRestV1 networkAdapterRestV1Tasks = new NetworkAdapterRestV1();
- @Mock
- ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
- @Before
- public void setup(){
- delegateExecution = new DelegateExecutionFake();
- }
-
- @Test
- public void testUnmarshalXml() throws IOException, JAXBException {
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><createNetworkResponse><messageId>ec37c121-e3ec-4697-8adf-2d7dca7044fc</messageId><networkCreated>true</networkCreated><networkFqdn>someNetworkFqdn</networkFqdn><networkId>991ec7bf-c9c4-4ac1-bb9c-4b61645bddb3</networkId><networkStackId>someStackId</networkStackId><neutronNetworkId>9c47521a-2916-4018-b2bc-71ab767497e3</neutronNetworkId><rollback><cloudId>someCloudId</cloudId><modelCustomizationUuid>b7171cdd-8b05-459b-80ef-2093150e8983</modelCustomizationUuid><msoRequest><requestId>90b32315-176e-4dab-bcf1-80eb97a1c4f4</requestId><serviceInstanceId>71e7db22-7907-4d78-8fcc-8d89d28e90be</serviceInstanceId></msoRequest><networkCreated>true</networkCreated><networkStackId>someStackId</networkStackId><networkType>SomeNetworkType</networkType><neutronNetworkId>9c47521a-2916-4018-b2bc-71ab767497e3</neutronNetworkId><tenantId>b60da4f71c1d4b35b8113d4eca6deaa1</tenantId></rollback><subnetMap><entry><key>6b381fa9-48ce-4e16-9978-d75309565bb6</key><value>bc1d5537-860b-4894-8eba-6faff41e648c</value></entry></subnetMap></createNetworkResponse>";
- CreateNetworkResponse response = (CreateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, CreateNetworkResponse.class);
- String returnedXml = response.toXmlString();
- System.out.println(returnedXml);
- }
-
- @Test
- public void testUnmarshalXmlUpdate() throws IOException, JAXBException {
- UpdateNetworkResponse expectedResponse = new UpdateNetworkResponse();
- expectedResponse.setMessageId("ec100bcc-2659-4aa4-b4d8-3255715c2a51");
- expectedResponse.setNetworkId("80de31e3-cc78-4111-a9d3-5b92bf0a39eb");
- Map<String,String>subnetMap = new HashMap<String,String>();
- subnetMap.put("95cd8437-25f1-4238-8720-cbfe7fa81476", "d8d16606-5d01-4822-b160-9a0d257303e0");
- expectedResponse.setSubnetMap(subnetMap);
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><updateNetworkResponse><messageId>ec100bcc-2659-4aa4-b4d8-3255715c2a51</messageId><networkId>80de31e3-cc78-4111-a9d3-5b92bf0a39eb</networkId><subnetMap><entry><key>95cd8437-25f1-4238-8720-cbfe7fa81476</key><value>d8d16606-5d01-4822-b160-9a0d257303e0</value></entry></subnetMap></updateNetworkResponse>";
- UpdateNetworkResponse response = (UpdateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, UpdateNetworkResponse.class);
- assertThat(expectedResponse, sameBeanAs(response));
- }
-
- @Test
- public void processCallbackTest() throws MapperException, BadResponseException, IOException{
- UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
- UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse();
- updateNetworkResponse.setMessageId("messageId");
- updateNetworkResponse.setNetworkId("networkId");
- delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest);
- delegateExecution.setVariable("NetworkAResponse_MESSAGE", updateNetworkResponse.toXmlString());
-
- networkAdapterRestV1Tasks.processCallback(delegateExecution);
-
- assertThat(updateNetworkResponse,sameBeanAs(delegateExecution.getVariable("updateNetworkResponse")));
- }
-
- @Test
- public void processCallbackErrorTest() throws MapperException, BadResponseException, IOException{
- UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
- UpdateNetworkError updateNetworkResponse = new UpdateNetworkError();
- updateNetworkResponse.setMessageId("messageId");
- updateNetworkResponse.setMessage("test error message");
- delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest);
- delegateExecution.setVariable("NetworkAResponse_MESSAGE", updateNetworkResponse.toXmlString());
-
- doThrow(new BpmnError("MSOWorkflowException")).when(exceptionBuilder).buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(String.class));
- try {
- networkAdapterRestV1Tasks.processCallback(delegateExecution);
- }
- catch (BpmnError be){
- assertEquals("MSOWorkflowException",be.getErrorCode());
- }
- assertNull(delegateExecution.getVariable("updateNetworkResponse"));
- verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000), eq("test error message"));
- }
+ @InjectMocks
+ NetworkAdapterRestV1 networkAdapterRestV1Tasks = new NetworkAdapterRestV1();
+ @Mock
+ ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
+
+ @Before
+ public void setup() {
+ delegateExecution = new DelegateExecutionFake();
+ }
+
+ @Test
+ public void testUnmarshalXml() throws IOException, JAXBException {
+ String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><createNetworkResponse><messageId>ec37c121-e3ec-4697-8adf-2d7dca7044fc</messageId><networkCreated>true</networkCreated><networkFqdn>someNetworkFqdn</networkFqdn><networkId>991ec7bf-c9c4-4ac1-bb9c-4b61645bddb3</networkId><networkStackId>someStackId</networkStackId><neutronNetworkId>9c47521a-2916-4018-b2bc-71ab767497e3</neutronNetworkId><rollback><cloudId>someCloudId</cloudId><modelCustomizationUuid>b7171cdd-8b05-459b-80ef-2093150e8983</modelCustomizationUuid><msoRequest><requestId>90b32315-176e-4dab-bcf1-80eb97a1c4f4</requestId><serviceInstanceId>71e7db22-7907-4d78-8fcc-8d89d28e90be</serviceInstanceId></msoRequest><networkCreated>true</networkCreated><networkStackId>someStackId</networkStackId><networkType>SomeNetworkType</networkType><neutronNetworkId>9c47521a-2916-4018-b2bc-71ab767497e3</neutronNetworkId><tenantId>b60da4f71c1d4b35b8113d4eca6deaa1</tenantId></rollback><subnetMap><entry><key>6b381fa9-48ce-4e16-9978-d75309565bb6</key><value>bc1d5537-860b-4894-8eba-6faff41e648c</value></entry></subnetMap></createNetworkResponse>";
+ CreateNetworkResponse response =
+ (CreateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, CreateNetworkResponse.class);
+ String returnedXml = response.toXmlString();
+ System.out.println(returnedXml);
+ }
+
+ @Test
+ public void testUnmarshalXmlUpdate() throws IOException, JAXBException {
+ UpdateNetworkResponse expectedResponse = new UpdateNetworkResponse();
+ expectedResponse.setMessageId("ec100bcc-2659-4aa4-b4d8-3255715c2a51");
+ expectedResponse.setNetworkId("80de31e3-cc78-4111-a9d3-5b92bf0a39eb");
+ Map<String, String> subnetMap = new HashMap<String, String>();
+ subnetMap.put("95cd8437-25f1-4238-8720-cbfe7fa81476", "d8d16606-5d01-4822-b160-9a0d257303e0");
+ expectedResponse.setSubnetMap(subnetMap);
+ String xml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><updateNetworkResponse><messageId>ec100bcc-2659-4aa4-b4d8-3255715c2a51</messageId><networkId>80de31e3-cc78-4111-a9d3-5b92bf0a39eb</networkId><subnetMap><entry><key>95cd8437-25f1-4238-8720-cbfe7fa81476</key><value>d8d16606-5d01-4822-b160-9a0d257303e0</value></entry></subnetMap></updateNetworkResponse>";
+ UpdateNetworkResponse response =
+ (UpdateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, UpdateNetworkResponse.class);
+ assertThat(expectedResponse, sameBeanAs(response));
+ }
+
+ @Test
+ public void processCallbackTest() throws MapperException, BadResponseException, IOException {
+ UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
+ UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse();
+ updateNetworkResponse.setMessageId("messageId");
+ updateNetworkResponse.setNetworkId("networkId");
+ delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest);
+ delegateExecution.setVariable("NetworkAResponse_MESSAGE", updateNetworkResponse.toXmlString());
+
+ networkAdapterRestV1Tasks.processCallback(delegateExecution);
+
+ assertThat(updateNetworkResponse, sameBeanAs(delegateExecution.getVariable("updateNetworkResponse")));
+ }
+
+ @Test
+ public void processCallbackErrorTest() throws MapperException, BadResponseException, IOException {
+ UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
+ UpdateNetworkError updateNetworkResponse = new UpdateNetworkError();
+ updateNetworkResponse.setMessageId("messageId");
+ updateNetworkResponse.setMessage("test error message");
+ delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest);
+ delegateExecution.setVariable("NetworkAResponse_MESSAGE", updateNetworkResponse.toXmlString());
+
+ doThrow(new BpmnError("MSOWorkflowException")).when(exceptionBuilder)
+ .buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(String.class));
+ try {
+ networkAdapterRestV1Tasks.processCallback(delegateExecution);
+ } catch (BpmnError be) {
+ assertEquals("MSOWorkflowException", be.getErrorCode());
+ }
+ assertNull(delegateExecution.getVariable("updateNetworkResponse"));
+ verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000),
+ eq("test error message"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java
index 0406ce09a3..af97c3d038 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java
@@ -30,11 +30,9 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.io.UnsupportedEncodingException;
import java.util.Map;
import java.util.Optional;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -56,45 +54,49 @@ import org.onap.so.client.adapter.network.NetworkAdapterClientException;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
-public class NetworkAdapterUpdateTasksTest extends BaseTaskTest{
- @InjectMocks
- private NetworkAdapterUpdateTasks networkAdapterUpdateTasks = new NetworkAdapterUpdateTasks();
-
- private ServiceInstance serviceInstance;
- private L3Network network;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
- private Map<String, String> userInput;
- private Customer customer;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- network = setL3Network();
- requestContext = setRequestContext();
- cloudRegion = setCloudRegion();
- orchestrationContext = setOrchestrationContext();
- userInput = setUserInput();
- userInput.put("userInputKey1", "userInputValue1");
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
-
- }
-
- @Test
- public void updateNetworkTest() throws Exception {
- String cloudRegionPo = "cloudRegionPo";
- UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
- execution.setVariable("cloudRegionPo", cloudRegionPo);
+public class NetworkAdapterUpdateTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private NetworkAdapterUpdateTasks networkAdapterUpdateTasks = new NetworkAdapterUpdateTasks();
+
+ private ServiceInstance serviceInstance;
+ private L3Network network;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+ private Map<String, String> userInput;
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ network = setL3Network();
+ requestContext = setRequestContext();
+ cloudRegion = setCloudRegion();
+ orchestrationContext = setOrchestrationContext();
+ userInput = setUserInput();
+ userInput.put("userInputKey1", "userInputValue1");
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+
+ }
+
+ @Test
+ public void updateNetworkTest() throws Exception {
+ String cloudRegionPo = "cloudRegionPo";
+ UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
+ execution.setVariable("cloudRegionPo", cloudRegionPo);
+
+ doReturn(updateNetworkRequest).when(networkAdapterObjectMapper).createNetworkUpdateRequestMapper(
+ isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class),
+ isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(Customer.class));
+ networkAdapterUpdateTasks.updateNetwork(execution);
+ verify(networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, network, userInput, customer);
+ assertEquals(updateNetworkRequest, execution.getVariable("networkAdapterRequest"));
+ }
- doReturn(updateNetworkRequest).when(networkAdapterObjectMapper).createNetworkUpdateRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(Customer.class));
- networkAdapterUpdateTasks.updateNetwork(execution);
- verify(networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer);
- assertEquals(updateNetworkRequest, execution.getVariable("networkAdapterRequest"));
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java
index 32b3201d11..13f2b81fd9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -47,178 +46,197 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-public class VnfAdapterCreateTasksTest extends BaseTaskTest{
- @InjectMocks
- private VnfAdapterCreateTasks vnfAdapterCreateTasks = new VnfAdapterCreateTasks();
-
-
- @Test
- public void test_createVolumeGroupRequest() throws Exception {
- RequestContext requestContext = setRequestContext();
-
- ServiceInstance serviceInstance = setServiceInstance();
-
- GenericVnf genericVnf = setGenericVnf();
-
- VfModule vfModule = setVfModule();
- vfModule.setSelflink("vfModuleSelfLink");
- VolumeGroup volumeGroup = setVolumeGroup();
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- CloudRegion cloudRegion = setCloudRegion();
-
- OrchestrationContext orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- String sdncVnfQueryResponse = "SDNCVnfQueryResponse";
+public class VnfAdapterCreateTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private VnfAdapterCreateTasks vnfAdapterCreateTasks = new VnfAdapterCreateTasks();
+
+
+ @Test
+ public void test_createVolumeGroupRequest() throws Exception {
+ RequestContext requestContext = setRequestContext();
+
+ ServiceInstance serviceInstance = setServiceInstance();
+
+ GenericVnf genericVnf = setGenericVnf();
+
+ VfModule vfModule = setVfModule();
+ vfModule.setSelflink("vfModuleSelfLink");
+ VolumeGroup volumeGroup = setVolumeGroup();
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ CloudRegion cloudRegion = setCloudRegion();
+
+ OrchestrationContext orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ String sdncVnfQueryResponse = "SDNCVnfQueryResponse";
execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVnfQueryResponse);
CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
request.setVolumeGroupId("volumeGroupStackId");
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVnfQueryResponse);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVnfQueryResponse);
vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
-
- verify(vnfAdapterVolumeGroupResources, times(1)).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVnfQueryResponse);
-
- assertEquals(request.toXmlString(), execution.getVariable("VNFREST_Request"));
- }
-
- @Test
- public void test_createVolumeGroupRequest_for_alaCarte_flow() throws Exception {
- RequestContext requestContext = setRequestContext();
- ServiceInstance serviceInstance = setServiceInstance();
- GenericVnf genericVnf = setGenericVnf();
- VolumeGroup volumeGroup = setVolumeGroup();
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- VfModule vfModule = setVfModule();
- vfModule.setSelflink("vfModuleSelfLink");
-
- CloudRegion cloudRegion = setCloudRegion();
-
- OrchestrationContext orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
+
+ verify(vnfAdapterVolumeGroupResources, times(1)).createVolumeGroupRequest(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVnfQueryResponse);
+
+ assertEquals(request.toXmlString(), execution.getVariable("VNFREST_Request"));
+ }
+
+ @Test
+ public void test_createVolumeGroupRequest_for_alaCarte_flow() throws Exception {
+ RequestContext requestContext = setRequestContext();
+ ServiceInstance serviceInstance = setServiceInstance();
+ GenericVnf genericVnf = setGenericVnf();
+ VolumeGroup volumeGroup = setVolumeGroup();
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ VfModule vfModule = setVfModule();
+ vfModule.setSelflink("vfModuleSelfLink");
+
+ CloudRegion cloudRegion = setCloudRegion();
+
+ OrchestrationContext orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
request.setVolumeGroupId("volumeGroupStackId");
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
-
- vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
-
- verify(vnfAdapterVolumeGroupResources, times(1)).createVolumeGroupRequest(any(RequestContext.class),
- any(CloudRegion.class), any(OrchestrationContext.class), eq(serviceInstance), eq(genericVnf), eq(volumeGroup), ArgumentMatchers.isNull());
-
- assertEquals(request.toXmlString(), execution.getVariable("VNFREST_Request"));
- }
-
- @Test
- public void test_createVolumeGroupRequest_exception() throws Exception {
- doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- expectedException.expect(BpmnError.class);
-
- vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
- }
-
- @Test
- public void test_createVfModule() throws Exception {
- RequestContext requestContext = setRequestContext();
-
- ServiceInstance serviceInstance = setServiceInstance();
-
- GenericVnf genericVnf = setGenericVnf();
-
- VfModule vfModule = setVfModule();
-
- CloudRegion cloudRegion = setCloudRegion();
-
- OrchestrationContext orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- CreateVfModuleRequest modRequest = new CreateVfModuleRequest();
- modRequest.setVfModuleId(vfModule.getVfModuleId());
- modRequest.setBaseVfModuleStackId("baseVfModuleStackId");
- modRequest.setVfModuleName(vfModule.getVfModuleName());
- CreateVfModuleRequest createVfModuleRequest = modRequest;
-
- String sdncVfModuleQueryResponse = "{someJson}";
- execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVfModuleQueryResponse);
-
- String sdncVnfQueryResponse = "{someJson}";
- execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), sdncVnfQueryResponse);
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
-
- doReturn(createVfModuleRequest).when(vnfAdapterVfModuleResources).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- vnfAdapterCreateTasks.createVfModule(execution);
-
- verify(vnfAdapterVfModuleResources, times(1)).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- assertEquals(execution.getVariable("VNFREST_Request"), createVfModuleRequest.toXmlString());
- }
-
- @Test
- public void test_createVfModuleWithVolumeGroup() throws Exception {
- RequestContext requestContext = setRequestContext();
-
- ServiceInstance serviceInstance = setServiceInstance();
-
- GenericVnf genericVnf = setGenericVnf();
-
- VfModule vfModule = setVfModule();
-
- VolumeGroup volumeGroup = setVolumeGroup();
-
- CloudRegion cloudRegion = setCloudRegion();
-
- OrchestrationContext orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- CreateVfModuleRequest modRequest = new CreateVfModuleRequest();
- modRequest.setVfModuleId(vfModule.getVfModuleId());
- modRequest.setBaseVfModuleStackId("baseVfModuleStackId");
- modRequest.setVfModuleName(vfModule.getVfModuleName());
- CreateVfModuleRequest createVfModuleRequest = modRequest;
-
- String sdncVfModuleQueryResponse = "{someJson}";
- execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVfModuleQueryResponse);
-
- String sdncVnfQueryResponse = "{someJson}";
- execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), sdncVnfQueryResponse);
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- doReturn(createVfModuleRequest).when(vnfAdapterVfModuleResources).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- vnfAdapterCreateTasks.createVfModule(execution);
-
- verify(vnfAdapterVfModuleResources, times(1)).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- assertEquals(execution.getVariable("VNFREST_Request"), createVfModuleRequest.toXmlString());
- }
-
- @Test
- public void createVfModuleExceptionTest() throws Exception {
- // run with no data setup, and it will throw a BBObjectNotFoundException
- doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- expectedException.expect(BpmnError.class);
- vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
- }
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
+
+ vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
+
+ verify(vnfAdapterVolumeGroupResources, times(1)).createVolumeGroupRequest(any(RequestContext.class),
+ any(CloudRegion.class), any(OrchestrationContext.class), eq(serviceInstance), eq(genericVnf),
+ eq(volumeGroup), ArgumentMatchers.isNull());
+
+ assertEquals(request.toXmlString(), execution.getVariable("VNFREST_Request"));
+ }
+
+ @Test
+ public void test_createVolumeGroupRequest_exception() throws Exception {
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ expectedException.expect(BpmnError.class);
+
+ vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
+ }
+
+ @Test
+ public void test_createVfModule() throws Exception {
+ RequestContext requestContext = setRequestContext();
+
+ ServiceInstance serviceInstance = setServiceInstance();
+
+ GenericVnf genericVnf = setGenericVnf();
+
+ VfModule vfModule = setVfModule();
+
+ CloudRegion cloudRegion = setCloudRegion();
+
+ OrchestrationContext orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ CreateVfModuleRequest modRequest = new CreateVfModuleRequest();
+ modRequest.setVfModuleId(vfModule.getVfModuleId());
+ modRequest.setBaseVfModuleStackId("baseVfModuleStackId");
+ modRequest.setVfModuleName(vfModule.getVfModuleName());
+ CreateVfModuleRequest createVfModuleRequest = modRequest;
+
+ String sdncVfModuleQueryResponse = "{someJson}";
+ execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVfModuleQueryResponse);
+
+ String sdncVnfQueryResponse = "{someJson}";
+ execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), sdncVnfQueryResponse);
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+
+ doReturn(createVfModuleRequest).when(vnfAdapterVfModuleResources).createVfModuleRequest(requestContext,
+ cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, null, sdncVnfQueryResponse,
+ sdncVfModuleQueryResponse);
+
+ vnfAdapterCreateTasks.createVfModule(execution);
+
+ verify(vnfAdapterVfModuleResources, times(1)).createVfModuleRequest(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, vfModule, null, sdncVnfQueryResponse,
+ sdncVfModuleQueryResponse);
+
+ assertEquals(execution.getVariable("VNFREST_Request"), createVfModuleRequest.toXmlString());
+ }
+
+ @Test
+ public void test_createVfModuleWithVolumeGroup() throws Exception {
+ RequestContext requestContext = setRequestContext();
+
+ ServiceInstance serviceInstance = setServiceInstance();
+
+ GenericVnf genericVnf = setGenericVnf();
+
+ VfModule vfModule = setVfModule();
+
+ VolumeGroup volumeGroup = setVolumeGroup();
+
+ CloudRegion cloudRegion = setCloudRegion();
+
+ OrchestrationContext orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ CreateVfModuleRequest modRequest = new CreateVfModuleRequest();
+ modRequest.setVfModuleId(vfModule.getVfModuleId());
+ modRequest.setBaseVfModuleStackId("baseVfModuleStackId");
+ modRequest.setVfModuleName(vfModule.getVfModuleName());
+ CreateVfModuleRequest createVfModuleRequest = modRequest;
+
+ String sdncVfModuleQueryResponse = "{someJson}";
+ execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncVfModuleQueryResponse);
+
+ String sdncVnfQueryResponse = "{someJson}";
+ execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), sdncVnfQueryResponse);
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ doReturn(createVfModuleRequest).when(vnfAdapterVfModuleResources).createVfModuleRequest(requestContext,
+ cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup,
+ sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+ vnfAdapterCreateTasks.createVfModule(execution);
+
+ verify(vnfAdapterVfModuleResources, times(1)).createVfModuleRequest(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse,
+ sdncVfModuleQueryResponse);
+
+ assertEquals(execution.getVariable("VNFREST_Request"), createVfModuleRequest.toXmlString());
+ }
+
+ @Test
+ public void createVfModuleExceptionTest() throws Exception {
+ // run with no data setup, and it will throw a BBObjectNotFoundException
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ expectedException.expect(BpmnError.class);
+ vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java
index efd2e7d849..c680978953 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -47,84 +46,97 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-public class VnfAdapterDeleteTasksTest extends BaseTaskTest{
- @InjectMocks
- private VnfAdapterDeleteTasks vnfAdapterDeleteTasks = new VnfAdapterDeleteTasks();
-
- private VolumeGroup volumeGroup;
- private VfModule vfModule;
- private GenericVnf genericVnf;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
- private ServiceInstance serviceInstance;
- private OrchestrationContext orchestrationContext;
-
- @Before
- public void before() throws Exception {
- requestContext = setRequestContext();
-
- serviceInstance = setServiceInstance();
-
- cloudRegion = setCloudRegion();
-
- genericVnf = setGenericVnf();
-
- vfModule = setVfModule();
-
- volumeGroup = setVolumeGroup();
-
- orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- }
-
- @Test
- public void test_deleteVfModule() throws Exception {
- DeleteVfModuleRequest deleteVfModuleRequest = new DeleteVfModuleRequest();
- deleteVfModuleRequest.setVfModuleId("vfModuleId");
-
- doReturn(deleteVfModuleRequest).when(vnfAdapterVfModuleResources).deleteVfModuleRequest(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
-
- vnfAdapterDeleteTasks.deleteVfModule(execution);
-
- verify(vnfAdapterVfModuleResources, times(1)).deleteVfModuleRequest(ArgumentMatchers.eq(requestContext), ArgumentMatchers.eq(cloudRegion), ArgumentMatchers.eq(serviceInstance), ArgumentMatchers.eq(genericVnf),ArgumentMatchers.eq(vfModule));
- assertEquals(execution.getVariable("VNFREST_Request"), deleteVfModuleRequest.toXmlString());
- }
-
- @Test
- public void deleteVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(vnfAdapterVfModuleResources).deleteVfModuleRequest(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
-
- vnfAdapterDeleteTasks.deleteVfModule(execution);
- }
-
- @Test
- public void test_deleteVolumeGroup() throws Exception {
- DeleteVolumeGroupRequest deleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
- deleteVolumeGroupRequest.setVolumeGroupId("volumeGroupId");
-
- doReturn(deleteVolumeGroupRequest).when(vnfAdapterVolumeGroupResources).deleteVolumeGroupRequest(requestContext, cloudRegion, serviceInstance, volumeGroup);
-
- vnfAdapterDeleteTasks.deleteVolumeGroup(execution);
-
- verify(vnfAdapterVolumeGroupResources, times(1)).deleteVolumeGroupRequest(ArgumentMatchers.eq(requestContext), ArgumentMatchers.eq(cloudRegion), ArgumentMatchers.eq(serviceInstance), ArgumentMatchers.eq(volumeGroup));
- assertEquals(execution.getVariable("VNFREST_Request"), deleteVolumeGroupRequest.toXmlString());
- }
-
- @Test
- public void deleteVolumeGroupExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- doThrow(RuntimeException.class).when(vnfAdapterVolumeGroupResources).deleteVolumeGroupRequest(requestContext, cloudRegion, serviceInstance, volumeGroup);
-
- vnfAdapterDeleteTasks.deleteVolumeGroup(execution);
- }
+public class VnfAdapterDeleteTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private VnfAdapterDeleteTasks vnfAdapterDeleteTasks = new VnfAdapterDeleteTasks();
+
+ private VolumeGroup volumeGroup;
+ private VfModule vfModule;
+ private GenericVnf genericVnf;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+ private ServiceInstance serviceInstance;
+ private OrchestrationContext orchestrationContext;
+
+ @Before
+ public void before() throws Exception {
+ requestContext = setRequestContext();
+
+ serviceInstance = setServiceInstance();
+
+ cloudRegion = setCloudRegion();
+
+ genericVnf = setGenericVnf();
+
+ vfModule = setVfModule();
+
+ volumeGroup = setVolumeGroup();
+
+ orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ }
+
+ @Test
+ public void test_deleteVfModule() throws Exception {
+ DeleteVfModuleRequest deleteVfModuleRequest = new DeleteVfModuleRequest();
+ deleteVfModuleRequest.setVfModuleId("vfModuleId");
+
+ doReturn(deleteVfModuleRequest).when(vnfAdapterVfModuleResources).deleteVfModuleRequest(requestContext,
+ cloudRegion, serviceInstance, genericVnf, vfModule);
+
+ vnfAdapterDeleteTasks.deleteVfModule(execution);
+
+ verify(vnfAdapterVfModuleResources, times(1)).deleteVfModuleRequest(ArgumentMatchers.eq(requestContext),
+ ArgumentMatchers.eq(cloudRegion), ArgumentMatchers.eq(serviceInstance), ArgumentMatchers.eq(genericVnf),
+ ArgumentMatchers.eq(vfModule));
+ assertEquals(execution.getVariable("VNFREST_Request"), deleteVfModuleRequest.toXmlString());
+ }
+
+ @Test
+ public void deleteVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(vnfAdapterVfModuleResources).deleteVfModuleRequest(requestContext,
+ cloudRegion, serviceInstance, genericVnf, vfModule);
+
+ vnfAdapterDeleteTasks.deleteVfModule(execution);
+ }
+
+ @Test
+ public void test_deleteVolumeGroup() throws Exception {
+ DeleteVolumeGroupRequest deleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
+ deleteVolumeGroupRequest.setVolumeGroupId("volumeGroupId");
+
+ doReturn(deleteVolumeGroupRequest).when(vnfAdapterVolumeGroupResources).deleteVolumeGroupRequest(requestContext,
+ cloudRegion, serviceInstance, volumeGroup);
+
+ vnfAdapterDeleteTasks.deleteVolumeGroup(execution);
+
+ verify(vnfAdapterVolumeGroupResources, times(1)).deleteVolumeGroupRequest(ArgumentMatchers.eq(requestContext),
+ ArgumentMatchers.eq(cloudRegion), ArgumentMatchers.eq(serviceInstance),
+ ArgumentMatchers.eq(volumeGroup));
+ assertEquals(execution.getVariable("VNFREST_Request"), deleteVolumeGroupRequest.toXmlString());
+ }
+
+ @Test
+ public void deleteVolumeGroupExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ doThrow(RuntimeException.class).when(vnfAdapterVolumeGroupResources).deleteVolumeGroupRequest(requestContext,
+ cloudRegion, serviceInstance, volumeGroup);
+
+ vnfAdapterDeleteTasks.deleteVolumeGroup(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java
index b515835f19..97a9388f8d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java
@@ -27,7 +27,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -46,173 +45,188 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
public class VnfAdapterImplTest extends BaseTaskTest {
-
- @InjectMocks
- private VnfAdapterImpl vnfAdapterImpl = new VnfAdapterImpl();
-
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private GenericVnf genericVnf;
- private VfModule vfModule;
+
+ @InjectMocks
+ private VnfAdapterImpl vnfAdapterImpl = new VnfAdapterImpl();
+
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
private VolumeGroup volumeGroup;
-
- private static final String VNF_ADAPTER_REST_DELETE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/VNFAdapterRestDeleteResponse.xml");
- private static final String VNF_ADAPTER_REST_CREATE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/VNFAdapterRestCreateCallback.xml");
- private static final String VNF_ADAPTER_VOLUME_CREATE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/CreateVfModuleVolumeCallbackResponse.xml");
- private static final String VNF_ADAPTER_VOLUME_DELETE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/DeleteVfModuleVolumeCallbackResponse.xml");
- private static final String TEST_VFMODULE_HEATSTACK_ID = "slowburn";
+
+ private static final String VNF_ADAPTER_REST_DELETE_RESPONSE =
+ FileUtil.readResourceFile("__files/VfModularity/VNFAdapterRestDeleteResponse.xml");
+ private static final String VNF_ADAPTER_REST_CREATE_RESPONSE =
+ FileUtil.readResourceFile("__files/VfModularity/VNFAdapterRestCreateCallback.xml");
+ private static final String VNF_ADAPTER_VOLUME_CREATE_RESPONSE =
+ FileUtil.readResourceFile("__files/VfModularity/CreateVfModuleVolumeCallbackResponse.xml");
+ private static final String VNF_ADAPTER_VOLUME_DELETE_RESPONSE =
+ FileUtil.readResourceFile("__files/VfModularity/DeleteVfModuleVolumeCallbackResponse.xml");
+ private static final String TEST_VFMODULE_HEATSTACK_ID = "slowburn";
private static final String TEST_VOLUME_HEATSTACK_ID = "testHeatStackId1";
private static final String TEST_CONTRAIL_SERVICE_INSTANCE_FQDN = "default-domain:MSOTest:MsoNW-RA";
private static final String TEST_OAM_MANAGEMENT_V4_ADDRESS = "127.0.0.1";
private static final String TEST_OAM_MANAGEMENT_V6_ADDRESS = "2000:abc:bce:1111";
- private static final String TEST_CONTRAIL_NETWORK_POLICY_FQDNS = "MSOTest:DefaultPolicyFQDN2,MSOTest:DefaultPolicyFQDN1";
-
- @Before
- public void before() throws BBObjectNotFoundException {
- requestContext = setRequestContext();
- serviceInstance = setServiceInstance();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
+ private static final String TEST_CONTRAIL_NETWORK_POLICY_FQDNS =
+ "MSOTest:DefaultPolicyFQDN2,MSOTest:DefaultPolicyFQDN1";
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ requestContext = setRequestContext();
+ serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
volumeGroup = setVolumeGroup();
- vfModule.setHeatStackId(null);
- volumeGroup.setHeatStackId(null);
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- }
-
- @Test
- public void preProcessVnfAdapterTest() {
- vnfAdapterImpl.preProcessVnfAdapter(execution);
-
- assertEquals(requestContext.getMsoRequestId(), execution.getVariable("mso-request-id"));
- assertEquals(serviceInstance.getServiceInstanceId(), execution.getVariable("mso-service-instance-id"));
- }
-
- @Test
- public void postProcessVnfAdapter_CreateResponseTest() {
- execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_CREATE_RESPONSE);
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
- assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, vfModule.getContrailServiceInstanceFqdn());
- assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, execution.getVariable("contrailServiceInstanceFqdn"));
- assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress());
- assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, execution.getVariable("oamManagementV4Address"));
- assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, genericVnf.getManagementV6Address());
- assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, execution.getVariable("oamManagementV6Address"));
- assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList"));
- }
-
-
- @Test
- public void postProcessVnfAdapter_CreateResponseTest_EmptyCreateVfModuleResponseTag() {
+ vfModule.setHeatStackId(null);
+ volumeGroup.setHeatStackId(null);
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ }
+
+ @Test
+ public void preProcessVnfAdapterTest() {
+ vnfAdapterImpl.preProcessVnfAdapter(execution);
+
+ assertEquals(requestContext.getMsoRequestId(), execution.getVariable("mso-request-id"));
+ assertEquals(serviceInstance.getServiceInstanceId(), execution.getVariable("mso-service-instance-id"));
+ }
+
+ @Test
+ public void postProcessVnfAdapter_CreateResponseTest() {
+ execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_CREATE_RESPONSE);
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
+ assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, vfModule.getContrailServiceInstanceFqdn());
+ assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, execution.getVariable("contrailServiceInstanceFqdn"));
+ assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress());
+ assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, execution.getVariable("oamManagementV4Address"));
+ assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, genericVnf.getManagementV6Address());
+ assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, execution.getVariable("oamManagementV6Address"));
+ assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList"));
+ }
+
+
+ @Test
+ public void postProcessVnfAdapter_CreateResponseTest_EmptyCreateVfModuleResponseTag() {
expectedException.expect(BpmnError.class);
- execution.setVariable("vnfAdapterRestV1Response", "<vfModuleStackId></vfModuleStackId>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- }
-
- @Test
- public void postProcessVnfAdapter_CreateResponseTest_EmptyVfModuleStackIdTag() {
- execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse></createVfModuleResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(vfModule.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapter_CreateResponseTest_EmptyHeatStackId() {
- execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse><vfModuleStackId></vfModuleStackId></createVfModuleResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(vfModule.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapter_CreateResponseTest_EmptyVfModuleOutputs() {
- execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(vfModule.getHeatStackId());
- assertNull(vfModule.getContrailServiceInstanceFqdn());
- assertNull(execution.getVariable("contrailServiceInstanceFqdn"));
- assertNotEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress());
- assertNull(execution.getVariable("oamManagementV4Address"));
- assertNull(genericVnf.getManagementV6Address());
- assertNull(execution.getVariable("oamManagementV6Address"));
- assertNull(execution.getVariable("contrailNetworkPolicyFqdnList"));
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest() {
- vfModule.setHeatStackId(TEST_VFMODULE_HEATSTACK_ID);
- execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_DELETE_RESPONSE);
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(vfModule.getHeatStackId());
- assertEquals(vfModule.getContrailServiceInstanceFqdn(), "");
- assertEquals(execution.getVariable("contrailServiceInstanceFqdn"), "");
- assertEquals(genericVnf.getIpv4OamAddress(), "");
- assertEquals(execution.getVariable("oamManagementV4Address"), "");
- assertEquals(genericVnf.getManagementV6Address(), "");
- assertEquals(execution.getVariable("oamManagementV6Address"), "");
- assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList"));
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest_EmptyVfModuleOutputs() {
- execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(vfModule.getHeatStackId());
- assertNull(vfModule.getContrailServiceInstanceFqdn());
- assertNull(execution.getVariable("contrailServiceInstanceFqdn"));
- assertNull(execution.getVariable("oamManagementV4Address"));
- assertNull(execution.getVariable("oamManagementV6Address"));
- assertNull(execution.getVariable("contrailNetworkPolicyFqdnList"));
- }
-
- @Test
- public void postProcessVnfAdapter_ResponseNullTest() {
- execution.setVariable("vnfAdapterRestV1Response", null);
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(vfModule.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapter_ResponseEmptyTest() {
+ execution.setVariable("vnfAdapterRestV1Response", "<vfModuleStackId></vfModuleStackId>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ }
+
+ @Test
+ public void postProcessVnfAdapter_CreateResponseTest_EmptyVfModuleStackIdTag() {
+ execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse></createVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void postProcessVnfAdapter_CreateResponseTest_EmptyHeatStackId() {
+ execution.setVariable("vnfAdapterRestV1Response",
+ "<createVfModuleResponse><vfModuleStackId></vfModuleStackId></createVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void postProcessVnfAdapter_CreateResponseTest_EmptyVfModuleOutputs() {
+ execution.setVariable("vnfAdapterRestV1Response",
+ "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ assertNull(vfModule.getContrailServiceInstanceFqdn());
+ assertNull(execution.getVariable("contrailServiceInstanceFqdn"));
+ assertNotEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress());
+ assertNull(execution.getVariable("oamManagementV4Address"));
+ assertNull(genericVnf.getManagementV6Address());
+ assertNull(execution.getVariable("oamManagementV6Address"));
+ assertNull(execution.getVariable("contrailNetworkPolicyFqdnList"));
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest() {
+ vfModule.setHeatStackId(TEST_VFMODULE_HEATSTACK_ID);
+ execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_DELETE_RESPONSE);
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ assertEquals(vfModule.getContrailServiceInstanceFqdn(), "");
+ assertEquals(execution.getVariable("contrailServiceInstanceFqdn"), "");
+ assertEquals(genericVnf.getIpv4OamAddress(), "");
+ assertEquals(execution.getVariable("oamManagementV4Address"), "");
+ assertEquals(genericVnf.getManagementV6Address(), "");
+ assertEquals(execution.getVariable("oamManagementV6Address"), "");
+ assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList"));
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_EmptyVfModuleOutputs() {
+ execution.setVariable("vnfAdapterRestV1Response",
+ "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ assertNull(vfModule.getContrailServiceInstanceFqdn());
+ assertNull(execution.getVariable("contrailServiceInstanceFqdn"));
+ assertNull(execution.getVariable("oamManagementV4Address"));
+ assertNull(execution.getVariable("oamManagementV6Address"));
+ assertNull(execution.getVariable("contrailNetworkPolicyFqdnList"));
+ }
+
+ @Test
+ public void postProcessVnfAdapter_ResponseNullTest() {
+ execution.setVariable("vnfAdapterRestV1Response", null);
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void postProcessVnfAdapter_ResponseEmptyTest() {
execution.setVariable("vnfAdapterRestV1Response", "");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
assertNull(vfModule.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest_VfModuleDeletedFalse() {
- vfModule.setHeatStackId(TEST_VFMODULE_HEATSTACK_ID);
- execution.setVariable("vnfAdapterRestV1Response", "<deleteVfModuleResponse><vfModuleDeleted>false</vfModuleDeleted></deleteVfModuleResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest_EmptyDeleteVfModuleResponseTag() {
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_VfModuleDeletedFalse() {
+ vfModule.setHeatStackId(TEST_VFMODULE_HEATSTACK_ID);
+ execution.setVariable("vnfAdapterRestV1Response",
+ "<deleteVfModuleResponse><vfModuleDeleted>false</vfModuleDeleted></deleteVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_EmptyDeleteVfModuleResponseTag() {
+ expectedException.expect(BpmnError.class);
+ execution.setVariable("vnfAdapterRestV1Response", "<vfModuleDeleted></vfModuleDeleted>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_EmptyVfModuleDeletedTag() {
+ vfModule.setHeatStackId(TEST_VFMODULE_HEATSTACK_ID);
+ execution.setVariable("vnfAdapterRestV1Response", "<deleteVfModuleResponse></deleteVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void preProcessVnfAdapterExceptionTest() throws BBObjectNotFoundException {
expectedException.expect(BpmnError.class);
- execution.setVariable("vnfAdapterRestV1Response", "<vfModuleDeleted></vfModuleDeleted>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest_EmptyVfModuleDeletedTag() {
- vfModule.setHeatStackId(TEST_VFMODULE_HEATSTACK_ID);
- execution.setVariable("vnfAdapterRestV1Response", "<deleteVfModuleResponse></deleteVfModuleResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
- }
-
- @Test
- public void preProcessVnfAdapterExceptionTest() throws BBObjectNotFoundException {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID));
-
- vnfAdapterImpl.preProcessVnfAdapter(execution);
- }
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID));
+
+ vnfAdapterImpl.preProcessVnfAdapter(execution);
+ }
@Test
public void postProcessVnfAdapter_CreateVolumeResponseTest() {
@@ -222,52 +236,54 @@ public class VnfAdapterImplTest extends BaseTaskTest {
}
@Test
- public void postProcessVnfAdapter_CreateVolumeEmptyResponseTest() {
+ public void postProcessVnfAdapter_CreateVolumeEmptyResponseTest() {
expectedException.expect(BpmnError.class);
execution.setVariable("vnfAdapterRestV1Response", "<createVolumeGroupResponse></createVolumeGroupResponse>");
vnfAdapterImpl.postProcessVnfAdapter(execution);
assertNull(volumeGroup.getHeatStackId());
}
-
+
@Test
- public void postProcessVnfAdapter_DeleteResponseTest_DeleteVolumeGroup() {
- volumeGroup.setHeatStackId(TEST_VOLUME_HEATSTACK_ID);
- execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_VOLUME_DELETE_RESPONSE);
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertNull(volumeGroup.getHeatStackId());
- }
-
-
+ public void postProcessVnfAdapter_DeleteResponseTest_DeleteVolumeGroup() {
+ volumeGroup.setHeatStackId(TEST_VOLUME_HEATSTACK_ID);
+ execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_VOLUME_DELETE_RESPONSE);
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(volumeGroup.getHeatStackId());
+ }
+
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_VolumeGroupDeletedFalse() {
+ volumeGroup.setHeatStackId(TEST_VOLUME_HEATSTACK_ID);
+ execution.setVariable("vnfAdapterRestV1Response",
+ "<deleteVolumeGroupResponse><volumeGroupDeleted>false</volumeGroupDeleted></deleteVolumeGroupResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertEquals(TEST_VOLUME_HEATSTACK_ID, volumeGroup.getHeatStackId());
+ }
+
@Test
- public void postProcessVnfAdapter_DeleteResponseTest_VolumeGroupDeletedFalse() {
- volumeGroup.setHeatStackId(TEST_VOLUME_HEATSTACK_ID);
- execution.setVariable("vnfAdapterRestV1Response", "<deleteVolumeGroupResponse><volumeGroupDeleted>false</volumeGroupDeleted></deleteVolumeGroupResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertEquals(TEST_VOLUME_HEATSTACK_ID, volumeGroup.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest_EmptyDeleteVolumeGroupResponseTag() {
+ public void postProcessVnfAdapter_DeleteResponseTest_EmptyDeleteVolumeGroupResponseTag() {
expectedException.expect(BpmnError.class);
- execution.setVariable("vnfAdapterRestV1Response", "<volumeGroupDeleted></volumeGroupDeleted>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- }
-
- @Test
- public void postProcessVnfAdapter_DeleteResponseTest_EmptyVolumeGroupDeletedTag() {
- volumeGroup.setHeatStackId(TEST_VOLUME_HEATSTACK_ID);
- execution.setVariable("vnfAdapterRestV1Response", "<deleteVolumeGroupResponse></deleteVolumeGroupResponse>");
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- assertEquals(TEST_VOLUME_HEATSTACK_ID, volumeGroup.getHeatStackId());
- }
-
- @Test
- public void postProcessVnfAdapterExceptionTest() throws BBObjectNotFoundException {
- doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID));
-
- execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_CREATE_RESPONSE);
- expectedException.expect(BpmnError.class);
-
- vnfAdapterImpl.postProcessVnfAdapter(execution);
- }
+ execution.setVariable("vnfAdapterRestV1Response", "<volumeGroupDeleted></volumeGroupDeleted>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_EmptyVolumeGroupDeletedTag() {
+ volumeGroup.setHeatStackId(TEST_VOLUME_HEATSTACK_ID);
+ execution.setVariable("vnfAdapterRestV1Response", "<deleteVolumeGroupResponse></deleteVolumeGroupResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertEquals(TEST_VOLUME_HEATSTACK_ID, volumeGroup.getHeatStackId());
+ }
+
+ @Test
+ public void postProcessVnfAdapterExceptionTest() throws BBObjectNotFoundException {
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID));
+
+ execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_CREATE_RESPONSE);
+ expectedException.expect(BpmnError.class);
+
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java
index 5c76018ced..5233203c05 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/EtsiVnfDeleteTaskTest.java
@@ -46,66 +46,66 @@ import com.google.common.base.Optional;
*/
public class EtsiVnfDeleteTaskTest extends BaseTaskTest {
- private static final String MODEL_INSTANCE_NAME = "MODEL_INSTANCE_NAME";
-
- private static final String VNF_ID = UUID.randomUUID().toString();
-
- private static final String VNF_NAME = "VNF_NAME";
-
- private static final String JOB_ID = UUID.randomUUID().toString();
-
- @Mock
- private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
-
- @Mock
- private GeneralBuildingBlock buildingBlock;
-
- @Mock
- private RequestContext requestContext;
-
- private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
-
- @Test
- public void testInvokeVnfmAdapter() throws Exception {
- final EtsiVnfDeleteTask objUnderTest = getEtsiVnfDeleteTask();
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- when(mockedVnfmAdapterServiceProvider.invokeDeleteRequest(eq(VNF_ID))).thenReturn(getDeleteVnfResponse());
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
- assertNotNull(stubbedxecution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME));
- }
-
- @Test
- public void testInvokeVnfmAdapterException() throws Exception {
- final EtsiVnfDeleteTask objUnderTest = getEtsiVnfDeleteTask();
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- when(mockedVnfmAdapterServiceProvider.invokeDeleteRequest(eq(VNF_ID))).thenReturn(Optional.absent());
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
- assertNull(stubbedxecution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME));
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1212),
- any(Exception.class));
- }
-
- private Optional<DeleteVnfResponse> getDeleteVnfResponse() {
- final DeleteVnfResponse response = new DeleteVnfResponse();
- response.setJobId(JOB_ID);
- return Optional.of(response);
- }
-
- private GenericVnf getGenericVnf() {
- final GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId(VNF_ID);
- genericVnf.setModelInfoGenericVnf(getModelInfoGenericVnf());
- genericVnf.setVnfName(VNF_NAME);
- return genericVnf;
- }
-
- private ModelInfoGenericVnf getModelInfoGenericVnf() {
- final ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInstanceName(MODEL_INSTANCE_NAME);
- return modelInfoGenericVnf;
- }
-
- private EtsiVnfDeleteTask getEtsiVnfDeleteTask() {
- return new EtsiVnfDeleteTask(exceptionUtil, extractPojosForBB, mockedVnfmAdapterServiceProvider);
- }
+ private static final String MODEL_INSTANCE_NAME = "MODEL_INSTANCE_NAME";
+
+ private static final String VNF_ID = UUID.randomUUID().toString();
+
+ private static final String VNF_NAME = "VNF_NAME";
+
+ private static final String JOB_ID = UUID.randomUUID().toString();
+
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+
+ @Mock
+ private GeneralBuildingBlock buildingBlock;
+
+ @Mock
+ private RequestContext requestContext;
+
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+
+ @Test
+ public void testInvokeVnfmAdapter() throws Exception {
+ final EtsiVnfDeleteTask objUnderTest = getEtsiVnfDeleteTask();
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ when(mockedVnfmAdapterServiceProvider.invokeDeleteRequest(eq(VNF_ID))).thenReturn(getDeleteVnfResponse());
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ assertNotNull(stubbedxecution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME));
+ }
+
+ @Test
+ public void testInvokeVnfmAdapterException() throws Exception {
+ final EtsiVnfDeleteTask objUnderTest = getEtsiVnfDeleteTask();
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ when(mockedVnfmAdapterServiceProvider.invokeDeleteRequest(eq(VNF_ID))).thenReturn(Optional.absent());
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ assertNull(stubbedxecution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME));
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1212),
+ any(Exception.class));
+ }
+
+ private Optional<DeleteVnfResponse> getDeleteVnfResponse() {
+ final DeleteVnfResponse response = new DeleteVnfResponse();
+ response.setJobId(JOB_ID);
+ return Optional.of(response);
+ }
+
+ private GenericVnf getGenericVnf() {
+ final GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId(VNF_ID);
+ genericVnf.setModelInfoGenericVnf(getModelInfoGenericVnf());
+ genericVnf.setVnfName(VNF_NAME);
+ return genericVnf;
+ }
+
+ private ModelInfoGenericVnf getModelInfoGenericVnf() {
+ final ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInstanceName(MODEL_INSTANCE_NAME);
+ return modelInfoGenericVnf;
+ }
+
+ private EtsiVnfDeleteTask getEtsiVnfDeleteTask() {
+ return new EtsiVnfDeleteTask(exceptionUtil, extractPojosForBB, mockedVnfmAdapterServiceProvider);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java
index 803b58b4b8..5805ea5ec1 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java
@@ -24,12 +24,10 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
-
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java
index ed5fa94100..718418eae0 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTaskTest.java
@@ -49,130 +49,131 @@ import com.google.common.base.Optional;
*/
public class MonitorVnfmCreateJobTaskTest extends BaseTaskTest {
- private static final String JOB_ID = UUID.randomUUID().toString();
-
- @Mock
- private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
-
- private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
-
- @Test
- public void testGetCurrentOperationStatus() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
- queryJobResponse.get().setOperationState(OperationStateEnum.COMPLETED);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertNotNull(operationState);
- assertEquals(OperationStateEnum.COMPLETED, operationState.get());
- }
-
- @Test
- public void testGetCurrentOperationStatusFailed() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.CANNOT_RETRIEVE_STATUS);
- queryJobResponse.get().setOperationState(OperationStateEnum.FAILED);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertNotNull(operationState);
- assertEquals(OperationStateEnum.FAILED, operationState.get());
- }
-
- @Test
- public void testGetCurrentOperationStatusEmpty() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertFalse(operationState.isPresent());
- }
-
- @Test
- public void testGetCurrentOperationStatusException() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertFalse(operationState.isPresent());
- }
-
- @Test
- public void testHasOperationFinished() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
- assertTrue(objUnderTest.hasOperationFinished(stubbedxecution));
- }
-
- @Test
- public void testHasOperationPending() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
- assertFalse(objUnderTest.hasOperationFinished(stubbedxecution));
- }
-
- @Test
- public void testTimeOutLogFailue() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- objUnderTest.timeOutLogFailue(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1205),
- eq("Instantiation operation time out"));
- }
-
- @Test
- public void testCheckIfOperationWasSuccessful() throws Exception {
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
- MonitorVnfmCreateJobTask objUnderTest = Mockito.spy(getEtsiVnfMonitorJobTask());
- objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
- verify(objUnderTest, times(1)).checkIfOperationWasSuccessful(stubbedxecution);
- }
-
- @Test
- public void testCheckIfOperationWasSuccessfulWithPending() throws Exception {
- final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.PROCESSING));
- objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1207), anyString());
- }
-
- @Test
- public void testCheckIfOperationWasSuccessfulEmpty() throws Exception {
- MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
- objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1206), anyString());
- }
-
- private CreateVnfResponse getCreateVnfResponse() {
- final CreateVnfResponse response = new CreateVnfResponse();
- response.setJobId(JOB_ID);
- return response;
- }
-
- private Optional<QueryJobResponse> getQueryJobResponse() {
- final QueryJobResponse queryJobResponse = new QueryJobResponse();
- queryJobResponse.setId(JOB_ID);
- return Optional.of(queryJobResponse);
- }
-
- private MonitorVnfmCreateJobTask getEtsiVnfMonitorJobTask() {
- return new MonitorVnfmCreateJobTask(mockedVnfmAdapterServiceProvider, exceptionUtil);
- }
+ private static final String JOB_ID = UUID.randomUUID().toString();
+
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+
+ @Test
+ public void testGetCurrentOperationStatus() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ queryJobResponse.get().setOperationState(OperationStateEnum.COMPLETED);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertNotNull(operationState);
+ assertEquals(OperationStateEnum.COMPLETED, operationState.get());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusFailed() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get()
+ .setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.CANNOT_RETRIEVE_STATUS);
+ queryJobResponse.get().setOperationState(OperationStateEnum.FAILED);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertNotNull(operationState);
+ assertEquals(OperationStateEnum.FAILED, operationState.get());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusEmpty() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertFalse(operationState.isPresent());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusException() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertFalse(operationState.isPresent());
+ }
+
+ @Test
+ public void testHasOperationFinished() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
+ assertTrue(objUnderTest.hasOperationFinished(stubbedxecution));
+ }
+
+ @Test
+ public void testHasOperationPending() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
+ assertFalse(objUnderTest.hasOperationFinished(stubbedxecution));
+ }
+
+ @Test
+ public void testTimeOutLogFailue() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ objUnderTest.timeOutLogFailue(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1205),
+ eq("Instantiation operation time out"));
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessful() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
+ MonitorVnfmCreateJobTask objUnderTest = Mockito.spy(getEtsiVnfMonitorJobTask());
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(objUnderTest, times(1)).checkIfOperationWasSuccessful(stubbedxecution);
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessfulWithPending() throws Exception {
+ final MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.PROCESSING));
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1207), anyString());
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessfulEmpty() throws Exception {
+ MonitorVnfmCreateJobTask objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.CREATE_VNF_RESPONSE_PARAM_NAME, getCreateVnfResponse());
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1206), anyString());
+ }
+
+ private CreateVnfResponse getCreateVnfResponse() {
+ final CreateVnfResponse response = new CreateVnfResponse();
+ response.setJobId(JOB_ID);
+ return response;
+ }
+
+ private Optional<QueryJobResponse> getQueryJobResponse() {
+ final QueryJobResponse queryJobResponse = new QueryJobResponse();
+ queryJobResponse.setId(JOB_ID);
+ return Optional.of(queryJobResponse);
+ }
+
+ private MonitorVnfmCreateJobTask getEtsiVnfMonitorJobTask() {
+ return new MonitorVnfmCreateJobTask(mockedVnfmAdapterServiceProvider, exceptionUtil);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTaskTest.java
index e41c571765..a821de1cd1 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTaskTest.java
@@ -50,124 +50,125 @@ import com.google.common.base.Optional;
*/
public class MonitorVnfmDeleteJobTaskTest extends BaseTaskTest {
- private static final String JOB_ID = UUID.randomUUID().toString();
-
- private MonitorVnfmDeleteJobTask objUnderTest;
-
- @Mock
- private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
-
- private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
-
- @Before
- public void setUp() {
- objUnderTest = getEtsiVnfMonitorJobTask();
- stubbedxecution.setVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME, getDeleteVnfResponse());
- }
-
- @Test
- public void testGetCurrentOperationStatus() throws Exception {
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
- queryJobResponse.get().setOperationState(OperationStateEnum.COMPLETED);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertNotNull(operationState);
- assertEquals(OperationStateEnum.COMPLETED, operationState.get());
- }
-
- @Test
- public void testGetCurrentOperationStatusFailed() throws Exception {
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.CANNOT_RETRIEVE_STATUS);
- queryJobResponse.get().setOperationState(OperationStateEnum.FAILED);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertNotNull(operationState);
- assertEquals(OperationStateEnum.FAILED, operationState.get());
- }
-
- @Test
- public void testGetCurrentOperationStatusEmpty() throws Exception {
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertFalse(operationState.isPresent());
- }
-
- @Test
- public void testGetCurrentOperationStatusException() throws Exception {
- Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
- queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
- when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
- objUnderTest.getCurrentOperationStatus(stubbedxecution);
- final Optional<OperationStateEnum> operationState =
- stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
- assertFalse(operationState.isPresent());
- }
-
- @Test
- public void testHasOperationFinished() throws Exception {
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
- assertTrue(objUnderTest.hasOperationFinished(stubbedxecution));
- }
-
- @Test
- public void testHasOperationPending() throws Exception {
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
- assertFalse(objUnderTest.hasOperationFinished(stubbedxecution));
- }
-
- @Test
- public void testTimeOutLogFailue() throws Exception {
- objUnderTest.timeOutLogFailue(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1213),
- eq("Delete operation time out"));
- }
-
- @Test
- public void testCheckIfOperationWasSuccessful() throws Exception {
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
- MonitorVnfmDeleteJobTask spyObject = Mockito.spy(objUnderTest);
- spyObject.checkIfOperationWasSuccessful(stubbedxecution);
- verify(spyObject, times(1)).checkIfOperationWasSuccessful(stubbedxecution);
- }
-
- @Test
- public void testCheckIfOperationWasSuccessfulWithPending() throws Exception {
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.PROCESSING));
- objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1215), anyString());
- }
-
- @Test
- public void testCheckIfOperationWasSuccessfulEmpty() throws Exception {
- stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
- objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1214), anyString());
- }
-
- private DeleteVnfResponse getDeleteVnfResponse() {
- final DeleteVnfResponse response = new DeleteVnfResponse();
- response.setJobId(JOB_ID);
- return response;
- }
-
- private Optional<QueryJobResponse> getQueryJobResponse() {
- final QueryJobResponse queryJobResponse = new QueryJobResponse();
- queryJobResponse.setId(JOB_ID);
- return Optional.of(queryJobResponse);
- }
-
- private MonitorVnfmDeleteJobTask getEtsiVnfMonitorJobTask() {
- return new MonitorVnfmDeleteJobTask(mockedVnfmAdapterServiceProvider, exceptionUtil);
- }
+ private static final String JOB_ID = UUID.randomUUID().toString();
+
+ private MonitorVnfmDeleteJobTask objUnderTest;
+
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+
+ @Before
+ public void setUp() {
+ objUnderTest = getEtsiVnfMonitorJobTask();
+ stubbedxecution.setVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME, getDeleteVnfResponse());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatus() throws Exception {
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ queryJobResponse.get().setOperationState(OperationStateEnum.COMPLETED);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertNotNull(operationState);
+ assertEquals(OperationStateEnum.COMPLETED, operationState.get());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusFailed() throws Exception {
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get()
+ .setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.CANNOT_RETRIEVE_STATUS);
+ queryJobResponse.get().setOperationState(OperationStateEnum.FAILED);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertNotNull(operationState);
+ assertEquals(OperationStateEnum.FAILED, operationState.get());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusEmpty() throws Exception {
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertFalse(operationState.isPresent());
+ }
+
+ @Test
+ public void testGetCurrentOperationStatusException() throws Exception {
+ Optional<QueryJobResponse> queryJobResponse = getQueryJobResponse();
+ queryJobResponse.get().setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
+ when(mockedVnfmAdapterServiceProvider.getInstantiateOperationJobStatus(JOB_ID)).thenReturn(queryJobResponse);
+ objUnderTest.getCurrentOperationStatus(stubbedxecution);
+ final Optional<OperationStateEnum> operationState =
+ stubbedxecution.getVariable(Constants.OPERATION_STATUS_PARAM_NAME);
+ assertFalse(operationState.isPresent());
+ }
+
+ @Test
+ public void testHasOperationFinished() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
+ assertTrue(objUnderTest.hasOperationFinished(stubbedxecution));
+ }
+
+ @Test
+ public void testHasOperationPending() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
+ assertFalse(objUnderTest.hasOperationFinished(stubbedxecution));
+ }
+
+ @Test
+ public void testTimeOutLogFailue() throws Exception {
+ objUnderTest.timeOutLogFailue(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1213),
+ eq("Delete operation time out"));
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessful() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.COMPLETED));
+ MonitorVnfmDeleteJobTask spyObject = Mockito.spy(objUnderTest);
+ spyObject.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(spyObject, times(1)).checkIfOperationWasSuccessful(stubbedxecution);
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessfulWithPending() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.of(OperationStateEnum.PROCESSING));
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1215), anyString());
+ }
+
+ @Test
+ public void testCheckIfOperationWasSuccessfulEmpty() throws Exception {
+ stubbedxecution.setVariable(Constants.OPERATION_STATUS_PARAM_NAME, Optional.absent());
+ objUnderTest.checkIfOperationWasSuccessful(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1214), anyString());
+ }
+
+ private DeleteVnfResponse getDeleteVnfResponse() {
+ final DeleteVnfResponse response = new DeleteVnfResponse();
+ response.setJobId(JOB_ID);
+ return response;
+ }
+
+ private Optional<QueryJobResponse> getQueryJobResponse() {
+ final QueryJobResponse queryJobResponse = new QueryJobResponse();
+ queryJobResponse.setId(JOB_ID);
+ return Optional.of(queryJobResponse);
+ }
+
+ private MonitorVnfmDeleteJobTask getEtsiVnfMonitorJobTask() {
+ return new MonitorVnfmDeleteJobTask(mockedVnfmAdapterServiceProvider, exceptionUtil);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java
index aa3ab113a0..6b84f6a918 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java
@@ -46,66 +46,66 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
*/
public class MonitorVnfmNodeJobTest extends BaseTaskTest {
- private static final String VNF_ID = UUID.randomUUID().toString();
-
- private static final String VNF_NAME = "VNF_NAME";
-
- private MonitorVnfmNodeTask objUnderTest;
-
- @Mock
- private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
-
- private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
-
- @Before
- public void setUp() {
- objUnderTest = getEtsiVnfMonitorNodeJobTask();
- }
-
- @Test
- public void testGetNodeStatusCreate() throws Exception {
- GenericVnf vnf = getGenericVnf();
- vnf.setOrchestrationStatus(VNF_CREATED);
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
- objUnderTest.getNodeStatus(stubbedxecution);
- assertTrue(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
- }
-
- @Test
- public void testGetNodeStatusDelete() throws Exception {
- GenericVnf vnf = getGenericVnf();
- vnf.setOrchestrationStatus(VNF_ASSIGNED);
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
- objUnderTest.getNodeStatus(stubbedxecution);
- assertTrue(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS));
- }
-
- @Test
- public void testGetNodeStatusException() throws Exception {
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
- objUnderTest.getNodeStatus(stubbedxecution);
- assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
- assertNull(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS));
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220),
- any(Exception.class));
- }
-
- @Test
- public void testTimeOutLogFailue() throws Exception {
- objUnderTest.timeOutLogFailue(stubbedxecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1221),
- eq("Node operation time out"));
- }
-
- private GenericVnf getGenericVnf() {
- final GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId(VNF_ID);
- genericVnf.setVnfName(VNF_NAME);
- return genericVnf;
- }
-
- private MonitorVnfmNodeTask getEtsiVnfMonitorNodeJobTask() {
- return new MonitorVnfmNodeTask(extractPojosForBB, exceptionUtil);
- }
+ private static final String VNF_ID = UUID.randomUUID().toString();
+
+ private static final String VNF_NAME = "VNF_NAME";
+
+ private MonitorVnfmNodeTask objUnderTest;
+
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+
+ @Before
+ public void setUp() {
+ objUnderTest = getEtsiVnfMonitorNodeJobTask();
+ }
+
+ @Test
+ public void testGetNodeStatusCreate() throws Exception {
+ GenericVnf vnf = getGenericVnf();
+ vnf.setOrchestrationStatus(VNF_CREATED);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
+ objUnderTest.getNodeStatus(stubbedxecution);
+ assertTrue(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
+ }
+
+ @Test
+ public void testGetNodeStatusDelete() throws Exception {
+ GenericVnf vnf = getGenericVnf();
+ vnf.setOrchestrationStatus(VNF_ASSIGNED);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf);
+ objUnderTest.getNodeStatus(stubbedxecution);
+ assertTrue(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS));
+ }
+
+ @Test
+ public void testGetNodeStatusException() throws Exception {
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
+ objUnderTest.getNodeStatus(stubbedxecution);
+ assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS));
+ assertNull(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS));
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220),
+ any(Exception.class));
+ }
+
+ @Test
+ public void testTimeOutLogFailue() throws Exception {
+ objUnderTest.timeOutLogFailue(stubbedxecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1221),
+ eq("Node operation time out"));
+ }
+
+ private GenericVnf getGenericVnf() {
+ final GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId(VNF_ID);
+ genericVnf.setVnfName(VNF_NAME);
+ return genericVnf;
+ }
+
+ private MonitorVnfmNodeTask getEtsiVnfMonitorNodeJobTask() {
+ return new MonitorVnfmNodeTask(extractPojosForBB, exceptionUtil);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java
index 260585d208..84012e8b8d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java
@@ -38,63 +38,63 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
*/
public class StubbedBuildingBlockExecution implements BuildingBlockExecution {
- private static final String CLOUD_OWNER = "CLOUD_OWNER";
- private static final String LCP_CLOUD_REGIONID = "RegionOnce";
- private static final String TENANT_ID = UUID.randomUUID().toString();
- private final Map<String, Serializable> execution = new HashMap<>();
- private final GeneralBuildingBlock generalBuildingBlock;
+ private static final String CLOUD_OWNER = "CLOUD_OWNER";
+ private static final String LCP_CLOUD_REGIONID = "RegionOnce";
+ private static final String TENANT_ID = UUID.randomUUID().toString();
+ private final Map<String, Serializable> execution = new HashMap<>();
+ private final GeneralBuildingBlock generalBuildingBlock;
- StubbedBuildingBlockExecution() {
- generalBuildingBlock = getGeneralBuildingBlockValue();
- }
+ StubbedBuildingBlockExecution() {
+ generalBuildingBlock = getGeneralBuildingBlockValue();
+ }
- @Override
- public GeneralBuildingBlock getGeneralBuildingBlock() {
- return generalBuildingBlock;
- }
+ @Override
+ public GeneralBuildingBlock getGeneralBuildingBlock() {
+ return generalBuildingBlock;
+ }
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getVariable(final String key) {
- return (T) execution.get(key);
- }
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getVariable(final String key) {
+ return (T) execution.get(key);
+ }
- @Override
- public <T> T getRequiredVariable(final String key) throws RequiredExecutionVariableExeception {
- return null;
- }
+ @Override
+ public <T> T getRequiredVariable(final String key) throws RequiredExecutionVariableExeception {
+ return null;
+ }
- @Override
- public void setVariable(final String key, final Serializable value) {
- execution.put(key, value);
- }
+ @Override
+ public void setVariable(final String key, final Serializable value) {
+ execution.put(key, value);
+ }
- @Override
- public Map<ResourceKey, String> getLookupMap() {
- return Collections.emptyMap();
- }
+ @Override
+ public Map<ResourceKey, String> getLookupMap() {
+ return Collections.emptyMap();
+ }
- @Override
- public String getFlowToBeCalled() {
- return null;
- }
+ @Override
+ public String getFlowToBeCalled() {
+ return null;
+ }
- public static String getTenantId() {
- return TENANT_ID;
- }
+ public static String getTenantId() {
+ return TENANT_ID;
+ }
- private GeneralBuildingBlock getGeneralBuildingBlockValue() {
- final GeneralBuildingBlock buildingBlock = new GeneralBuildingBlock();
- buildingBlock.setCloudRegion(getCloudRegion());
- return buildingBlock;
- }
+ private GeneralBuildingBlock getGeneralBuildingBlockValue() {
+ final GeneralBuildingBlock buildingBlock = new GeneralBuildingBlock();
+ buildingBlock.setCloudRegion(getCloudRegion());
+ return buildingBlock;
+ }
- private CloudRegion getCloudRegion() {
- final CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setCloudOwner(CLOUD_OWNER);
- cloudRegion.setLcpCloudRegionId(LCP_CLOUD_REGIONID);
- cloudRegion.setTenantId(TENANT_ID);
- return cloudRegion;
- }
+ private CloudRegion getCloudRegion() {
+ final CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner(CLOUD_OWNER);
+ cloudRegion.setLcpCloudRegionId(LCP_CLOUD_REGIONID);
+ cloudRegion.setTenantId(TENANT_ID);
+ return cloudRegion;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java
index c4f19d6d1a..7b63e5f811 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/TestConstants.java
@@ -21,9 +21,7 @@
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.DUMMY_URL;
-
import java.util.UUID;
-
import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.VnfmBasicHttpConfigProvider;
/**
@@ -36,7 +34,7 @@ public class TestConstants {
public static final String DUMMY_BASIC_AUTH = "Basic 123abc";
public static final String DUMMY_URL = "http://localhost:30406/so/vnfm-adapter/v1/";
public static final String EXPECTED_URL = DUMMY_URL + "vnfs/" + DUMMY_GENERIC_VND_ID;
-
+
public static final String DUMMY_JOB_ID = UUID.randomUUID().toString();
public static final String JOB_STATUS_EXPECTED_URL = DUMMY_URL + "jobs/" + DUMMY_JOB_ID;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java
index 5aaebea76e..75151d9c6a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskConfigurationTest.java
@@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
import static org.junit.Assert.assertNotNull;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.getVnfmBasicHttpConfigProvider;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java
index 22c4c15079..cfa5aaa4b8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTaskTest.java
@@ -51,131 +51,132 @@ import com.google.common.base.Optional;
*/
public class VnfmAdapterCreateVnfTaskTest extends BaseTaskTest {
- private static final String MODEL_INSTANCE_NAME = "MODEL_INSTANCE_NAME";
+ private static final String MODEL_INSTANCE_NAME = "MODEL_INSTANCE_NAME";
- private static final String CLOUD_OWNER = "CLOUD_OWNER";
+ private static final String CLOUD_OWNER = "CLOUD_OWNER";
- private static final String LCP_CLOUD_REGIONID = "RegionOnce";
+ private static final String LCP_CLOUD_REGIONID = "RegionOnce";
- private static final String VNF_ID = UUID.randomUUID().toString();
+ private static final String VNF_ID = UUID.randomUUID().toString();
- private static final String VNF_NAME = "VNF_NAME";
+ private static final String VNF_NAME = "VNF_NAME";
- private static final String JOB_ID = UUID.randomUUID().toString();
+ private static final String JOB_ID = UUID.randomUUID().toString();
- @Mock
- private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
+ @Mock
+ private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider;
- private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
+ private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution();
- @Test
- public void testBuildCreateVnfRequest_withValidValues_storesRequestInExecution() throws Exception {
+ @Test
+ public void testBuildCreateVnfRequest_withValidValues_storesRequestInExecution() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- stubbedxecution.setVariable(INPUT_PARAMETER, new InputParameter(Collections.emptyMap(), Collections.emptyList()));
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ stubbedxecution.setVariable(INPUT_PARAMETER,
+ new InputParameter(Collections.emptyMap(), Collections.emptyList()));
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- objUnderTest.buildCreateVnfRequest(stubbedxecution);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ objUnderTest.buildCreateVnfRequest(stubbedxecution);
- final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
- assertNotNull(actual);
- assertEquals(VNF_NAME + "." + MODEL_INSTANCE_NAME, actual.getName());
+ final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
+ assertNotNull(actual);
+ assertEquals(VNF_NAME + "." + MODEL_INSTANCE_NAME, actual.getName());
- final Tenant actualTenant = actual.getTenant();
- assertEquals(CLOUD_OWNER, actualTenant.getCloudOwner());
- assertEquals(LCP_CLOUD_REGIONID, actualTenant.getRegionName());
- assertEquals(StubbedBuildingBlockExecution.getTenantId(), actualTenant.getTenantId());
+ final Tenant actualTenant = actual.getTenant();
+ assertEquals(CLOUD_OWNER, actualTenant.getCloudOwner());
+ assertEquals(LCP_CLOUD_REGIONID, actualTenant.getRegionName());
+ assertEquals(StubbedBuildingBlockExecution.getTenantId(), actualTenant.getTenantId());
- }
+ }
- @Test
- public void testBuildCreateVnfRequest_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
+ @Test
+ public void testBuildCreateVnfRequest_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
- objUnderTest.buildCreateVnfRequest(stubbedxecution);
+ objUnderTest.buildCreateVnfRequest(stubbedxecution);
- final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
+ final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
- assertNull(actual);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1200),
- any(Exception.class));
+ assertNull(actual);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1200),
+ any(Exception.class));
- }
+ }
- @Test
- public void testInvokeVnfmAdapter_validValues_storesResponseInExecution() throws Exception {
+ @Test
+ public void testInvokeVnfmAdapter_validValues_storesResponseInExecution() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
+ stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class)))
- .thenReturn(getCreateVnfResponse());
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class)))
+ .thenReturn(getCreateVnfResponse());
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
- assertNotNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
- }
+ assertNotNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
+ }
- @Test
- public void testInvokeVnfmAdapter_invalidValues_storesResponseInExecution() throws Exception {
+ @Test
+ public void testInvokeVnfmAdapter_invalidValues_storesResponseInExecution() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
+ stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
- when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class)))
- .thenReturn(Optional.absent());
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
+ when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class)))
+ .thenReturn(Optional.absent());
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
- assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202),
- any(Exception.class));
- }
+ assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202),
+ any(Exception.class));
+ }
- @Test
- public void testInvokeVnfmAdapter_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
+ @Test
+ public void testInvokeVnfmAdapter_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
- final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
+ final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
+ when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
- objUnderTest.invokeVnfmAdapter(stubbedxecution);
+ objUnderTest.invokeVnfmAdapter(stubbedxecution);
- assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202),
- any(Exception.class));
+ assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202),
+ any(Exception.class));
- }
+ }
- private Optional<CreateVnfResponse> getCreateVnfResponse() {
- final CreateVnfResponse response = new CreateVnfResponse();
- response.setJobId(JOB_ID);
- return Optional.of(response);
- }
+ private Optional<CreateVnfResponse> getCreateVnfResponse() {
+ final CreateVnfResponse response = new CreateVnfResponse();
+ response.setJobId(JOB_ID);
+ return Optional.of(response);
+ }
- private GenericVnf getGenericVnf() {
- final GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId(VNF_ID);
- genericVnf.setModelInfoGenericVnf(getModelInfoGenericVnf());
- genericVnf.setVnfName(VNF_NAME);
- return genericVnf;
- }
+ private GenericVnf getGenericVnf() {
+ final GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId(VNF_ID);
+ genericVnf.setModelInfoGenericVnf(getModelInfoGenericVnf());
+ genericVnf.setVnfName(VNF_NAME);
+ return genericVnf;
+ }
- private ModelInfoGenericVnf getModelInfoGenericVnf() {
- final ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInstanceName(MODEL_INSTANCE_NAME);
- return modelInfoGenericVnf;
- }
+ private ModelInfoGenericVnf getModelInfoGenericVnf() {
+ final ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInstanceName(MODEL_INSTANCE_NAME);
+ return modelInfoGenericVnf;
+ }
- private VnfmAdapterCreateVnfTask getEtsiVnfInstantiateTask() {
- return new VnfmAdapterCreateVnfTask(exceptionUtil, extractPojosForBB, mockedVnfmAdapterServiceProvider);
- }
+ private VnfmAdapterCreateVnfTask getEtsiVnfInstantiateTask() {
+ return new VnfmAdapterCreateVnfTask(exceptionUtil, extractPojosForBB, mockedVnfmAdapterServiceProvider);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java
index 6f1b6f0bd2..7bd6435b60 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java
@@ -52,242 +52,242 @@ import com.google.common.base.Optional;
@RunWith(MockitoJUnitRunner.class)
public class VnfmAdapterServiceProviderImplTest {
- private static final String EMPTY_JOB_ID = "";
-
- private static final CreateVnfRequest CREATE_VNF_REQUEST = new CreateVnfRequest();
-
- @Mock
- private HttpRestServiceProvider mockedHttpServiceProvider;
-
- @Mock
- private ResponseEntity<CreateVnfResponse> mockedResponseEntity;
-
- @Mock
- private ResponseEntity<DeleteVnfResponse> deleteVnfResponse;
- @Mock
- private ResponseEntity<QueryJobResponse> mockedQueryJobResponseResponseEntity;
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBody_validResponse() {
-
- when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class)))
- .thenReturn(mockedResponseEntity);
- when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
- when(mockedResponseEntity.hasBody()).thenReturn(true);
- final CreateVnfResponse response = getCreateVnfResponse(DUMMY_JOB_ID);
- when(mockedResponseEntity.getBody()).thenReturn(response);
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- final Optional<CreateVnfResponse> actual =
- objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
- assertTrue(actual.isPresent());
- assertEquals(actual.get(), response);
- }
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithNoBody_noResponse() {
- assertWithStatuCode(HttpStatus.ACCEPTED);
- }
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusNotOkWithNoBody_noResponse() {
- assertWithStatuCode(HttpStatus.UNAUTHORIZED);
- }
-
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBodyWithInvalidJobId_noResponse() {
- assertWithJobId(null);
- assertWithJobId(EMPTY_JOB_ID);
- }
-
- @Test
- public void testInvokeCreateInstantiationRequest_httpServiceProviderThrowException_httpRestServiceProviderNotNull() {
-
- when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class)))
- .thenThrow(RestProcessingException.class);
-
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<CreateVnfResponse> actual =
- objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
- assertFalse(actual.isPresent());
-
- }
-
- @Test
- public void testInvokeDeleteRequest() {
- when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
- .thenReturn(deleteVnfResponse);
- when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
- when(deleteVnfResponse.hasBody()).thenReturn(true);
- final DeleteVnfResponse response = getDeleteVnfResponse(DUMMY_JOB_ID);
- when(deleteVnfResponse.getBody()).thenReturn(response);
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
- assertTrue(actual.isPresent());
- }
-
- @Test
- public void testInvokeDeleteRequestNotAccepted() {
- when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
- .thenReturn(deleteVnfResponse);
- when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.BAD_GATEWAY);
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
- assertFalse(actual.isPresent());
- }
-
- @Test
- public void testInvokeDeleteRequestNoBody() {
- when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
- .thenReturn(deleteVnfResponse);
- when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
- when(deleteVnfResponse.hasBody()).thenReturn(false);
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
- assertFalse(actual.isPresent());
- }
-
- @Test
- public void testInvokeDeleteRequestNoJobId() {
- when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
- .thenReturn(deleteVnfResponse);
- when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
- when(deleteVnfResponse.hasBody()).thenReturn(true);
- final DeleteVnfResponse response = getDeleteVnfResponse("");
- when(deleteVnfResponse.getBody()).thenReturn(response);
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
- assertFalse(actual.isPresent());
- }
-
- @Test
- public void testInvokeDeleteRequestException() {
- when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
- .thenThrow(RestProcessingException.class);
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
- assertFalse(actual.isPresent());
- }
-
- @Test
- public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusOkWithBody_validResponse() {
-
- when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
- when(mockedQueryJobResponseResponseEntity.hasBody()).thenReturn(true);
- when(mockedQueryJobResponseResponseEntity.getBody()).thenReturn(getQueryJobResponse());
-
- when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
- eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
- assertTrue(actual.isPresent());
- final QueryJobResponse actualQueryJobResponse = actual.get();
- assertNotNull(actualQueryJobResponse);
- }
-
- @Test
- public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusOkWithOutBody_invalidResponse() {
-
- when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
- when(mockedQueryJobResponseResponseEntity.hasBody()).thenReturn(false);
-
- when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
- eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
- assertFalse(actual.isPresent());
- }
-
- @Test
- public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusNotOkWithOutBody_invalidResponse() {
-
- when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR);
-
- when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
- eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
- assertFalse(actual.isPresent());
- }
-
- @Test
- public void testGetInstantiateOperationJobStatus_Exception() {
-
- when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
- eq(QueryJobResponse.class))).thenThrow(RestProcessingException.class);
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
- assertFalse(actual.isPresent());
- }
-
- private QueryJobResponse getQueryJobResponse() {
- return new QueryJobResponse().id(DUMMY_JOB_ID).operationState(OperationStateEnum.COMPLETED);
-
- }
-
- private void assertWithJobId(final String jobId) {
- when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class)))
- .thenReturn(mockedResponseEntity);
- when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
- when(mockedResponseEntity.hasBody()).thenReturn(true);
- final CreateVnfResponse response = getCreateVnfResponse(jobId);
- when(mockedResponseEntity.getBody()).thenReturn(response);
-
-
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
-
- final Optional<CreateVnfResponse> actual =
- objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
- assertFalse(actual.isPresent());
- }
-
- private void assertWithStatuCode(final HttpStatus status) {
- when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(), eq(CreateVnfResponse.class)))
- .thenReturn(mockedResponseEntity);
- when(mockedResponseEntity.getStatusCode()).thenReturn(status);
- when(mockedResponseEntity.hasBody()).thenReturn(false);
+ private static final String EMPTY_JOB_ID = "";
+
+ private static final CreateVnfRequest CREATE_VNF_REQUEST = new CreateVnfRequest();
+
+ @Mock
+ private HttpRestServiceProvider mockedHttpServiceProvider;
+
+ @Mock
+ private ResponseEntity<CreateVnfResponse> mockedResponseEntity;
+
+ @Mock
+ private ResponseEntity<DeleteVnfResponse> deleteVnfResponse;
+ @Mock
+ private ResponseEntity<QueryJobResponse> mockedQueryJobResponseResponseEntity;
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBody_validResponse() {
+
+ when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(),
+ eq(CreateVnfResponse.class))).thenReturn(mockedResponseEntity);
+ when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(mockedResponseEntity.hasBody()).thenReturn(true);
+ final CreateVnfResponse response = getCreateVnfResponse(DUMMY_JOB_ID);
+ when(mockedResponseEntity.getBody()).thenReturn(response);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<CreateVnfResponse> actual =
+ objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
+ assertTrue(actual.isPresent());
+ assertEquals(actual.get(), response);
+ }
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithNoBody_noResponse() {
+ assertWithStatuCode(HttpStatus.ACCEPTED);
+ }
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusNotOkWithNoBody_noResponse() {
+ assertWithStatuCode(HttpStatus.UNAUTHORIZED);
+ }
+
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderReturnsStatusAcceptedWithBodyWithInvalidJobId_noResponse() {
+ assertWithJobId(null);
+ assertWithJobId(EMPTY_JOB_ID);
+ }
+
+ @Test
+ public void testInvokeCreateInstantiationRequest_httpServiceProviderThrowException_httpRestServiceProviderNotNull() {
+
+ when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(),
+ eq(CreateVnfResponse.class))).thenThrow(RestProcessingException.class);
+
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<CreateVnfResponse> actual =
+ objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
+ assertFalse(actual.isPresent());
+
+ }
+
+ @Test
+ public void testInvokeDeleteRequest() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenReturn(deleteVnfResponse);
+ when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(deleteVnfResponse.hasBody()).thenReturn(true);
+ final DeleteVnfResponse response = getDeleteVnfResponse(DUMMY_JOB_ID);
+ when(deleteVnfResponse.getBody()).thenReturn(response);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertTrue(actual.isPresent());
+ }
+
+ @Test
+ public void testInvokeDeleteRequestNotAccepted() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenReturn(deleteVnfResponse);
+ when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.BAD_GATEWAY);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testInvokeDeleteRequestNoBody() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenReturn(deleteVnfResponse);
+ when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(deleteVnfResponse.hasBody()).thenReturn(false);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testInvokeDeleteRequestNoJobId() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenReturn(deleteVnfResponse);
+ when(deleteVnfResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(deleteVnfResponse.hasBody()).thenReturn(true);
+ final DeleteVnfResponse response = getDeleteVnfResponse("");
+ when(deleteVnfResponse.getBody()).thenReturn(response);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testInvokeDeleteRequestException() {
+ when(mockedHttpServiceProvider.deleteHttpRequest(anyString(), eq(DeleteVnfResponse.class)))
+ .thenThrow(RestProcessingException.class);
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ final Optional<DeleteVnfResponse> actual = objUnderTest.invokeDeleteRequest(DUMMY_GENERIC_VND_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusOkWithBody_validResponse() {
+
+ when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
+ when(mockedQueryJobResponseResponseEntity.hasBody()).thenReturn(true);
+ when(mockedQueryJobResponseResponseEntity.getBody()).thenReturn(getQueryJobResponse());
+
+ when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
+ eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
+ assertTrue(actual.isPresent());
+ final QueryJobResponse actualQueryJobResponse = actual.get();
+ assertNotNull(actualQueryJobResponse);
+ }
+
+ @Test
+ public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusOkWithOutBody_invalidResponse() {
+
+ when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.OK);
+ when(mockedQueryJobResponseResponseEntity.hasBody()).thenReturn(false);
+
+ when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
+ eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testGetInstantiateOperationJobStatus_httpServiceProviderReturnsStatusNotOkWithOutBody_invalidResponse() {
+
+ when(mockedQueryJobResponseResponseEntity.getStatusCode()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR);
+
+ when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
+ eq(QueryJobResponse.class))).thenReturn(mockedQueryJobResponseResponseEntity);
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ @Test
+ public void testGetInstantiateOperationJobStatus_Exception() {
+
+ when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
+ eq(QueryJobResponse.class))).thenThrow(RestProcessingException.class);
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
+ assertFalse(actual.isPresent());
+ }
+
+ private QueryJobResponse getQueryJobResponse() {
+ return new QueryJobResponse().id(DUMMY_JOB_ID).operationState(OperationStateEnum.COMPLETED);
+
+ }
+
+ private void assertWithJobId(final String jobId) {
+ when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(),
+ eq(CreateVnfResponse.class))).thenReturn(mockedResponseEntity);
+ when(mockedResponseEntity.getStatusCode()).thenReturn(HttpStatus.ACCEPTED);
+ when(mockedResponseEntity.hasBody()).thenReturn(true);
+ final CreateVnfResponse response = getCreateVnfResponse(jobId);
+ when(mockedResponseEntity.getBody()).thenReturn(response);
+
+
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+
+ final Optional<CreateVnfResponse> actual =
+ objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
+ assertFalse(actual.isPresent());
+ }
- final VnfmAdapterServiceProvider objUnderTest =
- new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
+ private void assertWithStatuCode(final HttpStatus status) {
+ when(mockedHttpServiceProvider.postHttpRequest(eq(CREATE_VNF_REQUEST), anyString(),
+ eq(CreateVnfResponse.class))).thenReturn(mockedResponseEntity);
+ when(mockedResponseEntity.getStatusCode()).thenReturn(status);
+ when(mockedResponseEntity.hasBody()).thenReturn(false);
- final Optional<CreateVnfResponse> actual =
- objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
- assertFalse(actual.isPresent());
- }
+ final VnfmAdapterServiceProvider objUnderTest =
+ new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
- private CreateVnfResponse getCreateVnfResponse(final String jobId) {
- return new CreateVnfResponse().jobId(jobId);
- }
+ final Optional<CreateVnfResponse> actual =
+ objUnderTest.invokeCreateInstantiationRequest(DUMMY_GENERIC_VND_ID, CREATE_VNF_REQUEST);
+ assertFalse(actual.isPresent());
+ }
- private DeleteVnfResponse getDeleteVnfResponse(final String jobId) {
- final DeleteVnfResponse response = new DeleteVnfResponse();
- response.setJobId(jobId);
- return response;
- }
+ private CreateVnfResponse getCreateVnfResponse(final String jobId) {
+ return new CreateVnfResponse().jobId(jobId);
+ }
- private VnfmAdapterUrlProvider getVnfmAdapterUrlProvider() {
- return new VnfmAdapterUrlProvider(getVnfmBasicHttpConfigProvider());
- }
+ private DeleteVnfResponse getDeleteVnfResponse(final String jobId) {
+ final DeleteVnfResponse response = new DeleteVnfResponse();
+ response.setJobId(jobId);
+ return response;
+ }
+
+ private VnfmAdapterUrlProvider getVnfmAdapterUrlProvider() {
+ return new VnfmAdapterUrlProvider(getVnfmBasicHttpConfigProvider());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java
index 133f24bbe1..4bffb845f4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterUrlProviderTest.java
@@ -26,7 +26,6 @@ import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.D
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.EXPECTED_URL;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.JOB_STATUS_EXPECTED_URL;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.getVnfmBasicHttpConfigProvider;
-
import org.junit.Test;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java
index d21942d08f..51e86c1fea 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImplTest.java
@@ -26,14 +26,12 @@ import static org.mockito.Mockito.when;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.FORWARD_SLASH;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.PRELOAD_VNFS_URL;
import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.TestConstants.DUMMY_GENERIC_VND_ID;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java
index 46018b8f39..c7c61f9a1d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameterTest.java
@@ -20,7 +20,6 @@
package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils;
import org.junit.Test;
-
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java
index 9cf1a1cdc9..e7a8b35db8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java
@@ -24,11 +24,9 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.HashMap;
import java.util.Optional;
import java.util.UUID;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.appc.client.lcm.model.Action;
@@ -40,62 +38,66 @@ import org.onap.so.db.catalog.beans.ControllerSelectionReference;
import org.springframework.beans.factory.annotation.Autowired;
public class AppcRunTasksIT extends BaseIntegrationTest {
-
- @Autowired
- private AppcRunTasks appcRunTasks;
-
- private GenericVnf genericVnf;
- private RequestContext requestContext;
- private String msoRequestId;
- @Before
- public void before() {
- genericVnf = setGenericVnf();
- msoRequestId = UUID.randomUUID().toString();
- requestContext = setRequestContext();
- requestContext.setMsoRequestId(msoRequestId);
- gBBInput.setRequestContext(requestContext);
- }
-
- @Test
- public void preProcessActivityTest() throws Exception {
- appcRunTasks.preProcessActivity(execution);
- assertEquals(execution.getVariable("actionQuiesceTraffic"), Action.QuiesceTraffic);
- assertEquals(execution.getVariable("rollbackQuiesceTraffic"), false);
- }
-
- @Test
- public void runAppcCommandTest() throws Exception {
- Action action = Action.QuiesceTraffic;
- ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
- controllerSelectionReference.setControllerName("testName");
- controllerSelectionReference.setActionCategory(action.toString());
- controllerSelectionReference.setVnfType("testVnfType");
-
- doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.QuiesceTraffic.toString());
-
- execution.setVariable("aicIdentity", "testAicIdentity");
-
- String vnfId = genericVnf.getVnfId();
- genericVnf.setIpv4OamAddress("testOamIpAddress");
- String payload = "{\"testName\":\"testValue\",}";
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setPayload(payload);
- gBBInput.getRequestContext().setRequestParameters(requestParameters);
-
- String controllerType = "testName";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName1");
- payloadInfo.put("aicIdentity", "testAicIdentity");
- payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
- payloadInfo.put("vserverIdList", null);
- payloadInfo.put("vfModuleId", null);
- payloadInfo.put("identityUrl", null);
- payloadInfo.put("vmIdList", null);
-
- doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
-
- appcRunTasks.runAppcCommand(execution, action);
- verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- }
+ @Autowired
+ private AppcRunTasks appcRunTasks;
+
+ private GenericVnf genericVnf;
+ private RequestContext requestContext;
+ private String msoRequestId;
+
+ @Before
+ public void before() {
+ genericVnf = setGenericVnf();
+ msoRequestId = UUID.randomUUID().toString();
+ requestContext = setRequestContext();
+ requestContext.setMsoRequestId(msoRequestId);
+ gBBInput.setRequestContext(requestContext);
+ }
+
+ @Test
+ public void preProcessActivityTest() throws Exception {
+ appcRunTasks.preProcessActivity(execution);
+ assertEquals(execution.getVariable("actionQuiesceTraffic"), Action.QuiesceTraffic);
+ assertEquals(execution.getVariable("rollbackQuiesceTraffic"), false);
+ }
+
+ @Test
+ public void runAppcCommandTest() throws Exception {
+ Action action = Action.QuiesceTraffic;
+ ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
+ controllerSelectionReference.setControllerName("testName");
+ controllerSelectionReference.setActionCategory(action.toString());
+ controllerSelectionReference.setVnfType("testVnfType");
+
+ doReturn(controllerSelectionReference).when(catalogDbClient)
+ .getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(),
+ Action.QuiesceTraffic.toString());
+
+ execution.setVariable("aicIdentity", "testAicIdentity");
+
+ String vnfId = genericVnf.getVnfId();
+ genericVnf.setIpv4OamAddress("testOamIpAddress");
+ String payload = "{\"testName\":\"testValue\",}";
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setPayload(payload);
+ gBBInput.getRequestContext().setRequestParameters(requestParameters);
+
+ String controllerType = "testName";
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName1");
+ payloadInfo.put("aicIdentity", "testAicIdentity");
+ payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
+ payloadInfo.put("vserverIdList", null);
+ payloadInfo.put("vfModuleId", null);
+ payloadInfo.put("identityUrl", null);
+ payloadInfo.put("vmIdList", null);
+
+ doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+
+ appcRunTasks.runAppcCommand(execution, action);
+ verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java
index a8518d9016..cf673c5eb5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java
@@ -30,7 +30,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.junit.Test;
import org.mockito.InjectMocks;
import org.onap.appc.client.lcm.model.Action;
@@ -45,47 +44,45 @@ import org.onap.so.db.catalog.beans.ControllerSelectionReference;
public class AppcRunTasksTest extends BaseTaskTest {
- @InjectMocks
- private AppcRunTasks appcRunTasks = new AppcRunTasks();
-
- @Test
- public void mapRollbackVariablesTest() {
-
- BuildingBlockExecution mock = mock(BuildingBlockExecution.class);
-
- appcRunTasks.mapRollbackVariables(mock, Action.Lock, "1");
- verify(mock, times(0)).setVariable(any(String.class), any());
- appcRunTasks.mapRollbackVariables(mock, Action.Lock, "0");
- verify(mock, times(1)).setVariable("rollbackVnfLock", true);
- appcRunTasks.mapRollbackVariables(mock, Action.Unlock, "0");
- verify(mock, times(1)).setVariable("rollbackVnfLock", false);
- appcRunTasks.mapRollbackVariables(mock, Action.Start, "0");
- verify(mock, times(1)).setVariable("rollbackVnfStop", false);
- appcRunTasks.mapRollbackVariables(mock, Action.Stop, "0");
- verify(mock, times(1)).setVariable("rollbackVnfStop", true);
- appcRunTasks.mapRollbackVariables(mock, Action.QuiesceTraffic, "0");
- verify(mock, times(1)).setVariable("rollbackQuiesceTraffic", true);
- appcRunTasks.mapRollbackVariables(mock, Action.ResumeTraffic, "0");
- verify(mock, times(1)).setVariable("rollbackQuiesceTraffic", false);
- }
+ @InjectMocks
+ private AppcRunTasks appcRunTasks = new AppcRunTasks();
+
+ @Test
+ public void mapRollbackVariablesTest() {
+
+ BuildingBlockExecution mock = mock(BuildingBlockExecution.class);
+
+ appcRunTasks.mapRollbackVariables(mock, Action.Lock, "1");
+ verify(mock, times(0)).setVariable(any(String.class), any());
+ appcRunTasks.mapRollbackVariables(mock, Action.Lock, "0");
+ verify(mock, times(1)).setVariable("rollbackVnfLock", true);
+ appcRunTasks.mapRollbackVariables(mock, Action.Unlock, "0");
+ verify(mock, times(1)).setVariable("rollbackVnfLock", false);
+ appcRunTasks.mapRollbackVariables(mock, Action.Start, "0");
+ verify(mock, times(1)).setVariable("rollbackVnfStop", false);
+ appcRunTasks.mapRollbackVariables(mock, Action.Stop, "0");
+ verify(mock, times(1)).setVariable("rollbackVnfStop", true);
+ appcRunTasks.mapRollbackVariables(mock, Action.QuiesceTraffic, "0");
+ verify(mock, times(1)).setVariable("rollbackQuiesceTraffic", true);
+ appcRunTasks.mapRollbackVariables(mock, Action.ResumeTraffic, "0");
+ verify(mock, times(1)).setVariable("rollbackQuiesceTraffic", false);
+ }
@Test
public void runAppcCommandVnfNull() throws BBObjectNotFoundException {
execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "NULL-TEST");
fillRequiredAppcExecutionFields();
- when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID)))
- .thenReturn(null);
- when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(
- isNull(), eq(Action.Lock.toString()))).
- thenThrow(new IllegalArgumentException("name or values is null"));
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(null);
+ when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(isNull(),
+ eq(Action.Lock.toString()))).thenThrow(new IllegalArgumentException("name or values is null"));
appcRunTasks.runAppcCommand(execution, Action.Lock);
// if vnf = null -> vnfType = null ->
- // IllegalArgumentException will be thrown in catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory
- verify(exceptionUtil, times(1)).
- buildAndThrowWorkflowException(
- any(BuildingBlockExecution.class), eq(1002), eq("name or values is null"));
+ // IllegalArgumentException will be thrown in
+ // catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002),
+ eq("name or values is null"));
}
@Test
@@ -93,13 +90,12 @@ public class AppcRunTasksTest extends BaseTaskTest {
execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "EXCEPTION-TEST");
fillRequiredAppcExecutionFields();
when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID)))
- .thenThrow(new BBObjectNotFoundException());
+ .thenThrow(new BBObjectNotFoundException());
appcRunTasks.runAppcCommand(execution, Action.Lock);
- verify(exceptionUtil, times(1)).
- buildAndThrowWorkflowException(
- any(BuildingBlockExecution.class), eq(7000), eq("No valid VNF exists"));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ eq("No valid VNF exists"));
}
@Test
@@ -107,12 +103,10 @@ public class AppcRunTasksTest extends BaseTaskTest {
execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "SUCCESS-TEST");
fillRequiredAppcExecutionFields();
GenericVnf genericVnf = getTestGenericVnf();
- when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID)))
- .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
mockReferenceResponse();
execution.getLookupMap().put(ResourceKey.VF_MODULE_ID, "VF-MODULE-ID-TEST");
- when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID)))
- .thenReturn(null);
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID))).thenReturn(null);
when(appCClient.getErrorCode()).thenReturn("0");
appcRunTasks.runAppcCommand(execution, Action.Lock);
@@ -125,14 +119,12 @@ public class AppcRunTasksTest extends BaseTaskTest {
execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "SUCCESS-TEST");
fillRequiredAppcExecutionFields();
GenericVnf genericVnf = getTestGenericVnf();
- when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID)))
- .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
mockReferenceResponse();
execution.getLookupMap().put(ResourceKey.VF_MODULE_ID, "VF-MODULE-ID-TEST");
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("VF-MODULE-ID");
- when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID)))
- .thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
when(appCClient.getErrorCode()).thenReturn("0");
appcRunTasks.runAppcCommand(execution, Action.Lock);
@@ -143,8 +135,8 @@ public class AppcRunTasksTest extends BaseTaskTest {
private void mockReferenceResponse() {
ControllerSelectionReference reference = new ControllerSelectionReference();
reference.setControllerName("TEST-CONTROLLER-NAME");
- when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(
- eq("TEST-VNF-TYPE"), eq(Action.Lock.toString()))).thenReturn(reference);
+ when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(eq("TEST-VNF-TYPE"),
+ eq(Action.Lock.toString()))).thenReturn(reference);
}
private void fillRequiredAppcExecutionFields() {
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/audit/AuditTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/audit/AuditTasksTest.java
index 3542d7fdb3..3bf24291ea 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/audit/AuditTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/audit/AuditTasksTest.java
@@ -23,7 +23,6 @@ import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -38,37 +37,39 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.client.exception.BBObjectNotFoundException;
-public class AuditTasksTest extends BaseTaskTest{
-
- @InjectMocks
- private AuditTasks auditTasks = new AuditTasks();
- private ServiceInstance serviceInstance;
- private GenericVnf genericVnf;
- private VfModule vfModule;
+public class AuditTasksTest extends BaseTaskTest {
+
+ @InjectMocks
+ private AuditTasks auditTasks = new AuditTasks();
+ private ServiceInstance serviceInstance;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+
+
+ @Rule
+ public final ExpectedException exception = ExpectedException.none();
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ setCloudRegion();
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ }
-
- @Rule
- public final ExpectedException exception = ExpectedException.none();
-
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- setCloudRegion();
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- }
-
- @Test
- public void setupAuditVariableTest() throws Exception {
- AuditInventory expectedAuditInventory = new AuditInventory();
- expectedAuditInventory.setCloudOwner("testCloudOwner");
- expectedAuditInventory.setCloudRegion("testLcpCloudRegionId");
- expectedAuditInventory.setHeatStackName("testVfModuleName1");
- expectedAuditInventory.setTenantId("testTenantId");
- auditTasks.setupAuditVariable(execution);
- assertThat((AuditInventory)execution.getVariable("auditInventory"), sameBeanAs(expectedAuditInventory));
- }
+ @Test
+ public void setupAuditVariableTest() throws Exception {
+ AuditInventory expectedAuditInventory = new AuditInventory();
+ expectedAuditInventory.setCloudOwner("testCloudOwner");
+ expectedAuditInventory.setCloudRegion("testLcpCloudRegionId");
+ expectedAuditInventory.setHeatStackName("testVfModuleName1");
+ expectedAuditInventory.setTenantId("testTenantId");
+ auditTasks.setupAuditVariable(execution);
+ assertThat((AuditInventory) execution.getVariable("auditInventory"), sameBeanAs(expectedAuditInventory));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java
index d1d167e561..0a880ad0e5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java
@@ -29,16 +29,18 @@ import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
public class ActivateVfModuleTest extends BaseTaskTest {
-
- @InjectMocks
- private ActivateVfModule activateVfModule = new ActivateVfModule();
-
- @Test
- public void setWaitBeforeDurationTest() throws Exception {
- when(env.getProperty(ActivateVfModule.VF_MODULE_TIMER_DURATION_PATH, ActivateVfModule.DEFAULT_TIMER_DURATION)).thenReturn("PT300S");
- activateVfModule.setTimerDuration(execution);
- verify(env, times(1)).getProperty(ActivateVfModule.VF_MODULE_TIMER_DURATION_PATH, ActivateVfModule.DEFAULT_TIMER_DURATION);
- assertEquals("PT300S", (String) execution.getVariable("vfModuleActivateTimerDuration"));
- }
+
+ @InjectMocks
+ private ActivateVfModule activateVfModule = new ActivateVfModule();
+
+ @Test
+ public void setWaitBeforeDurationTest() throws Exception {
+ when(env.getProperty(ActivateVfModule.VF_MODULE_TIMER_DURATION_PATH, ActivateVfModule.DEFAULT_TIMER_DURATION))
+ .thenReturn("PT300S");
+ activateVfModule.setTimerDuration(execution);
+ verify(env, times(1)).getProperty(ActivateVfModule.VF_MODULE_TIMER_DURATION_PATH,
+ ActivateVfModule.DEFAULT_TIMER_DURATION);
+ assertEquals("PT300S", (String) execution.getVariable("vfModuleActivateTimerDuration"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtilsTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtilsTest.java
index e7f841fa47..8ca0e79c6e 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtilsTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtilsTest.java
@@ -20,7 +20,6 @@
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import static org.junit.Assert.assertEquals;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -28,34 +27,34 @@ import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
public class AssignNetworkBBUtilsTest extends BaseTaskTest {
-
- @InjectMocks
- private AssignNetworkBBUtils nonMockAssignNetworkBBUtils = new AssignNetworkBBUtils();
-
- private CloudRegion cloudRegion;
-
- @Before
- public void before() {
- cloudRegion = setCloudRegion();
- }
-
- @Test
- public void getCloudRegionTest25() throws Exception {
- cloudRegion.setCloudRegionVersion("2.5");
-
- nonMockAssignNetworkBBUtils.getCloudRegion(execution);
-
- assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionPo"));
- assertEquals("AAIAIC25", execution.getVariable("cloudRegionSdnc"));
- }
-
- @Test
- public void getCloudRegionTest30() throws Exception {
- cloudRegion.setCloudRegionVersion("3.0");
-
- nonMockAssignNetworkBBUtils.getCloudRegion(execution);
-
- assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionPo"));
- assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionSdnc"));
- }
+
+ @InjectMocks
+ private AssignNetworkBBUtils nonMockAssignNetworkBBUtils = new AssignNetworkBBUtils();
+
+ private CloudRegion cloudRegion;
+
+ @Before
+ public void before() {
+ cloudRegion = setCloudRegion();
+ }
+
+ @Test
+ public void getCloudRegionTest25() throws Exception {
+ cloudRegion.setCloudRegionVersion("2.5");
+
+ nonMockAssignNetworkBBUtils.getCloudRegion(execution);
+
+ assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionPo"));
+ assertEquals("AAIAIC25", execution.getVariable("cloudRegionSdnc"));
+ }
+
+ @Test
+ public void getCloudRegionTest30() throws Exception {
+ cloudRegion.setCloudRegionVersion("3.0");
+
+ nonMockAssignNetworkBBUtils.getCloudRegion(execution);
+
+ assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionPo"));
+ assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionSdnc"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java
index 19981bc45a..d7a5dbd8f0 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java
@@ -24,7 +24,6 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -38,39 +37,40 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
public class AssignNetworkTest extends BaseTaskTest {
-
- @InjectMocks
- private AssignNetwork assignNetwork = new AssignNetwork();
-
- private L3Network network;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- network = setL3Network();
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- }
-
- @Test
- public void networkNotFoundTest() throws Exception {
- //network status to PRECREATED - when it was NOT found by name
- try {
- network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- } catch(BBObjectNotFoundException e) {
- }
-
- network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- boolean networkFound = assignNetwork.networkFoundByName(execution);
- assertEquals(false, networkFound);
- }
- @Test
- public void networkFoundTest() throws Exception {
- try {
- network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
- } catch(BBObjectNotFoundException e) {
- }
- boolean networkFound = assignNetwork.networkFoundByName(execution);
- assertEquals(true, networkFound);
- }
+ @InjectMocks
+ private AssignNetwork assignNetwork = new AssignNetwork();
+
+ private L3Network network;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ network = setL3Network();
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ }
+
+ @Test
+ public void networkNotFoundTest() throws Exception {
+ // network status to PRECREATED - when it was NOT found by name
+ try {
+ network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ } catch (BBObjectNotFoundException e) {
+ }
+
+ network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ boolean networkFound = assignNetwork.networkFoundByName(execution);
+ assertEquals(false, networkFound);
+ }
+
+ @Test
+ public void networkFoundTest() throws Exception {
+ try {
+ network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ } catch (BBObjectNotFoundException e) {
+ }
+ boolean networkFound = assignNetwork.networkFoundByName(execution);
+ assertEquals(true, networkFound);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java
index 834990db5a..06ad66e855 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java
@@ -28,9 +28,7 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -48,94 +46,103 @@ import org.onap.so.client.aai.entities.AAIEdgeLabel;
import org.onap.so.client.exception.BBObjectNotFoundException;
public class AssignVnfTest extends BaseTaskTest {
- @InjectMocks
- private AssignVnf assignVnf = new AssignVnf();
-
- @Mock
- private AAIObjectInstanceNameGenerator aaiObjectInstanceNameGenerator = new AAIObjectInstanceNameGenerator();
-
- private InstanceGroup instanceGroup1;
- private InstanceGroup instanceGroup2;
- private InstanceGroup instanceGroup3;
- private InstanceGroup instanceGroup4;
- private GenericVnf genericVnf;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
- modelVnfc.setType("VNFC");
- modelVnfc.setFunction("function");
-
- ModelInfoInstanceGroup modelNetworkInstanceGroup = new ModelInfoInstanceGroup();
- modelNetworkInstanceGroup.setType("L3-NETWORK");
- modelNetworkInstanceGroup.setFunction("function");
-
- instanceGroup1 = new InstanceGroup();
- instanceGroup1.setId("test-001");
- instanceGroup1.setModelInfoInstanceGroup(modelVnfc);
-
- instanceGroup2 = new InstanceGroup();
- instanceGroup2.setId("test-002");
- instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
-
- instanceGroup3 = new InstanceGroup();
- instanceGroup3.setId("test-003");
- instanceGroup3.setModelInfoInstanceGroup(modelNetworkInstanceGroup);
-
- instanceGroup4 = new InstanceGroup();
- instanceGroup4.setId("test-004");
- instanceGroup4.setModelInfoInstanceGroup(modelNetworkInstanceGroup);
-
- genericVnf = setGenericVnf();
- genericVnf.setVnfName("vnfName");
-
-
- doNothing().when(aaiInstanceGroupResources).createInstanceGroup(isA(InstanceGroup.class));
- doNothing().when(aaiInstanceGroupResources).connectInstanceGroupToVnf(isA(InstanceGroup.class), isA(GenericVnf.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
-
- @Test
- public void createInstanceGroupsSunnyDayTest() throws Exception {
-
- List<InstanceGroup> instanceGroupList = genericVnf.getInstanceGroups();
- instanceGroupList.add(instanceGroup1);
- instanceGroupList.add(instanceGroup2);
- instanceGroupList.add(instanceGroup3);
- instanceGroupList.add(instanceGroup4);
-
-
- assignVnf.createInstanceGroups(execution);
- verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup1);
- verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup2);
- verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup1, genericVnf, AAIEdgeLabel.BELONGS_TO);
- verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup2, genericVnf, AAIEdgeLabel.BELONGS_TO);
- verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup3, genericVnf, AAIEdgeLabel.USES);
- verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup4, genericVnf, AAIEdgeLabel.USES);
- }
-
- @Test
- public void createVnfcInstanceGroupNoneTest() throws Exception {
- assignVnf.createInstanceGroups(execution);
-
-
- verify(aaiInstanceGroupResources, times(0)).createInstanceGroup(any(InstanceGroup.class));
- verify(aaiInstanceGroupResources, times(0)).connectInstanceGroupToVnf(any(InstanceGroup.class), any(GenericVnf.class));
- }
-
- @Test
- public void createVnfcInstanceGroupExceptionTest() throws Exception {
- List<InstanceGroup> instanceGroupList = genericVnf.getInstanceGroups();
- instanceGroupList.add(instanceGroup1);
- instanceGroupList.add(instanceGroup2);
- instanceGroupList.add(instanceGroup3);
- instanceGroupList.add(instanceGroup4);
- doThrow(RuntimeException.class).when(aaiInstanceGroupResources).createInstanceGroup(isA(InstanceGroup.class));
- expectedException.expect(BpmnError.class);
-
- genericVnf.setVnfId("test-999");
- assignVnf.createInstanceGroups(execution);
- }
+ @InjectMocks
+ private AssignVnf assignVnf = new AssignVnf();
+
+ @Mock
+ private AAIObjectInstanceNameGenerator aaiObjectInstanceNameGenerator = new AAIObjectInstanceNameGenerator();
+
+ private InstanceGroup instanceGroup1;
+ private InstanceGroup instanceGroup2;
+ private InstanceGroup instanceGroup3;
+ private InstanceGroup instanceGroup4;
+ private GenericVnf genericVnf;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
+ modelVnfc.setType("VNFC");
+ modelVnfc.setFunction("function");
+
+ ModelInfoInstanceGroup modelNetworkInstanceGroup = new ModelInfoInstanceGroup();
+ modelNetworkInstanceGroup.setType("L3-NETWORK");
+ modelNetworkInstanceGroup.setFunction("function");
+
+ instanceGroup1 = new InstanceGroup();
+ instanceGroup1.setId("test-001");
+ instanceGroup1.setModelInfoInstanceGroup(modelVnfc);
+
+ instanceGroup2 = new InstanceGroup();
+ instanceGroup2.setId("test-002");
+ instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
+
+ instanceGroup3 = new InstanceGroup();
+ instanceGroup3.setId("test-003");
+ instanceGroup3.setModelInfoInstanceGroup(modelNetworkInstanceGroup);
+
+ instanceGroup4 = new InstanceGroup();
+ instanceGroup4.setId("test-004");
+ instanceGroup4.setModelInfoInstanceGroup(modelNetworkInstanceGroup);
+
+ genericVnf = setGenericVnf();
+ genericVnf.setVnfName("vnfName");
+
+
+ doNothing().when(aaiInstanceGroupResources).createInstanceGroup(isA(InstanceGroup.class));
+ doNothing().when(aaiInstanceGroupResources).connectInstanceGroupToVnf(isA(InstanceGroup.class),
+ isA(GenericVnf.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ }
+
+ @Test
+ public void createInstanceGroupsSunnyDayTest() throws Exception {
+
+ List<InstanceGroup> instanceGroupList = genericVnf.getInstanceGroups();
+ instanceGroupList.add(instanceGroup1);
+ instanceGroupList.add(instanceGroup2);
+ instanceGroupList.add(instanceGroup3);
+ instanceGroupList.add(instanceGroup4);
+
+
+ assignVnf.createInstanceGroups(execution);
+ verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup1);
+ verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup2);
+ verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup1, genericVnf,
+ AAIEdgeLabel.BELONGS_TO);
+ verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup2, genericVnf,
+ AAIEdgeLabel.BELONGS_TO);
+ verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup3, genericVnf,
+ AAIEdgeLabel.USES);
+ verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup4, genericVnf,
+ AAIEdgeLabel.USES);
+ }
+
+ @Test
+ public void createVnfcInstanceGroupNoneTest() throws Exception {
+ assignVnf.createInstanceGroups(execution);
+
+
+ verify(aaiInstanceGroupResources, times(0)).createInstanceGroup(any(InstanceGroup.class));
+ verify(aaiInstanceGroupResources, times(0)).connectInstanceGroupToVnf(any(InstanceGroup.class),
+ any(GenericVnf.class));
+ }
+
+ @Test
+ public void createVnfcInstanceGroupExceptionTest() throws Exception {
+ List<InstanceGroup> instanceGroupList = genericVnf.getInstanceGroups();
+ instanceGroupList.add(instanceGroup1);
+ instanceGroupList.add(instanceGroup2);
+ instanceGroupList.add(instanceGroup3);
+ instanceGroupList.add(instanceGroup4);
+ doThrow(RuntimeException.class).when(aaiInstanceGroupResources).createInstanceGroup(isA(InstanceGroup.class));
+ expectedException.expect(BpmnError.class);
+
+ genericVnf.setVnfId("test-999");
+ assignVnf.createInstanceGroups(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtilsTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtilsTest.java
index 125c97109c..99516e69e3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtilsTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CloudSiteCatalogUtilsTest.java
@@ -25,64 +25,63 @@ import java.util.Optional;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
-
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
public class CloudSiteCatalogUtilsTest extends BaseTaskTest {
-
- @InjectMocks
- private CloudSiteCatalogUtils cloudSiteCatalogUtils = new CloudSiteCatalogUtils();
-
- @Test
- public void testGetCloudSiteGetVersion30Test() throws Exception {
- CloudSite cloudSite = new CloudSite();
- String testCloudSiteId = "testCloudSiteId";
- cloudSite.setClli(testCloudSiteId);
- doReturn(cloudSite).when(catalogDbClient).getCloudSite(testCloudSiteId);
- Optional<CloudSite> actualCloudSite = cloudSiteCatalogUtils.getCloudSite(testCloudSiteId);
- assertEquals(actualCloudSite.get().getClli(), testCloudSiteId);
- }
-
- @Test
- public void testGetCloudSiteGetVersion25Test() throws Exception {
- CloudSite cloudSite = new CloudSite();
- String testCloudSiteId = "testCloudSiteId";
- cloudSite.setClli(testCloudSiteId);
- doReturn(null).when(catalogDbClient).getCloudSite(testCloudSiteId);
- doReturn(cloudSite).when(catalogDbClient).getCloudSiteByClliAndAicVersion(testCloudSiteId, "2.5");
- Optional<CloudSite> actualCloudSite = cloudSiteCatalogUtils.getCloudSite(testCloudSiteId);
- assertEquals(actualCloudSite.get().getClli(), testCloudSiteId);
- }
-
- @Test
- public void testGetIdentityUrlFromCloudSiteSuccessTest() throws Exception {
- CloudSite cloudSite = new CloudSite();
- String testCloudSiteId = "testCloudSiteId";
- String testIdentityUrl = "testIdentityUrl";
- delegateExecution.setVariable("lcpCloudRegionId", testCloudSiteId);
- cloudSite.setClli(testCloudSiteId);
- CloudIdentity cloudIdentity = new CloudIdentity();
- cloudIdentity.setIdentityUrl(testIdentityUrl);
- cloudSite.setIdentityService(cloudIdentity);
- doReturn(cloudSite).when(catalogDbClient).getCloudSite(testCloudSiteId);
- cloudSiteCatalogUtils.getIdentityUrlFromCloudSite(delegateExecution);
- String actualIdentityUrl = (String) delegateExecution.getVariable("identityUrl");
- assertEquals(testIdentityUrl, actualIdentityUrl);
- }
-
- @Test
- public void testGetIdentityUrlFromCloudSiteNoCloudIdProvidedTest() throws Exception {
- CloudSite cloudSite = new CloudSite();
- String testCloudSiteId = "testCloudSiteId";
- String testIdentityUrl = "testIdentityUrl";
- cloudSite.setClli(testCloudSiteId);
- CloudIdentity cloudIdentity = new CloudIdentity();
- cloudIdentity.setIdentityUrl(testIdentityUrl);
- cloudSite.setIdentityService(cloudIdentity);
- doReturn(cloudSite).when(catalogDbClient).getCloudSite(testCloudSiteId);
- cloudSiteCatalogUtils.getIdentityUrlFromCloudSite(delegateExecution);
- String actualIdentityUrl = (String) delegateExecution.getVariable("identityUrl");
- assertEquals(null, actualIdentityUrl);
- }
+
+ @InjectMocks
+ private CloudSiteCatalogUtils cloudSiteCatalogUtils = new CloudSiteCatalogUtils();
+
+ @Test
+ public void testGetCloudSiteGetVersion30Test() throws Exception {
+ CloudSite cloudSite = new CloudSite();
+ String testCloudSiteId = "testCloudSiteId";
+ cloudSite.setClli(testCloudSiteId);
+ doReturn(cloudSite).when(catalogDbClient).getCloudSite(testCloudSiteId);
+ Optional<CloudSite> actualCloudSite = cloudSiteCatalogUtils.getCloudSite(testCloudSiteId);
+ assertEquals(actualCloudSite.get().getClli(), testCloudSiteId);
+ }
+
+ @Test
+ public void testGetCloudSiteGetVersion25Test() throws Exception {
+ CloudSite cloudSite = new CloudSite();
+ String testCloudSiteId = "testCloudSiteId";
+ cloudSite.setClli(testCloudSiteId);
+ doReturn(null).when(catalogDbClient).getCloudSite(testCloudSiteId);
+ doReturn(cloudSite).when(catalogDbClient).getCloudSiteByClliAndAicVersion(testCloudSiteId, "2.5");
+ Optional<CloudSite> actualCloudSite = cloudSiteCatalogUtils.getCloudSite(testCloudSiteId);
+ assertEquals(actualCloudSite.get().getClli(), testCloudSiteId);
+ }
+
+ @Test
+ public void testGetIdentityUrlFromCloudSiteSuccessTest() throws Exception {
+ CloudSite cloudSite = new CloudSite();
+ String testCloudSiteId = "testCloudSiteId";
+ String testIdentityUrl = "testIdentityUrl";
+ delegateExecution.setVariable("lcpCloudRegionId", testCloudSiteId);
+ cloudSite.setClli(testCloudSiteId);
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setIdentityUrl(testIdentityUrl);
+ cloudSite.setIdentityService(cloudIdentity);
+ doReturn(cloudSite).when(catalogDbClient).getCloudSite(testCloudSiteId);
+ cloudSiteCatalogUtils.getIdentityUrlFromCloudSite(delegateExecution);
+ String actualIdentityUrl = (String) delegateExecution.getVariable("identityUrl");
+ assertEquals(testIdentityUrl, actualIdentityUrl);
+ }
+
+ @Test
+ public void testGetIdentityUrlFromCloudSiteNoCloudIdProvidedTest() throws Exception {
+ CloudSite cloudSite = new CloudSite();
+ String testCloudSiteId = "testCloudSiteId";
+ String testIdentityUrl = "testIdentityUrl";
+ cloudSite.setClli(testCloudSiteId);
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setIdentityUrl(testIdentityUrl);
+ cloudSite.setIdentityService(cloudIdentity);
+ doReturn(cloudSite).when(catalogDbClient).getCloudSite(testCloudSiteId);
+ cloudSiteCatalogUtils.getIdentityUrlFromCloudSite(delegateExecution);
+ String actualIdentityUrl = (String) delegateExecution.getVariable("identityUrl");
+ assertEquals(null, actualIdentityUrl);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java
index 07983ccd50..7d96a18305 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigAssignVnfTest.java
@@ -25,9 +25,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-
import java.util.UUID;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java
index e5aa702dad..6f76c83c6f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java
@@ -1,23 +1,18 @@
/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2019 TechMahindra
-*=================================================================================
-* 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=========================================================
-*/
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright 2019 TechMahindra
+ * ================================================================================= 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.flowspecific.tasks;
@@ -26,9 +21,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-
import java.util.UUID;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -46,52 +39,55 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
public class ConfigDeployVnfTest extends BaseTaskTest {
- @InjectMocks
- private ConfigDeployVnf configDeployVnf = new ConfigDeployVnf();
- @Mock
- AAIUpdateTasks aAIUpdateTasks = new AAIUpdateTasks();
-
-
- private GenericVnf genericVnf;
- private ServiceInstance serviceInstance;
- private RequestContext requestContext;
- private String msoRequestId;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- genericVnf = setGenericVnf();
- serviceInstance = setServiceInstance();
- msoRequestId = UUID.randomUUID().toString();
- requestContext = setRequestContext();
- requestContext.setMsoRequestId(msoRequestId);
- gBBInput.setRequestContext(requestContext);
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- }
-
-
-
- @Test
- public void preProcessAbstractCDSProcessingTest() throws Exception {
-
- configDeployVnf.preProcessAbstractCDSProcessing(execution);
-
- assertTrue(true);
- }
-
- @Test
- public void updateAAIConfigureTaskTest() throws Exception {
-
- configDeployVnf.updateAAIConfigure(execution);
- assertTrue(true);
- }
-
- @Test
- public void updateAAIConfiguredTaskTest() throws Exception {
- configDeployVnf.updateAAIConfigured(execution);
- assertTrue(true);
- }
+ @InjectMocks
+ private ConfigDeployVnf configDeployVnf = new ConfigDeployVnf();
+ @Mock
+ AAIUpdateTasks aAIUpdateTasks = new AAIUpdateTasks();
+
+
+ private GenericVnf genericVnf;
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private String msoRequestId;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ genericVnf = setGenericVnf();
+ serviceInstance = setServiceInstance();
+ msoRequestId = UUID.randomUUID().toString();
+ requestContext = setRequestContext();
+ requestContext.setMsoRequestId(msoRequestId);
+ gBBInput.setRequestContext(requestContext);
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ }
+
+
+
+ @Test
+ public void preProcessAbstractCDSProcessingTest() throws Exception {
+
+ configDeployVnf.preProcessAbstractCDSProcessing(execution);
+
+ assertTrue(true);
+ }
+
+ @Test
+ public void updateAAIConfigureTaskTest() throws Exception {
+
+ configDeployVnf.updateAAIConfigure(execution);
+ assertTrue(true);
+ }
+
+ @Test
+ public void updateAAIConfiguredTaskTest() throws Exception {
+ configDeployVnf.updateAAIConfigured(execution);
+ assertTrue(true);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java
index 6390268a0c..4d43bbbce7 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
@@ -37,7 +36,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -54,137 +52,153 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
public class ConfigurationScaleOutTest extends BaseTaskTest {
-
- @InjectMocks
- private ConfigurationScaleOut configurationScaleOut = new ConfigurationScaleOut();
-
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private RequestContext requestContext;
- private String msoRequestId;
- private List<Map<String, String>> configurationParameters = new ArrayList<>();
- private Map<String, String> configParamsMap = new HashMap<>();
-
-
-
- @Before
- public void before() throws BBObjectNotFoundException {
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- msoRequestId = UUID.randomUUID().toString();
- requestContext = setRequestContext();
- requestContext.setMsoRequestId(msoRequestId);
- configParamsMap.put("availability-zone", "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]");
- configParamsMap.put("vnf-id", "$.vnf-topology.vnf-topology-identifier-structure.vnf-id");
- configurationParameters.add(configParamsMap);
- requestContext.setConfigurationParameters(configurationParameters);
- gBBInput.setRequestContext(requestContext);
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
-
- }
-
- @Test
- public void setParamsForConfigurationScaleOutTest() throws Exception {
- ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
- controllerSelectionReference.setControllerName("testName");
- controllerSelectionReference.setActionCategory("testAction");
- controllerSelectionReference.setVnfType("testVnfType");
- String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientGetResponse.json")));
- String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
- + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
- + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
- execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse);
-
- doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.ConfigScaleOut.toString());
-
- configurationScaleOut.setParamsForConfigurationScaleOut(execution);
-
- assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
- assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
- assertEquals("ConfigScaleOut", execution.getVariable("action"));
- assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
- assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
- assertEquals(vfModule.getVfModuleId(), execution.getVariable("vfModuleId"));
- assertEquals(expectedPayload, execution.getVariable("payload"));
- }
- @Test
- public void callAppcClientTest() throws Exception {
- Action action = Action.ConfigScaleOut;
- String vnfId = genericVnf.getVnfId();
- String controllerType = "testType";
- String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
- + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
- + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- payloadInfo.put("vfModuleId", "testVfModuleId");
-
- execution.setVariable("action", Action.ConfigScaleOut.toString());
- execution.setVariable("msoRequestId", msoRequestId);
- execution.setVariable("controllerType", controllerType);
- execution.setVariable("vnfId", "testVnfId1");
- execution.setVariable("vnfName", "testVnfName");
- execution.setVariable("vfModuleId", "testVfModuleId");
- execution.setVariable("payload", payload);
-
- doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
-
- configurationScaleOut.callAppcClient(execution);
- verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- }
- @Test
- public void setParamsForConfigurationScaleOutBadPathTest() throws Exception {
- ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
- controllerSelectionReference.setControllerName("testName");
- controllerSelectionReference.setActionCategory("testAction");
- controllerSelectionReference.setVnfType("testVnfType");
- String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientResponseIncorrectPath.json")));
- String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
- + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
- + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":null}}";
- execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse);
-
- doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.ConfigScaleOut.toString());
-
- configurationScaleOut.setParamsForConfigurationScaleOut(execution);
-
- assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
- assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
- assertEquals("ConfigScaleOut", execution.getVariable("action"));
- assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
- assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
- assertEquals(vfModule.getVfModuleId(), execution.getVariable("vfModuleId"));
- assertEquals(expectedPayload, execution.getVariable("payload"));
- }
-
- @Test
- public void callAppcClientExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- Action action = Action.ConfigScaleOut;
- String vnfId = genericVnf.getVnfId();
- String controllerType = "testType";
- String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
- + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
- + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- payloadInfo.put("vfModuleId", "testVfModuleId");
-
- execution.setVariable("action", Action.ConfigScaleOut.toString());
- execution.setVariable("msoRequestId", msoRequestId);
- execution.setVariable("controllerType", controllerType);
- execution.setVariable("vnfId", "testVnfId1");
- execution.setVariable("vnfName", "testVnfName");
- execution.setVariable("vfModuleId", "testVfModuleId");
- execution.setVariable("payload", payload);
-
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed"));
- doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- configurationScaleOut.callAppcClient(execution);
- verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- }
+
+ @InjectMocks
+ private ConfigurationScaleOut configurationScaleOut = new ConfigurationScaleOut();
+
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private RequestContext requestContext;
+ private String msoRequestId;
+ private List<Map<String, String>> configurationParameters = new ArrayList<>();
+ private Map<String, String> configParamsMap = new HashMap<>();
+
+
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ msoRequestId = UUID.randomUUID().toString();
+ requestContext = setRequestContext();
+ requestContext.setMsoRequestId(msoRequestId);
+ configParamsMap.put("availability-zone",
+ "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]");
+ configParamsMap.put("vnf-id", "$.vnf-topology.vnf-topology-identifier-structure.vnf-id");
+ configurationParameters.add(configParamsMap);
+ requestContext.setConfigurationParameters(configurationParameters);
+ gBBInput.setRequestContext(requestContext);
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+
+ }
+
+ @Test
+ public void setParamsForConfigurationScaleOutTest() throws Exception {
+ ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
+ controllerSelectionReference.setControllerName("testName");
+ controllerSelectionReference.setActionCategory("testAction");
+ controllerSelectionReference.setVnfType("testVnfType");
+ String sdncResponse =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientGetResponse.json")));
+ String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+ + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+ + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
+ execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse);
+
+ doReturn(controllerSelectionReference).when(catalogDbClient)
+ .getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(),
+ Action.ConfigScaleOut.toString());
+
+ configurationScaleOut.setParamsForConfigurationScaleOut(execution);
+
+ assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
+ assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
+ assertEquals("ConfigScaleOut", execution.getVariable("action"));
+ assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
+ assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
+ assertEquals(vfModule.getVfModuleId(), execution.getVariable("vfModuleId"));
+ assertEquals(expectedPayload, execution.getVariable("payload"));
+ }
+
+ @Test
+ public void callAppcClientTest() throws Exception {
+ Action action = Action.ConfigScaleOut;
+ String vnfId = genericVnf.getVnfId();
+ String controllerType = "testType";
+ String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+ + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+ + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ payloadInfo.put("vfModuleId", "testVfModuleId");
+
+ execution.setVariable("action", Action.ConfigScaleOut.toString());
+ execution.setVariable("msoRequestId", msoRequestId);
+ execution.setVariable("controllerType", controllerType);
+ execution.setVariable("vnfId", "testVnfId1");
+ execution.setVariable("vnfName", "testVnfName");
+ execution.setVariable("vfModuleId", "testVfModuleId");
+ execution.setVariable("payload", payload);
+
+ doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+
+ configurationScaleOut.callAppcClient(execution);
+ verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+ }
+
+ @Test
+ public void setParamsForConfigurationScaleOutBadPathTest() throws Exception {
+ ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
+ controllerSelectionReference.setControllerName("testName");
+ controllerSelectionReference.setActionCategory("testAction");
+ controllerSelectionReference.setVnfType("testVnfType");
+ String sdncResponse = new String(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientResponseIncorrectPath.json")));
+ String expectedPayload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+ + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+ + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":null}}";
+ execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), sdncResponse);
+
+ doReturn(controllerSelectionReference).when(catalogDbClient)
+ .getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(),
+ Action.ConfigScaleOut.toString());
+
+ configurationScaleOut.setParamsForConfigurationScaleOut(execution);
+
+ assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
+ assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
+ assertEquals("ConfigScaleOut", execution.getVariable("action"));
+ assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
+ assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
+ assertEquals(vfModule.getVfModuleId(), execution.getVariable("vfModuleId"));
+ assertEquals(expectedPayload, execution.getVariable("payload"));
+ }
+
+ @Test
+ public void callAppcClientExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ Action action = Action.ConfigScaleOut;
+ String vnfId = genericVnf.getVnfId();
+ String controllerType = "testType";
+ String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"10.222.22.2\","
+ + "\"vf-module-id\":\"testVfModuleId1\"},\"configuration-parameters\""
+ + ":{\"vnf-id\":\"66dac89b-2a5b-4cb9-b22e-a7e4488fb3db\",\"availability-zone\":\"AZ-MN02\"}}";
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ payloadInfo.put("vfModuleId", "testVfModuleId");
+
+ execution.setVariable("action", Action.ConfigScaleOut.toString());
+ execution.setVariable("msoRequestId", msoRequestId);
+ execution.setVariable("controllerType", controllerType);
+ execution.setVariable("vnfId", "testVnfId1");
+ execution.setVariable("vnfName", "testVnfName");
+ execution.setVariable("vfModuleId", "testVfModuleId");
+ execution.setVariable("payload", payload);
+
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed"));
+ doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId,
+ Optional.of(payload), payloadInfo, controllerType);
+ configurationScaleOut.callAppcClient(execution);
+ verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollectionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollectionTest.java
index 423029c59b..f0889f62c0 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollectionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollectionTest.java
@@ -18,6 +18,7 @@
* ============LICENSE_END=========================================================
*/
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
+
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@@ -26,10 +27,8 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.ArrayList;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -45,73 +44,84 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
import org.onap.so.client.exception.BBObjectNotFoundException;
-public class CreateNetworkCollectionTest extends BaseTaskTest{
- @InjectMocks
- private CreateNetworkCollection createNetworkCollection = new CreateNetworkCollection();
-
- private L3Network network;
- private ServiceInstance serviceInstance;
- private OrchestrationContext orchestrationContext;
- private CloudRegion cloudRegion;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- network = setL3Network();
- cloudRegion = setCloudRegion();
-
- List<L3Network> l3NetworkList = new ArrayList<L3Network>();
- l3NetworkList.add(network);
- ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
- modelInfoInstanceGroup.setFunction("function");
- serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
-
- orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- }
-
- @Test
- public void buildCreateNetworkRequestTest() throws Exception {
- createNetworkCollection.buildNetworkCollectionName(execution);
-
- assertEquals(serviceInstance.getServiceInstanceName() + "_" + serviceInstance.getCollection().getInstanceGroup().getModelInfoInstanceGroup().getFunction(), execution.getVariable("networkCollectionName"));
- }
-
- @Test(expected = BpmnError.class)
- public void buildCreateNetworkRequestInstanceGroupModelInfoFunctionNullExceptionTest() throws Exception {
- ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
- serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
- createNetworkCollection.buildNetworkCollectionName(execution);
- }
-
- @Test(expected = BpmnError.class)
- public void buildCreateNetworkRequestInstanceGroupModelInfoNullTest() throws Exception {
- serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(null);
- createNetworkCollection.buildNetworkCollectionName(execution);
- }
-
- @Test
- public void connectCollectionToInstanceGroupTest() throws Exception {
- doNothing().when(aaiNetworkResources).connectNetworkCollectionInstanceGroupToNetworkCollection(serviceInstance.getCollection().getInstanceGroup(), serviceInstance.getCollection());
- createNetworkCollection.connectCollectionToInstanceGroup(execution);
- verify(aaiNetworkResources, times(1)).connectNetworkCollectionInstanceGroupToNetworkCollection(serviceInstance.getCollection().getInstanceGroup(), serviceInstance.getCollection());
- }
-
- @Test
- public void connectCollectionToServiceInstanceTest() throws Exception {
- doNothing().when(aaiNetworkResources).connectNetworkCollectionToServiceInstance(serviceInstance.getCollection(), serviceInstance);
- createNetworkCollection.connectCollectionToServiceInstance(execution);
- verify(aaiNetworkResources, times(1)).connectNetworkCollectionToServiceInstance(serviceInstance.getCollection(), serviceInstance);
- }
-
- @Test
- public void connectInstanceGroupToCloudRegionTest() throws Exception {
- doNothing().when(aaiNetworkResources).connectInstanceGroupToCloudRegion(serviceInstance.getCollection().getInstanceGroup(), cloudRegion);
- createNetworkCollection.connectInstanceGroupToCloudRegion(execution);
- verify(aaiNetworkResources, times(1)).connectInstanceGroupToCloudRegion(serviceInstance.getCollection().getInstanceGroup(), cloudRegion);
- }
+public class CreateNetworkCollectionTest extends BaseTaskTest {
+ @InjectMocks
+ private CreateNetworkCollection createNetworkCollection = new CreateNetworkCollection();
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private OrchestrationContext orchestrationContext;
+ private CloudRegion cloudRegion;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ network = setL3Network();
+ cloudRegion = setCloudRegion();
+
+ List<L3Network> l3NetworkList = new ArrayList<L3Network>();
+ l3NetworkList.add(network);
+ ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
+ modelInfoInstanceGroup.setFunction("function");
+ serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
+
+ orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ }
+
+ @Test
+ public void buildCreateNetworkRequestTest() throws Exception {
+ createNetworkCollection.buildNetworkCollectionName(execution);
+
+ assertEquals(
+ serviceInstance.getServiceInstanceName() + "_"
+ + serviceInstance.getCollection().getInstanceGroup().getModelInfoInstanceGroup().getFunction(),
+ execution.getVariable("networkCollectionName"));
+ }
+
+ @Test(expected = BpmnError.class)
+ public void buildCreateNetworkRequestInstanceGroupModelInfoFunctionNullExceptionTest() throws Exception {
+ ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
+ serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
+ createNetworkCollection.buildNetworkCollectionName(execution);
+ }
+
+ @Test(expected = BpmnError.class)
+ public void buildCreateNetworkRequestInstanceGroupModelInfoNullTest() throws Exception {
+ serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(null);
+ createNetworkCollection.buildNetworkCollectionName(execution);
+ }
+
+ @Test
+ public void connectCollectionToInstanceGroupTest() throws Exception {
+ doNothing().when(aaiNetworkResources).connectNetworkCollectionInstanceGroupToNetworkCollection(
+ serviceInstance.getCollection().getInstanceGroup(), serviceInstance.getCollection());
+ createNetworkCollection.connectCollectionToInstanceGroup(execution);
+ verify(aaiNetworkResources, times(1)).connectNetworkCollectionInstanceGroupToNetworkCollection(
+ serviceInstance.getCollection().getInstanceGroup(), serviceInstance.getCollection());
+ }
+
+ @Test
+ public void connectCollectionToServiceInstanceTest() throws Exception {
+ doNothing().when(aaiNetworkResources).connectNetworkCollectionToServiceInstance(serviceInstance.getCollection(),
+ serviceInstance);
+ createNetworkCollection.connectCollectionToServiceInstance(execution);
+ verify(aaiNetworkResources, times(1)).connectNetworkCollectionToServiceInstance(serviceInstance.getCollection(),
+ serviceInstance);
+ }
+
+ @Test
+ public void connectInstanceGroupToCloudRegionTest() throws Exception {
+ doNothing().when(aaiNetworkResources)
+ .connectInstanceGroupToCloudRegion(serviceInstance.getCollection().getInstanceGroup(), cloudRegion);
+ createNetworkCollection.connectInstanceGroupToCloudRegion(execution);
+ verify(aaiNetworkResources, times(1))
+ .connectInstanceGroupToCloudRegion(serviceInstance.getCollection().getInstanceGroup(), cloudRegion);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkTest.java
index de1aa63f55..1e0ab20d97 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkTest.java
@@ -26,9 +26,7 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.Map;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -45,47 +43,51 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.springframework.beans.factory.annotation.Autowired;
-public class CreateNetworkTest extends BaseTaskTest{
- @InjectMocks
- private CreateNetwork createNetwork = new CreateNetwork();
-
- private L3Network network;
- private ServiceInstance serviceInstance;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
- private Map<String, String> userInput;
- private RequestContext requestContext;
- private String cloudRegionPo = "testCloudRegionPo";
- private Customer customer;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- network = setL3Network();
- cloudRegion = setCloudRegion();
- orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
- requestContext = setRequestContext();
- userInput = setUserInput();
+public class CreateNetworkTest extends BaseTaskTest {
+ @InjectMocks
+ private CreateNetwork createNetwork = new CreateNetwork();
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+ private Map<String, String> userInput;
+ private RequestContext requestContext;
+ private String cloudRegionPo = "testCloudRegionPo";
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ network = setL3Network();
+ cloudRegion = setCloudRegion();
+ orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+ requestContext = setRequestContext();
+ userInput = setUserInput();
+
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ }
+
+ @Test
+ public void buildCreateNetworkRequestTest() throws Exception {
+ execution.setVariable("cloudRegionPo", cloudRegionPo);
+
+ CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
+
+ doReturn(expectedCreateNetworkRequest).when(networkAdapterObjectMapper).createNetworkRequestMapper(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, cloudRegionPo,
+ customer);
+
+ createNetwork.buildCreateNetworkRequest(execution);
+
+ verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, network, userInput, cloudRegionPo, customer);
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- }
-
- @Test
- public void buildCreateNetworkRequestTest() throws Exception {
- execution.setVariable("cloudRegionPo", cloudRegionPo);
-
- CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
-
- doReturn(expectedCreateNetworkRequest).when(networkAdapterObjectMapper).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, cloudRegionPo, customer);
-
- createNetwork.buildCreateNetworkRequest(execution);
-
- verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, cloudRegionPo, customer);
-
- assertThat(expectedCreateNetworkRequest, sameBeanAs(execution.getVariable("createNetworkRequest")));
- }
+ assertThat(expectedCreateNetworkRequest, sameBeanAs(execution.getVariable("createNetworkRequest")));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java
index 2386da743b..f23bbd8c91 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java
@@ -28,11 +28,9 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.HashMap;
import java.util.Optional;
import java.util.UUID;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Ignore;
@@ -49,128 +47,140 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
public class GenericVnfHealthCheckTest extends BaseTaskTest {
-
- @InjectMocks
- private GenericVnfHealthCheck genericVnfHealthCheck = new GenericVnfHealthCheck();
-
- private GenericVnf genericVnf;
- private RequestContext requestContext;
- private String msoRequestId;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- genericVnf = setGenericVnf();
- msoRequestId = UUID.randomUUID().toString();
- requestContext = setRequestContext();
- requestContext.setMsoRequestId(msoRequestId);
- gBBInput.setRequestContext(requestContext);
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- }
-
- @Test
- public void setParamsForGenericVnfHealthCheckTest() throws Exception {
- ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
- controllerSelectionReference.setControllerName("testName");
- controllerSelectionReference.setActionCategory("testAction");
- controllerSelectionReference.setVnfType("testVnfType");
-
- doReturn(controllerSelectionReference).when(catalogDbClient).getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(), Action.HealthCheck.toString());
-
- genericVnfHealthCheck.setParamsForGenericVnfHealthCheck(execution);
-
- assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
- assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
- assertEquals(genericVnf.getIpv4OamAddress(), execution.getVariable("oamIpAddress"));
- assertEquals("HealthCheck", execution.getVariable("action"));
- assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
- assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
- }
- @Test
- public void callAppcClientTest() throws Exception {
- Action action = Action.HealthCheck;
- String vnfId = genericVnf.getVnfId();
- String payload = "{\"testName\":\"testValue\",}";
- String controllerType = "testType";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- payloadInfo.put("vfModuleId", "testVfModuleId");
- payloadInfo.put("oamIpAddress", "testOamIpAddress");
- payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
- execution.setVariable("action", Action.HealthCheck.toString());
- execution.setVariable("msoRequestId", msoRequestId);
- execution.setVariable("controllerType", controllerType);
- execution.setVariable("vnfId", "testVnfId1");
- execution.setVariable("vnfName", "testVnfName");
- execution.setVariable("vfModuleId", "testVfModuleId");
- execution.setVariable("oamIpAddress", "testOamIpAddress");
- execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
- execution.setVariable("payload", payload);
-
- doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
-
- genericVnfHealthCheck.callAppcClient(execution);
- verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- }
-
- @Test
- public void callAppcClientExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- Action action = Action.HealthCheck;
- String vnfId = genericVnf.getVnfId();
- String payload = "{\"testName\":\"testValue\",}";
- String controllerType = "testType";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- payloadInfo.put("vfModuleId", "testVfModuleId");
- payloadInfo.put("oamIpAddress", "testOamIpAddress");
- payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
- execution.setVariable("action", Action.HealthCheck.toString());
- execution.setVariable("msoRequestId", msoRequestId);
- execution.setVariable("controllerType", controllerType);
- execution.setVariable("vnfId", "testVnfId1");
- execution.setVariable("vnfName", "testVnfName");
- execution.setVariable("vfModuleId", "testVfModuleId");
- execution.setVariable("oamIpAddress", "testOamIpAddress");
- execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
- execution.setVariable("payload", payload);
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed"));
- doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
-
-
- genericVnfHealthCheck.callAppcClient(execution);
- verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- }
-
- @Test
- @Ignore //The runAppCCommand method in not capable of throwing this exception
- public void callAppcClientTimeOutExceptionTest() {
- expectedException.expect(java.util.concurrent.TimeoutException.class);
- Action action = Action.HealthCheck;
- String vnfId = genericVnf.getVnfId();
- String payload = "{\"testName\":\"testValue\",}";
- String controllerType = "testType";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- payloadInfo.put("vfModuleId", "testVfModuleId");
- payloadInfo.put("oamIpAddress", "testOamIpAddress");
- payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
- execution.setVariable("action", Action.HealthCheck.toString());
- execution.setVariable("msoRequestId", msoRequestId);
- execution.setVariable("controllerType", controllerType);
- execution.setVariable("vnfId", "testVnfId1");
- execution.setVariable("vnfName", "testVnfName");
- execution.setVariable("vfModuleId", "testVfModuleId");
- execution.setVariable("oamIpAddress", "testOamIpAddress");
- execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
- execution.setVariable("payload", payload);
-
- doThrow(java.util.concurrent.TimeoutException.class).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
-
-
- genericVnfHealthCheck.callAppcClient(execution);
- verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
- }
+
+ @InjectMocks
+ private GenericVnfHealthCheck genericVnfHealthCheck = new GenericVnfHealthCheck();
+
+ private GenericVnf genericVnf;
+ private RequestContext requestContext;
+ private String msoRequestId;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ genericVnf = setGenericVnf();
+ msoRequestId = UUID.randomUUID().toString();
+ requestContext = setRequestContext();
+ requestContext.setMsoRequestId(msoRequestId);
+ gBBInput.setRequestContext(requestContext);
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ }
+
+ @Test
+ public void setParamsForGenericVnfHealthCheckTest() throws Exception {
+ ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
+ controllerSelectionReference.setControllerName("testName");
+ controllerSelectionReference.setActionCategory("testAction");
+ controllerSelectionReference.setVnfType("testVnfType");
+
+ doReturn(controllerSelectionReference).when(catalogDbClient)
+ .getControllerSelectionReferenceByVnfTypeAndActionCategory(genericVnf.getVnfType(),
+ Action.HealthCheck.toString());
+
+ genericVnfHealthCheck.setParamsForGenericVnfHealthCheck(execution);
+
+ assertEquals(genericVnf.getVnfId(), execution.getVariable("vnfId"));
+ assertEquals(genericVnf.getVnfName(), execution.getVariable("vnfName"));
+ assertEquals(genericVnf.getIpv4OamAddress(), execution.getVariable("oamIpAddress"));
+ assertEquals("HealthCheck", execution.getVariable("action"));
+ assertEquals(requestContext.getMsoRequestId(), execution.getVariable("msoRequestId"));
+ assertEquals(controllerSelectionReference.getControllerName(), execution.getVariable("controllerType"));
+ }
+
+ @Test
+ public void callAppcClientTest() throws Exception {
+ Action action = Action.HealthCheck;
+ String vnfId = genericVnf.getVnfId();
+ String payload = "{\"testName\":\"testValue\",}";
+ String controllerType = "testType";
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ payloadInfo.put("vfModuleId", "testVfModuleId");
+ payloadInfo.put("oamIpAddress", "testOamIpAddress");
+ payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
+ execution.setVariable("action", Action.HealthCheck.toString());
+ execution.setVariable("msoRequestId", msoRequestId);
+ execution.setVariable("controllerType", controllerType);
+ execution.setVariable("vnfId", "testVnfId1");
+ execution.setVariable("vnfName", "testVnfName");
+ execution.setVariable("vfModuleId", "testVfModuleId");
+ execution.setVariable("oamIpAddress", "testOamIpAddress");
+ execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
+ execution.setVariable("payload", payload);
+
+ doNothing().when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+
+ genericVnfHealthCheck.callAppcClient(execution);
+ verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+ }
+
+ @Test
+ public void callAppcClientExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ Action action = Action.HealthCheck;
+ String vnfId = genericVnf.getVnfId();
+ String payload = "{\"testName\":\"testValue\",}";
+ String controllerType = "testType";
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ payloadInfo.put("vfModuleId", "testVfModuleId");
+ payloadInfo.put("oamIpAddress", "testOamIpAddress");
+ payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
+ execution.setVariable("action", Action.HealthCheck.toString());
+ execution.setVariable("msoRequestId", msoRequestId);
+ execution.setVariable("controllerType", controllerType);
+ execution.setVariable("vnfId", "testVnfId1");
+ execution.setVariable("vnfName", "testVnfName");
+ execution.setVariable("vfModuleId", "testVfModuleId");
+ execution.setVariable("oamIpAddress", "testOamIpAddress");
+ execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
+ execution.setVariable("payload", payload);
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed"));
+ doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId,
+ Optional.of(payload), payloadInfo, controllerType);
+
+
+ genericVnfHealthCheck.callAppcClient(execution);
+ verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+ }
+
+ @Test
+ @Ignore // The runAppCCommand method in not capable of throwing this exception
+ public void callAppcClientTimeOutExceptionTest() {
+ expectedException.expect(java.util.concurrent.TimeoutException.class);
+ Action action = Action.HealthCheck;
+ String vnfId = genericVnf.getVnfId();
+ String payload = "{\"testName\":\"testValue\",}";
+ String controllerType = "testType";
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ payloadInfo.put("vfModuleId", "testVfModuleId");
+ payloadInfo.put("oamIpAddress", "testOamIpAddress");
+ payloadInfo.put("vnfHostIpAddress", "testOamIpAddress");
+ execution.setVariable("action", Action.HealthCheck.toString());
+ execution.setVariable("msoRequestId", msoRequestId);
+ execution.setVariable("controllerType", controllerType);
+ execution.setVariable("vnfId", "testVnfId1");
+ execution.setVariable("vnfName", "testVnfName");
+ execution.setVariable("vfModuleId", "testVfModuleId");
+ execution.setVariable("oamIpAddress", "testOamIpAddress");
+ execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
+ execution.setVariable("payload", payload);
+
+ doThrow(java.util.concurrent.TimeoutException.class).when(appCClient).runAppCCommand(action, msoRequestId,
+ vnfId, Optional.of(payload), payloadInfo, controllerType);
+
+
+ genericVnfHealthCheck.callAppcClient(execution);
+ verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo,
+ controllerType);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtilsTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtilsTest.java
index bf9be282d4..5eafb982e6 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtilsTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtilsTest.java
@@ -23,11 +23,9 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -38,82 +36,84 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.springframework.beans.factory.annotation.Autowired;
-public class NetworkBBUtilsTest extends BaseTaskTest{
- @InjectMocks
- private NetworkBBUtils networkBBUtils = new NetworkBBUtils();
-
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/Network/";
-
- private CloudRegion cloudRegion;
-
- @Before
- public void before() {
- cloudRegion = setCloudRegion();
- }
-
- @Test
- public void isRelationshipRelatedToExistsTrueTest() throws Exception {
- final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
- Optional<L3Network> l3network = aaiResultWrapper.asBean(L3Network.class);
-
- boolean isVfModule = networkBBUtils.isRelationshipRelatedToExists(l3network, "vf-module");
- assertTrue(isVfModule);
-
- }
-
- @Test
- public void isRelationshipRelatedToExistsFalseTest() throws Exception {
- final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAAIResponse.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
- Optional<L3Network> l3network = aaiResultWrapper.asBean(L3Network.class);
-
- boolean isVfModule = networkBBUtils.isRelationshipRelatedToExists(l3network, "vf-module");
- assertFalse(isVfModule);
-
- }
-
- @Test
- public void getCloudRegionSDNC25Test() throws Exception {
- cloudRegion.setCloudRegionVersion("2.5");
-
- NetworkBBUtils spyAssign = Mockito.spy(NetworkBBUtils.class);
- String cloudRegionId = spyAssign.getCloudRegion(execution, SourceSystem.SDNC);
- Mockito.verify(spyAssign).getCloudRegion(execution, SourceSystem.SDNC);
-
- assertEquals("AAIAIC25", cloudRegionId);
- }
-
- @Test
- public void getCloudRegionSDNC30Test() throws Exception {
- cloudRegion.setCloudRegionVersion("3.0");
-
- NetworkBBUtils spyAssign = Mockito.spy(NetworkBBUtils.class);
- String cloudRegionId = spyAssign.getCloudRegion(execution, SourceSystem.SDNC);
- Mockito.verify(spyAssign).getCloudRegion(execution, SourceSystem.SDNC);
-
- assertEquals(cloudRegion.getLcpCloudRegionId(), cloudRegionId);
- }
-
- @Test
- public void getCloudRegionPO25Test() throws Exception {
- cloudRegion.setCloudRegionVersion("2.5");
-
- NetworkBBUtils spyAssign = Mockito.spy(NetworkBBUtils.class);
- String cloudRegionId = spyAssign.getCloudRegion(execution, SourceSystem.PO);
- Mockito.verify(spyAssign).getCloudRegion(execution, SourceSystem.PO);
-
- assertEquals(cloudRegion.getLcpCloudRegionId(), cloudRegionId);
- }
-
- @Test
- public void getCloudRegionPO30Test() throws Exception {
- cloudRegion.setCloudRegionVersion("3.0");
-
- NetworkBBUtils spyAssignPO = Mockito.spy(NetworkBBUtils.class);
- String cloudRegionIdPO = spyAssignPO.getCloudRegion(execution, SourceSystem.PO);
- Mockito.verify(spyAssignPO).getCloudRegion(execution, SourceSystem.PO);
-
- assertEquals(cloudRegion.getLcpCloudRegionId(), cloudRegionIdPO);
- }
+public class NetworkBBUtilsTest extends BaseTaskTest {
+ @InjectMocks
+ private NetworkBBUtils networkBBUtils = new NetworkBBUtils();
+
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/Network/";
+
+ private CloudRegion cloudRegion;
+
+ @Before
+ public void before() {
+ cloudRegion = setCloudRegion();
+ }
+
+ @Test
+ public void isRelationshipRelatedToExistsTrueTest() throws Exception {
+ final String aaiResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
+ Optional<L3Network> l3network = aaiResultWrapper.asBean(L3Network.class);
+
+ boolean isVfModule = networkBBUtils.isRelationshipRelatedToExists(l3network, "vf-module");
+ assertTrue(isVfModule);
+
+ }
+
+ @Test
+ public void isRelationshipRelatedToExistsFalseTest() throws Exception {
+ final String aaiResponse =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAAIResponse.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
+ Optional<L3Network> l3network = aaiResultWrapper.asBean(L3Network.class);
+
+ boolean isVfModule = networkBBUtils.isRelationshipRelatedToExists(l3network, "vf-module");
+ assertFalse(isVfModule);
+
+ }
+
+ @Test
+ public void getCloudRegionSDNC25Test() throws Exception {
+ cloudRegion.setCloudRegionVersion("2.5");
+
+ NetworkBBUtils spyAssign = Mockito.spy(NetworkBBUtils.class);
+ String cloudRegionId = spyAssign.getCloudRegion(execution, SourceSystem.SDNC);
+ Mockito.verify(spyAssign).getCloudRegion(execution, SourceSystem.SDNC);
+
+ assertEquals("AAIAIC25", cloudRegionId);
+ }
+
+ @Test
+ public void getCloudRegionSDNC30Test() throws Exception {
+ cloudRegion.setCloudRegionVersion("3.0");
+
+ NetworkBBUtils spyAssign = Mockito.spy(NetworkBBUtils.class);
+ String cloudRegionId = spyAssign.getCloudRegion(execution, SourceSystem.SDNC);
+ Mockito.verify(spyAssign).getCloudRegion(execution, SourceSystem.SDNC);
+
+ assertEquals(cloudRegion.getLcpCloudRegionId(), cloudRegionId);
+ }
+
+ @Test
+ public void getCloudRegionPO25Test() throws Exception {
+ cloudRegion.setCloudRegionVersion("2.5");
+
+ NetworkBBUtils spyAssign = Mockito.spy(NetworkBBUtils.class);
+ String cloudRegionId = spyAssign.getCloudRegion(execution, SourceSystem.PO);
+ Mockito.verify(spyAssign).getCloudRegion(execution, SourceSystem.PO);
+
+ assertEquals(cloudRegion.getLcpCloudRegionId(), cloudRegionId);
+ }
+
+ @Test
+ public void getCloudRegionPO30Test() throws Exception {
+ cloudRegion.setCloudRegionVersion("3.0");
+
+ NetworkBBUtils spyAssignPO = Mockito.spy(NetworkBBUtils.class);
+ String cloudRegionIdPO = spyAssignPO.getCloudRegion(execution, SourceSystem.PO);
+ Mockito.verify(spyAssignPO).getCloudRegion(execution, SourceSystem.PO);
+
+ assertEquals(cloudRegion.getLcpCloudRegionId(), cloudRegionIdPO);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java
index b50cd69f73..8d51ceb65f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java
@@ -29,11 +29,9 @@ import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -53,443 +51,542 @@ import org.onap.so.bpmn.servicedecomposition.homingobjects.Candidate;
import org.onap.so.bpmn.servicedecomposition.homingobjects.CandidateType;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.sniro.beans.SniroManagerRequest;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class SniroHomingV2IT extends BaseIntegrationTest{
+public class SniroHomingV2IT extends BaseIntegrationTest {
+
+ private ServiceInstance serviceInstance;
+
+ private RequestContext requestContext;
+
+ private Customer customer;
+ ObjectMapper mapper = new ObjectMapper();
+
+ private static final String RESOURCE_PATH = "__files/BuildingBlocks/SniroHoming/";
+
+
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"corys cool\", \"requestStatus\": \"accepted\"}";
+
+ @Before
+ public void before() {
+ serviceInstance = setServiceInstance();
+ customer = setCustomer();
+ customer.setGlobalCustomerId("testCustomerId");
+ customer.setSubscriberName("testCustomerName");
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+
+ requestContext = setRequestContext();
+ requestContext.setMsoRequestId("testRequestId");
+ RequestParameters params = new RequestParameters();
+ params.setaLaCarte(false);
+ params.setSubscriptionServiceType("testSubscriptionServiceType");
+ requestContext.setRequestParameters(params);
+ }
+
+ public void beforeVpnBondingLink(String id) {
+ VpnBondingLink bondingLink = new VpnBondingLink();
+ bondingLink.setVpnBondingLinkId("testVpnBondingId" + id);
+ bondingLink.getServiceProxies().add(setServiceProxy("1", "transport"));
+ ServiceProxy sp2 = setServiceProxy("2", "infrastructure");
+ Candidate requiredCandidate = new Candidate();
+ requiredCandidate.setIdentifierType(CandidateType.VNF_ID);
+ List<String> c = new ArrayList<String>();
+ c.add("testVnfId");
+ requiredCandidate.setIdentifiers(c);
+ sp2.addRequiredCandidates(requiredCandidate);
+ bondingLink.getServiceProxies().add(sp2);
+ serviceInstance.getVpnBondingLinks().add(bondingLink);
+
+ }
+
+ public void beforeAllottedResource() {
+ serviceInstance.getAllottedResources().add(setAllottedResource("1"));
+ serviceInstance.getAllottedResources().add(setAllottedResource("2"));
+ serviceInstance.getAllottedResources().add(setAllottedResource("3"));
+ }
+
+ public void beforeVnf() {
+ setGenericVnf();
+ }
+
+ @Test(expected = Test.None.class)
+ public void testCallSniro_success_1VpnLink() throws BadResponseException, IOException {
+ beforeVpnBondingLink("1");
+
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
+
+ sniroHoming.callSniro(execution);
+
+ String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest1Vpn.json");
+ request = request.replace("28080", wireMockPort);
+
+ ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
+ verify(sniroClient, times(1)).postDemands(argument.capture());
+ assertEquals(request, argument.getValue().toJsonString());
+ }
+
+ @Test
+ public void testCallSniro_success_3VpnLink() throws JsonProcessingException, BadResponseException {
+ beforeVpnBondingLink("1");
+ beforeVpnBondingLink("2");
+ beforeVpnBondingLink("3");
+
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
+
+ sniroHoming.callSniro(execution);
+
+ String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest3Vpn.json");
+ request = request.replace("28080", wireMockPort);
+
+ ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
+ verify(sniroClient, times(1)).postDemands(argument.capture());
+ assertEquals(request, argument.getValue().toJsonString());
+ }
+
+ @Test
+ public void testCallSniro_success_3Allotteds() throws BadResponseException, JsonProcessingException {
+ beforeAllottedResource();
- private ServiceInstance serviceInstance;
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- private RequestContext requestContext;
+ sniroHoming.callSniro(execution);
- private Customer customer;
- ObjectMapper mapper = new ObjectMapper();
+ String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest3AR.json");
+ request = request.replace("28080", wireMockPort);
- private static final String RESOURCE_PATH = "__files/BuildingBlocks/SniroHoming/";
+ ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
+ verify(sniroClient, times(1)).postDemands(argument.capture());
+ assertEquals(request, argument.getValue().toJsonString());
+ }
+ @Test
+ public void testCallSniro_success_1Vnf() throws JsonProcessingException, BadResponseException {
+ beforeVnf();
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"corys cool\", \"requestStatus\": \"accepted\"}";
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- @Before
- public void before() {
- serviceInstance = setServiceInstance();
- customer = setCustomer();
- customer.setGlobalCustomerId("testCustomerId");
- customer.setSubscriberName("testCustomerName");
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ sniroHoming.callSniro(execution);
- requestContext = setRequestContext();
- requestContext.setMsoRequestId("testRequestId");
- RequestParameters params = new RequestParameters();
- params.setaLaCarte(false);
- params.setSubscriptionServiceType("testSubscriptionServiceType");
- requestContext.setRequestParameters(params);
- }
+ ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
+ verify(sniroClient, times(1)).postDemands(argument.capture());
+ // TODO assertEquals(request, argument.getValue().toJsonString());
+ }
- public void beforeVpnBondingLink(String id){
- VpnBondingLink bondingLink = new VpnBondingLink();
- bondingLink.setVpnBondingLinkId("testVpnBondingId" + id);
- bondingLink.getServiceProxies().add(setServiceProxy("1", "transport"));
- ServiceProxy sp2 = setServiceProxy("2", "infrastructure");
- Candidate requiredCandidate = new Candidate();
- requiredCandidate.setIdentifierType(CandidateType.VNF_ID);
- List<String> c = new ArrayList<String>();
- c.add("testVnfId");
- requiredCandidate.setIdentifiers(c);
- sp2.addRequiredCandidates(requiredCandidate);
- bondingLink.getServiceProxies().add(sp2);
- serviceInstance.getVpnBondingLinks().add(bondingLink);
+ @Test
+ public void testCallSniro_success_3Allotteds1Vnf() throws JsonProcessingException, BadResponseException {
+ beforeAllottedResource();
+ beforeVnf();
- }
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- public void beforeAllottedResource(){
- serviceInstance.getAllottedResources().add(setAllottedResource("1"));
- serviceInstance.getAllottedResources().add(setAllottedResource("2"));
- serviceInstance.getAllottedResources().add(setAllottedResource("3"));
- }
+ sniroHoming.callSniro(execution);
- public void beforeVnf(){
- setGenericVnf();
- }
+ verify(sniroClient, times(1)).postDemands(isA(SniroManagerRequest.class));
+ }
@Test(expected = Test.None.class)
- public void testCallSniro_success_1VpnLink() throws BadResponseException, IOException{
- beforeVpnBondingLink("1");
-
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
-
- sniroHoming.callSniro(execution);
-
- String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest1Vpn.json");
- request = request.replace("28080", wireMockPort);
-
- ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
- verify(sniroClient, times(1)).postDemands(argument.capture());
- assertEquals(request, argument.getValue().toJsonString());
- }
-
- @Test
- public void testCallSniro_success_3VpnLink() throws JsonProcessingException, BadResponseException{
- beforeVpnBondingLink("1");
- beforeVpnBondingLink("2");
- beforeVpnBondingLink("3");
-
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
-
- sniroHoming.callSniro(execution);
-
- String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest3Vpn.json");
- request = request.replace("28080", wireMockPort);
-
- ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
- verify(sniroClient, times(1)).postDemands(argument.capture());
- assertEquals(request, argument.getValue().toJsonString());
- }
-
- @Test
- public void testCallSniro_success_3Allotteds() throws BadResponseException, JsonProcessingException{
- beforeAllottedResource();
-
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
-
- sniroHoming.callSniro(execution);
-
- String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest3AR.json");
- request = request.replace("28080", wireMockPort);
-
- ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
- verify(sniroClient, times(1)).postDemands(argument.capture());
- assertEquals(request, argument.getValue().toJsonString());
- }
-
- @Test
- public void testCallSniro_success_1Vnf() throws JsonProcessingException, BadResponseException{
- beforeVnf();
-
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
-
- sniroHoming.callSniro(execution);
-
- ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class);
- verify(sniroClient, times(1)).postDemands(argument.capture());
- //TODO assertEquals(request, argument.getValue().toJsonString());
- }
-
- @Test
- public void testCallSniro_success_3Allotteds1Vnf() throws JsonProcessingException, BadResponseException{
- beforeAllottedResource();
- beforeVnf();
-
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
-
- sniroHoming.callSniro(execution);
-
- verify(sniroClient, times(1)).postDemands(isA(SniroManagerRequest.class));
- }
-
- @Test(expected = Test.None.class)
- public void testProcessSolution_success_1VpnLink_1Solution(){
- beforeVpnBondingLink("1");
-
- JSONObject asyncResponse = new JSONObject();
- asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
- JSONArray solution1 = new JSONArray();
- solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1"))));
- solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "secondaryPnfName").put("value", "testSecondaryPnfName2")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId2"))));
-
- asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)).put("licenseSolutions", new JSONArray()));
-
- sniroHoming.processSolution(execution, asyncResponse.toString());
-
- ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
-
- assertFalse(si.getVpnBondingLinks().isEmpty());
- VpnBondingLink link = si.getVpnBondingLinks().get(0);
- assertNotNull(link);
- assertFalse(link.getServiceProxies().isEmpty());
-
- assertEquals("testServiceInstanceId1", link.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
- assertNotNull(link.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName1", link.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
-
- assertEquals("testServiceInstanceId2", link.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
- assertNotNull(link.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
- assertFalse(link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
- assertEquals("testPrimaryPnfName2", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
- assertEquals("primary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
- assertEquals("testSecondaryPnfName2", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
- assertEquals("secondary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
- }
-
- @Test
- public void testProcessSolution_success_1VpnLink_2Solutions(){
- beforeVpnBondingLink("1");
-
- JSONObject asyncResponse = new JSONObject();
- asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
- JSONArray solution1 = new JSONArray();
- solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1"))));
- solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "secondaryPnfName").put("value", "testSecondaryPnfName2")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId2"))));
-
- JSONArray solution2 = new JSONArray();
- solution2.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId3")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName3"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli3")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId3")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId3"))));
- solution2.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId4")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName4"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli4")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "secondaryPnfName").put("value", "testSecondaryPnfName4")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId4"))));
-
- asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1).put(solution2)).put("licenseSolutions", new JSONArray()));
-
- sniroHoming.processSolution(execution, asyncResponse.toString());
-
- ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
-
- assertFalse(si.getVpnBondingLinks().isEmpty());
- VpnBondingLink link = si.getVpnBondingLinks().get(0);
- VpnBondingLink link2 = si.getVpnBondingLinks().get(1);
- assertNotNull(link);
- assertFalse(link.getServiceProxies().isEmpty());
-
- assertEquals("testServiceInstanceId1", link.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
- assertNotNull(link.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName1", link.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
-
- assertEquals("testServiceInstanceId2", link.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
- assertNotNull(link.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
- assertFalse(link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
- assertEquals("testPrimaryPnfName2", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
- assertEquals("primary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
- assertEquals("testSecondaryPnfName2", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
- assertEquals("secondary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
-
- assertNotNull(link2);
- assertFalse(link2.getServiceProxies().isEmpty());
-
- assertEquals("testServiceInstanceId3", link2.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
- assertNotNull(link2.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName3", link2.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
-
- assertEquals("testServiceInstanceId4", link2.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
- assertNotNull(link2.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
- assertFalse(link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
- assertEquals("testPrimaryPnfName4", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
- assertEquals("primary", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
- assertEquals("testSecondaryPnfName4", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
- assertEquals("secondary", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
-
- }
-
- @Test
- public void testProcessSolution_success_3VpnLink_2Solutions(){
- //TODO
- }
-
- @Test
- public void testProcessSolution_success_3Allotteds_1Solution(){
- beforeAllottedResource();
-
- JSONObject asyncResponse = new JSONObject();
- asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
- JSONArray solution1 = new JSONArray();
- solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId1"))));
- solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId2"))));
- solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3").put("solution", new JSONObject()
- .put("identifierType", "cloudRegionId").put("identifiers", new JSONArray().put("testCloudRegionId3")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))));
-
- asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)).put("licenseSolutions", new JSONArray()));
-
- sniroHoming.processSolution(execution, asyncResponse.toString());
-
- ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
-
- assertFalse(si.getAllottedResources().isEmpty());
- AllottedResource ar = si.getAllottedResources().get(0);
- assertNotNull(ar);
- assertEquals("testServiceInstanceId1", ar.getParentServiceInstance().getServiceInstanceId());
- assertNotNull(ar.getParentServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName1", ar.getParentServiceInstance().getVnfs().get(0).getVnfName());
-
- AllottedResource ar2 = si.getAllottedResources().get(1);
- assertNotNull(ar2);
- assertEquals("testServiceInstanceId2", ar2.getParentServiceInstance().getServiceInstanceId());
- assertNotNull(ar2.getParentServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName2", ar2.getParentServiceInstance().getVnfs().get(0).getVnfName());
-
- AllottedResource ar3 = si.getAllottedResources().get(2);
- assertNotNull(ar3);
- assertNotNull(ar3.getParentServiceInstance().getSolutionInfo());
- assertEquals("testCloudRegionId3", ar3.getParentServiceInstance().getSolutionInfo().getTargetedCloudRegion().getLcpCloudRegionId());
- }
-
- @Test
- public void testProcessSolution_success_3Allotteds1Vnf_1Solution(){
- beforeVnf();
- beforeAllottedResource();
-
- JSONObject asyncResponse = new JSONObject();
- asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
- JSONArray solution1 = new JSONArray();
- JSONArray licenseSolution = new JSONArray();
- solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId1"))));
- solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2").put("solution", new JSONObject()
- .put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2"))
- .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))
- .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId2"))));
- solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3").put("solution", new JSONObject()
- .put("identifierType", "cloudRegionId").put("identifiers", new JSONArray().put("testCloudRegionId3")))
- .put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
- .put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
- .put(new JSONObject().put("key", "aicVersion").put("value", "3"))));
-
- licenseSolution.put(
- new JSONObject().put("serviceResourceId", "testVnfId1").put("entitlementPoolUUID", new JSONArray().put("f1d563e8-e714-4393-8f99-cc480144a05e").put("j1d563e8-e714-4393-8f99-cc480144a05e"))
- .put("licenseKeyGroupUUID", new JSONArray().put("s1d563e8-e714-4393-8f99-cc480144a05e").put("b1d563e8-e714-4393-8f99-cc480144a05e")));
-
- asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)).put("licenseSolutions", licenseSolution));
-
- sniroHoming.processSolution(execution, asyncResponse.toString());
-
- ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
-
- assertFalse(si.getAllottedResources().isEmpty());
- AllottedResource ar = si.getAllottedResources().get(0);
- assertNotNull(ar);
- assertEquals("testServiceInstanceId1", ar.getParentServiceInstance().getServiceInstanceId());
- assertNotNull(ar.getParentServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName1", ar.getParentServiceInstance().getVnfs().get(0).getVnfName());
-
- AllottedResource ar2 = si.getAllottedResources().get(1);
- assertNotNull(ar2);
- assertEquals("testServiceInstanceId2", ar2.getParentServiceInstance().getServiceInstanceId());
- assertNotNull(ar2.getParentServiceInstance().getSolutionInfo());
- assertEquals("testVnfHostName2", ar2.getParentServiceInstance().getVnfs().get(0).getVnfName());
-
- AllottedResource ar3 = si.getAllottedResources().get(2);
- assertNotNull(ar3);
- assertNotNull(ar3.getParentServiceInstance().getSolutionInfo());
- assertEquals("testCloudRegionId3", ar3.getParentServiceInstance().getSolutionInfo().getTargetedCloudRegion().getLcpCloudRegionId());
-
- GenericVnf vnf = si.getVnfs().get(0);
- assertNotNull(vnf);
- assertNotNull(vnf.getLicense());
- assertEquals(2, vnf.getLicense().getEntitlementPoolUuids().size());
- assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0));
-
- }
-
- @Test
- public void testProcessSolution_success_1Vnf_1Solution(){
- beforeVnf();
-
- JSONObject asyncResponse = new JSONObject();
- asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
- JSONArray licenseSolution = new JSONArray();
-
- licenseSolution.put(
- new JSONObject().put("serviceResourceId", "testVnfId1").put("entitlementPoolUUID", new JSONArray().put("f1d563e8-e714-4393-8f99-cc480144a05e").put("j1d563e8-e714-4393-8f99-cc480144a05e"))
- .put("licenseKeyGroupUUID", new JSONArray().put("s1d563e8-e714-4393-8f99-cc480144a05e").put("b1d563e8-e714-4393-8f99-cc480144a05e")));
-
- asyncResponse.put("solutions", new JSONObject().put("licenseSolutions", licenseSolution));
-
- sniroHoming.processSolution(execution, asyncResponse.toString());
-
- ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
-
- GenericVnf vnf = si.getVnfs().get(0);
- assertNotNull(vnf);
- assertNotNull(vnf.getLicense());
- assertEquals(2, vnf.getLicense().getEntitlementPoolUuids().size());
- assertEquals(2, vnf.getLicense().getLicenseKeyGroupUuids().size());
- assertEquals("f1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getEntitlementPoolUuids().get(0));
- assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0));
-
-
- }
-
- @Test(expected = BpmnError.class)
- public void testCallSniro_error_0Resources() throws BadResponseException, JsonProcessingException{
-
- sniroHoming.callSniro(execution);
-
- verify(sniroClient, times(0)).postDemands(isA(SniroManagerRequest.class));
- }
-
- @Test(expected = BpmnError.class)
- public void testCallSniro_error_badResponse() throws BadResponseException, JsonProcessingException{
- beforeAllottedResource();
-
- mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
-
- sniroHoming.callSniro(execution);
+ public void testProcessSolution_success_1VpnLink_1Solution() {
+ beforeVpnBondingLink("1");
+
+ JSONObject asyncResponse = new JSONObject();
+ asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState",
+ "completed");
+ JSONArray solution1 = new JSONArray();
+ solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId1")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1"))));
+ solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId2")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "secondaryPnfName").put("value",
+ "testSecondaryPnfName2"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId2"))));
+
+ asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1))
+ .put("licenseSolutions", new JSONArray()));
+
+ sniroHoming.processSolution(execution, asyncResponse.toString());
+
+ ServiceInstance si =
+ execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
+
+ assertFalse(si.getVpnBondingLinks().isEmpty());
+ VpnBondingLink link = si.getVpnBondingLinks().get(0);
+ assertNotNull(link);
+ assertFalse(link.getServiceProxies().isEmpty());
+
+ assertEquals("testServiceInstanceId1",
+ link.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
+ assertNotNull(link.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName1",
+ link.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
+
+ assertEquals("testServiceInstanceId2",
+ link.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
+ assertNotNull(link.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
+ assertFalse(link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
+ assertEquals("testPrimaryPnfName2",
+ link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
+ assertEquals("primary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
+ assertEquals("testSecondaryPnfName2",
+ link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
+ assertEquals("secondary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
+ }
+
+ @Test
+ public void testProcessSolution_success_1VpnLink_2Solutions() {
+ beforeVpnBondingLink("1");
+
+ JSONObject asyncResponse = new JSONObject();
+ asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState",
+ "completed");
+ JSONArray solution1 = new JSONArray();
+ solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId1")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1"))));
+ solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId2")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "secondaryPnfName").put("value",
+ "testSecondaryPnfName2"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId2"))));
+
+ JSONArray solution2 = new JSONArray();
+ solution2.put(new JSONObject().put("serviceResourceId", "testProxyId1")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId3")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName3"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli3"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId3"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId3"))));
+ solution2.put(new JSONObject().put("serviceResourceId", "testProxyId2")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId4")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName4"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli4"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "secondaryPnfName").put("value",
+ "testSecondaryPnfName4"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId4"))));
+
+ asyncResponse.put("solutions",
+ new JSONObject().put("placementSolutions", new JSONArray().put(solution1).put(solution2))
+ .put("licenseSolutions", new JSONArray()));
+
+ sniroHoming.processSolution(execution, asyncResponse.toString());
+
+ ServiceInstance si =
+ execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
+
+ assertFalse(si.getVpnBondingLinks().isEmpty());
+ VpnBondingLink link = si.getVpnBondingLinks().get(0);
+ VpnBondingLink link2 = si.getVpnBondingLinks().get(1);
+ assertNotNull(link);
+ assertFalse(link.getServiceProxies().isEmpty());
+
+ assertEquals("testServiceInstanceId1",
+ link.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
+ assertNotNull(link.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName1",
+ link.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
+
+ assertEquals("testServiceInstanceId2",
+ link.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
+ assertNotNull(link.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
+ assertFalse(link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
+ assertEquals("testPrimaryPnfName2",
+ link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
+ assertEquals("primary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
+ assertEquals("testSecondaryPnfName2",
+ link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
+ assertEquals("secondary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
+
+ assertNotNull(link2);
+ assertFalse(link2.getServiceProxies().isEmpty());
+
+ assertEquals("testServiceInstanceId3",
+ link2.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
+ assertNotNull(link2.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName3",
+ link2.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
+
+ assertEquals("testServiceInstanceId4",
+ link2.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
+ assertNotNull(link2.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
+ assertFalse(link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
+ assertEquals("testPrimaryPnfName4",
+ link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
+ assertEquals("primary", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
+ assertEquals("testSecondaryPnfName4",
+ link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
+ assertEquals("secondary",
+ link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
+
+ }
+
+ @Test
+ public void testProcessSolution_success_3VpnLink_2Solutions() {
+ // TODO
+ }
+
+ @Test
+ public void testProcessSolution_success_3Allotteds_1Solution() {
+ beforeAllottedResource();
+
+ JSONObject asyncResponse = new JSONObject();
+ asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState",
+ "completed");
+ JSONArray solution1 = new JSONArray();
+ solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId1")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId1"))));
+ solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId2")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId2"))));
+ solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3")
+ .put("solution",
+ new JSONObject().put("identifierType", "cloudRegionId").put("identifiers",
+ new JSONArray().put("testCloudRegionId3")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))));
+
+ asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1))
+ .put("licenseSolutions", new JSONArray()));
+
+ sniroHoming.processSolution(execution, asyncResponse.toString());
+
+ ServiceInstance si =
+ execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
+
+ assertFalse(si.getAllottedResources().isEmpty());
+ AllottedResource ar = si.getAllottedResources().get(0);
+ assertNotNull(ar);
+ assertEquals("testServiceInstanceId1", ar.getParentServiceInstance().getServiceInstanceId());
+ assertNotNull(ar.getParentServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName1", ar.getParentServiceInstance().getVnfs().get(0).getVnfName());
+
+ AllottedResource ar2 = si.getAllottedResources().get(1);
+ assertNotNull(ar2);
+ assertEquals("testServiceInstanceId2", ar2.getParentServiceInstance().getServiceInstanceId());
+ assertNotNull(ar2.getParentServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName2", ar2.getParentServiceInstance().getVnfs().get(0).getVnfName());
+
+ AllottedResource ar3 = si.getAllottedResources().get(2);
+ assertNotNull(ar3);
+ assertNotNull(ar3.getParentServiceInstance().getSolutionInfo());
+ assertEquals("testCloudRegionId3",
+ ar3.getParentServiceInstance().getSolutionInfo().getTargetedCloudRegion().getLcpCloudRegionId());
+ }
+
+ @Test
+ public void testProcessSolution_success_3Allotteds1Vnf_1Solution() {
+ beforeVnf();
+ beforeAllottedResource();
+
+ JSONObject asyncResponse = new JSONObject();
+ asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState",
+ "completed");
+ JSONArray solution1 = new JSONArray();
+ JSONArray licenseSolution = new JSONArray();
+ solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId1")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId1"))));
+ solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2")
+ .put("solution",
+ new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers",
+ new JSONArray().put("testServiceInstanceId2")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))
+ .put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1"))
+ .put(new JSONObject().put("key", "cloudRegionId").put("value", "testCloudRegionId2"))));
+ solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3")
+ .put("solution",
+ new JSONObject().put("identifierType", "cloudRegionId").put("identifiers",
+ new JSONArray().put("testCloudRegionId3")))
+ .put("assignmentInfo",
+ new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True"))
+ .put(new JSONObject().put("key", "cloudOwner").put("value", "aic"))
+ .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2"))
+ .put(new JSONObject().put("key", "aicVersion").put("value", "3"))));
+
+ licenseSolution.put(new JSONObject().put("serviceResourceId", "testVnfId1")
+ .put("entitlementPoolUUID",
+ new JSONArray().put("f1d563e8-e714-4393-8f99-cc480144a05e")
+ .put("j1d563e8-e714-4393-8f99-cc480144a05e"))
+ .put("licenseKeyGroupUUID", new JSONArray().put("s1d563e8-e714-4393-8f99-cc480144a05e")
+ .put("b1d563e8-e714-4393-8f99-cc480144a05e")));
+
+ asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1))
+ .put("licenseSolutions", licenseSolution));
+
+ sniroHoming.processSolution(execution, asyncResponse.toString());
+
+ ServiceInstance si =
+ execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
+
+ assertFalse(si.getAllottedResources().isEmpty());
+ AllottedResource ar = si.getAllottedResources().get(0);
+ assertNotNull(ar);
+ assertEquals("testServiceInstanceId1", ar.getParentServiceInstance().getServiceInstanceId());
+ assertNotNull(ar.getParentServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName1", ar.getParentServiceInstance().getVnfs().get(0).getVnfName());
+
+ AllottedResource ar2 = si.getAllottedResources().get(1);
+ assertNotNull(ar2);
+ assertEquals("testServiceInstanceId2", ar2.getParentServiceInstance().getServiceInstanceId());
+ assertNotNull(ar2.getParentServiceInstance().getSolutionInfo());
+ assertEquals("testVnfHostName2", ar2.getParentServiceInstance().getVnfs().get(0).getVnfName());
+
+ AllottedResource ar3 = si.getAllottedResources().get(2);
+ assertNotNull(ar3);
+ assertNotNull(ar3.getParentServiceInstance().getSolutionInfo());
+ assertEquals("testCloudRegionId3",
+ ar3.getParentServiceInstance().getSolutionInfo().getTargetedCloudRegion().getLcpCloudRegionId());
+
+ GenericVnf vnf = si.getVnfs().get(0);
+ assertNotNull(vnf);
+ assertNotNull(vnf.getLicense());
+ assertEquals(2, vnf.getLicense().getEntitlementPoolUuids().size());
+ assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0));
+
+ }
+
+ @Test
+ public void testProcessSolution_success_1Vnf_1Solution() {
+ beforeVnf();
+
+ JSONObject asyncResponse = new JSONObject();
+ asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState",
+ "completed");
+ JSONArray licenseSolution = new JSONArray();
+
+ licenseSolution.put(new JSONObject().put("serviceResourceId", "testVnfId1")
+ .put("entitlementPoolUUID",
+ new JSONArray().put("f1d563e8-e714-4393-8f99-cc480144a05e")
+ .put("j1d563e8-e714-4393-8f99-cc480144a05e"))
+ .put("licenseKeyGroupUUID", new JSONArray().put("s1d563e8-e714-4393-8f99-cc480144a05e")
+ .put("b1d563e8-e714-4393-8f99-cc480144a05e")));
+
+ asyncResponse.put("solutions", new JSONObject().put("licenseSolutions", licenseSolution));
+
+ sniroHoming.processSolution(execution, asyncResponse.toString());
+
+ ServiceInstance si =
+ execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
+
+ GenericVnf vnf = si.getVnfs().get(0);
+ assertNotNull(vnf);
+ assertNotNull(vnf.getLicense());
+ assertEquals(2, vnf.getLicense().getEntitlementPoolUuids().size());
+ assertEquals(2, vnf.getLicense().getLicenseKeyGroupUuids().size());
+ assertEquals("f1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getEntitlementPoolUuids().get(0));
+ assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0));
+
+
+ }
+
+ @Test(expected = BpmnError.class)
+ public void testCallSniro_error_0Resources() throws BadResponseException, JsonProcessingException {
+
+ sniroHoming.callSniro(execution);
+
+ verify(sniroClient, times(0)).postDemands(isA(SniroManagerRequest.class));
+ }
+
+ @Test(expected = BpmnError.class)
+ public void testCallSniro_error_badResponse() throws BadResponseException, JsonProcessingException {
+ beforeAllottedResource();
+
+ mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
+
+ sniroHoming.callSniro(execution);
- verify(sniroClient, times(1)).postDemands(isA(SniroManagerRequest.class));
- }
+ verify(sniroClient, times(1)).postDemands(isA(SniroManagerRequest.class));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java
index ecdf11bd05..bacc57758b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java
@@ -27,11 +27,9 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Optional;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -47,71 +45,77 @@ import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.springframework.beans.factory.annotation.Autowired;
public class UnassignNetworkBBTest extends BaseTaskTest {
-
- @Mock
- private NetworkBBUtils networkBBUtils;
- @InjectMocks
- private UnassignNetworkBB unassignNetworkBB = new UnassignNetworkBB();
-
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/Network/";
- private L3Network network;
-
- @Before
- public void setup(){
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
-
- @Test
- public void checkRelationshipRelatedToTrueTest() throws Exception {
- expectedException.expect(BpmnError.class);
- network = setL3Network();
- network.setNetworkId("testNetworkId1");
- final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
- Optional<org.onap.aai.domain.yang.L3Network> l3network = aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class);
-
- doReturn(network).when(extractPojosForBB).extractByKey(execution, ResourceKey.NETWORK_ID);
- doReturn(aaiResultWrapper).when(aaiNetworkResources).queryNetworkWrapperById(network);
-
- doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(any(Optional.class), eq("vf-module"));
-
- unassignNetworkBB.checkRelationshipRelatedTo(execution, "vf-module");
- assertThat(execution.getVariable("ErrorUnassignNetworkBB"), notNullValue());
- }
-
- @Test
- public void getCloudSdncRegion25Test() throws Exception {
- CloudRegion cloudRegion = setCloudRegion();
- cloudRegion.setCloudRegionVersion("2.5");
- doReturn("AAIAIC25").when(networkBBUtils).getCloudRegion(execution, SourceSystem.SDNC);
- unassignNetworkBB.getCloudSdncRegion(execution);
- assertEquals("AAIAIC25", execution.getVariable("cloudRegionSdnc"));
- }
-
- @Test
- public void getCloudSdncRegion30Test() throws Exception {
- CloudRegion cloudRegion = setCloudRegion();
- cloudRegion.setCloudRegionVersion("3.0");
- gBBInput.setCloudRegion(cloudRegion);
- doReturn(cloudRegion.getLcpCloudRegionId()).when(networkBBUtils).getCloudRegion(execution, SourceSystem.SDNC);
- unassignNetworkBB.getCloudSdncRegion(execution);
- assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionSdnc"));
- }
-
- @Test
- public void errorEncounteredTest_rollback() throws Exception {
- expectedException.expect(BpmnError.class);
- execution.setVariable("ErrorUnassignNetworkBB", "Relationship's RelatedTo still exists in AAI, remove the relationship vf-module first.");
- execution.setVariable("isRollbackNeeded", true);
- unassignNetworkBB.errorEncountered(execution);
- }
-
- @Test
- public void errorEncounteredTest_noRollback() throws Exception {
- expectedException.expect(BpmnError.class);
- execution.setVariable("ErrorUnassignNetworkBB", "Relationship's RelatedTo still exists in AAI, remove the relationship vf-module first.");
- unassignNetworkBB.errorEncountered(execution);
- }
+ @Mock
+ private NetworkBBUtils networkBBUtils;
+
+ @InjectMocks
+ private UnassignNetworkBB unassignNetworkBB = new UnassignNetworkBB();
+
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/Network/";
+ private L3Network network;
+
+ @Before
+ public void setup() {
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ }
+
+ @Test
+ public void checkRelationshipRelatedToTrueTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ network = setL3Network();
+ network.setNetworkId("testNetworkId1");
+ final String aaiResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
+ Optional<org.onap.aai.domain.yang.L3Network> l3network =
+ aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class);
+
+ doReturn(network).when(extractPojosForBB).extractByKey(execution, ResourceKey.NETWORK_ID);
+ doReturn(aaiResultWrapper).when(aaiNetworkResources).queryNetworkWrapperById(network);
+
+ doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(any(Optional.class), eq("vf-module"));
+
+ unassignNetworkBB.checkRelationshipRelatedTo(execution, "vf-module");
+ assertThat(execution.getVariable("ErrorUnassignNetworkBB"), notNullValue());
+ }
+
+ @Test
+ public void getCloudSdncRegion25Test() throws Exception {
+ CloudRegion cloudRegion = setCloudRegion();
+ cloudRegion.setCloudRegionVersion("2.5");
+ doReturn("AAIAIC25").when(networkBBUtils).getCloudRegion(execution, SourceSystem.SDNC);
+ unassignNetworkBB.getCloudSdncRegion(execution);
+ assertEquals("AAIAIC25", execution.getVariable("cloudRegionSdnc"));
+ }
+
+ @Test
+ public void getCloudSdncRegion30Test() throws Exception {
+ CloudRegion cloudRegion = setCloudRegion();
+ cloudRegion.setCloudRegionVersion("3.0");
+ gBBInput.setCloudRegion(cloudRegion);
+ doReturn(cloudRegion.getLcpCloudRegionId()).when(networkBBUtils).getCloudRegion(execution, SourceSystem.SDNC);
+ unassignNetworkBB.getCloudSdncRegion(execution);
+ assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionSdnc"));
+ }
+
+ @Test
+ public void errorEncounteredTest_rollback() throws Exception {
+ expectedException.expect(BpmnError.class);
+ execution.setVariable("ErrorUnassignNetworkBB",
+ "Relationship's RelatedTo still exists in AAI, remove the relationship vf-module first.");
+ execution.setVariable("isRollbackNeeded", true);
+ unassignNetworkBB.errorEncountered(execution);
+ }
+
+ @Test
+ public void errorEncounteredTest_noRollback() throws Exception {
+ expectedException.expect(BpmnError.class);
+ execution.setVariable("ErrorUnassignNetworkBB",
+ "Relationship's RelatedTo still exists in AAI, remove the relationship vf-module first.");
+ unassignNetworkBB.errorEncountered(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnfTest.java
index 394ffcf0ac..b4cb214483 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnfTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnfTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -41,43 +40,46 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
-public class UnassignVnfTest extends BaseTaskTest{
- @InjectMocks
- private UnassignVnf unassignVnf = new UnassignVnf();
-
- @Before
- public void setup(){
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
-
- }
+public class UnassignVnfTest extends BaseTaskTest {
+ @InjectMocks
+ private UnassignVnf unassignVnf = new UnassignVnf();
+
+ @Before
+ public void setup() {
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+
+ }
+
+ @Test
+ public void deleteInstanceGroupsSunnyDayTest() throws Exception {
+ GenericVnf genericVnf = setGenericVnf();
+
+ ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
+ modelVnfc.setType("VNFC");
+
+ InstanceGroup instanceGroup1 = new InstanceGroup();
+ instanceGroup1.setId("test-001");
+ instanceGroup1.setModelInfoInstanceGroup(modelVnfc);
+ genericVnf.getInstanceGroups().add(instanceGroup1);
+
+ InstanceGroup instanceGroup2 = new InstanceGroup();
+ instanceGroup2.setId("test-002");
+ instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
+ genericVnf.getInstanceGroups().add(instanceGroup2);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ unassignVnf.deleteInstanceGroups(execution);
+ verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup1));
+ verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup2));
+ }
+
+ @Test
+ public void deletecreateVnfcInstanceGroupExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
- @Test
- public void deleteInstanceGroupsSunnyDayTest() throws Exception {
- GenericVnf genericVnf = setGenericVnf();
-
- ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
- modelVnfc.setType("VNFC");
-
- InstanceGroup instanceGroup1 = new InstanceGroup();
- instanceGroup1.setId("test-001");
- instanceGroup1.setModelInfoInstanceGroup(modelVnfc);
- genericVnf.getInstanceGroups().add(instanceGroup1);
-
- InstanceGroup instanceGroup2 = new InstanceGroup();
- instanceGroup2.setId("test-002");
- instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
- genericVnf.getInstanceGroups().add(instanceGroup2);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- unassignVnf.deleteInstanceGroups(execution);
- verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup1));
- verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup2));
- }
-
- @Test
- public void deletecreateVnfcInstanceGroupExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- unassignVnf.deleteInstanceGroups(execution);
- }
+ unassignVnf.deleteInstanceGroups(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java
index 5e9565446f..f9ad473e5a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java
@@ -6,10 +6,8 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.HashMap;
import java.util.Map;
-
import org.camunda.bpm.engine.ProcessEngineServices;
import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
@@ -23,76 +21,76 @@ import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.db.request.beans.InfraActiveRequests;
public class ManualHandlingTasksTest extends BaseTaskTest {
- @InjectMocks
- protected ManualHandlingTasks manualHandlingTasks = new ManualHandlingTasks();
-
- @Mock
- TaskService taskService;
-
- @Mock
- private DelegateExecution mockExecution;
-
- @Mock
- ProcessEngineServices processEngineServices;
-
- @Mock
- private DelegateTask task;
-
- private DelegateExecution delegateExecution;
-
- @Before
- public void before() throws Exception {
- delegateExecution = new DelegateExecutionFake();
- }
-
- @Test
- public void setFalloutTaskVariables_Test () {
- when(task.getId()).thenReturn("taskId");
- when(task.getExecution()).thenReturn(mockExecution);
- when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
- when(processEngineServices.getTaskService()).thenReturn(taskService);
- manualHandlingTasks.setFalloutTaskVariables(task);
- verify(taskService, times(1)).setVariables(any(String.class), any(Map.class));
- }
-
- @Test
- public void setPauseTaskVariables_Test () {
- when(task.getId()).thenReturn("taskId");
- when(task.getExecution()).thenReturn(mockExecution);
- when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
- when(processEngineServices.getTaskService()).thenReturn(taskService);
- manualHandlingTasks.setPauseTaskVariables(task);
- verify(taskService, times(1)).setVariables(any(String.class), any(Map.class));
- }
-
- @Test
- public void completeTask_Test() throws Exception{
- when(task.getId()).thenReturn("taskId");
- when(task.getExecution()).thenReturn(mockExecution);
- Map<String, Object> taskVariables = new HashMap<String, Object>();
- taskVariables.put("responseValue", "resume");
- when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
- when(processEngineServices.getTaskService()).thenReturn(taskService);
- when(taskService.getVariables(any(String.class))).thenReturn(taskVariables);
- manualHandlingTasks.completeTask(task);
- verify(mockExecution, times(1)).setVariable("responseValueTask", "Resume");
- }
-
- @Test
- public void updateRequestDbStatus_Test() throws Exception{
- InfraActiveRequests mockedRequest = new InfraActiveRequests();
- delegateExecution.setVariable("msoRequestId", "testMsoRequestId");
- when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
- doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
- manualHandlingTasks.updateRequestDbStatus(delegateExecution, "IN_PROGRESS");
- verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
- assertEquals(mockedRequest.getRequestStatus(), "IN_PROGRESS");
- }
-
- @Test
- public void createExternalTicket_Test() throws Exception{
- delegateExecution.setVariable("msoRequestId", ("testMsoRequestId"));
- delegateExecution.setVariable("vnfType", "testVnfType");
- manualHandlingTasks.createExternalTicket(delegateExecution);
- }
+ @InjectMocks
+ protected ManualHandlingTasks manualHandlingTasks = new ManualHandlingTasks();
+
+ @Mock
+ TaskService taskService;
+
+ @Mock
+ private DelegateExecution mockExecution;
+
+ @Mock
+ ProcessEngineServices processEngineServices;
+
+ @Mock
+ private DelegateTask task;
+
+ private DelegateExecution delegateExecution;
+
+ @Before
+ public void before() throws Exception {
+ delegateExecution = new DelegateExecutionFake();
+ }
+
+ @Test
+ public void setFalloutTaskVariables_Test() {
+ when(task.getId()).thenReturn("taskId");
+ when(task.getExecution()).thenReturn(mockExecution);
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+ when(processEngineServices.getTaskService()).thenReturn(taskService);
+ manualHandlingTasks.setFalloutTaskVariables(task);
+ verify(taskService, times(1)).setVariables(any(String.class), any(Map.class));
+ }
+
+ @Test
+ public void setPauseTaskVariables_Test() {
+ when(task.getId()).thenReturn("taskId");
+ when(task.getExecution()).thenReturn(mockExecution);
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+ when(processEngineServices.getTaskService()).thenReturn(taskService);
+ manualHandlingTasks.setPauseTaskVariables(task);
+ verify(taskService, times(1)).setVariables(any(String.class), any(Map.class));
+ }
+
+ @Test
+ public void completeTask_Test() throws Exception {
+ when(task.getId()).thenReturn("taskId");
+ when(task.getExecution()).thenReturn(mockExecution);
+ Map<String, Object> taskVariables = new HashMap<String, Object>();
+ taskVariables.put("responseValue", "resume");
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+ when(processEngineServices.getTaskService()).thenReturn(taskService);
+ when(taskService.getVariables(any(String.class))).thenReturn(taskVariables);
+ manualHandlingTasks.completeTask(task);
+ verify(mockExecution, times(1)).setVariable("responseValueTask", "Resume");
+ }
+
+ @Test
+ public void updateRequestDbStatus_Test() throws Exception {
+ InfraActiveRequests mockedRequest = new InfraActiveRequests();
+ delegateExecution.setVariable("msoRequestId", "testMsoRequestId");
+ when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ manualHandlingTasks.updateRequestDbStatus(delegateExecution, "IN_PROGRESS");
+ verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ assertEquals(mockedRequest.getRequestStatus(), "IN_PROGRESS");
+ }
+
+ @Test
+ public void createExternalTicket_Test() throws Exception {
+ delegateExecution.setVariable("msoRequestId", ("testMsoRequestId"));
+ delegateExecution.setVariable("vnfType", "testVnfType");
+ manualHandlingTasks.createExternalTicket(delegateExecution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java
index 67c48d1e91..f5785f94fd 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -38,44 +37,50 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.client.exception.BBObjectNotFoundException;
public class NamingServiceCreateTasksTest extends BaseTaskTest {
- @InjectMocks
- private NamingServiceCreateTasks namingServiceCreateTasks = new NamingServiceCreateTasks();
-
- private InstanceGroup instanceGroup;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- instanceGroup = setInstanceGroup();
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID))).thenReturn(instanceGroup);
- }
-
- @Test
- public void createInstanceGroupTest() throws Exception {
- String policyInstanceName = "policyInstanceName";
- String nfNamingCode = "nfNamingCode";
- String generatedName = "generatedInstanceGroupName";
- execution.setVariable(policyInstanceName, policyInstanceName);
- execution.setVariable(nfNamingCode, nfNamingCode);
- doReturn(generatedName).when(namingServiceResources).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
-
- namingServiceCreateTasks.createInstanceGroupName(execution);
- verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
- assertEquals(instanceGroup.getInstanceGroupName(), generatedName);
- }
-
- @Test
- public void createInstanceGroupExceptionTest() throws Exception {
- expectedException.expect(BBObjectNotFoundException.class);
- lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, "notfound");
- doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID));
- String policyInstanceName = "policyInstanceName";
- String nfNamingCode = "nfNamingCode";
- execution.setVariable(policyInstanceName, policyInstanceName);
- execution.setVariable(nfNamingCode, nfNamingCode);
- doReturn("").when(namingServiceResources).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
- namingServiceCreateTasks.createInstanceGroupName(execution);
- verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
-
- }
-
+ @InjectMocks
+ private NamingServiceCreateTasks namingServiceCreateTasks = new NamingServiceCreateTasks();
+
+ private InstanceGroup instanceGroup;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ instanceGroup = setInstanceGroup();
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
+ .thenReturn(instanceGroup);
+ }
+
+ @Test
+ public void createInstanceGroupTest() throws Exception {
+ String policyInstanceName = "policyInstanceName";
+ String nfNamingCode = "nfNamingCode";
+ String generatedName = "generatedInstanceGroupName";
+ execution.setVariable(policyInstanceName, policyInstanceName);
+ execution.setVariable(nfNamingCode, nfNamingCode);
+ doReturn(generatedName).when(namingServiceResources).generateInstanceGroupName(instanceGroup,
+ policyInstanceName, nfNamingCode);
+
+ namingServiceCreateTasks.createInstanceGroupName(execution);
+ verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName,
+ nfNamingCode);
+ assertEquals(instanceGroup.getInstanceGroupName(), generatedName);
+ }
+
+ @Test
+ public void createInstanceGroupExceptionTest() throws Exception {
+ expectedException.expect(BBObjectNotFoundException.class);
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, "notfound");
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID));
+ String policyInstanceName = "policyInstanceName";
+ String nfNamingCode = "nfNamingCode";
+ execution.setVariable(policyInstanceName, policyInstanceName);
+ execution.setVariable(nfNamingCode, nfNamingCode);
+ doReturn("").when(namingServiceResources).generateInstanceGroupName(instanceGroup, policyInstanceName,
+ nfNamingCode);
+ namingServiceCreateTasks.createInstanceGroupName(execution);
+ verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName,
+ nfNamingCode);
+
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java
index 56226dfa96..758b8f4ffd 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
@@ -37,34 +36,36 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.client.exception.BBObjectNotFoundException;
public class NamingServiceDeleteTasksTest extends BaseTaskTest {
- @InjectMocks
- private NamingServiceDeleteTasks namingServiceDeleteTasks = new NamingServiceDeleteTasks();
-
- private InstanceGroup instanceGroup;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- instanceGroup = setInstanceGroup();
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID))).thenReturn(instanceGroup);
- }
-
- @Test
- public void deleteInstanceGroupTest() throws Exception {
-
- doReturn("").when(namingServiceResources).deleteInstanceGroupName(instanceGroup);
-
- namingServiceDeleteTasks.deleteInstanceGroupName(execution);
- verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup);
- }
-
- @Test
- public void deleteInstanceGroupExceptionTest() throws Exception {
- expectedException.expect(BBObjectNotFoundException.class);
- lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, "notfound");
- doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID));
- doReturn("").when(namingServiceResources).deleteInstanceGroupName(instanceGroup);
- namingServiceDeleteTasks.deleteInstanceGroupName(execution);
- verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup);
- }
-
+ @InjectMocks
+ private NamingServiceDeleteTasks namingServiceDeleteTasks = new NamingServiceDeleteTasks();
+
+ private InstanceGroup instanceGroup;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ instanceGroup = setInstanceGroup();
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
+ .thenReturn(instanceGroup);
+ }
+
+ @Test
+ public void deleteInstanceGroupTest() throws Exception {
+
+ doReturn("").when(namingServiceResources).deleteInstanceGroupName(instanceGroup);
+
+ namingServiceDeleteTasks.deleteInstanceGroupName(execution);
+ verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup);
+ }
+
+ @Test
+ public void deleteInstanceGroupExceptionTest() throws Exception {
+ expectedException.expect(BBObjectNotFoundException.class);
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, "notfound");
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID));
+ doReturn("").when(namingServiceResources).deleteInstanceGroupName(instanceGroup);
+ namingServiceDeleteTasks.deleteInstanceGroupName(execution);
+ verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup);
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java
index cbd7605aa4..4eb1432bbf 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java
@@ -29,7 +29,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -52,84 +51,98 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
-public class SDNCActivateTaskTest extends BaseTaskTest{
-
- @InjectMocks
- private SDNCActivateTasks sdncActivateTasks = new SDNCActivateTasks();
-
- private L3Network network;
- private ServiceInstance serviceInstance;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private Customer customer;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- network = setL3Network();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- cloudRegion = setCloudRegion();
- requestContext = setRequestContext();
- customer = setCustomer();
+public class SDNCActivateTaskTest extends BaseTaskTest {
+
+ @InjectMocks
+ private SDNCActivateTasks sdncActivateTasks = new SDNCActivateTasks();
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ network = setL3Network();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ cloudRegion = setCloudRegion();
+ requestContext = setRequestContext();
+ customer = setCustomer();
+
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+
+ }
+
+ @Test
+ public void activateVnfTest() throws Exception {
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).activateVnf(genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncActivateTasks.activateVnf(execution);
+ verify(sdncVnfResources, times(1)).activateVnf(genericVnf, serviceInstance, customer, cloudRegion,
+ requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
+ }
+
+ @Test
+ public void activateVnfTestException() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVnfResources).activateVnf(genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ sdncActivateTasks.activateVnf(execution);
+ }
+
+ @Test
+ public void activateNetworkTest() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).activateNetwork(
+ isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class),
+ isA(CloudRegion.class));
+ sdncActivateTasks.activateNetwork(execution);
+ verify(sdncNetworkResources, times(1)).activateNetwork(network, serviceInstance, customer, requestContext,
+ cloudRegion);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.NETWORK, sdncRequest.getTopology());
+ }
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
+ @Test
+ public void activateNetworkExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncNetworkResources).activateNetwork(isA(L3Network.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.class));
+ sdncActivateTasks.activateNetwork(execution);
+ }
- }
+ @Test
+ public void activateVfModuleTest() throws Exception {
+ doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources)
+ .activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ sdncActivateTasks.activateVfModule(execution);
+ verify(sdncVfModuleResources, times(1)).activateVfModule(vfModule, genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology());
+ }
- @Test
- public void activateVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).activateVnf(genericVnf,serviceInstance, customer, cloudRegion,requestContext);
- sdncActivateTasks.activateVnf(execution);
- verify(sdncVnfResources, times(1)).activateVnf(genericVnf,serviceInstance, customer,cloudRegion,requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
- }
-
- @Test
- public void activateVnfTestException() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVnfResources).activateVnf(genericVnf,serviceInstance, customer,cloudRegion,requestContext);
- sdncActivateTasks.activateVnf(execution);
- }
-
- @Test
- public void activateNetworkTest() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).activateNetwork(isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.class));
- sdncActivateTasks.activateNetwork(execution);
- verify(sdncNetworkResources, times(1)).activateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology());
- }
-
- @Test
- public void activateNetworkExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncNetworkResources).activateNetwork(isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.class));
- sdncActivateTasks.activateNetwork(execution);
- }
-
- @Test
- public void activateVfModuleTest() throws Exception {
- doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncActivateTasks.activateVfModule(execution);
- verify(sdncVfModuleResources, times(1)).activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
- }
-
- @Test
- public void activateVfModuleTestException() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVfModuleResources).activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncActivateTasks.activateVfModule(execution);
- }
+ @Test
+ public void activateVfModuleTestException() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).activateVfModule(vfModule, genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncActivateTasks.activateVfModule(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java
index b5509b1e12..7d8e94d1e9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -54,101 +53,117 @@ import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
-public class SDNCAssignTasksTest extends BaseTaskTest{
- @InjectMocks
- private SDNCAssignTasks sdncAssignTasks = new SDNCAssignTasks();
+public class SDNCAssignTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private SDNCAssignTasks sdncAssignTasks = new SDNCAssignTasks();
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private VolumeGroup volumeGroup;
+ private Customer customer;
- private L3Network network;
- private ServiceInstance serviceInstance;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private VolumeGroup volumeGroup;
- private Customer customer;
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ network = setL3Network();
+ cloudRegion = setCloudRegion();
+ requestContext = setRequestContext();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ volumeGroup = setVolumeGroup();
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- network = setL3Network();
- cloudRegion = setCloudRegion();
- requestContext = setRequestContext();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- volumeGroup = setVolumeGroup();
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))).thenReturn(volumeGroup);
- }
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ .thenReturn(volumeGroup);
+ }
- @Test
- public void assignServiceInstanceTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext);
- sdncAssignTasks.assignServiceInstance(execution);
- verify(sdncServiceInstanceResources, times(1)).assignServiceInstance(serviceInstance, customer, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.SERVICE,sdncRequest.getTopology());
- }
+ @Test
+ public void assignServiceInstanceTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources)
+ .assignServiceInstance(serviceInstance, customer, requestContext);
+ sdncAssignTasks.assignServiceInstance(execution);
+ verify(sdncServiceInstanceResources, times(1)).assignServiceInstance(serviceInstance, customer, requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.SERVICE, sdncRequest.getTopology());
+ }
- @Test
- public void assignServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext);
- sdncAssignTasks.assignServiceInstance(execution);
- }
+ @Test
+ public void assignServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance,
+ customer, requestContext);
+ sdncAssignTasks.assignServiceInstance(execution);
+ }
- @Test
- public void assignVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
- execution.setVariable("generalBuildingBlock", gBBInput);
- sdncAssignTasks.assignVnf(execution);
- verify(sdncVnfResources, times(1)).assignVnf(genericVnf, serviceInstance,customer, cloudRegion, requestContext, false);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
- }
+ @Test
+ public void assignVnfTest() throws Exception {
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).assignVnf(genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext, false);
+ execution.setVariable("generalBuildingBlock", gBBInput);
+ sdncAssignTasks.assignVnf(execution);
+ verify(sdncVnfResources, times(1)).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext,
+ false);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
+ }
- @Test
- public void assignVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
- sdncAssignTasks.assignVnf(execution);
- }
+ @Test
+ public void assignVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext, false);
+ sdncAssignTasks.assignVnf(execution);
+ }
- @Test
- public void assignVfModuleTest() throws Exception {
- doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncAssignTasks.assignVfModule(execution);
- verify(sdncVfModuleResources, times(1)).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
- }
+ @Test
+ public void assignVfModuleTest() throws Exception {
+ doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).assignVfModule(
+ vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ sdncAssignTasks.assignVfModule(execution);
+ verify(sdncVfModuleResources, times(1)).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance,
+ customer, cloudRegion, requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology());
+ }
- @Test
- public void assignVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncAssignTasks.assignVfModule(execution);
- }
+ @Test
+ public void assignVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncAssignTasks.assignVfModule(execution);
+ }
- @Test
- public void assignNetworkTest() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- sdncAssignTasks.assignNetwork(execution);
- verify(sdncNetworkResources, times(1)).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology());
- }
+ @Test
+ public void assignNetworkTest() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).assignNetwork(network,
+ serviceInstance, customer, requestContext, cloudRegion);
+ sdncAssignTasks.assignNetwork(execution);
+ verify(sdncNetworkResources, times(1)).assignNetwork(network, serviceInstance, customer, requestContext,
+ cloudRegion);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.NETWORK, sdncRequest.getTopology());
+ }
- @Test
- public void assignNetworkExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- sdncAssignTasks.assignNetwork(execution);
- }
+ @Test
+ public void assignNetworkExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ sdncAssignTasks.assignNetwork(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java
index be792115c9..1c1616a472 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -48,61 +47,70 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
-public class SDNCChangeAssignTasksTest extends BaseTaskTest{
- @InjectMocks
- private SDNCChangeAssignTasks sdncChangeAssignTasks = new SDNCChangeAssignTasks();
-
- private ServiceInstance serviceInstance;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
- private VfModule vfModule;
- private GenericVnf genericVnf;
- private Customer customer;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- cloudRegion = setCloudRegion();
- requestContext = setRequestContext();
+public class SDNCChangeAssignTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private SDNCChangeAssignTasks sdncChangeAssignTasks = new SDNCChangeAssignTasks();
+
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+ private VfModule vfModule;
+ private GenericVnf genericVnf;
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ cloudRegion = setCloudRegion();
+ requestContext = setRequestContext();
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ }
+
+ @Test
+ public void changeModelVnfTest() throws Exception {
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).changeModelVnf(genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncChangeAssignTasks.changeModelVnf(execution);
+ verify(sdncVnfResources, times(1)).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion,
+ requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
+ }
+
+ @Test
+ public void changeModelVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVnfResources).changeModelVnf(genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ sdncChangeAssignTasks.changeModelVnf(execution);
+ }
+
+ @Test
+ public void changeAssignModelVfModuleTest() throws Exception {
+ doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources)
+ .changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ sdncChangeAssignTasks.changeAssignModelVfModule(execution);
+ verify(sdncVfModuleResources, times(1)).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology());
+ }
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- }
-
- @Test
- public void changeModelVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncChangeAssignTasks.changeModelVnf(execution);
- verify(sdncVnfResources, times(1)).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
- }
-
- @Test
- public void changeModelVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVnfResources).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncChangeAssignTasks.changeModelVnf(execution);
- }
-
- @Test
- public void changeAssignModelVfModuleTest() throws Exception {
- doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncChangeAssignTasks.changeAssignModelVfModule(execution);
- verify(sdncVfModuleResources, times(1)).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
- }
-
- @Test
- public void changeAssignModelVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVfModuleResources).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncChangeAssignTasks.changeAssignModelVfModule(execution);
- }
+ @Test
+ public void changeAssignModelVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).changeAssignVfModule(vfModule, genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncChangeAssignTasks.changeAssignModelVfModule(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java
index 18048da50d..08d4d196da 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -53,97 +52,113 @@ import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
public class SDNCDeactivateTaskTest extends BaseTaskTest {
- @InjectMocks
- private SDNCDeactivateTasks sdncDeactivateTasks = new SDNCDeactivateTasks();
-
- private ServiceInstance serviceInstance;
- private CloudRegion cloudRegion;
- private RequestContext requestContext;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private L3Network network;
- private Customer customer;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- cloudRegion = setCloudRegion();
- requestContext = setRequestContext();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- network = setL3Network();
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
+ @InjectMocks
+ private SDNCDeactivateTasks sdncDeactivateTasks = new SDNCDeactivateTasks();
+
+ private ServiceInstance serviceInstance;
+ private CloudRegion cloudRegion;
+ private RequestContext requestContext;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private L3Network network;
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ cloudRegion = setCloudRegion();
+ requestContext = setRequestContext();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ network = setL3Network();
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+
+ }
+
+ @Test
+ public void deactivateVfModuleTest() throws Exception {
+ doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources)
+ .deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ sdncDeactivateTasks.deactivateVfModule(execution);
+ verify(sdncVfModuleResources, times(1)).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology());
+ }
+
+ @Test
+ public void deactivateVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncDeactivateTasks.deactivateVfModule(execution);
+ }
+
+ @Test
+ public void deactivateVnfTest() throws Exception {
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).deactivateVnf(genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncDeactivateTasks.deactivateVnf(execution);
+ verify(sdncVnfResources, times(1)).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion,
+ requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
+ }
+
+ @Test
+ public void deactivateVnfExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(sdncVnfResources).deactivateVnf(genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ expectedException.expect(BpmnError.class);
+ sdncDeactivateTasks.deactivateVnf(execution);
+ }
+
+ @Test
+ public void deactivateServiceInstanceTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources)
+ .deactivateServiceInstance(serviceInstance, customer, requestContext);
+ sdncDeactivateTasks.deactivateServiceInstance(execution);
+ verify(sdncServiceInstanceResources, times(1)).deactivateServiceInstance(serviceInstance, customer,
+ requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.SERVICE, sdncRequest.getTopology());
+ }
+
+ @Test
+ public void deactivateServiceInstanceExceptionTest() throws Exception {
+ doThrow(RuntimeException.class).when(sdncServiceInstanceResources).deactivateServiceInstance(serviceInstance,
+ customer, requestContext);
+ expectedException.expect(BpmnError.class);
+ sdncDeactivateTasks.deactivateServiceInstance(execution);
+ }
+
+ @Test
+ public void test_deactivateNetwork() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources)
+ .deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ sdncDeactivateTasks.deactivateNetwork(execution);
+ verify(sdncNetworkResources, times(1)).deactivateNetwork(network, serviceInstance, customer, requestContext,
+ cloudRegion);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.NETWORK, sdncRequest.getTopology());
+ }
- }
-
- @Test
- public void deactivateVfModuleTest() throws Exception {
- doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncDeactivateTasks.deactivateVfModule(execution);
- verify(sdncVfModuleResources, times(1)).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
- }
-
- @Test
- public void deactivateVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncDeactivateTasks.deactivateVfModule(execution);
- }
-
- @Test
- public void deactivateVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncDeactivateTasks.deactivateVnf(execution);
- verify(sdncVnfResources, times(1)).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
- }
-
- @Test
- public void deactivateVnfExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(sdncVnfResources).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- expectedException.expect(BpmnError.class);
- sdncDeactivateTasks.deactivateVnf(execution);
- }
-
- @Test
- public void deactivateServiceInstanceTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources).deactivateServiceInstance(serviceInstance, customer, requestContext);
- sdncDeactivateTasks.deactivateServiceInstance(execution);
- verify(sdncServiceInstanceResources, times(1)).deactivateServiceInstance(serviceInstance, customer, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.SERVICE,sdncRequest.getTopology());
- }
-
- @Test
- public void deactivateServiceInstanceExceptionTest() throws Exception {
- doThrow(RuntimeException.class).when(sdncServiceInstanceResources).deactivateServiceInstance(serviceInstance, customer, requestContext);
- expectedException.expect(BpmnError.class);
- sdncDeactivateTasks.deactivateServiceInstance(execution);
- }
-
- @Test
- public void test_deactivateNetwork() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- sdncDeactivateTasks.deactivateNetwork(execution);
- verify(sdncNetworkResources, times(1)).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology());
- }
-
- @Test
- public void test_deactivateNetwork_exception() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID));
- sdncDeactivateTasks.deactivateNetwork(execution);
- verify(sdncNetworkResources, times(0)).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- }
+ @Test
+ public void test_deactivateNetwork_exception() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.NETWORK_ID));
+ sdncDeactivateTasks.deactivateNetwork(execution);
+ verify(sdncNetworkResources, times(0)).deactivateNetwork(network, serviceInstance, customer, requestContext,
+ cloudRegion);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java
index 28551baa7a..3ea8474b24 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java
@@ -29,7 +29,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Rule;
@@ -45,95 +44,99 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.client.exception.BBObjectNotFoundException;
-public class SDNCQueryTasksTest extends BaseTaskTest{
- @InjectMocks
- private SDNCQueryTasks sdncQueryTasks = new SDNCQueryTasks();
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- private ServiceInstance serviceInstance;
- private GenericVnf genericVnf;
- private VfModule vfModule;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- serviceInstance = setServiceInstance();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
-
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
-
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
-
- }
-
- @Test
- public void queryVfModuleTest() throws Exception {
- String sdncQueryResponse = "response";
- vfModule.setSelflink("vfModuleSelfLink");
-
- doReturn(sdncQueryResponse).when(sdncVfModuleResources).queryVfModule(vfModule);
-
- assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
- sdncQueryTasks.queryVfModule(execution);
- assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
-
- verify(sdncVfModuleResources, times(1)).queryVfModule(vfModule);
- }
-
- @Test
- public void queryVnfTest() throws Exception {
- String sdncQueryResponse = "response";
-
- doReturn(sdncQueryResponse).when(sdncVnfResources).queryVnf(genericVnf);
-
- assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId()));
- sdncQueryTasks.queryVnf(execution);
- assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId()));
-
- verify(sdncVnfResources, times(1)).queryVnf(genericVnf);
- }
-
- @Test
- public void queryVfModuleForVolumeGroupTest() throws Exception {
- String sdncQueryResponse = "response";
- vfModule.setSelflink("vfModuleSelfLink");
-
- doReturn(sdncQueryResponse).when(sdncVfModuleResources).queryVfModule(vfModule);
-
- assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
- sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
- assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
-
- verify(sdncVfModuleResources, times(1)).queryVfModule(vfModule);
- }
-
- @Test
- public void queryVfModuleForVolumeGroupNoSelfLinkExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- vfModule.setSelflink("");
-
- sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
- }
-
- @Test
- public void queryVfModuleForVolumeGroupVfObjectExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID));
- sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
-
- verify(sdncVfModuleResources, times(0)).queryVfModule(any(VfModule.class));
- }
-
- @Test
- public void queryVfModuleForVolumeGroupNonVfObjectExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
- sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
- }
+public class SDNCQueryTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private SDNCQueryTasks sdncQueryTasks = new SDNCQueryTasks();
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private ServiceInstance serviceInstance;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+
+ }
+
+ @Test
+ public void queryVfModuleTest() throws Exception {
+ String sdncQueryResponse = "response";
+ vfModule.setSelflink("vfModuleSelfLink");
+
+ doReturn(sdncQueryResponse).when(sdncVfModuleResources).queryVfModule(vfModule);
+
+ assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
+ sdncQueryTasks.queryVfModule(execution);
+ assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
+
+ verify(sdncVfModuleResources, times(1)).queryVfModule(vfModule);
+ }
+
+ @Test
+ public void queryVnfTest() throws Exception {
+ String sdncQueryResponse = "response";
+
+ doReturn(sdncQueryResponse).when(sdncVnfResources).queryVnf(genericVnf);
+
+ assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId()));
+ sdncQueryTasks.queryVnf(execution);
+ assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId()));
+
+ verify(sdncVnfResources, times(1)).queryVnf(genericVnf);
+ }
+
+ @Test
+ public void queryVfModuleForVolumeGroupTest() throws Exception {
+ String sdncQueryResponse = "response";
+ vfModule.setSelflink("vfModuleSelfLink");
+
+ doReturn(sdncQueryResponse).when(sdncVfModuleResources).queryVfModule(vfModule);
+
+ assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
+ sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
+ assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()));
+
+ verify(sdncVfModuleResources, times(1)).queryVfModule(vfModule);
+ }
+
+ @Test
+ public void queryVfModuleForVolumeGroupNoSelfLinkExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ vfModule.setSelflink("");
+
+ sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
+ }
+
+ @Test
+ public void queryVfModuleForVolumeGroupVfObjectExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),
+ ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID));
+ sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
+
+ verify(sdncVfModuleResources, times(0)).queryVfModule(any(VfModule.class));
+ }
+
+ @Test
+ public void queryVfModuleForVolumeGroupNonVfObjectExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
index 043aad43b1..b5d34ea4c9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
@@ -25,18 +25,14 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.IOException;
import java.io.StringReader;
import java.nio.file.Files;
import java.nio.file.Paths;
-
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
-
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
import org.junit.Rule;
@@ -57,128 +53,133 @@ import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
-
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
-public class SDNCRequestTasksTest extends SDNCRequestTasks{
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @InjectMocks
- SDNCRequestTasks sndcRequestTasks = new SDNCRequestTasks();
-
- @Mock
- SDNCClient sdncClient;
-
- @Spy
- private ExceptionBuilder exceptionBuilder;
-
- protected DelegateExecution delegateExecution;
-
-
- @Before
- public void setup(){
- delegateExecution = new DelegateExecutionFake();
- delegateExecution.setVariable("SDNCRequest", createSDNCRequest());
- }
-
- @Test
- public void createCorrelationVariables_Test(){
- sndcRequestTasks.createCorrelationVariables(delegateExecution);
- assertEquals("correlationValue",delegateExecution.getVariable("correlationName_CORRELATOR"));
- }
-
- @Test
- public void callSDNC_Final_Test() throws MapperException, BadResponseException, IOException{
- final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientPut200Response.json")));
- doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),SDNCTopology.CONFIGURATION);
- sndcRequestTasks.callSDNC(delegateExecution);
- assertEquals(true,delegateExecution.getVariable("isSDNCCompleted"));
- }
-
- @Test
- public void callSDNC_Not_Final_Test() throws MapperException, BadResponseException, IOException{
- final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json")));
- doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),SDNCTopology.CONFIGURATION);
- sndcRequestTasks.callSDNC(delegateExecution);
- assertEquals(false,delegateExecution.getVariable("isSDNCCompleted"));
- }
-
- @Test
- public void callSDNC_Error_Test() throws MapperException, BadResponseException{
- doThrow(MapperException.class).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),SDNCTopology.CONFIGURATION);
- doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution);
- expectedException.expect(BpmnError.class);
- sndcRequestTasks.callSDNC(delegateExecution);
- }
-
- @Test
- public void convertIndicatorToBoolean_True_Test() throws MapperException, BadResponseException{
- boolean testValue = sndcRequestTasks.convertIndicatorToBoolean("Y");
- assertEquals(true,testValue);
- }
-
- @Test
- public void convertIndicatorToBoolean_False_Test() throws MapperException, BadResponseException{
- boolean testValue = sndcRequestTasks.convertIndicatorToBoolean("N");
- assertEquals(false,testValue);
- }
-
- @Test
- public void HandleTimeout_Test() throws MapperException, BadResponseException{
- doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution);
- expectedException.expect(BpmnError.class);
- sndcRequestTasks.handleTimeOutException(delegateExecution);
- }
-
- @Test
- public void processCallBack_Final_Test() throws MapperException, BadResponseException, IOException{
- final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
- delegateExecution.setVariable("correlationName_MESSAGE", sdncResponse);
- sndcRequestTasks.processCallback(delegateExecution);
- assertEquals(true,delegateExecution.getVariable(IS_CALLBACK_COMPLETED));
- }
-
- @Test
- public void getXmlElementTest() throws Exception {
- final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+public class SDNCRequestTasksTest extends SDNCRequestTasks {
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @InjectMocks
+ SDNCRequestTasks sndcRequestTasks = new SDNCRequestTasks();
+
+ @Mock
+ SDNCClient sdncClient;
+
+ @Spy
+ private ExceptionBuilder exceptionBuilder;
+
+ protected DelegateExecution delegateExecution;
+
+
+ @Before
+ public void setup() {
+ delegateExecution = new DelegateExecutionFake();
+ delegateExecution.setVariable("SDNCRequest", createSDNCRequest());
+ }
+
+ @Test
+ public void createCorrelationVariables_Test() {
+ sndcRequestTasks.createCorrelationVariables(delegateExecution);
+ assertEquals("correlationValue", delegateExecution.getVariable("correlationName_CORRELATOR"));
+ }
+
+ @Test
+ public void callSDNC_Final_Test() throws MapperException, BadResponseException, IOException {
+ final String sdncResponse =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientPut200Response.json")));
+ doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(), SDNCTopology.CONFIGURATION);
+ sndcRequestTasks.callSDNC(delegateExecution);
+ assertEquals(true, delegateExecution.getVariable("isSDNCCompleted"));
+ }
+
+ @Test
+ public void callSDNC_Not_Final_Test() throws MapperException, BadResponseException, IOException {
+ final String sdncResponse = new String(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json")));
+ doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(), SDNCTopology.CONFIGURATION);
+ sndcRequestTasks.callSDNC(delegateExecution);
+ assertEquals(false, delegateExecution.getVariable("isSDNCCompleted"));
+ }
+
+ @Test
+ public void callSDNC_Error_Test() throws MapperException, BadResponseException {
+ doThrow(MapperException.class).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),
+ SDNCTopology.CONFIGURATION);
+ doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution);
+ expectedException.expect(BpmnError.class);
+ sndcRequestTasks.callSDNC(delegateExecution);
+ }
+
+ @Test
+ public void convertIndicatorToBoolean_True_Test() throws MapperException, BadResponseException {
+ boolean testValue = sndcRequestTasks.convertIndicatorToBoolean("Y");
+ assertEquals(true, testValue);
+ }
+
+ @Test
+ public void convertIndicatorToBoolean_False_Test() throws MapperException, BadResponseException {
+ boolean testValue = sndcRequestTasks.convertIndicatorToBoolean("N");
+ assertEquals(false, testValue);
+ }
+
+ @Test
+ public void HandleTimeout_Test() throws MapperException, BadResponseException {
+ doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution);
+ expectedException.expect(BpmnError.class);
+ sndcRequestTasks.handleTimeOutException(delegateExecution);
+ }
+
+ @Test
+ public void processCallBack_Final_Test() throws MapperException, BadResponseException, IOException {
+ final String sdncResponse =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
+ delegateExecution.setVariable("correlationName_MESSAGE", sdncResponse);
+ sndcRequestTasks.processCallback(delegateExecution);
+ assertEquals(true, delegateExecution.getVariable(IS_CALLBACK_COMPLETED));
+ }
+
+ @Test
+ public void getXmlElementTest() throws Exception {
+ final String sdncResponse =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
- db = dbf.newDocumentBuilder ();
- Document doc = db.parse (new InputSource(new StringReader(sdncResponse)));
-
+ db = dbf.newDocumentBuilder();
+ Document doc = db.parse(new InputSource(new StringReader(sdncResponse)));
+
String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
String responseCode = getXmlElement(doc, "/input/response-code");
- String responseMessage = getXmlElement(doc, "/input/response-message");
-
- assertEquals("Y", finalMessageIndicator);
- assertEquals("200", responseCode);
- assertEquals("Success", responseMessage);
- }
-
- public SDNCRequest createSDNCRequest(){
- SDNCRequest request = new SDNCRequest();
- request.setCorrelationName("correlationName");
- request.setCorrelationValue("correlationValue");
- request.setTopology(SDNCTopology.CONFIGURATION);
- ObjectMapper mapper = new ObjectMapper();
- try {
- GenericResourceApiServiceOperationInformation sdncReq =
- mapper.readValue(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Client_Request.json")), GenericResourceApiServiceOperationInformation.class);
- request.setSDNCPayload(sdncReq);
- } catch (JsonParseException e) {
-
- } catch (JsonMappingException e) {
-
- } catch (IOException e) {
-
- }
-
- return request;
- }
-
+ String responseMessage = getXmlElement(doc, "/input/response-message");
+
+ assertEquals("Y", finalMessageIndicator);
+ assertEquals("200", responseCode);
+ assertEquals("Success", responseMessage);
+ }
+
+ public SDNCRequest createSDNCRequest() {
+ SDNCRequest request = new SDNCRequest();
+ request.setCorrelationName("correlationName");
+ request.setCorrelationValue("correlationValue");
+ request.setTopology(SDNCTopology.CONFIGURATION);
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ GenericResourceApiServiceOperationInformation sdncReq = mapper.readValue(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Client_Request.json")),
+ GenericResourceApiServiceOperationInformation.class);
+ request.setSDNCPayload(sdncReq);
+ } catch (JsonParseException e) {
+
+ } catch (JsonMappingException e) {
+
+ } catch (IOException e) {
+
+ }
+
+ return request;
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
index 527fe0d916..c6ed1cca7a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java
@@ -30,7 +30,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -54,99 +53,111 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
-public class SDNCUnassignTasksTest extends BaseTaskTest{
- @InjectMocks
- private SDNCUnassignTasks sdncUnassignTasks = new SDNCUnassignTasks();
-
- private ServiceInstance serviceInstance;
- private RequestContext requestContext;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private CloudRegion cloudRegion;
- private L3Network network;
- private Customer customer;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- customer = setCustomer();
- serviceInstance = setServiceInstance();
- requestContext = setRequestContext();
- genericVnf = setGenericVnf();
- vfModule = setVfModule();
- cloudRegion = setCloudRegion();
- network = setL3Network();
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
- }
-
- @Test
- public void unassignServiceInstanceTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext);
- sdncUnassignTasks.unassignServiceInstance(execution);
- verify(sdncServiceInstanceResources, times(1)).unassignServiceInstance(serviceInstance, customer, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.SERVICE,sdncRequest.getTopology());
- }
-
-
-
- @Test
- public void unassignServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext);
- sdncUnassignTasks.unassignServiceInstance(execution);
- }
-
- @Test
- public void unassignVfModuleTest() throws Exception {
- doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf, serviceInstance);
- sdncUnassignTasks.unassignVfModule(execution);
- verify(sdncVfModuleResources, times(1)).unassignVfModule(vfModule, genericVnf, serviceInstance);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
- }
-
-
-
-
- @Test
- public void unassignVfModuleExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf, serviceInstance);
- sdncUnassignTasks.unassignVfModule(execution);
- }
-
- @Test
- public void unassignVnfTest() throws Exception {
- doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncUnassignTasks.unassignVnf(execution);
- verify(sdncVnfResources, times(1)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
- }
-
-
- @Test
- public void unassignVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
- doThrow(RuntimeException.class).when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- sdncUnassignTasks.unassignVnf(execution);
- }
-
- @Test
- public void unassignNetworkTest() throws Exception {
- String cloudRegionSdnc = "AAIAIC25";
- cloudRegion.setCloudRegionVersion("2.5");
- execution.setVariable("cloudRegionSdnc", cloudRegionSdnc);
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- assertNotEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId());
- sdncUnassignTasks.unassignNetwork(execution);
- verify(sdncNetworkResources, times(1)).unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- assertEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId());
- SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
- assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology());
- }
+public class SDNCUnassignTasksTest extends BaseTaskTest {
+ @InjectMocks
+ private SDNCUnassignTasks sdncUnassignTasks = new SDNCUnassignTasks();
+
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private CloudRegion cloudRegion;
+ private L3Network network;
+ private Customer customer;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ customer = setCustomer();
+ serviceInstance = setServiceInstance();
+ requestContext = setRequestContext();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ cloudRegion = setCloudRegion();
+ network = setL3Network();
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+ }
+
+ @Test
+ public void unassignServiceInstanceTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources)
+ .unassignServiceInstance(serviceInstance, customer, requestContext);
+ sdncUnassignTasks.unassignServiceInstance(execution);
+ verify(sdncServiceInstanceResources, times(1)).unassignServiceInstance(serviceInstance, customer,
+ requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.SERVICE, sdncRequest.getTopology());
+ }
+
+
+
+ @Test
+ public void unassignServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance,
+ customer, requestContext);
+ sdncUnassignTasks.unassignServiceInstance(execution);
+ }
+
+ @Test
+ public void unassignVfModuleTest() throws Exception {
+ doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources)
+ .unassignVfModule(vfModule, genericVnf, serviceInstance);
+ sdncUnassignTasks.unassignVfModule(execution);
+ verify(sdncVfModuleResources, times(1)).unassignVfModule(vfModule, genericVnf, serviceInstance);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology());
+ }
+
+
+
+ @Test
+ public void unassignVfModuleExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf,
+ serviceInstance);
+ sdncUnassignTasks.unassignVfModule(execution);
+ }
+
+ @Test
+ public void unassignVnfTest() throws Exception {
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).unassignVnf(genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext);
+ sdncUnassignTasks.unassignVnf(execution);
+ verify(sdncVnfResources, times(1)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion,
+ requestContext);
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VNF, sdncRequest.getTopology());
+ }
+
+
+ @Test
+ public void unassignVnfExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer,
+ cloudRegion, requestContext);
+ sdncUnassignTasks.unassignVnf(execution);
+ }
+
+ @Test
+ public void unassignNetworkTest() throws Exception {
+ String cloudRegionSdnc = "AAIAIC25";
+ cloudRegion.setCloudRegionVersion("2.5");
+ execution.setVariable("cloudRegionSdnc", cloudRegionSdnc);
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources)
+ .unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ assertNotEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId());
+ sdncUnassignTasks.unassignNetwork(execution);
+ verify(sdncNetworkResources, times(1)).unassignNetwork(network, serviceInstance, customer, requestContext,
+ cloudRegion);
+ assertEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId());
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.NETWORK, sdncRequest.getTopology());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java
index 81ec388649..2fc3cf639c 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import java.util.Optional;
import java.util.Set;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -35,83 +34,84 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
public class CloudRegionOrchestrationValidatorTest {
-
- private BuildingBlockExecution mockExecution;
- private CloudRegion cloudRegion;
-
- @Before
- public void setUp() {
- cloudRegion = new CloudRegion();
- cloudRegion.setCloudOwner("CloudOwner");
- cloudRegion.setLcpCloudRegionId("my-region-id");
- GeneralBuildingBlock gbb = new GeneralBuildingBlock();
- gbb.setCloudRegion(cloudRegion);
- mockExecution = mock(BuildingBlockExecution.class);
- doReturn(gbb).when(mockExecution).getGeneralBuildingBlock();
- }
-
- @Test
- public void validateDisabledTest() {
- cloudRegion.setOrchestrationDisabled(true);
- CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
- Optional<String> result = validation.validate(mockExecution);
- assertEquals("Error: The request has failed due to orchestration currently disabled for the target cloud region my-region-id for cloud owner CloudOwner",
- result.get());
- }
-
- @Test
- public void validateNotDisabledTest() {
- cloudRegion.setOrchestrationDisabled(false);
- CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
- Optional<String> result = validation.validate(mockExecution);
- assertFalse(result.isPresent());
- }
-
- @Test
- public void validateDisabledIsNullTest() {
- CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
- Optional<String> result = validation.validate(mockExecution);
- assertFalse(result.isPresent());
- }
- @Test
- public void shouldRunForTest() {
- CloudRegionOrchestrationValidator validator = new CloudRegionOrchestrationValidator();
- assertTrue(validator.shouldRunFor("ActivateNetworkBB"));
- assertTrue(validator.shouldRunFor("AssignNetworkBB"));
- assertTrue(validator.shouldRunFor("CreateNetworkBB"));
- assertTrue(validator.shouldRunFor("DeactivateNetworkBB"));
- assertTrue(validator.shouldRunFor("DeleteNetworkBB"));
- assertTrue(validator.shouldRunFor("UnassignNetworkBB"));
- assertTrue(validator.shouldRunFor("UpdateNetworkBB"));
-
- assertTrue(validator.shouldRunFor("ActivateVnfBB"));
- assertTrue(validator.shouldRunFor("AssignVnfBB"));
- assertTrue(validator.shouldRunFor("UnassignVnfBB"));
- assertTrue(validator.shouldRunFor("DeactivateVnfBB"));
+ private BuildingBlockExecution mockExecution;
+ private CloudRegion cloudRegion;
+
+ @Before
+ public void setUp() {
+ cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner("CloudOwner");
+ cloudRegion.setLcpCloudRegionId("my-region-id");
+ GeneralBuildingBlock gbb = new GeneralBuildingBlock();
+ gbb.setCloudRegion(cloudRegion);
+ mockExecution = mock(BuildingBlockExecution.class);
+ doReturn(gbb).when(mockExecution).getGeneralBuildingBlock();
+ }
+
+ @Test
+ public void validateDisabledTest() {
+ cloudRegion.setOrchestrationDisabled(true);
+ CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
+ Optional<String> result = validation.validate(mockExecution);
+ assertEquals(
+ "Error: The request has failed due to orchestration currently disabled for the target cloud region my-region-id for cloud owner CloudOwner",
+ result.get());
+ }
+
+ @Test
+ public void validateNotDisabledTest() {
+ cloudRegion.setOrchestrationDisabled(false);
+ CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
+ Optional<String> result = validation.validate(mockExecution);
+ assertFalse(result.isPresent());
+ }
+
+ @Test
+ public void validateDisabledIsNullTest() {
+ CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
+ Optional<String> result = validation.validate(mockExecution);
+ assertFalse(result.isPresent());
+ }
+
+ @Test
+ public void shouldRunForTest() {
+ CloudRegionOrchestrationValidator validator = new CloudRegionOrchestrationValidator();
+ assertTrue(validator.shouldRunFor("ActivateNetworkBB"));
+ assertTrue(validator.shouldRunFor("AssignNetworkBB"));
+ assertTrue(validator.shouldRunFor("CreateNetworkBB"));
+ assertTrue(validator.shouldRunFor("DeactivateNetworkBB"));
+ assertTrue(validator.shouldRunFor("DeleteNetworkBB"));
+ assertTrue(validator.shouldRunFor("UnassignNetworkBB"));
+ assertTrue(validator.shouldRunFor("UpdateNetworkBB"));
+
+ assertTrue(validator.shouldRunFor("ActivateVnfBB"));
+ assertTrue(validator.shouldRunFor("AssignVnfBB"));
+ assertTrue(validator.shouldRunFor("UnassignVnfBB"));
+ assertTrue(validator.shouldRunFor("DeactivateVnfBB"));
+
+ assertTrue(validator.shouldRunFor("ActivateVfModuleBB"));
+ assertTrue(validator.shouldRunFor("AssignVfModuleBB"));
+ assertTrue(validator.shouldRunFor("CreateVfModuleBB"));
+ assertTrue(validator.shouldRunFor("DeactivateVfModuleBB"));
+ assertTrue(validator.shouldRunFor("DeleteVfModuleBB"));
+ assertTrue(validator.shouldRunFor("UnassignVfModuleBB"));
+
+ assertTrue(validator.shouldRunFor("ActivateVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("AssignVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("CreateVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("DeactivateVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("DeleteVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("UnassignVolumeGroupBB"));
+
+ assertTrue(validator.shouldRunFor("ActivateFabricConfigurationBB"));
+ assertTrue(validator.shouldRunFor("AssignFabricConfigurationBB"));
+ assertTrue(validator.shouldRunFor("UnassignFabricConfigurationBB"));
+ assertTrue(validator.shouldRunFor("DeactivateFabricConfigurationBB"));
- assertTrue(validator.shouldRunFor("ActivateVfModuleBB"));
- assertTrue(validator.shouldRunFor("AssignVfModuleBB"));
- assertTrue(validator.shouldRunFor("CreateVfModuleBB"));
- assertTrue(validator.shouldRunFor("DeactivateVfModuleBB"));
- assertTrue(validator.shouldRunFor("DeleteVfModuleBB"));
- assertTrue(validator.shouldRunFor("UnassignVfModuleBB"));
-
- assertTrue(validator.shouldRunFor("ActivateVolumeGroupBB"));
- assertTrue(validator.shouldRunFor("AssignVolumeGroupBB"));
- assertTrue(validator.shouldRunFor("CreateVolumeGroupBB"));
- assertTrue(validator.shouldRunFor("DeactivateVolumeGroupBB"));
- assertTrue(validator.shouldRunFor("DeleteVolumeGroupBB"));
- assertTrue(validator.shouldRunFor("UnassignVolumeGroupBB"));
-
- assertTrue(validator.shouldRunFor("ActivateFabricConfigurationBB"));
- assertTrue(validator.shouldRunFor("AssignFabricConfigurationBB"));
- assertTrue(validator.shouldRunFor("UnassignFabricConfigurationBB"));
- assertTrue(validator.shouldRunFor("DeactivateFabricConfigurationBB"));
-
- assertFalse(validator.shouldRunFor("AssignServiceInstanceBB"));
- assertFalse(validator.shouldRunFor("AAICheckVnfInMaintBB"));
- assertFalse(validator.shouldRunFor("ChangeModelVfModuleBB"));
- assertFalse(validator.shouldRunFor("CreateNetworkCollectionBB"));
- }
+ assertFalse(validator.shouldRunFor("AssignServiceInstanceBB"));
+ assertFalse(validator.shouldRunFor("AAICheckVnfInMaintBB"));
+ assertFalse(validator.shouldRunFor("ChangeModelVfModuleBB"));
+ assertFalse(validator.shouldRunFor("CreateNetworkCollectionBB"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java
index 3cf003d1ad..1bdde8f904 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -37,33 +36,33 @@ import org.springframework.beans.factory.annotation.Autowired;
public class FlowCompletionTasksTest extends BaseTaskTest {
- @InjectMocks
- protected FlowCompletionTasks flowCompletionTasks = new FlowCompletionTasks();
+ @InjectMocks
+ protected FlowCompletionTasks flowCompletionTasks = new FlowCompletionTasks();
+
+ @Before
+ public void before() {
+ setRequestContext();
+ }
+
+ @Test
+ public void updateRequestDbStatusComplete_Test() throws Exception {
+ InfraActiveRequests mockedRequest = new InfraActiveRequests();
+ when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ flowCompletionTasks.updateRequestDbStatus(execution);
+ verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ assertEquals(mockedRequest.getRequestStatus(), "COMPLETE");
+ }
- @Before
- public void before() {
- setRequestContext();
- }
-
- @Test
- public void updateRequestDbStatusComplete_Test() throws Exception{
- InfraActiveRequests mockedRequest = new InfraActiveRequests();
- when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
- doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
- flowCompletionTasks.updateRequestDbStatus(execution);
- verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
- assertEquals(mockedRequest.getRequestStatus(), "COMPLETE");
- }
-
- @Test
- public void updateRequestDbStatusFailed_Test() throws Exception{
- WorkflowException workflowException = new WorkflowException("testProcessKey", 7000, "Error");
- execution.setVariable("WorkflowException", workflowException);
- InfraActiveRequests mockedRequest = new InfraActiveRequests();
- when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
- doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
- flowCompletionTasks.updateRequestDbStatus(execution);
- verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
- assertEquals(mockedRequest.getRequestStatus(), "FAILED");
- }
+ @Test
+ public void updateRequestDbStatusFailed_Test() throws Exception {
+ WorkflowException workflowException = new WorkflowException("testProcessKey", 7000, "Error");
+ execution.setVariable("WorkflowException", workflowException);
+ InfraActiveRequests mockedRequest = new InfraActiveRequests();
+ when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ flowCompletionTasks.updateRequestDbStatus(execution);
+ verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
+ assertEquals(mockedRequest.getRequestStatus(), "FAILED");
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java
index 60d456e2b5..b371e3a48a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java
@@ -26,11 +26,9 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Ignore;
@@ -54,384 +52,434 @@ import org.springframework.beans.factory.annotation.Autowired;
@Ignore
public class OrchestrationStatusValidatorTest extends BaseTaskTest {
- @InjectMocks
- protected OrchestrationStatusValidator orchestrationStatusValidator = new OrchestrationStatusValidator();
-
-
-
- @Test
- public void test_validateOrchestrationStatus() throws Exception {
- String flowToBeCalled = "AssignServiceInstanceBB";
- setServiceInstance().setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.SERVICE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED, OrchestrationAction.ASSIGN);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.CONTINUE, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatusConfiguration() throws Exception {
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
- String flowToBeCalled = "UnassignFabricConfigurationBB";
- ServiceInstance si = setServiceInstance();
- List<Configuration> configurations = new ArrayList<>();
- Configuration config = new Configuration();
-
- si.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- config.setConfigurationId("configurationId");
- config.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- configurations.add(config);
- si.setConfigurations(configurations);
-
- execution.setVariable("flowToBeCalled", flowToBeCalled);
- execution.setVariable("aLaCarte", true);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("UnassignFabricConfigurationBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.CONFIGURATION);
- buildingBlockDetail.setTargetAction(OrchestrationAction.UNASSIGN);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.CONFIGURATION);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.UNASSIGN);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.CONFIGURATION, OrchestrationStatus.PRECREATED, OrchestrationAction.UNASSIGN);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatus_buildingBlockDetailNotFound() throws Exception {
- expectedException.expect(BpmnError.class);
-
- String flowToBeCalled = "AssignServiceInstanceBB";
-
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- doReturn(null).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
- }
-
- @Test
- public void test_validateOrchestrationStatus_orchestrationValidationFail() throws Exception {
- expectedException.expect(BpmnError.class);
-
- String flowToBeCalled = "AssignServiceInstanceBB";
-
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.SERVICE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED, OrchestrationAction.ASSIGN);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
- }
-
- @Test
- public void test_validateOrchestrationStatus_orchestrationValidationNotFound() throws Exception {
- expectedException.expect(BpmnError.class);
-
- String flowToBeCalled = "AssignServiceInstanceBB";
-
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.SERVICE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.NETWORK, OrchestrationStatus.PRECREATED, OrchestrationAction.ASSIGN);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
- }
-
- @Test
- public void test_validateOrchestrationStatus_unassignNotFound() throws Exception{
- String flowToBeCalled = "UnassignServiceInstanceBB";
-
- execution.setVariable("flowToBeCalled", flowToBeCalled);
- execution.setVariable("aLaCarte", true);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("UnassignServiceInstanceBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.SERVICE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.UNASSIGN);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- lookupKeyMap = new HashMap<ResourceKey, String>();
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatusSecondStageOfMultiStageEnabledVfModule() throws Exception {
- String flowToBeCalled = "CreateVfModuleBB";
-
- execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- GenericVnf genericVnf = buildGenericVnf();
- ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
- setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.CONTINUE, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
-
- @Test
- public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongPrevStatusVfModule() throws Exception {
- String flowToBeCalled = "CreateVfModuleBB";
-
- execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.CONTINUE);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- GenericVnf genericVnf = buildGenericVnf();
- ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
- setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatusSecondStageOfMultiStageDisabledVfModule() throws Exception {
- String flowToBeCalled = "CreateVfModuleBB";
-
- execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- GenericVnf genericVnf = buildGenericVnf();
- ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("false");
- setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
- setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongOrchStatusVfModule() throws Exception {
- String flowToBeCalled = "CreateVfModuleBB";
-
- execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- GenericVnf genericVnf = buildGenericVnf();
- ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
- setVfModule().setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.ASSIGNED, OrchestrationAction.CREATE);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongTargetActionVfModule() throws Exception {
- String flowToBeCalled = "CreateVfModuleBB";
-
- execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- GenericVnf genericVnf = buildGenericVnf();
- ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
- setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.ACTIVATE);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.ACTIVATE);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
- }
-
- @Test
- public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongAlacarteValueVfModule() throws Exception {
- String flowToBeCalled = "CreateVfModuleBB";
-
- execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("flowToBeCalled", flowToBeCalled);
-
- GenericVnf genericVnf = buildGenericVnf();
- ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- modelInfoGenericVnf.setMultiStageDesign("true");
- setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
- setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
-
- BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
- buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
- buildingBlockDetail.setId(1);
- buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
- buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
-
- doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
-
- OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective();
- orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
- orchestrationStatusStateTransitionDirective.setId(1);
- orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
- orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
- orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE);
-
- doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
-
- orchestrationStatusValidator.validateOrchestrationStatus(execution);
-
- assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult"));
- }
+ @InjectMocks
+ protected OrchestrationStatusValidator orchestrationStatusValidator = new OrchestrationStatusValidator();
+
+
+
+ @Test
+ public void test_validateOrchestrationStatus() throws Exception {
+ String flowToBeCalled = "AssignServiceInstanceBB";
+ setServiceInstance().setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.SERVICE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED,
+ OrchestrationAction.ASSIGN);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.CONTINUE,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatusConfiguration() throws Exception {
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
+ String flowToBeCalled = "UnassignFabricConfigurationBB";
+ ServiceInstance si = setServiceInstance();
+ List<Configuration> configurations = new ArrayList<>();
+ Configuration config = new Configuration();
+
+ si.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ config.setConfigurationId("configurationId");
+ config.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ configurations.add(config);
+ si.setConfigurations(configurations);
+
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+ execution.setVariable("aLaCarte", true);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("UnassignFabricConfigurationBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.CONFIGURATION);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.UNASSIGN);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.CONFIGURATION);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.UNASSIGN);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.CONFIGURATION,
+ OrchestrationStatus.PRECREATED, OrchestrationAction.UNASSIGN);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatus_buildingBlockDetailNotFound() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ String flowToBeCalled = "AssignServiceInstanceBB";
+
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ doReturn(null).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+ }
+
+ @Test
+ public void test_validateOrchestrationStatus_orchestrationValidationFail() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ String flowToBeCalled = "AssignServiceInstanceBB";
+
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.SERVICE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.SERVICE, OrchestrationStatus.PRECREATED,
+ OrchestrationAction.ASSIGN);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+ }
+
+ @Test
+ public void test_validateOrchestrationStatus_orchestrationValidationNotFound() throws Exception {
+ expectedException.expect(BpmnError.class);
+
+ String flowToBeCalled = "AssignServiceInstanceBB";
+
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("AssignServiceInstanceBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.SERVICE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.ASSIGN);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.SERVICE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ASSIGN);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.NETWORK, OrchestrationStatus.PRECREATED,
+ OrchestrationAction.ASSIGN);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+ }
+
+ @Test
+ public void test_validateOrchestrationStatus_unassignNotFound() throws Exception {
+ String flowToBeCalled = "UnassignServiceInstanceBB";
+
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+ execution.setVariable("aLaCarte", true);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("UnassignServiceInstanceBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.SERVICE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.UNASSIGN);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ lookupKeyMap = new HashMap<ResourceKey, String>();
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatusSecondStageOfMultiStageEnabledVfModule() throws Exception {
+ String flowToBeCalled = "CreateVfModuleBB";
+
+ execution.setVariable("orchestrationStatusValidationResult",
+ OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ GenericVnf genericVnf = buildGenericVnf();
+ ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+ setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.FAIL);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE,
+ OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.CONTINUE,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+
+ @Test
+ public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongPrevStatusVfModule() throws Exception {
+ String flowToBeCalled = "CreateVfModuleBB";
+
+ execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.CONTINUE);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ GenericVnf genericVnf = buildGenericVnf();
+ ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+ setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE,
+ OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatusSecondStageOfMultiStageDisabledVfModule() throws Exception {
+ String flowToBeCalled = "CreateVfModuleBB";
+
+ execution.setVariable("orchestrationStatusValidationResult",
+ OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ GenericVnf genericVnf = buildGenericVnf();
+ ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("false");
+ setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+ setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE,
+ OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongOrchStatusVfModule() throws Exception {
+ String flowToBeCalled = "CreateVfModuleBB";
+
+ execution.setVariable("orchestrationStatusValidationResult",
+ OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ GenericVnf genericVnf = buildGenericVnf();
+ ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+ setVfModule().setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.ASSIGNED,
+ OrchestrationAction.CREATE);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongTargetActionVfModule() throws Exception {
+ String flowToBeCalled = "CreateVfModuleBB";
+
+ execution.setVariable("orchestrationStatusValidationResult",
+ OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ GenericVnf genericVnf = buildGenericVnf();
+ ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+ setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.ACTIVATE);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE,
+ OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.ACTIVATE);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
+
+ @Test
+ public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongAlacarteValueVfModule() throws Exception {
+ String flowToBeCalled = "CreateVfModuleBB";
+
+ execution.setVariable("orchestrationStatusValidationResult",
+ OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("flowToBeCalled", flowToBeCalled);
+
+ GenericVnf genericVnf = buildGenericVnf();
+ ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
+ modelInfoGenericVnf.setMultiStageDesign("true");
+ setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf);
+ setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+
+ BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail();
+ buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB");
+ buildingBlockDetail.setId(1);
+ buildingBlockDetail.setResourceType(ResourceType.VF_MODULE);
+ buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE);
+
+ doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled);
+
+ OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective =
+ new OrchestrationStatusStateTransitionDirective();
+ orchestrationStatusStateTransitionDirective
+ .setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS);
+ orchestrationStatusStateTransitionDirective.setId(1);
+ orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION);
+ orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE);
+ orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE);
+
+ doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient)
+ .getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE,
+ OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE);
+
+ orchestrationStatusValidator.validateOrchestrationStatus(execution);
+
+ assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS,
+ execution.getVariable("orchestrationStatusValidationResult"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java
index 03b39f57e5..0da683de62 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java
@@ -23,7 +23,6 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -41,25 +40,27 @@ import org.onap.so.db.catalog.client.CatalogDbClient;
@RunWith(MockitoJUnitRunner.class)
public class OrchestrationStatusValidatorUnitTest {
- @Mock
- private CatalogDbClient catalogDbClient;
-
- @InjectMocks
- private OrchestrationStatusValidator validator;
- @Test
- public void skipValidationTest() {
- BuildingBlockDetail bbDetail = new BuildingBlockDetail();
- bbDetail.setBuildingBlockName("customBB");
- bbDetail.setResourceType(ResourceType.NO_VALIDATE);
- bbDetail.setTargetAction(OrchestrationAction.CUSTOM);
- when(catalogDbClient.getBuildingBlockDetail("customBB")).thenReturn(bbDetail);
- BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
- execution.setVariable("flowToBeCalled", "customBB");
- execution.setVariable("aLaCarte", false);
- validator.validateOrchestrationStatus(execution);
-
-
- assertThat(execution.getVariable("orchestrationStatusValidationResult"), equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED));
- }
-
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @InjectMocks
+ private OrchestrationStatusValidator validator;
+
+ @Test
+ public void skipValidationTest() {
+ BuildingBlockDetail bbDetail = new BuildingBlockDetail();
+ bbDetail.setBuildingBlockName("customBB");
+ bbDetail.setResourceType(ResourceType.NO_VALIDATE);
+ bbDetail.setTargetAction(OrchestrationAction.CUSTOM);
+ when(catalogDbClient.getBuildingBlockDetail("customBB")).thenReturn(bbDetail);
+ BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
+ execution.setVariable("flowToBeCalled", "customBB");
+ execution.setVariable("aLaCarte", false);
+ validator.validateOrchestrationStatus(execution);
+
+
+ assertThat(execution.getVariable("orchestrationStatusValidationResult"),
+ equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED));
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
index 14261e876d..a6ce88f164 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
@@ -26,7 +26,6 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
@@ -42,105 +41,105 @@ import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.db.request.beans.InfraActiveRequests;
-public class WorkflowActionBBFailureTest extends BaseTaskTest {
+public class WorkflowActionBBFailureTest extends BaseTaskTest {
+
+ @Mock
+ protected WorkflowAction workflowAction;
+
+ @InjectMocks
+ @Spy
+ protected WorkflowActionBBFailure workflowActionBBFailure;
+
+ @Mock
+ InfraActiveRequests reqMock;
+
+ private DelegateExecution execution;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void before() throws Exception {
+ execution = new DelegateExecutionFake();
+ org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ servInstance.setServiceInstanceId("TEST");
+ when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), isA(Customer.class))).thenReturn(servInstance);
+ workflowAction.setBbInputSetupUtils(bbSetupUtils);
+ workflowAction.setBbInputSetup(bbInputSetup);
+ }
+
+ @Test
+ public void updateRequestStatusToFailed_Null_Rollback() {
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ execution.setVariable("retryCount", 3);
+ execution.setVariable("handlingCode", "Success");
+ execution.setVariable("gCurrentSequence", 1);
+ WorkflowException we = new WorkflowException("WorkflowAction", 1231, "Error Case");
+ execution.setVariable("WorkflowException", we);
+
+ doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ Mockito.verify(reqMock, Mockito.times(1)).setStatusMessage("Error Case");
+ Mockito.verify(reqMock, Mockito.times(1)).setRequestStatus("FAILED");
+ Mockito.verify(reqMock, Mockito.times(1)).setProgress(Long.valueOf(100));
+ Mockito.verify(reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN");
+ }
+
+ @Test
+ public void updateRequestStatusToFailed() {
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", false);
+ execution.setVariable("isRollback", false);
+ InfraActiveRequests req = new InfraActiveRequests();
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in test case");
+ execution.setVariable("WorkflowException", wfe);
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("ErrorMessage");
+ assertEquals("error in test case", errorMsg);
+ }
+
+ @Test
+ public void updateRequestStatusToFailedRollback() {
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", false);
+ execution.setVariable("isRollback", true);
+ InfraActiveRequests req = new InfraActiveRequests();
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback");
+ execution.setVariable("WorkflowException", wfe);
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
+ assertEquals("error in rollback", errorMsg);
+ }
+
+ @Test
+ public void updateRequestStatusToFailedRollbackCompleted() {
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", true);
+ execution.setVariable("isRollback", true);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
+ assertEquals("Rollback has been completed successfully.", errorMsg);
+ }
- @Mock
- protected WorkflowAction workflowAction;
-
- @InjectMocks
- @Spy
- protected WorkflowActionBBFailure workflowActionBBFailure;
-
- @Mock
- InfraActiveRequests reqMock;
-
- private DelegateExecution execution;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Before
- public void before() throws Exception {
- execution = new DelegateExecutionFake();
- org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
- servInstance.setServiceInstanceId("TEST");
- when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), isA(Customer.class))).thenReturn(servInstance);
- workflowAction.setBbInputSetupUtils(bbSetupUtils);
- workflowAction.setBbInputSetup(bbInputSetup);
- }
-
- @Test
- public void updateRequestStatusToFailed_Null_Rollback(){
- String reqId = "reqId123";
- execution.setVariable("mso-request-id", reqId);
- execution.setVariable("retryCount", 3);
- execution.setVariable("handlingCode","Success");
- execution.setVariable("gCurrentSequence",1);
- WorkflowException we = new WorkflowException("WorkflowAction",1231,"Error Case");
- execution.setVariable("WorkflowException",we);
-
- doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- workflowActionBBFailure.updateRequestStatusToFailed(execution);
- Mockito.verify( reqMock, Mockito.times(1)).setStatusMessage("Error Case");
- Mockito.verify( reqMock, Mockito.times(1)).setRequestStatus("FAILED");
- Mockito.verify( reqMock, Mockito.times(1)).setProgress(Long.valueOf(100));
- Mockito.verify( reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN");
- }
-
- @Test
- public void updateRequestStatusToFailed(){
- execution.setVariable("mso-request-id", "123");
- execution.setVariable("isRollbackComplete", false);
- execution.setVariable("isRollback", false);
- InfraActiveRequests req = new InfraActiveRequests();
- WorkflowException wfe = new WorkflowException("processKey123", 1, "error in test case");
- execution.setVariable("WorkflowException", wfe);
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBFailure.updateRequestStatusToFailed(execution);
- String errorMsg = (String) execution.getVariable("ErrorMessage");
- assertEquals("error in test case", errorMsg);
- }
-
- @Test
- public void updateRequestStatusToFailedRollback(){
- execution.setVariable("mso-request-id", "123");
- execution.setVariable("isRollbackComplete", false);
- execution.setVariable("isRollback", true);
- InfraActiveRequests req = new InfraActiveRequests();
- WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback");
- execution.setVariable("WorkflowException", wfe);
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBFailure.updateRequestStatusToFailed(execution);
- String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
- assertEquals("error in rollback", errorMsg);
- }
-
- @Test
- public void updateRequestStatusToFailedRollbackCompleted(){
- execution.setVariable("mso-request-id", "123");
- execution.setVariable("isRollbackComplete", true);
- execution.setVariable("isRollback", true);
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBFailure.updateRequestStatusToFailed(execution);
- String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
- assertEquals("Rollback has been completed successfully.", errorMsg);
- }
-
- @Test
- public void updateRequestStatusToFailedNoWorkflowException(){
- execution.setVariable("mso-request-id", "123");
- execution.setVariable("isRollbackComplete", false);
- execution.setVariable("isRollback", false);
- execution.setVariable("WorkflowExceptionErrorMessage", "error in test case");
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBFailure.updateRequestStatusToFailed(execution);
- String errorMsg = (String) execution.getVariable("ErrorMessage");
- assertEquals("error in test case", errorMsg);
- }
+ @Test
+ public void updateRequestStatusToFailedNoWorkflowException() {
+ execution.setVariable("mso-request-id", "123");
+ execution.setVariable("isRollbackComplete", false);
+ execution.setVariable("isRollback", false);
+ execution.setVariable("WorkflowExceptionErrorMessage", "error in test case");
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(execution);
+ String errorMsg = (String) execution.getVariable("ErrorMessage");
+ assertEquals("error in test case", errorMsg);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
index c5b4a482b7..029562a6e9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
@@ -27,10 +27,8 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
-
import java.util.ArrayList;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
@@ -51,314 +49,315 @@ import org.springframework.core.env.Environment;
public class WorkflowActionBBTasksTest extends BaseTaskTest {
- @Mock
- protected WorkflowAction workflowAction;
-
- @Mock
- protected WorkflowActionBBFailure workflowActionBBFailure;
-
- @InjectMocks
- @Spy
- protected WorkflowActionBBTasks workflowActionBBTasks;
-
- @Mock
- InfraActiveRequests reqMock;
-
- private DelegateExecution execution;
-
- @Mock
- protected Environment environment;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Before
- public void before() throws Exception {
- execution = new DelegateExecutionFake();
- org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
- servInstance.setServiceInstanceId("TEST");
- when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
- workflowAction.setBbInputSetupUtils(bbSetupUtils);
- workflowAction.setBbInputSetup(bbInputSetup);
- }
-
- @Test
- public void selectBBTest() throws Exception{
- String gAction = "Delete-Network-Collection";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- execution.setVariable("gCurrentSequence", 0);
- execution.setVariable("homing", false);
- execution.setVariable("calledHoming", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- flowsToExecute.add(ebb);
- execution.setVariable("flowsToExecute", flowsToExecute);
- workflowActionBBTasks.selectBB(execution);
- boolean success = (boolean) execution.getVariable("completed");
- int currentSequence = (int) execution.getVariable("gCurrentSequence");
- assertEquals(true,success);
- assertEquals(1,currentSequence);
- }
-
- @Test
- public void select2BBTest() throws Exception{
- String gAction = "Delete-Network-Collection";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- execution.setVariable("gCurrentSequence", 0);
- execution.setVariable("homing", false);
- execution.setVariable("calledHoming", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- flowsToExecute.add(ebb);
- flowsToExecute.add(ebb2);
- execution.setVariable("flowsToExecute", flowsToExecute);
- workflowActionBBTasks.selectBB(execution);
- boolean success = (boolean) execution.getVariable("completed");
- int currentSequence = (int) execution.getVariable("gCurrentSequence");
- assertEquals(false,success);
- assertEquals(1,currentSequence);
- }
-
- @Test
- public void updateRequestStatusToCompleteTest() throws Exception{
- String reqId = "reqId123";
- execution.setVariable("mso-request-id", reqId);
- execution.setVariable("requestAction", "createInstance");
- execution.setVariable("resourceName", "Service");
- execution.setVariable("aLaCarte", true);
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBTasks.updateRequestStatusToComplete(execution);
- assertEquals("ALaCarte-Service-createInstance request was executed correctly.",execution.getVariable("finalStatusMessage"));
- }
-
- @Test
- public void rollbackExecutionPathTest(){
- execution.setVariable("handlingCode", "Rollback");
- execution.setVariable("isRollback", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
- flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
- flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
- flowsToExecute.add(ebb3);
-
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("gCurrentSequence", 3);
- doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
-
- workflowActionBBTasks.rollbackExecutionPath(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeactivateVfModuleBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"DeleteVfModuleBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"UnassignVfModuleBB");
- assertEquals(0,execution.getVariable("gCurrentSequence"));
- }
-
- @Test
- public void rollbackExecutionPathUnfinishedFlowTest(){
- execution.setVariable("handlingCode", "Rollback");
- execution.setVariable("isRollback", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
- flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
- flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
- flowsToExecute.add(ebb3);
-
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("gCurrentSequence", 2);
- doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
-
- workflowActionBBTasks.rollbackExecutionPath(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeleteVfModuleBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"UnassignVfModuleBB");
- assertEquals(0,execution.getVariable("gCurrentSequence"));
- assertEquals(0,execution.getVariable("retryCount"));
- }
-
- @Test
- public void rollbackExecutionTest(){
- execution.setVariable("handlingCode", "Rollback");
- execution.setVariable("isRollback", false);
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignServiceInstanceBB");
- ebb1.setBuildingBlock(bb1);
- flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateNetworkCollectionBB");
- ebb2.setBuildingBlock(bb2);
- flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("AssignNetworkBB");
- ebb3.setBuildingBlock(bb3);
- flowsToExecute.add(ebb3);
- ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
- BuildingBlock bb4 = new BuildingBlock();
- bb4.setBpmnFlowName("CreateNetworkBB");
- ebb4.setBuildingBlock(bb4);
- flowsToExecute.add(ebb4);
-
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("gCurrentSequence", 3);
- doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
-
- workflowActionBBTasks.rollbackExecutionPath(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"UnassignNetworkBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkCollectionBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"UnassignServiceInstanceBB");
- assertEquals(0,execution.getVariable("gCurrentSequence"));
- }
-
- @Test
- public void rollbackExecutionRollbackToAssignedTest(){
- execution.setVariable("isRollback", false);
- execution.setVariable("handlingCode", "RollbackToAssigned");
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
- flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
- flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
- flowsToExecute.add(ebb3);
-
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("gCurrentSequence", 2);
-
- workflowActionBBTasks.rollbackExecutionPath(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals("DeleteVfModuleBB",ebbs.get(0).getBuildingBlock().getBpmnFlowName());
- assertEquals(0,execution.getVariable("gCurrentSequence"));
- assertEquals(1,ebbs.size());
- }
-
- @Test
- public void rollbackExecutionRollbackToCreatedTest(){
- execution.setVariable("isRollback", false);
- execution.setVariable("handlingCode", "RollbackToCreated");
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("AssignVfModuleBB");
- ebb1.setBuildingBlock(bb1);
- flowsToExecute.add(ebb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("CreateVfModuleBB");
- ebb2.setBuildingBlock(bb2);
- flowsToExecute.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("ActivateVfModuleBB");
- ebb3.setBuildingBlock(bb3);
- flowsToExecute.add(ebb3);
-
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("gCurrentSequence", 3);
-
- workflowActionBBTasks.rollbackExecutionPath(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals("DeactivateVfModuleBB",ebbs.get(0).getBuildingBlock().getBpmnFlowName());
- assertEquals(0,execution.getVariable("gCurrentSequence"));
- assertEquals(1,ebbs.size());
- }
-
- @Test
- public void checkRetryStatusTest(){
- String reqId = "reqId123";
- execution.setVariable("mso-request-id", reqId);
- doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
- doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
- execution.setVariable("handlingCode","Retry");
- execution.setVariable("retryCount", 1);
- execution.setVariable("gCurrentSequence",1);
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- workflowActionBBTasks.checkRetryStatus(execution);
- assertEquals(0,execution.getVariable("gCurrentSequence"));
- }
-
- @Test
- public void checkRetryStatusTestExceededMaxRetries(){
- String reqId = "reqId123";
- execution.setVariable("mso-request-id", reqId);
- doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
- doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
- execution.setVariable("handlingCode","Retry");
- execution.setVariable("retryCount", 6);
- execution.setVariable("gCurrentSequence",1);
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- try{
- workflowActionBBTasks.checkRetryStatus(execution);
- } catch (BpmnError e) {
- WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
- assertEquals("Exceeded maximum retries. Ending flow with status Abort",exception.getErrorMessage());
- }
- }
-
- @Test
- public void checkRetryStatusNoRetryTest(){
- String reqId = "reqId123";
- execution.setVariable("mso-request-id", reqId);
- execution.setVariable("retryCount", 3);
- execution.setVariable("handlingCode","Success");
- execution.setVariable("gCurrentSequence",1);
- InfraActiveRequests req = new InfraActiveRequests();
- doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- workflowActionBBTasks.checkRetryStatus(execution);
- assertEquals(0,execution.getVariable("retryCount"));
- }
-
- @Test
- public void updateInstanceId(){
- String reqId = "req123";
- String instanceId = "123123123";
- execution.setVariable("mso-request-id", reqId);
- execution.setVariable("resourceId", instanceId);
- execution.setVariable("resourceType", WorkflowType.SERVICE);
- doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
- doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
- workflowActionBBTasks.updateInstanceId(execution);
- Mockito.verify( reqMock, Mockito.times(1)).setServiceInstanceId(instanceId);
- }
+ @Mock
+ protected WorkflowAction workflowAction;
+
+ @Mock
+ protected WorkflowActionBBFailure workflowActionBBFailure;
+
+ @InjectMocks
+ @Spy
+ protected WorkflowActionBBTasks workflowActionBBTasks;
+
+ @Mock
+ InfraActiveRequests reqMock;
+
+ private DelegateExecution execution;
+
+ @Mock
+ protected Environment environment;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void before() throws Exception {
+ execution = new DelegateExecutionFake();
+ org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ servInstance.setServiceInstanceId("TEST");
+ when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
+ workflowAction.setBbInputSetupUtils(bbSetupUtils);
+ workflowAction.setBbInputSetup(bbInputSetup);
+ }
+
+ @Test
+ public void selectBBTest() throws Exception {
+ String gAction = "Delete-Network-Collection";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ execution.setVariable("gCurrentSequence", 0);
+ execution.setVariable("homing", false);
+ execution.setVariable("calledHoming", false);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
+ flowsToExecute.add(ebb);
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ workflowActionBBTasks.selectBB(execution);
+ boolean success = (boolean) execution.getVariable("completed");
+ int currentSequence = (int) execution.getVariable("gCurrentSequence");
+ assertEquals(true, success);
+ assertEquals(1, currentSequence);
+ }
+
+ @Test
+ public void select2BBTest() throws Exception {
+ String gAction = "Delete-Network-Collection";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ execution.setVariable("gCurrentSequence", 0);
+ execution.setVariable("homing", false);
+ execution.setVariable("calledHoming", false);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ flowsToExecute.add(ebb);
+ flowsToExecute.add(ebb2);
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ workflowActionBBTasks.selectBB(execution);
+ boolean success = (boolean) execution.getVariable("completed");
+ int currentSequence = (int) execution.getVariable("gCurrentSequence");
+ assertEquals(false, success);
+ assertEquals(1, currentSequence);
+ }
+
+ @Test
+ public void updateRequestStatusToCompleteTest() throws Exception {
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ execution.setVariable("requestAction", "createInstance");
+ execution.setVariable("resourceName", "Service");
+ execution.setVariable("aLaCarte", true);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBTasks.updateRequestStatusToComplete(execution);
+ assertEquals("ALaCarte-Service-createInstance request was executed correctly.",
+ execution.getVariable("finalStatusMessage"));
+ }
+
+ @Test
+ public void rollbackExecutionPathTest() {
+ execution.setVariable("handlingCode", "Rollback");
+ execution.setVariable("isRollback", false);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("AssignVfModuleBB");
+ ebb1.setBuildingBlock(bb1);
+ flowsToExecute.add(ebb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("CreateVfModuleBB");
+ ebb2.setBuildingBlock(bb2);
+ flowsToExecute.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("ActivateVfModuleBB");
+ ebb3.setBuildingBlock(bb3);
+ flowsToExecute.add(ebb3);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 3);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "DeactivateVfModuleBB");
+ assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "DeleteVfModuleBB");
+ assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(), "UnassignVfModuleBB");
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ }
+
+ @Test
+ public void rollbackExecutionPathUnfinishedFlowTest() {
+ execution.setVariable("handlingCode", "Rollback");
+ execution.setVariable("isRollback", false);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("AssignVfModuleBB");
+ ebb1.setBuildingBlock(bb1);
+ flowsToExecute.add(ebb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("CreateVfModuleBB");
+ ebb2.setBuildingBlock(bb2);
+ flowsToExecute.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("ActivateVfModuleBB");
+ ebb3.setBuildingBlock(bb3);
+ flowsToExecute.add(ebb3);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 2);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "DeleteVfModuleBB");
+ assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "UnassignVfModuleBB");
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ assertEquals(0, execution.getVariable("retryCount"));
+ }
+
+ @Test
+ public void rollbackExecutionTest() {
+ execution.setVariable("handlingCode", "Rollback");
+ execution.setVariable("isRollback", false);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("AssignServiceInstanceBB");
+ ebb1.setBuildingBlock(bb1);
+ flowsToExecute.add(ebb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("CreateNetworkCollectionBB");
+ ebb2.setBuildingBlock(bb2);
+ flowsToExecute.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("AssignNetworkBB");
+ ebb3.setBuildingBlock(bb3);
+ flowsToExecute.add(ebb3);
+ ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
+ BuildingBlock bb4 = new BuildingBlock();
+ bb4.setBpmnFlowName("CreateNetworkBB");
+ ebb4.setBuildingBlock(bb4);
+ flowsToExecute.add(ebb4);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 3);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "UnassignNetworkBB");
+ assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(), "DeleteNetworkCollectionBB");
+ assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(), "UnassignServiceInstanceBB");
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ }
+
+ @Test
+ public void rollbackExecutionRollbackToAssignedTest() {
+ execution.setVariable("isRollback", false);
+ execution.setVariable("handlingCode", "RollbackToAssigned");
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("AssignVfModuleBB");
+ ebb1.setBuildingBlock(bb1);
+ flowsToExecute.add(ebb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("CreateVfModuleBB");
+ ebb2.setBuildingBlock(bb2);
+ flowsToExecute.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("ActivateVfModuleBB");
+ ebb3.setBuildingBlock(bb3);
+ flowsToExecute.add(ebb3);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 2);
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals("DeleteVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ assertEquals(1, ebbs.size());
+ }
+
+ @Test
+ public void rollbackExecutionRollbackToCreatedTest() {
+ execution.setVariable("isRollback", false);
+ execution.setVariable("handlingCode", "RollbackToCreated");
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("AssignVfModuleBB");
+ ebb1.setBuildingBlock(bb1);
+ flowsToExecute.add(ebb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("CreateVfModuleBB");
+ ebb2.setBuildingBlock(bb2);
+ flowsToExecute.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("ActivateVfModuleBB");
+ ebb3.setBuildingBlock(bb3);
+ flowsToExecute.add(ebb3);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 3);
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals("DeactivateVfModuleBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ assertEquals(1, ebbs.size());
+ }
+
+ @Test
+ public void checkRetryStatusTest() {
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+ doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
+ execution.setVariable("handlingCode", "Retry");
+ execution.setVariable("retryCount", 1);
+ execution.setVariable("gCurrentSequence", 1);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ workflowActionBBTasks.checkRetryStatus(execution);
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ }
+
+ @Test
+ public void checkRetryStatusTestExceededMaxRetries() {
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
+ doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
+ execution.setVariable("handlingCode", "Retry");
+ execution.setVariable("retryCount", 6);
+ execution.setVariable("gCurrentSequence", 1);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ try {
+ workflowActionBBTasks.checkRetryStatus(execution);
+ } catch (BpmnError e) {
+ WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
+ assertEquals("Exceeded maximum retries. Ending flow with status Abort", exception.getErrorMessage());
+ }
+ }
+
+ @Test
+ public void checkRetryStatusNoRetryTest() {
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ execution.setVariable("retryCount", 3);
+ execution.setVariable("handlingCode", "Success");
+ execution.setVariable("gCurrentSequence", 1);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ workflowActionBBTasks.checkRetryStatus(execution);
+ assertEquals(0, execution.getVariable("retryCount"));
+ }
+
+ @Test
+ public void updateInstanceId() {
+ String reqId = "req123";
+ String instanceId = "123123123";
+ execution.setVariable("mso-request-id", reqId);
+ execution.setVariable("resourceId", instanceId);
+ execution.setVariable("resourceType", WorkflowType.SERVICE);
+ doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBTasks.updateInstanceId(execution);
+ Mockito.verify(reqMock, Mockito.times(1)).setServiceInstanceId(instanceId);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java
index 0f106ad913..9c3f0c6f0b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java
@@ -26,10 +26,8 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
-
import java.util.ArrayList;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
@@ -43,52 +41,53 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.db.request.beans.InfraActiveRequests;
-public class WorkflowActionBBTasksUpdateReqDbTest extends BaseTaskTest{
+public class WorkflowActionBBTasksUpdateReqDbTest extends BaseTaskTest {
+
+ protected WorkflowAction workflowAction = new WorkflowAction();
+
+ @Spy
+ @InjectMocks
+ protected WorkflowActionBBTasks workflowActionBBTasks;
+
+ private DelegateExecution execution;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void before() throws Exception {
+ execution = new DelegateExecutionFake();
+ org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ servInstance.setServiceInstanceId("TEST");
+ when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), any())).thenReturn(servInstance);
+ workflowAction.setBbInputSetupUtils(bbSetupUtils);
+ workflowAction.setBbInputSetup(bbInputSetup);
+ }
- protected WorkflowAction workflowAction = new WorkflowAction();
-
- @Spy
- @InjectMocks
- protected WorkflowActionBBTasks workflowActionBBTasks;
-
- private DelegateExecution execution;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Before
- public void before() throws Exception {
- execution = new DelegateExecutionFake();
- org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
- servInstance.setServiceInstanceId("TEST");
- when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), any())).thenReturn(servInstance);
- workflowAction.setBbInputSetupUtils(bbSetupUtils);
- workflowAction.setBbInputSetup(bbInputSetup);
- }
-
- @Test
- public void getUpdatedRequestTest() throws Exception{
- List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
- ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
- BuildingBlock bb1 = new BuildingBlock();
- bb1.setBpmnFlowName("CreateNetworkBB");
- flowsToExecute.add(ebb1);
- ebb1.setBuildingBlock(bb1);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("ActivateNetworkBB");
- flowsToExecute.add(ebb2);
- ebb2.setBuildingBlock(bb2);
- String requestId = "requestId";
- execution.setVariable("mso-request-id", requestId);
- execution.setVariable("flowsToExecute", flowsToExecute);
- int currentSequence = 2;
- String expectedStatusMessage = "Execution of CreateNetworkBB has completed successfully, next invoking ActivateNetworkBB (Execution Path progress: BBs completed = 1; BBs remaining = 1).";
- Long expectedLong = new Long(52);
- InfraActiveRequests mockedRequest = new InfraActiveRequests();
- doReturn(mockedRequest).when(requestsDbClient).getInfraActiveRequestbyRequestId(isA(String.class));
- InfraActiveRequests actual = workflowActionBBTasks.getUpdatedRequest(execution, currentSequence);
- assertEquals(expectedStatusMessage, actual.getFlowStatus());
- assertEquals(expectedLong, actual.getProgress());
- }
+ @Test
+ public void getUpdatedRequestTest() throws Exception {
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
+ BuildingBlock bb1 = new BuildingBlock();
+ bb1.setBpmnFlowName("CreateNetworkBB");
+ flowsToExecute.add(ebb1);
+ ebb1.setBuildingBlock(bb1);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("ActivateNetworkBB");
+ flowsToExecute.add(ebb2);
+ ebb2.setBuildingBlock(bb2);
+ String requestId = "requestId";
+ execution.setVariable("mso-request-id", requestId);
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ int currentSequence = 2;
+ String expectedStatusMessage =
+ "Execution of CreateNetworkBB has completed successfully, next invoking ActivateNetworkBB (Execution Path progress: BBs completed = 1; BBs remaining = 1).";
+ Long expectedLong = new Long(52);
+ InfraActiveRequests mockedRequest = new InfraActiveRequests();
+ doReturn(mockedRequest).when(requestsDbClient).getInfraActiveRequestbyRequestId(isA(String.class));
+ InfraActiveRequests actual = workflowActionBBTasks.getUpdatedRequest(execution, currentSequence);
+ assertEquals(expectedStatusMessage, actual.getFlowStatus());
+ assertEquals(expectedLong, actual.getProgress());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index 87e6daa58a..ad1238b86f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -30,7 +30,6 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -97,687 +96,808 @@ import org.onap.so.serviceinstancebeans.SubscriberInfo;
import org.springframework.core.env.Environment;
public class WorkflowActionTest extends BaseTaskTest {
-
-
- @Mock
- protected Environment environment;
- @InjectMocks
- protected WorkflowAction workflowAction;
- private DelegateExecution execution;
-
-
- @InjectMocks
- @Spy
- protected WorkflowAction SPY_workflowAction;
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private String RESOURCE_PATH = "src/test/resources/__files/";
-
- @Before
- public void before() throws Exception {
- execution = new DelegateExecutionFake();
- org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
- servInstance.setServiceInstanceId("TEST");
- when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
- workflowAction.setBbInputSetupUtils(bbSetupUtils);
- workflowAction.setBbInputSetup(bbInputSetup);
- }
- /**
- * ALACARTE TESTS
- */
- @Test
- public void selectExecutionListALaCarteNetworkCreateTest() throws Exception{
- String gAction = "createInstance";
- String resource = "Network";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/networks/123");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignNetwork1802BB","CreateNetworkBB","ActivateNetworkBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignNetwork1802BB","CreateNetworkBB","ActivateNetworkBB");
- }
-
- @Test
- public void selectExecutionListALaCarteNetworkDeleteTest() throws Exception{
- String gAction = "deleteInstance";
- String resource = "Network";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/networks/123");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateNetworkBB","DeleteNetworkBB","UnassignNetwork1802BB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"DeactivateNetworkBB","DeleteNetworkBB","UnassignNetwork1802BB");
- }
-
- @Test
- public void selectExecutionListALaCarteServiceCreateTest() throws Exception{
- String gAction = "createInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","ActivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","ActivateServiceInstanceBB");
- }
-
- /**
- * SERVICE MACRO TESTS
- */
- @Test
- public void selectExecutionListServiceMacroAssignTest() throws Exception{
- String gAction = "assignInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- HeatEnvironment volumeHeatEnv = new HeatEnvironment();
- vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
- org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
- HeatTemplate volumeHeatTemplate = new HeatTemplate();
- vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
- vfModuleCustomization.setVfModule(vfModule);
-
- VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
- vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- HeatEnvironment heatEnvironment = new HeatEnvironment();
- vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
- org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
- HeatTemplate moduleHeatTemplate = new HeatTemplate();
- vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
- vfModuleCustomization2.setVfModule(vfModule2);
-
- VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
- vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f")).thenReturn(vfModuleCustomization);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8")).thenReturn(vfModuleCustomization2);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969")).thenReturn(vfModuleCustomization3);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB","AssignVfModuleBB","AssignVfModuleBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroAssignNoCloudTest() throws Exception{
- String gAction = "assignInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- HeatEnvironment volumeHeatEnv = new HeatEnvironment();
- vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
- org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
- HeatTemplate volumeHeatTemplate = new HeatTemplate();
- vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
- vfModuleCustomization.setVfModule(vfModule);
-
- VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
- vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- HeatEnvironment heatEnvironment = new HeatEnvironment();
- vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
- org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
- HeatTemplate moduleHeatTemplate = new HeatTemplate();
- vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
- vfModuleCustomization2.setVfModule(vfModule2);
-
- VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
- vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
-
- when(environment.getProperty("org.onap.so.cloud-owner")).thenReturn("att-aic");
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"att-aic")).thenReturn(northBoundRequest);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f")).thenReturn(vfModuleCustomization);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8")).thenReturn(vfModuleCustomization2);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969")).thenReturn(vfModuleCustomization3);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB","AssignVfModuleBB","AssignVfModuleBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroActivateTest() throws Exception{
- String gAction = "activateInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/si0");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkBB","ActivateNetworkBB","CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","ActivateVfModuleBB"
- ,"ActivateVnfBB","ActivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- ServiceInstance serviceInstanceAAI = new ServiceInstance();
- serviceInstanceAAI.setServiceInstanceId("si0");
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
- vnf.setVnfId("vnf0");
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
- vfModule.setVfModuleId("vfModule0");
- vnf.getVfModules().add(vfModule);
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
- vfModule2.setVfModuleId("vfModule1");
- vnf.getVfModules().add(vfModule2);
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroup0");
- vnf.getVolumeGroups().add(volumeGroup);
-
- serviceInstanceMSO.getVnfs().add(vnf);
-
- doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("si0");
- doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","ActivateVfModuleBB","ActivateVnfBB","ActivateServiceInstanceBB");
- assertEquals("volumeGroup0", ebbs.get(0).getWorkflowResourceIds().getVolumeGroupId());
- assertEquals("volumeGroup0", ebbs.get(1).getWorkflowResourceIds().getVolumeGroupId());
- assertEquals("vfModule0", ebbs.get(2).getWorkflowResourceIds().getVfModuleId());
- assertEquals("vfModule1", ebbs.get(3).getWorkflowResourceIds().getVfModuleId());
- assertEquals("vfModule0", ebbs.get(4).getWorkflowResourceIds().getVfModuleId());
- assertEquals("vfModule1", ebbs.get(5).getWorkflowResourceIds().getVfModuleId());
- assertEquals("vnf0", ebbs.get(6).getWorkflowResourceIds().getVnfId());
- assertEquals("si0", ebbs.get(7).getWorkflowResourceIds().getServiceInstanceId());
-
- }
-
- @Test
- public void selectExecutionListServiceMacroDeactivateTest() throws Exception{
- String gAction = "deactivateInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeactivateServiceInstanceBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroEmptyServiceTest() throws Exception{
- String gAction = "createInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- northBoundRequest.setIsToplevelflow(true);
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","CreateNetworkCollectionBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB"
- ,"CreateNetworkBB","ActivateNetworkBB","CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB"
- ,"ActivateVnfBB","ActivateNetworkCollectionBB","ActivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- Service service = new Service();
- doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","ActivateServiceInstanceBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroCreateJustNetworkTest() throws Exception{
- String gAction = "createInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- northBoundRequest.setIsToplevelflow(true);
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","CreateNetworkCollectionBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB"
- ,"CreateNetworkBB","ActivateNetworkBB","CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB"
- ,"ActivateVnfBB","ActivateNetworkCollectionBB","ActivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- Service service = new Service();
- NetworkResourceCustomization networkCustomization = new NetworkResourceCustomization();
- networkCustomization.setModelCustomizationUUID("1234");
- service.getNetworkCustomizations().add(networkCustomization);
- doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","ActivateServiceInstanceBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroCreateWithNetworkCollectionTest() throws Exception{
- String gAction = "createInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- northBoundRequest.setIsToplevelflow(true);
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","CreateNetworkCollectionBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB"
- ,"CreateNetworkBB","ActivateNetworkBB","CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB"
- ,"ActivateVnfBB","ActivateNetworkCollectionBB","ActivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- Service service = new Service();
- List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
- NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
- networkCust.setModelCustomizationUUID("123");
- networkCustomizations.add(networkCust);
- service.setNetworkCustomizations(networkCustomizations);
- NetworkCollectionResourceCustomization collectionResourceCustomization = new NetworkCollectionResourceCustomization();
- collectionResourceCustomization.setModelCustomizationUUID("123");
-
- CollectionResource collectionResource = new CollectionResource();
- collectionResource.setToscaNodeType("NetworkCollection");
- InstanceGroup instanceGroup = new InstanceGroup();
- instanceGroup.setToscaNodeType("NetworkCollectionResource");
- instanceGroup.setCollectionNetworkResourceCustomizations(new ArrayList<>());
- CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
- collectionNetworkResourceCust.setModelCustomizationUUID("123");
- collectionNetworkResourceCust.setNetworkResourceCustomization(collectionResourceCustomization);
- instanceGroup.getCollectionNetworkResourceCustomizations().add(collectionNetworkResourceCust );
- List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
- CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
- collectionInstanceGroupCustomization.setModelCustomizationUUID("123");
- collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
- collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
- collectionInstanceGroupCustomization.setInstanceGroup(instanceGroup);
- collectionInstanceGroupCustomization.setCollectionResourceCust(collectionResourceCustomization);
- instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
- collectionResource.setInstanceGroup(instanceGroup);
- collectionResourceCustomization.setCollectionResource(collectionResource);;
- service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
- doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
- doReturn(collectionResourceCustomization).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","CreateNetworkCollectionBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB"
- ,"AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","ActivateNetworkCollectionBB","ActivateServiceInstanceBB");
- assertEquals("Network id not empty", !ebbs.get(2).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id not empty", !ebbs.get(3).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id not empty", !ebbs.get(4).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB",
- ebbs.get(2).getWorkflowResourceIds().getNetworkId() == ebbs.get(3).getWorkflowResourceIds().getNetworkId()
- && ebbs.get(3).getWorkflowResourceIds().getNetworkId() == ebbs.get(4).getWorkflowResourceIds().getNetworkId(), true);
- assertEquals("Network id not empty", !ebbs.get(5).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id not empty", !ebbs.get(6).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id not empty", !ebbs.get(7).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB",
- ebbs.get(5).getWorkflowResourceIds().getNetworkId() == ebbs.get(6).getWorkflowResourceIds().getNetworkId()
- && ebbs.get(6).getWorkflowResourceIds().getNetworkId() == ebbs.get(7).getWorkflowResourceIds().getNetworkId(), true);
- assertEquals("Network id not empty", !ebbs.get(8).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id not empty", !ebbs.get(9).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id not empty", !ebbs.get(10).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB",
- ebbs.get(8).getWorkflowResourceIds().getNetworkId() == ebbs.get(9).getWorkflowResourceIds().getNetworkId()
- && ebbs.get(9).getWorkflowResourceIds().getNetworkId() == ebbs.get(10).getWorkflowResourceIds().getNetworkId(), true);
- }
-
- @Test
- public void selectExecutionListServiceMacroCreateWithUserParams() throws Exception{
- String gAction = "createInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","CreateNetworkCollectionBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB"
- ,"CreateNetworkBB","ActivateNetworkBB","CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB"
- ,"ActivateVnfBB","ActivateNetworkCollectionBB","ActivateServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- Service service = new Service();
- service.setModelUUID("3c40d244-808e-42ca-b09a-256d83d19d0a");
-
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- HeatEnvironment volumeHeatEnv = new HeatEnvironment();
- vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
- org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
- HeatTemplate volumeHeatTemplate = new HeatTemplate();
- vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
- vfModuleCustomization.setVfModule(vfModule);
-
- VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
- vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- HeatEnvironment heatEnvironment = new HeatEnvironment();
- vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
- org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
- HeatTemplate moduleHeatTemplate = new HeatTemplate();
- vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
- vfModuleCustomization2.setVfModule(vfModule2);
-
- VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
- vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f")).thenReturn(vfModuleCustomization);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8")).thenReturn(vfModuleCustomization2);
- when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969")).thenReturn(vfModuleCustomization3);
- when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB","AssignVfModuleBB","AssignVfModuleBB","CreateVolumeGroupBB"
- ,"ActivateVolumeGroupBB","CreateVfModuleBB","CreateVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","ActivateVfModuleBB","ActivateVfModuleBB","ActivateVnfBB","ActivateServiceInstanceBB");
- assertEquals(3,ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
- int randomUUIDLength = UUID.randomUUID().toString().length();
- assertEquals(randomUUIDLength,ebbs.get(1).getWorkflowResourceIds().getVnfId().length());
- assertEquals(randomUUIDLength,ebbs.get(2).getWorkflowResourceIds().getVolumeGroupId().length());
- assertEquals(randomUUIDLength,ebbs.get(3).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(4).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(5).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(6).getWorkflowResourceIds().getVolumeGroupId().length());
- assertEquals(randomUUIDLength,ebbs.get(7).getWorkflowResourceIds().getVolumeGroupId().length());
- assertEquals(randomUUIDLength,ebbs.get(8).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(9).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(10).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(11).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(12).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(13).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(randomUUIDLength,ebbs.get(14).getWorkflowResourceIds().getVnfId().length());
- assertEquals(3,ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
- assertEquals(true, execution.getVariable("homing"));
- }
-
- @Test
- public void selectExecutionListServiceMacroDeleteTest() throws Exception{
- String gAction = "deleteInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","DeactivateVolumeGroupBB","DeleteVolumeGroupBB","DeactivateVnfBB","DeactivateNetworkBB"
- ,"DeleteNetworkBB","DeleteNetworkCollectionBB","DeactivateServiceInstanceBB","UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignNetworkBB","UnassignServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- ServiceInstance serviceInstanceAAI = new ServiceInstance();
- serviceInstanceAAI.setServiceInstanceId("aaisi123");
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
- vnf.setVnfId("vnfId123");
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
- vfModule.setVfModuleId("vfModule1");
- vnf.getVfModules().add(vfModule);
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
- vfModule2.setVfModuleId("vfModule2");
- vnf.getVfModules().add(vfModule2);
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
- volumeGroup.setVolumeGroupId("vg123");
- vnf.getVolumeGroups().add(volumeGroup);
-
- serviceInstanceMSO.getVnfs().add(vnf);
-
- doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
- doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"DeactivateVfModuleBB","DeactivateVfModuleBB","DeleteVfModuleBB","DeleteVfModuleBB","DeactivateVolumeGroupBB","DeleteVolumeGroupBB","DeactivateVnfBB"
- ,"DeactivateServiceInstanceBB","UnassignVfModuleBB","UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignServiceInstanceBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroUnassignTest() throws Exception{
- String gAction = "unassignInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignNetworkBB","UnassignServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- ServiceInstance serviceInstanceAAI = new ServiceInstance();
- serviceInstanceAAI.setServiceInstanceId("aaisi123");
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
- vnf.setVnfId("vnfId123");
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
- vfModule.setVfModuleId("vfModule1");
- vnf.getVfModules().add(vfModule);
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
- vfModule2.setVfModuleId("vfModule2");
- vnf.getVfModules().add(vfModule2);
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
- volumeGroup.setVolumeGroupId("vg123");
- vnf.getVolumeGroups().add(volumeGroup);
-
- serviceInstanceMSO.getVnfs().add(vnf);
-
- doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
- doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"UnassignVfModuleBB","UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignServiceInstanceBB");
- }
-
- @Test
- public void selectExecutionListServiceMacroDeleteNetworkCollectionTest() throws Exception{
- String gAction = "deleteInstance";
- String resource = "Service";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","DeactivateVolumeGroupBB","DeleteVolumeGroupBB","DeactivateVnfBB","DeactivateNetworkBB"
- ,"DeleteNetworkBB","DeleteNetworkCollectionBB","DeactivateServiceInstanceBB","UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignNetworkBB","UnassignServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- ServiceInstance serviceInstanceAAI = new ServiceInstance();
- serviceInstanceAAI.setServiceInstanceId("aaisi123");
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network = new org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network();
- network.setNetworkId("123");
- serviceInstanceMSO.getNetworks().add(network);
- org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network();
- network2.setNetworkId("321");
- serviceInstanceMSO.getNetworks().add(network2);
-
- Collection collection = new Collection();
- serviceInstanceMSO.setCollection(collection);
-
- doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
- doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeleteNetworkCollectionBB"
- ,"DeactivateServiceInstanceBB","UnassignServiceInstanceBB");
- }
-
+
+
+ @Mock
+ protected Environment environment;
+ @InjectMocks
+ protected WorkflowAction workflowAction;
+ private DelegateExecution execution;
+
+
+ @InjectMocks
+ @Spy
+ protected WorkflowAction SPY_workflowAction;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private String RESOURCE_PATH = "src/test/resources/__files/";
+
+ @Before
+ public void before() throws Exception {
+ execution = new DelegateExecutionFake();
+ org.onap.aai.domain.yang.ServiceInstance servInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ servInstance.setServiceInstanceId("TEST");
+ when(bbSetupUtils.getAAIServiceInstanceByName(anyString(), anyObject())).thenReturn(servInstance);
+ workflowAction.setBbInputSetupUtils(bbSetupUtils);
+ workflowAction.setBbInputSetup(bbInputSetup);
+ }
+
+ /**
+ * ALACARTE TESTS
+ */
+ @Test
+ public void selectExecutionListALaCarteNetworkCreateTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Network";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/networks/123");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows =
+ createFlowList("AssignNetwork1802BB", "CreateNetworkBB", "ActivateNetworkBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignNetwork1802BB", "CreateNetworkBB", "ActivateNetworkBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteNetworkDeleteTest() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "Network";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/networks/123");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows =
+ createFlowList("DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetwork1802BB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetwork1802BB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteServiceCreateTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "ActivateServiceInstanceBB");
+ }
+
+ /**
+ * SERVICE MACRO TESTS
+ */
+ @Test
+ public void selectExecutionListServiceMacroAssignTest() throws Exception {
+ String gAction = "assignInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB",
+ "AssignVolumeGroupBB", "AssignVfModuleBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ HeatEnvironment volumeHeatEnv = new HeatEnvironment();
+ vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate volumeHeatTemplate = new HeatTemplate();
+ vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
+ vfModuleCustomization.setVfModule(vfModule);
+
+ VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
+ vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+ vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
+ org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate moduleHeatTemplate = new HeatTemplate();
+ vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
+ vfModuleCustomization2.setVfModule(vfModule2);
+
+ VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
+ vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"))
+ .thenReturn(vfModuleCustomization);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"))
+ .thenReturn(vfModuleCustomization2);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969"))
+ .thenReturn(vfModuleCustomization3);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB",
+ "AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB");
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroAssignNoCloudTest() throws Exception {
+ String gAction = "assignInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB",
+ "AssignVolumeGroupBB", "AssignVfModuleBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ HeatEnvironment volumeHeatEnv = new HeatEnvironment();
+ vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate volumeHeatTemplate = new HeatTemplate();
+ vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
+ vfModuleCustomization.setVfModule(vfModule);
+
+ VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
+ vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+ vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
+ org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate moduleHeatTemplate = new HeatTemplate();
+ vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
+ vfModuleCustomization2.setVfModule(vfModule2);
+
+ VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
+ vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+
+ when(environment.getProperty("org.onap.so.cloud-owner")).thenReturn("att-aic");
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "att-aic")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"))
+ .thenReturn(vfModuleCustomization);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"))
+ .thenReturn(vfModuleCustomization2);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969"))
+ .thenReturn(vfModuleCustomization3);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB",
+ "AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB");
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroActivateTest() throws Exception {
+ String gAction = "activateInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/si0");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows =
+ createFlowList("CreateNetworkBB", "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB",
+ "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB", "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ ServiceInstance serviceInstanceAAI = new ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId("si0");
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
+ vnf.setVnfId("vnf0");
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ vfModule.setVfModuleId("vfModule0");
+ vnf.getVfModules().add(vfModule);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ vfModule2.setVfModuleId("vfModule1");
+ vnf.getVfModules().add(vfModule2);
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroup0");
+ vnf.getVolumeGroups().add(volumeGroup);
+
+ serviceInstanceMSO.getVnfs().add(vnf);
+
+ doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("si0");
+ doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
+ "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB",
+ "ActivateServiceInstanceBB");
+ assertEquals("volumeGroup0", ebbs.get(0).getWorkflowResourceIds().getVolumeGroupId());
+ assertEquals("volumeGroup0", ebbs.get(1).getWorkflowResourceIds().getVolumeGroupId());
+ assertEquals("vfModule0", ebbs.get(2).getWorkflowResourceIds().getVfModuleId());
+ assertEquals("vfModule1", ebbs.get(3).getWorkflowResourceIds().getVfModuleId());
+ assertEquals("vfModule0", ebbs.get(4).getWorkflowResourceIds().getVfModuleId());
+ assertEquals("vfModule1", ebbs.get(5).getWorkflowResourceIds().getVfModuleId());
+ assertEquals("vnf0", ebbs.get(6).getWorkflowResourceIds().getVnfId());
+ assertEquals("si0", ebbs.get(7).getWorkflowResourceIds().getServiceInstanceId());
+
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroDeactivateTest() throws Exception {
+ String gAction = "deactivateInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(), "DeactivateServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroEmptyServiceTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setIsToplevelflow(true);
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
+ "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB",
+ "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB",
+ "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "ActivateServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroCreateJustNetworkTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setIsToplevelflow(true);
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
+ "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB",
+ "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB",
+ "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ NetworkResourceCustomization networkCustomization = new NetworkResourceCustomization();
+ networkCustomization.setModelCustomizationUUID("1234");
+ service.getNetworkCustomizations().add(networkCustomization);
+ doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignNetworkBB", "CreateNetworkBB",
+ "ActivateNetworkBB", "ActivateServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroCreateWithNetworkCollectionTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ northBoundRequest.setIsToplevelflow(true);
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
+ "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB",
+ "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB",
+ "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
+ NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
+ networkCust.setModelCustomizationUUID("123");
+ networkCustomizations.add(networkCust);
+ service.setNetworkCustomizations(networkCustomizations);
+ NetworkCollectionResourceCustomization collectionResourceCustomization =
+ new NetworkCollectionResourceCustomization();
+ collectionResourceCustomization.setModelCustomizationUUID("123");
+
+ CollectionResource collectionResource = new CollectionResource();
+ collectionResource.setToscaNodeType("NetworkCollection");
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroup.setToscaNodeType("NetworkCollectionResource");
+ instanceGroup.setCollectionNetworkResourceCustomizations(new ArrayList<>());
+ CollectionNetworkResourceCustomization collectionNetworkResourceCust =
+ new CollectionNetworkResourceCustomization();
+ collectionNetworkResourceCust.setModelCustomizationUUID("123");
+ collectionNetworkResourceCust.setNetworkResourceCustomization(collectionResourceCustomization);
+ instanceGroup.getCollectionNetworkResourceCustomizations().add(collectionNetworkResourceCust);
+ List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
+ CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization =
+ new CollectionResourceInstanceGroupCustomization();
+ collectionInstanceGroupCustomization.setModelCustomizationUUID("123");
+ collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
+ collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
+ collectionInstanceGroupCustomization.setInstanceGroup(instanceGroup);
+ collectionInstanceGroupCustomization.setCollectionResourceCust(collectionResourceCustomization);
+ instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
+ collectionResource.setInstanceGroup(instanceGroup);
+ collectionResourceCustomization.setCollectionResource(collectionResource);;
+ service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
+ doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
+ doReturn(collectionResourceCustomization).when(catalogDbClient)
+ .getNetworkCollectionResourceCustomizationByID("123");
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "CreateNetworkCollectionBB", "AssignNetworkBB",
+ "CreateNetworkBB", "ActivateNetworkBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB",
+ "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "ActivateNetworkCollectionBB",
+ "ActivateServiceInstanceBB");
+ assertEquals("Network id not empty", !ebbs.get(2).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id not empty", !ebbs.get(3).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id not empty", !ebbs.get(4).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB",
+ ebbs.get(2).getWorkflowResourceIds().getNetworkId() == ebbs.get(3).getWorkflowResourceIds()
+ .getNetworkId()
+ && ebbs.get(3).getWorkflowResourceIds().getNetworkId() == ebbs.get(4).getWorkflowResourceIds()
+ .getNetworkId(),
+ true);
+ assertEquals("Network id not empty", !ebbs.get(5).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id not empty", !ebbs.get(6).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id not empty", !ebbs.get(7).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB",
+ ebbs.get(5).getWorkflowResourceIds().getNetworkId() == ebbs.get(6).getWorkflowResourceIds()
+ .getNetworkId()
+ && ebbs.get(6).getWorkflowResourceIds().getNetworkId() == ebbs.get(7).getWorkflowResourceIds()
+ .getNetworkId(),
+ true);
+ assertEquals("Network id not empty", !ebbs.get(8).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id not empty", !ebbs.get(9).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id not empty", !ebbs.get(10).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
+ assertEquals("Network id same for AssignNetworkBB CreateNetworkBB ActivateNetworkBB",
+ ebbs.get(8).getWorkflowResourceIds().getNetworkId() == ebbs.get(9).getWorkflowResourceIds()
+ .getNetworkId()
+ && ebbs.get(9).getWorkflowResourceIds().getNetworkId() == ebbs.get(10).getWorkflowResourceIds()
+ .getNetworkId(),
+ true);
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroCreateWithUserParams() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
+ "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB",
+ "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB",
+ "ActivateNetworkCollectionBB", "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ service.setModelUUID("3c40d244-808e-42ca-b09a-256d83d19d0a");
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ HeatEnvironment volumeHeatEnv = new HeatEnvironment();
+ vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate volumeHeatTemplate = new HeatTemplate();
+ vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
+ vfModuleCustomization.setVfModule(vfModule);
+
+ VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
+ vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+ vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
+ org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate moduleHeatTemplate = new HeatTemplate();
+ vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
+ vfModuleCustomization2.setVfModule(vfModule2);
+
+ VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
+ vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"))
+ .thenReturn(vfModuleCustomization);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"))
+ .thenReturn(vfModuleCustomization2);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969"))
+ .thenReturn(vfModuleCustomization3);
+ when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB",
+ "AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB", "CreateVolumeGroupBB",
+ "ActivateVolumeGroupBB", "CreateVfModuleBB", "CreateVfModuleBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB",
+ "ActivateServiceInstanceBB");
+ assertEquals(3, ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
+ int randomUUIDLength = UUID.randomUUID().toString().length();
+ assertEquals(randomUUIDLength, ebbs.get(1).getWorkflowResourceIds().getVnfId().length());
+ assertEquals(randomUUIDLength, ebbs.get(2).getWorkflowResourceIds().getVolumeGroupId().length());
+ assertEquals(randomUUIDLength, ebbs.get(3).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(4).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(5).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(6).getWorkflowResourceIds().getVolumeGroupId().length());
+ assertEquals(randomUUIDLength, ebbs.get(7).getWorkflowResourceIds().getVolumeGroupId().length());
+ assertEquals(randomUUIDLength, ebbs.get(8).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(9).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(10).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(11).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(12).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(13).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(14).getWorkflowResourceIds().getVnfId().length());
+ assertEquals(3, ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
+ assertEquals(true, execution.getVariable("homing"));
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroDeleteTest() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivateNetworkBB",
+ "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB",
+ "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ ServiceInstance serviceInstanceAAI = new ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId("aaisi123");
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
+ vnf.setVnfId("vnfId123");
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ vfModule.setVfModuleId("vfModule1");
+ vnf.getVfModules().add(vfModule);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ vfModule2.setVfModuleId("vfModule2");
+ vnf.getVfModules().add(vfModule2);
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
+ volumeGroup.setVolumeGroupId("vg123");
+ vnf.getVolumeGroups().add(volumeGroup);
+
+ serviceInstanceMSO.getVnfs().add(vnf);
+
+ doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
+ doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB",
+ "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVfModuleBB", "UnassignVolumeGroupBB",
+ "UnassignVnfBB", "UnassignServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListServiceMacroUnassignTest() throws Exception {
+ String gAction = "unassignInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("UnassignVfModuleBB", "UnassignVolumeGroupBB",
+ "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ ServiceInstance serviceInstanceAAI = new ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId("aaisi123");
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
+ vnf.setVnfId("vnfId123");
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ vfModule.setVfModuleId("vfModule1");
+ vnf.getVfModules().add(vfModule);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ vfModule2.setVfModuleId("vfModule2");
+ vnf.getVfModules().add(vfModule2);
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
+ volumeGroup.setVolumeGroupId("vg123");
+ vnf.getVolumeGroups().add(volumeGroup);
+
+ serviceInstanceMSO.getVnfs().add(vnf);
+
+ doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
+ doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "UnassignVfModuleBB", "UnassignVfModuleBB", "UnassignVolumeGroupBB",
+ "UnassignVnfBB", "UnassignServiceInstanceBB");
+ }
+
@Test
- public void selectExecutionListVnfMacroRecreateTest() throws Exception{
+ public void selectExecutionListServiceMacroDeleteNetworkCollectionTest() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "Service";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivateNetworkBB",
+ "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB",
+ "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ ServiceInstance serviceInstanceAAI = new ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId("aaisi123");
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network();
+ network.setNetworkId("123");
+ serviceInstanceMSO.getNetworks().add(network);
+ org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network2 =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network();
+ network2.setNetworkId("321");
+ serviceInstanceMSO.getNetworks().add(network2);
+
+ Collection collection = new Collection();
+ serviceInstanceMSO.setCollection(collection);
+
+ doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
+ doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB",
+ "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB", "DeleteNetworkCollectionBB",
+ "DeactivateServiceInstanceBB", "UnassignServiceInstanceBB");
+ }
+
+ @Test
+ public void selectExecutionListVnfMacroRecreateTest() throws Exception {
String gAction = "recreateInstance";
String resource = "Vnf";
execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
execution.setVariable("aLaCarte", false);
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/recreate");
execution.setVariable("serviceInstanceId", "123");
execution.setVariable("vnfId", "1234");
-
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB","AAISetVnfInMaintBB","DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB","DeleteVfModuleBB","DeactivateVnfBB","CreateVfModuleBB"
- ,"ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB","ActivateVnfBB","SDNOVnfHealthCheckBB","AAIUnsetVnfInMaintBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
+ List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB", "AAISetVnfInMaintBB",
+ "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB",
+ "DeleteVfModuleBB", "DeactivateVnfBB", "CreateVfModuleBB", "ActivateVfModuleBB",
+ "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB", "SDNOVnfHealthCheckBB",
+ "AAIUnsetVnfInMaintBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId("123");
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
vnf.setVnfId("1234");
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
vfModule.setVfModuleId("vfModule1");
vnf.getVfModules().add(vfModule);
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
vfModule2.setVfModuleId("vfModule2");
vnf.getVfModules().add(vfModule2);
-
+
serviceInstanceMSO.getVnfs().add(vnf);
-
+
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AAICheckVnfInMaintBB","AAISetVnfInMaintBB","DeactivateVfModuleBB","DeactivateVfModuleBB","DeleteVfModuleBB","DeleteVfModuleBB","DeactivateVnfBB"
- ,"CreateVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","ActivateVfModuleBB","ActivateVnfBB","SDNOVnfHealthCheckBB","AAIUnsetVnfInMaintBB");
+ assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateVfModuleBB",
+ "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "CreateVfModuleBB",
+ "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB", "SDNOVnfHealthCheckBB",
+ "AAIUnsetVnfInMaintBB");
}
-
+
@Test
- public void selectExecutionListVnfMacroReplaceTest() throws Exception{
+ public void selectExecutionListVnfMacroReplaceTest() throws Exception {
String gAction = "replaceInstance";
String resource = "Vnf";
execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
execution.setVariable("aLaCarte", false);
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/replace");
execution.setVariable("serviceInstanceId", "123");
execution.setVariable("vnfId", "1234");
-
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB","AAISetVnfInMaintBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB","DeactivateVfModuleBB","DeleteVfModuleBB"
- ,"DeactivateVnfBB","ChangeModelVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB","ChangeModelVnfBB","ActivateVnfBB","ChangeModelServiceInstanceBB","SDNOVnfHealthCheckBB","AAIUnsetVnfInMaintBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
+ List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB", "AAISetVnfInMaintBB",
+ "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB",
+ "DeleteVfModuleBB", "DeactivateVnfBB", "ChangeModelVfModuleBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB",
+ "ChangeModelVnfBB", "ActivateVnfBB", "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB",
+ "AAIUnsetVnfInMaintBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId("123");
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
- org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
vnf.setVnfId("1234");
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
vfModule.setVfModuleId("vfModule1");
vnf.getVfModules().add(vfModule);
- org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
+ org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
vfModule2.setVfModuleId("vfModule2");
vnf.getVfModules().add(vfModule2);
serviceInstanceMSO.getVnfs().add(vnf);
@@ -792,647 +912,716 @@ public class WorkflowActionTest extends BaseTaskTest {
config.setConfigurationId("configId");
Optional<Configuration> configOp = Optional.of(config);
Optional<Relationships> relationshipsOp = Optional.of(relationships);
-
+
doReturn(relationshipsOp).when(workflowActionUtils).extractRelationshipsVnfc(isA(Relationships.class));
doReturn(configOp).when(workflowActionUtils).extractRelationshipsConfiguration(isA(Relationships.class));
doReturn(vfModuleAAI).when(bbSetupUtils).getAAIVfModule("1234", "vfModule2");
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateFabricConfigurationBB",
+ "UnassignFabricConfigurationBB", "DeactivateVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "DeleteVfModuleBB", "DeactivateVnfBB", "ChangeModelVfModuleBB", "ChangeModelVfModuleBB",
+ "CreateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB",
+ "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ChangeModelVnfBB", "ActivateVnfBB",
+ "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
+ }
+
+ @Ignore
+ @Test
+ public void selectExecutionListNetworkCollectionMacroCreate() throws Exception {
+ String gAction = "createInstance";
+ String resource = "NetworkCollection";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkCollectionBB", "AssignNetworkBB",
+ "CreateNetworkBB", "ActivateNetworkBB", "ActivateNetworkCollectionBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ CollectionResourceCustomization collectionResourceCustomization = new CollectionResourceCustomization();
+ CollectionResource collectionResource = new CollectionResource();
+ collectionResource.setToscaNodeType("Data NetworkCollection Data");
+ collectionResourceCustomization.setCollectionResource(collectionResource);
+ service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "CreateNetworkCollectionBB", "AssignNetworkBB", "CreateNetworkBB",
+ "ActivateNetworkBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB",
+ "ActivateNetworkCollectionBB");
+ }
+
+ @Ignore
+ @Test
+ public void selectExecutionListNetworkCollectionMacroDelete() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "NetworkCollection";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(
+ Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", false);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateNetworkBB", "DeleteNetworkBB",
+ "UnassignNetworkBB", "DeactivateNetworkCollectionBB", "DeleteNetworkCollectionBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ CollectionResourceCustomization collectionResourceCustomization = new CollectionResourceCustomization();
+ CollectionResource collectionResource = new CollectionResource();
+ collectionResource.setToscaNodeType("Data NetworkCollection Data");
+ collectionResourceCustomization.setCollectionResource(collectionResource);
+ service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB",
+ "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB", "DeactivateNetworkCollectionBB",
+ "DeleteNetworkCollectionBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleNoFabricCreateTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
+ "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleFabricCreateTest() throws Exception {
+ String gAction = "createInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
+ "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ List<CvnfcCustomization> cvnfcCustomizations = new ArrayList<CvnfcCustomization>();
+ CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
+ CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization =
+ new CvnfcConfigurationCustomization();
+ ConfigurationResource configurationResource = new ConfigurationResource();
+ configurationResource.setToscaNodeType("FabricConfiguration");
+ vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
+ vnfVfmoduleCvnfcConfigurationCustomization.setModelInstanceName("modelInstanceName1");
+ vnfVfmoduleCvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization);
+ Set<CvnfcConfigurationCustomization> custSet = new HashSet<CvnfcConfigurationCustomization>();
+ custSet.add(vnfVfmoduleCvnfcConfigurationCustomization);
+ cvnfcCustomization.setCvnfcConfigurationCustomization(custSet);
+ cvnfcCustomization.setDescription("description");
+ cvnfcCustomizations.add(cvnfcCustomization);
+
+ CvnfcCustomization cvnfcCustomization2 = new CvnfcCustomization();
+ CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization2 =
+ new CvnfcConfigurationCustomization();
+ ConfigurationResource configurationResource2 = new ConfigurationResource();
+ configurationResource2.setToscaNodeType("FabricConfiguration");
+ vnfVfmoduleCvnfcConfigurationCustomization2.setConfigurationResource(configurationResource2);
+ vnfVfmoduleCvnfcConfigurationCustomization2.setModelInstanceName("modelInstanceName2");
+ vnfVfmoduleCvnfcConfigurationCustomization2.setCvnfcCustomization(cvnfcCustomization2);
+ Set<CvnfcConfigurationCustomization> custSet2 = new HashSet<CvnfcConfigurationCustomization>();
+ custSet2.add(vnfVfmoduleCvnfcConfigurationCustomization2);
+ cvnfcCustomization2.setCvnfcConfigurationCustomization(custSet2);
+ cvnfcCustomization2.setDescription("description2");
+ cvnfcCustomizations.add(cvnfcCustomization2);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ // when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID("fc25201d-36d6-43a3-8d39-fdae88e526ae",
+ // "9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(cvnfcCustomizations);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AAICheckVnfInMaintBB","AAISetVnfInMaintBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB","DeactivateVfModuleBB","DeleteVfModuleBB","DeleteVfModuleBB","DeactivateVnfBB"
- ,"ChangeModelVfModuleBB" ,"ChangeModelVfModuleBB" , "CreateVfModuleBB","CreateVfModuleBB", "ActivateVfModuleBB","ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ChangeModelVnfBB", "ActivateVnfBB","ChangeModelServiceInstanceBB","SDNOVnfHealthCheckBB","AAIUnsetVnfInMaintBB");
+ assertEqualsBulkFlowName(ebbs, "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
+ "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "AssignFabricConfigurationBB",
+ "ActivateFabricConfigurationBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
+ org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+ vnf.setVnfId("vnf0");
+ vnf.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
+
+ org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+ vfModule.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+ vnfcs.add(vnfc);
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(),
+ anyObject());
+
+ List<org.onap.aai.domain.yang.Configuration> configurations =
+ new ArrayList<org.onap.aai.domain.yang.Configuration>();
+ org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+ configuration.setConfigurationId("configurationId");
+ configuration.setModelCustomizationId("modelCustimizationId");
+ configuration.setConfigurationName("testConfigurationName");
+ configurations.add(configuration);
+ doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(),
+ anyObject());
+
+ doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
+
+ SPY_workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB",
+ "DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB");
}
-
- @Ignore
- @Test
- public void selectExecutionListNetworkCollectionMacroCreate() throws Exception{
- String gAction = "createInstance";
- String resource = "NetworkCollection";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkCollectionBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","ActivateNetworkCollectionBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- Service service = new Service();
- CollectionResourceCustomization collectionResourceCustomization = new CollectionResourceCustomization();
- CollectionResource collectionResource = new CollectionResource();
- collectionResource.setToscaNodeType("Data NetworkCollection Data");
- collectionResourceCustomization.setCollectionResource(collectionResource);
- service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"CreateNetworkCollectionBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","ActivateNetworkCollectionBB");
- }
-
- @Ignore
- @Test
- public void selectExecutionListNetworkCollectionMacroDelete() throws Exception{
- String gAction = "deleteInstance";
- String resource = "NetworkCollection";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", false);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkCollectionBB","DeleteNetworkCollectionBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- Service service = new Service();
- CollectionResourceCustomization collectionResourceCustomization = new CollectionResourceCustomization();
- CollectionResource collectionResource = new CollectionResource();
- collectionResource.setToscaNodeType("Data NetworkCollection Data");
- collectionResourceCustomization.setCollectionResource(collectionResource);
- service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkCollectionBB"
- ,"DeleteNetworkCollectionBB");
- }
-
- @Test
- public void selectExecutionListALaCarteVfModuleNoFabricCreateTest() throws Exception{
- String gAction = "createInstance";
- String resource = "VfModule";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
-
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB");
- }
-
- @Test
- public void selectExecutionListALaCarteVfModuleFabricCreateTest() throws Exception{
- String gAction = "createInstance";
- String resource = "VfModule";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- List<CvnfcCustomization> cvnfcCustomizations = new ArrayList<CvnfcCustomization>();
- CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
- CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
- ConfigurationResource configurationResource = new ConfigurationResource();
- configurationResource.setToscaNodeType("FabricConfiguration");
- vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
- vnfVfmoduleCvnfcConfigurationCustomization.setModelInstanceName("modelInstanceName1");
- vnfVfmoduleCvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization);
- Set<CvnfcConfigurationCustomization> custSet = new HashSet<CvnfcConfigurationCustomization>();
- custSet.add(vnfVfmoduleCvnfcConfigurationCustomization);
- cvnfcCustomization.setCvnfcConfigurationCustomization(custSet);
- cvnfcCustomization.setDescription("description");
- cvnfcCustomizations.add(cvnfcCustomization);
-
- CvnfcCustomization cvnfcCustomization2 = new CvnfcCustomization();
- CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization2 = new CvnfcConfigurationCustomization();
- ConfigurationResource configurationResource2 = new ConfigurationResource();
- configurationResource2.setToscaNodeType("FabricConfiguration");
- vnfVfmoduleCvnfcConfigurationCustomization2.setConfigurationResource(configurationResource2);
- vnfVfmoduleCvnfcConfigurationCustomization2.setModelInstanceName("modelInstanceName2");
- vnfVfmoduleCvnfcConfigurationCustomization2.setCvnfcCustomization(cvnfcCustomization2);
- Set<CvnfcConfigurationCustomization> custSet2 = new HashSet<CvnfcConfigurationCustomization>();
- custSet2.add(vnfVfmoduleCvnfcConfigurationCustomization2);
- cvnfcCustomization2.setCvnfcConfigurationCustomization(custSet2);
- cvnfcCustomization2.setDescription("description2");
- cvnfcCustomizations.add(cvnfcCustomization2);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- //when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID("fc25201d-36d6-43a3-8d39-fdae88e526ae", "9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(cvnfcCustomizations);
- workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB", "AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
- }
-
- @Test
- public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception{
- String gAction = "deleteInstance";
- String resource = "VfModule";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
-
- org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
- vnf.setVnfId("vnf0");
- vnf.setModelCustomizationId("modelCustomizationId");
- when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
-
- org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
- vfModule.setModelCustomizationId("modelCustomizationId");
- when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
-
- List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
- org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
- vnfc.setModelInvariantId("modelInvariantId");
- vnfc.setVnfcName("testVnfcName");
- vnfcs.add(vnfc);
- doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
-
- List<org.onap.aai.domain.yang.Configuration> configurations = new ArrayList<org.onap.aai.domain.yang.Configuration>();
- org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
- configuration.setConfigurationId("configurationId");
- configuration.setModelCustomizationId("modelCustimizationId");
- configuration.setConfigurationName("testConfigurationName");
- configurations.add(configuration);
- doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
-
- doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
-
- SPY_workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB","DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB");
- }
-
- @Test
- public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception{
- String gAction = "deleteInstance";
- String resource = "VfModule";
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("requestAction", gAction);
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
- execution.setVariable("bpmnRequest", bpmnRequest);
- execution.setVariable("aLaCarte", true);
- execution.setVariable("apiVersion", "7");
- execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
-
- org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
- vnf.setVnfId("vnf0");
- vnf.setModelCustomizationId("modelCustomizationId");
- when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
-
- org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
- vfModule.setModelCustomizationId("modelCustomizationId");
- when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
-
- List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
- org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
- vnfc.setModelInvariantId("modelInvariantId");
- vnfc.setVnfcName("testVnfcName");
- vnfcs.add(vnfc);
- doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
-
- List<org.onap.aai.domain.yang.Configuration> configurations = new ArrayList<org.onap.aai.domain.yang.Configuration>();
- org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
- doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
-
- doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
-
- SPY_workflowAction.selectExecutionList(execution);
- List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs,"DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB");
- }
-
- @Test
- public void getRelatedResourcesInVfModuleTest() throws Exception{
- org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
- vnfc.setModelInvariantId("modelInvariantId");
- vnfc.setVnfcName("testVnfcName");
-
- String vfncPayload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/vnfcResponse.json")));
- AAIResultWrapper vfncWrapper = new AAIResultWrapper(vfncPayload);
-
- String configurationPayload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/configurationResponse.json")));
- AAIResultWrapper configurationWrapper = new AAIResultWrapper(configurationPayload);
- List<AAIResultWrapper> configurationResultWrappers = new ArrayList<AAIResultWrapper>();
- configurationResultWrappers.add(configurationWrapper);
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
- when(bbSetupUtils.getAAIResourceDepthOne(uri)).thenReturn(vfncWrapper);
-
- doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(),anyObject());
- List<org.onap.aai.domain.yang.Configuration> configurationsList = SPY_workflowAction.getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
- assertEquals(1,configurationsList.size());
- assertEquals("testConfigurationId",configurationsList.get(0).getConfigurationId());
- }
-
- /**
- * WorkflowActionBB Tests
- */
-
- @Test
- public void pluralTest() {
- List<String> items = Arrays.asList(
- "serviceInstances, Service",
- "vnfs, Vnf",
- "vfModules, VfModule",
- "networks, Network",
- "invalidNames, invalidNames");
- items.forEach(item -> {
- String[] split = item.split(",");
- String type = split[0].trim();
- String expected = split[1].trim();
- assertThat(workflowAction.convertTypeFromPlural(type), equalTo(expected));
- });
- }
-
- @Test
- public void sortExecutionPathByObjectForVlanTaggingCreateTest() throws Exception{
- List<ExecuteBuildingBlock> executeFlows = new ArrayList<>();
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- BuildingBlock bb = new BuildingBlock();
- bb.setBpmnFlowName("AssignNetworkBB");
- bb.setKey("0");
- ebb.setBuildingBlock(bb);
- executeFlows.add(ebb);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("AssignNetworkBB");
- bb2.setKey("1");
- ebb2.setBuildingBlock(bb2);
- executeFlows.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("CreateNetworkBB");
- bb3.setKey("0");
- ebb3.setBuildingBlock(bb3);
- executeFlows.add(ebb3);
- ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
- BuildingBlock bb4 = new BuildingBlock();
- bb4.setBpmnFlowName("CreateNetworkBB");
- bb4.setKey("1");
- ebb4.setBuildingBlock(bb4);
- executeFlows.add(ebb4);
- ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock();
- BuildingBlock bb5 = new BuildingBlock();
- bb5.setBpmnFlowName("ActivateNetworkBB");
- bb5.setKey("0");
- ebb5.setBuildingBlock(bb5);
- executeFlows.add(ebb5);
- ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock();
- BuildingBlock bb6 = new BuildingBlock();
- bb6.setBpmnFlowName("ActivateNetworkBB");
- bb6.setKey("1");
- ebb6.setBuildingBlock(bb6);
- executeFlows.add(ebb6);
-
- List<ExecuteBuildingBlock> sorted = workflowAction.sortExecutionPathByObjectForVlanTagging(executeFlows,"createInstance");
- assertEqualsBulkFlowName(sorted,"AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB");
- }
-
- @Test
- public void sortExecutionPathByObjectForVlanTaggingDeleteTest() throws Exception{
- List<ExecuteBuildingBlock> executeFlows = new ArrayList<>();
- ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
- BuildingBlock bb = new BuildingBlock();
- bb.setBpmnFlowName("DeactivateNetworkBB");
- bb.setKey("0");
- ebb.setBuildingBlock(bb);
- executeFlows.add(ebb);
- ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
- BuildingBlock bb2 = new BuildingBlock();
- bb2.setBpmnFlowName("DeactivateNetworkBB");
- bb2.setKey("1");
- ebb2.setBuildingBlock(bb2);
- executeFlows.add(ebb2);
- ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
- BuildingBlock bb3 = new BuildingBlock();
- bb3.setBpmnFlowName("DeleteNetworkBB");
- bb3.setKey("0");
- ebb3.setBuildingBlock(bb3);
- executeFlows.add(ebb3);
- ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
- BuildingBlock bb4 = new BuildingBlock();
- bb4.setBpmnFlowName("DeleteNetworkBB");
- bb4.setKey("1");
- ebb4.setBuildingBlock(bb4);
- executeFlows.add(ebb4);
- ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock();
- BuildingBlock bb5 = new BuildingBlock();
- bb5.setBpmnFlowName("UnassignNetworkBB");
- bb5.setKey("0");
- ebb5.setBuildingBlock(bb5);
- executeFlows.add(ebb5);
- ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock();
- BuildingBlock bb6 = new BuildingBlock();
- bb6.setBpmnFlowName("UnassignNetworkBB");
- bb6.setKey("1");
- ebb6.setBuildingBlock(bb6);
- executeFlows.add(ebb6);
-
- List<ExecuteBuildingBlock> sorted = workflowAction.sortExecutionPathByObjectForVlanTagging(executeFlows,"deleteInstance");
- assertEqualsBulkFlowName(sorted,"DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB");
- }
- @Test
- public void queryNorthBoundRequestCatalogDbNestedTest() throws MalformedURLException {
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB","AAISetVnfInMaintBB","VNF-Macro-Replace","SDNOVnfHealthCheckBB","AAIUnsetVnfInMaintBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
- List<OrchestrationFlow> macroFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","DeactivateVnfBB","CreateVfModuleBB","ActivateVfModuleBB","ActivateVnfBB");
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("replaceInstance","Vnf",false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
- when(catalogDbClient.getOrchestrationFlowByAction("VNF-Macro-Replace")).thenReturn(macroFlows);
- List<OrchestrationFlow> flows = workflowAction.queryNorthBoundRequestCatalogDb(execution, "replaceInstance", WorkflowType.VNF, false,"my-custom-cloud-owner");
- assertEquals(flows.get(0).getFlowName(),"AAICheckVnfInMaintBB");
- assertEquals(flows.get(1).getFlowName(),"AAISetVnfInMaintBB");
- assertEquals(flows.get(2).getFlowName(),"DeactivateVfModuleBB");
- assertEquals(flows.get(3).getFlowName(),"DeleteVfModuleBB");
- assertEquals(flows.get(4).getFlowName(),"DeactivateVnfBB");
- assertEquals(flows.get(5).getFlowName(),"CreateVfModuleBB");
- assertEquals(flows.get(6).getFlowName(),"ActivateVfModuleBB");
- assertEquals(flows.get(7).getFlowName(),"ActivateVnfBB");
- assertEquals(flows.get(8).getFlowName(),"SDNOVnfHealthCheckBB");
- assertEquals(flows.get(9).getFlowName(),"AAIUnsetVnfInMaintBB");
- }
-
- @Test
- public void queryNorthBoundRequestCatalogDbTransportTest() throws MalformedURLException {
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType("createInstance","Service",true,"my-custom-cloud-owner","TRANSPORT")).thenReturn(northBoundRequest);
-
- List<OrchestrationFlow> flows = workflowAction.queryNorthBoundRequestCatalogDb(execution, "createInstance", WorkflowType.SERVICE, true,"my-custom-cloud-owner","TRANSPORT");
- assertEquals(flows.get(0).getFlowName(),"AssignServiceInstanceBB");
- }
-
- @Test
- public void extractResourceIdAndTypeFromUriTest(){
- String uri = "/v6/serviceInstances/123";
- String uri2 = "/v6/serviceInstances/123/vnfs/1234";
- String uri3 = "/v6/serviceInstances";
- String uri4 = "/v6/serviceInstances/assign";
- String uri5 = "'/v6/serviceInstances/123/vnfs";
- String uri6 = "/v6/serviceInstances/123/vnfs/1234/someAction";
- String uri7 = "/v6/serviceInstances/123/vnfs/1234/vfModules/5678/replace";
- String uri8 = "/v6/serviceInstances/123/vnfs/1234/vfModules/scaleOut";
- Resource expected1 = new Resource(WorkflowType.SERVICE, "123", true);
- Resource expected2 = new Resource(WorkflowType.VNF, "1234", false);
- Resource expected3 = new Resource(WorkflowType.VNF, "1234", false);
- Resource expected4 = new Resource(WorkflowType.VFMODULE, "5678", false);
- Resource result = workflowAction.extractResourceIdAndTypeFromUri(uri);
- assertEquals(expected1.getResourceId(),result.getResourceId());
- assertEquals(expected1.getResourceType(),result.getResourceType());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri2);
- assertEquals(expected2.getResourceId(),result.getResourceId());
- assertEquals(expected2.getResourceType(),result.getResourceType());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri3);
- assertEquals("Service", result.getResourceType().toString());
- assertEquals(UUID.randomUUID().toString().length(),result.getResourceId().length());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri4);
- assertEquals("Service", result.getResourceType().toString());
- assertEquals(UUID.randomUUID().toString().length(),result.getResourceId().length());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri5);
- assertEquals("Vnf", result.getResourceType().toString());
- assertEquals(UUID.randomUUID().toString().length(),result.getResourceId().length());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri6);
- assertEquals(expected3.getResourceId(),result.getResourceId());
- assertEquals(expected3.getResourceType(),result.getResourceType());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri7);
- assertEquals(expected4.getResourceId(),result.getResourceId());
- assertEquals(expected4.getResourceType(),result.getResourceType());
- result = workflowAction.extractResourceIdAndTypeFromUri(uri8);
- assertEquals(UUID.randomUUID().toString().length(),result.getResourceId().length());
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
+ org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+ vnf.setVnfId("vnf0");
+ vnf.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
+
+ org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+ vfModule.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+ vnfcs.add(vnfc);
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(),
+ anyObject());
+
+ List<org.onap.aai.domain.yang.Configuration> configurations =
+ new ArrayList<org.onap.aai.domain.yang.Configuration>();
+ org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+ doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(),
+ anyObject());
+
+ doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
+
+ SPY_workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB");
+ }
+
+ @Test
+ public void getRelatedResourcesInVfModuleTest() throws Exception {
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+
+ String vfncPayload =
+ new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/vnfcResponse.json")));
+ AAIResultWrapper vfncWrapper = new AAIResultWrapper(vfncPayload);
+
+ String configurationPayload =
+ new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/configurationResponse.json")));
+ AAIResultWrapper configurationWrapper = new AAIResultWrapper(configurationPayload);
+ List<AAIResultWrapper> configurationResultWrappers = new ArrayList<AAIResultWrapper>();
+ configurationResultWrappers.add(configurationWrapper);
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
+ when(bbSetupUtils.getAAIResourceDepthOne(uri)).thenReturn(vfncWrapper);
+
+ doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(),
+ anyObject());
+ List<org.onap.aai.domain.yang.Configuration> configurationsList = SPY_workflowAction.getRelatedResourcesInVnfc(
+ vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+ assertEquals(1, configurationsList.size());
+ assertEquals("testConfigurationId", configurationsList.get(0).getConfigurationId());
+ }
+
+ /**
+ * WorkflowActionBB Tests
+ */
+
+ @Test
+ public void pluralTest() {
+ List<String> items = Arrays.asList("serviceInstances, Service", "vnfs, Vnf", "vfModules, VfModule",
+ "networks, Network", "invalidNames, invalidNames");
+ items.forEach(item -> {
+ String[] split = item.split(",");
+ String type = split[0].trim();
+ String expected = split[1].trim();
+ assertThat(workflowAction.convertTypeFromPlural(type), equalTo(expected));
+ });
+ }
+
+ @Test
+ public void sortExecutionPathByObjectForVlanTaggingCreateTest() throws Exception {
+ List<ExecuteBuildingBlock> executeFlows = new ArrayList<>();
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
+ BuildingBlock bb = new BuildingBlock();
+ bb.setBpmnFlowName("AssignNetworkBB");
+ bb.setKey("0");
+ ebb.setBuildingBlock(bb);
+ executeFlows.add(ebb);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("AssignNetworkBB");
+ bb2.setKey("1");
+ ebb2.setBuildingBlock(bb2);
+ executeFlows.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("CreateNetworkBB");
+ bb3.setKey("0");
+ ebb3.setBuildingBlock(bb3);
+ executeFlows.add(ebb3);
+ ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
+ BuildingBlock bb4 = new BuildingBlock();
+ bb4.setBpmnFlowName("CreateNetworkBB");
+ bb4.setKey("1");
+ ebb4.setBuildingBlock(bb4);
+ executeFlows.add(ebb4);
+ ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock();
+ BuildingBlock bb5 = new BuildingBlock();
+ bb5.setBpmnFlowName("ActivateNetworkBB");
+ bb5.setKey("0");
+ ebb5.setBuildingBlock(bb5);
+ executeFlows.add(ebb5);
+ ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock();
+ BuildingBlock bb6 = new BuildingBlock();
+ bb6.setBpmnFlowName("ActivateNetworkBB");
+ bb6.setKey("1");
+ ebb6.setBuildingBlock(bb6);
+ executeFlows.add(ebb6);
+
+ List<ExecuteBuildingBlock> sorted =
+ workflowAction.sortExecutionPathByObjectForVlanTagging(executeFlows, "createInstance");
+ assertEqualsBulkFlowName(sorted, "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "AssignNetworkBB",
+ "CreateNetworkBB", "ActivateNetworkBB");
+ }
+
+ @Test
+ public void sortExecutionPathByObjectForVlanTaggingDeleteTest() throws Exception {
+ List<ExecuteBuildingBlock> executeFlows = new ArrayList<>();
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
+ BuildingBlock bb = new BuildingBlock();
+ bb.setBpmnFlowName("DeactivateNetworkBB");
+ bb.setKey("0");
+ ebb.setBuildingBlock(bb);
+ executeFlows.add(ebb);
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock();
+ BuildingBlock bb2 = new BuildingBlock();
+ bb2.setBpmnFlowName("DeactivateNetworkBB");
+ bb2.setKey("1");
+ ebb2.setBuildingBlock(bb2);
+ executeFlows.add(ebb2);
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock();
+ BuildingBlock bb3 = new BuildingBlock();
+ bb3.setBpmnFlowName("DeleteNetworkBB");
+ bb3.setKey("0");
+ ebb3.setBuildingBlock(bb3);
+ executeFlows.add(ebb3);
+ ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock();
+ BuildingBlock bb4 = new BuildingBlock();
+ bb4.setBpmnFlowName("DeleteNetworkBB");
+ bb4.setKey("1");
+ ebb4.setBuildingBlock(bb4);
+ executeFlows.add(ebb4);
+ ExecuteBuildingBlock ebb5 = new ExecuteBuildingBlock();
+ BuildingBlock bb5 = new BuildingBlock();
+ bb5.setBpmnFlowName("UnassignNetworkBB");
+ bb5.setKey("0");
+ ebb5.setBuildingBlock(bb5);
+ executeFlows.add(ebb5);
+ ExecuteBuildingBlock ebb6 = new ExecuteBuildingBlock();
+ BuildingBlock bb6 = new BuildingBlock();
+ bb6.setBpmnFlowName("UnassignNetworkBB");
+ bb6.setKey("1");
+ ebb6.setBuildingBlock(bb6);
+ executeFlows.add(ebb6);
+
+ List<ExecuteBuildingBlock> sorted =
+ workflowAction.sortExecutionPathByObjectForVlanTagging(executeFlows, "deleteInstance");
+ assertEqualsBulkFlowName(sorted, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB",
+ "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetworkBB");
+ }
+
+ @Test
+ public void queryNorthBoundRequestCatalogDbNestedTest() throws MalformedURLException {
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB", "AAISetVnfInMaintBB",
+ "VNF-Macro-Replace", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+ List<OrchestrationFlow> macroFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "DeactivateVnfBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB");
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("replaceInstance",
+ "Vnf", false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getOrchestrationFlowByAction("VNF-Macro-Replace")).thenReturn(macroFlows);
+ List<OrchestrationFlow> flows = workflowAction.queryNorthBoundRequestCatalogDb(execution, "replaceInstance",
+ WorkflowType.VNF, false, "my-custom-cloud-owner");
+ assertEquals(flows.get(0).getFlowName(), "AAICheckVnfInMaintBB");
+ assertEquals(flows.get(1).getFlowName(), "AAISetVnfInMaintBB");
+ assertEquals(flows.get(2).getFlowName(), "DeactivateVfModuleBB");
+ assertEquals(flows.get(3).getFlowName(), "DeleteVfModuleBB");
+ assertEquals(flows.get(4).getFlowName(), "DeactivateVnfBB");
+ assertEquals(flows.get(5).getFlowName(), "CreateVfModuleBB");
+ assertEquals(flows.get(6).getFlowName(), "ActivateVfModuleBB");
+ assertEquals(flows.get(7).getFlowName(), "ActivateVnfBB");
+ assertEquals(flows.get(8).getFlowName(), "SDNOVnfHealthCheckBB");
+ assertEquals(flows.get(9).getFlowName(), "AAIUnsetVnfInMaintBB");
+ }
+
+ @Test
+ public void queryNorthBoundRequestCatalogDbTransportTest() throws MalformedURLException {
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType(
+ "createInstance", "Service", true, "my-custom-cloud-owner", "TRANSPORT")).thenReturn(northBoundRequest);
+
+ List<OrchestrationFlow> flows = workflowAction.queryNorthBoundRequestCatalogDb(execution, "createInstance",
+ WorkflowType.SERVICE, true, "my-custom-cloud-owner", "TRANSPORT");
+ assertEquals(flows.get(0).getFlowName(), "AssignServiceInstanceBB");
+ }
+
+ @Test
+ public void extractResourceIdAndTypeFromUriTest() {
+ String uri = "/v6/serviceInstances/123";
+ String uri2 = "/v6/serviceInstances/123/vnfs/1234";
+ String uri3 = "/v6/serviceInstances";
+ String uri4 = "/v6/serviceInstances/assign";
+ String uri5 = "'/v6/serviceInstances/123/vnfs";
+ String uri6 = "/v6/serviceInstances/123/vnfs/1234/someAction";
+ String uri7 = "/v6/serviceInstances/123/vnfs/1234/vfModules/5678/replace";
+ String uri8 = "/v6/serviceInstances/123/vnfs/1234/vfModules/scaleOut";
+ Resource expected1 = new Resource(WorkflowType.SERVICE, "123", true);
+ Resource expected2 = new Resource(WorkflowType.VNF, "1234", false);
+ Resource expected3 = new Resource(WorkflowType.VNF, "1234", false);
+ Resource expected4 = new Resource(WorkflowType.VFMODULE, "5678", false);
+ Resource result = workflowAction.extractResourceIdAndTypeFromUri(uri);
+ assertEquals(expected1.getResourceId(), result.getResourceId());
+ assertEquals(expected1.getResourceType(), result.getResourceType());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri2);
+ assertEquals(expected2.getResourceId(), result.getResourceId());
+ assertEquals(expected2.getResourceType(), result.getResourceType());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri3);
+ assertEquals("Service", result.getResourceType().toString());
+ assertEquals(UUID.randomUUID().toString().length(), result.getResourceId().length());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri4);
+ assertEquals("Service", result.getResourceType().toString());
+ assertEquals(UUID.randomUUID().toString().length(), result.getResourceId().length());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri5);
+ assertEquals("Vnf", result.getResourceType().toString());
+ assertEquals(UUID.randomUUID().toString().length(), result.getResourceId().length());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri6);
+ assertEquals(expected3.getResourceId(), result.getResourceId());
+ assertEquals(expected3.getResourceType(), result.getResourceType());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri7);
+ assertEquals(expected4.getResourceId(), result.getResourceId());
+ assertEquals(expected4.getResourceType(), result.getResourceType());
+ result = workflowAction.extractResourceIdAndTypeFromUri(uri8);
+ assertEquals(UUID.randomUUID().toString().length(), result.getResourceId().length());
assertEquals("VfModule", result.getResourceType().toString());
-
- }
-
- @Test
- public void extractResourceIdAndTypeFromUriInvalidTypeTest() {
- this.expectedException.expect(IllegalArgumentException.class);
- this.expectedException.expectMessage(containsString("Uri could not be parsed. No type found."));
- workflowAction.extractResourceIdAndTypeFromUri("/v6/serviceInstances/123/vnfs/1234/vfmodules/5678/replace");
- }
-
- @Test
- public void extractResourceIdAndTypeFromUriInvalidUriTest() {
- this.expectedException.expect(IllegalArgumentException.class);
- this.expectedException.expectMessage(containsString("Uri could not be parsed:"));
- workflowAction.extractResourceIdAndTypeFromUri("something that doesn't match anything");
- }
-
- @Test
- public void populateResourceIdsFromApiHandlerTest(){
- execution.setVariable("serviceInstanceId", "123");
- execution.setVariable("vnfId", "888");
- WorkflowResourceIds x = workflowAction.populateResourceIdsFromApiHandler(execution);
- assertEquals("123",x.getServiceInstanceId());
- assertEquals("888",x.getVnfId());
- assertNull(x.getVolumeGroupId());
- }
-
- @Test
- public void validateResourceIdInAAITest() throws Exception{
- //SI
- RequestDetails reqDetails = new RequestDetails();
- SubscriberInfo subInfo = new SubscriberInfo();
- subInfo.setGlobalSubscriberId("id123");
- reqDetails.setSubscriberInfo(subInfo);
- RequestParameters reqParams = new RequestParameters();
- reqParams.setSubscriptionServiceType("subServiceType123");
- reqDetails.setRequestParameters(reqParams );
- WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
- ServiceInstance si = new ServiceInstance();
- si.setServiceInstanceId("siId123");
- Optional<ServiceInstance> siOp = Optional.of(si);
- when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
- when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "111111")).thenReturn(Optional.empty());
- String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails, workflowResourceIds);
- assertEquals("siId123",id);
- String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "111111", reqDetails, workflowResourceIds);
- assertEquals("generatedId123",id2);
-
- //Network
- L3Network network = new L3Network();
- network.setNetworkId("id123");
- network.setNetworkName("name123");
- workflowResourceIds.setServiceInstanceId("siId123");
- Optional<L3Network> opNetwork = Optional.of(network);
- when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123","name123")).thenReturn(opNetwork);
- when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123","111111")).thenReturn(Optional.empty());
- id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123", reqDetails, workflowResourceIds);
- assertEquals("id123",id);
- id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111", reqDetails, workflowResourceIds);
- assertEquals("generatedId123",id2);
-
- //Vnf
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("id123");
- vnf.setVnfName("vnfName123");
- Optional<GenericVnf> opVnf = Optional.of(vnf);
- when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123","name123")).thenReturn(opVnf);
- when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123","111111")).thenReturn(Optional.empty());
- id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "name123", reqDetails, workflowResourceIds);
- assertEquals("id123",id);
- id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "111111", reqDetails, workflowResourceIds);
- assertEquals("generatedId123",id2);
-
- //VfModule
- VfModules vfModules = new VfModules();
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("id123");
- vfModule.setVfModuleName("name123");
- vfModules.getVfModule().add(vfModule);
- vnf.setVfModules(vfModules);
- workflowResourceIds.setVnfId("id123");
- when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf);
- id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123", reqDetails, workflowResourceIds);
- assertEquals("id123",id);
-
- GenericVnf vnf2 = new GenericVnf();
- VfModules vfModules2 = new VfModules();
- VfModule vfModule2 = new VfModule();
- vfModule2.setVfModuleId("id123");
- vfModule2.setVfModuleName("name123");
- vfModules2.getVfModule().add(vfModule2);
- vnf2.setVfModules(vfModules2);
- workflowResourceIds.setVnfId("id111");
- when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf2);
- id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111", reqDetails, workflowResourceIds);
- assertEquals("generatedId123",id2);
-
- //VolumeGroup
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("id123");
- volumeGroup.setVolumeGroupName("name123");
- workflowResourceIds.setVnfId("id123");
- Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
- when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123","name123")).thenReturn(opVolumeGroup);
- id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails, workflowResourceIds);
- assertEquals("id123",id);
-
- workflowResourceIds.setVnfId("id444");
- when(bbSetupUtils.getAAIGenericVnf("id444")).thenReturn(vnf);
- when(bbSetupUtils.getRelatedVolumeGroupByNameFromVfModule("id123", "id123","111111")).thenReturn(opVolumeGroup);
- when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id444","111111")).thenReturn(Optional.empty());
- id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "111111", reqDetails, workflowResourceIds);
- assertEquals("id123",id2);
- }
-
- @Test
- public void handleRuntimeExceptionTest(){
- execution.setVariable("BPMN_javaExpMsg", "test runtime error message");
- execution.setVariable("testProcessKey", "testProcessKeyValue");
- try{
- workflowAction.handleRuntimeException(execution);
- } catch (BpmnError wfe) {
- assertEquals("MSOWorkflowException",wfe.getErrorCode());
- }
- }
-
- @Ignore
- @Test
- public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException{
- execution.setVariable("testProcessKey", "testProcessKeyValue");
- Service service = new Service();
- List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
- NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
- networkCust.setModelCustomizationUUID("123");
- networkCustomizations.add(networkCust);
- service.setNetworkCustomizations(networkCustomizations);
- NetworkCollectionResourceCustomization collectionResourceCustomization = new NetworkCollectionResourceCustomization();
- collectionResourceCustomization.setModelCustomizationUUID("123");
- CollectionResource collectionResource = new CollectionResource();
- collectionResource.setToscaNodeType("NetworkCollection");
- InstanceGroup instanceGroup = new InstanceGroup();
- List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
- CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
- collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
- collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
- instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
- collectionResource.setInstanceGroup(instanceGroup);
- collectionResourceCustomization.setCollectionResource(collectionResource);;
- service.setModelUUID("abc");
- service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
- service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
- doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
- doReturn(collectionResourceCustomization).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
- String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
- ObjectMapper mapper = new ObjectMapper();
- ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
- List<Resource> resourceCounter = new ArrayList<>();
- thrown.expect(BpmnError.class);
- workflowAction.traverseCatalogDbService(execution, sIRequest, resourceCounter);
- }
-
- @Test
- public void sortVfModulesByBaseFirstTest(){
- List<Resource> resources = new ArrayList<>();
- Resource resource1 = new Resource(WorkflowType.VFMODULE,"111",false);
- resource1.setBaseVfModule(false);
- resources.add(resource1);
- Resource resource2 = new Resource(WorkflowType.VFMODULE,"222",false);
- resource2.setBaseVfModule(false);
- resources.add(resource2);
- Resource resource3 = new Resource(WorkflowType.VFMODULE,"333",false);
- resource3.setBaseVfModule(true);
- resources.add(resource3);
- List<Resource> result = workflowAction.sortVfModulesByBaseFirst(resources);
- assertEquals("333",result.get(0).getResourceId());
- assertEquals("222",result.get(1).getResourceId());
- assertEquals("111",result.get(2).getResourceId());
- }
-
- @Test
- public void sortVfModulesByBaseLastTest(){
- List<Resource> resources = new ArrayList<>();
- Resource resource1 = new Resource(WorkflowType.VFMODULE,"111",false);
- resource1.setBaseVfModule(true);
- resources.add(resource1);
- Resource resource2 = new Resource(WorkflowType.VFMODULE,"222",false);
- resource2.setBaseVfModule(false);
- resources.add(resource2);
- Resource resource3 = new Resource(WorkflowType.VFMODULE,"333",false);
- resource3.setBaseVfModule(false);
- resources.add(resource3);
- List<Resource> result = workflowAction.sortVfModulesByBaseLast(resources);
- assertEquals("333",result.get(0).getResourceId());
- assertEquals("222",result.get(1).getResourceId());
- assertEquals("111",result.get(2).getResourceId());
- }
+
+ }
+
+ @Test
+ public void extractResourceIdAndTypeFromUriInvalidTypeTest() {
+ this.expectedException.expect(IllegalArgumentException.class);
+ this.expectedException.expectMessage(containsString("Uri could not be parsed. No type found."));
+ workflowAction.extractResourceIdAndTypeFromUri("/v6/serviceInstances/123/vnfs/1234/vfmodules/5678/replace");
+ }
+
+ @Test
+ public void extractResourceIdAndTypeFromUriInvalidUriTest() {
+ this.expectedException.expect(IllegalArgumentException.class);
+ this.expectedException.expectMessage(containsString("Uri could not be parsed:"));
+ workflowAction.extractResourceIdAndTypeFromUri("something that doesn't match anything");
+ }
+
+ @Test
+ public void populateResourceIdsFromApiHandlerTest() {
+ execution.setVariable("serviceInstanceId", "123");
+ execution.setVariable("vnfId", "888");
+ WorkflowResourceIds x = workflowAction.populateResourceIdsFromApiHandler(execution);
+ assertEquals("123", x.getServiceInstanceId());
+ assertEquals("888", x.getVnfId());
+ assertNull(x.getVolumeGroupId());
+ }
+
+ @Test
+ public void validateResourceIdInAAITest() throws Exception {
+ // SI
+ RequestDetails reqDetails = new RequestDetails();
+ SubscriberInfo subInfo = new SubscriberInfo();
+ subInfo.setGlobalSubscriberId("id123");
+ reqDetails.setSubscriberInfo(subInfo);
+ RequestParameters reqParams = new RequestParameters();
+ reqParams.setSubscriptionServiceType("subServiceType123");
+ reqDetails.setRequestParameters(reqParams);
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ ServiceInstance si = new ServiceInstance();
+ si.setServiceInstanceId("siId123");
+ Optional<ServiceInstance> siOp = Optional.of(si);
+ when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
+ when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "111111"))
+ .thenReturn(Optional.empty());
+ String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123",
+ reqDetails, workflowResourceIds);
+ assertEquals("siId123", id);
+ String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "111111",
+ reqDetails, workflowResourceIds);
+ assertEquals("generatedId123", id2);
+
+ // Network
+ L3Network network = new L3Network();
+ network.setNetworkId("id123");
+ network.setNetworkName("name123");
+ workflowResourceIds.setServiceInstanceId("siId123");
+ Optional<L3Network> opNetwork = Optional.of(network);
+ when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
+ when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty());
+ id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123", reqDetails,
+ workflowResourceIds);
+ assertEquals("id123", id);
+ id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111", reqDetails,
+ workflowResourceIds);
+ assertEquals("generatedId123", id2);
+
+ // Vnf
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("id123");
+ vnf.setVnfName("vnfName123");
+ Optional<GenericVnf> opVnf = Optional.of(vnf);
+ when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "name123")).thenReturn(opVnf);
+ when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty());
+ id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "name123", reqDetails,
+ workflowResourceIds);
+ assertEquals("id123", id);
+ id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "111111", reqDetails,
+ workflowResourceIds);
+ assertEquals("generatedId123", id2);
+
+ // VfModule
+ VfModules vfModules = new VfModules();
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("id123");
+ vfModule.setVfModuleName("name123");
+ vfModules.getVfModule().add(vfModule);
+ vnf.setVfModules(vfModules);
+ workflowResourceIds.setVnfId("id123");
+ when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf);
+ id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123", reqDetails,
+ workflowResourceIds);
+ assertEquals("id123", id);
+
+ GenericVnf vnf2 = new GenericVnf();
+ VfModules vfModules2 = new VfModules();
+ VfModule vfModule2 = new VfModule();
+ vfModule2.setVfModuleId("id123");
+ vfModule2.setVfModuleName("name123");
+ vfModules2.getVfModule().add(vfModule2);
+ vnf2.setVfModules(vfModules2);
+ workflowResourceIds.setVnfId("id111");
+ when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf2);
+ id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111", reqDetails,
+ workflowResourceIds);
+ assertEquals("generatedId123", id2);
+
+ // VolumeGroup
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("id123");
+ volumeGroup.setVolumeGroupName("name123");
+ workflowResourceIds.setVnfId("id123");
+ Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
+ when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "name123")).thenReturn(opVolumeGroup);
+ id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails,
+ workflowResourceIds);
+ assertEquals("id123", id);
+
+ workflowResourceIds.setVnfId("id444");
+ when(bbSetupUtils.getAAIGenericVnf("id444")).thenReturn(vnf);
+ when(bbSetupUtils.getRelatedVolumeGroupByNameFromVfModule("id123", "id123", "111111"))
+ .thenReturn(opVolumeGroup);
+ when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id444", "111111")).thenReturn(Optional.empty());
+ id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "111111", reqDetails,
+ workflowResourceIds);
+ assertEquals("id123", id2);
+ }
+
+ @Test
+ public void handleRuntimeExceptionTest() {
+ execution.setVariable("BPMN_javaExpMsg", "test runtime error message");
+ execution.setVariable("testProcessKey", "testProcessKeyValue");
+ try {
+ workflowAction.handleRuntimeException(execution);
+ } catch (BpmnError wfe) {
+ assertEquals("MSOWorkflowException", wfe.getErrorCode());
+ }
+ }
+
+ @Ignore
+ @Test
+ public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException {
+ execution.setVariable("testProcessKey", "testProcessKeyValue");
+ Service service = new Service();
+ List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
+ NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
+ networkCust.setModelCustomizationUUID("123");
+ networkCustomizations.add(networkCust);
+ service.setNetworkCustomizations(networkCustomizations);
+ NetworkCollectionResourceCustomization collectionResourceCustomization =
+ new NetworkCollectionResourceCustomization();
+ collectionResourceCustomization.setModelCustomizationUUID("123");
+ CollectionResource collectionResource = new CollectionResource();
+ collectionResource.setToscaNodeType("NetworkCollection");
+ InstanceGroup instanceGroup = new InstanceGroup();
+ List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
+ CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization =
+ new CollectionResourceInstanceGroupCustomization();
+ collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
+ collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
+ instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
+ collectionResource.setInstanceGroup(instanceGroup);
+ collectionResourceCustomization.setCollectionResource(collectionResource);;
+ service.setModelUUID("abc");
+ service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
+ service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
+ doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
+ doReturn(collectionResourceCustomization).when(catalogDbClient)
+ .getNetworkCollectionResourceCustomizationByID("123");
+ String bpmnRequest = new String(Files
+ .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json")));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
+ List<Resource> resourceCounter = new ArrayList<>();
+ thrown.expect(BpmnError.class);
+ workflowAction.traverseCatalogDbService(execution, sIRequest, resourceCounter);
+ }
+
+ @Test
+ public void sortVfModulesByBaseFirstTest() {
+ List<Resource> resources = new ArrayList<>();
+ Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
+ resource1.setBaseVfModule(false);
+ resources.add(resource1);
+ Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
+ resource2.setBaseVfModule(false);
+ resources.add(resource2);
+ Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
+ resource3.setBaseVfModule(true);
+ resources.add(resource3);
+ List<Resource> result = workflowAction.sortVfModulesByBaseFirst(resources);
+ assertEquals("333", result.get(0).getResourceId());
+ assertEquals("222", result.get(1).getResourceId());
+ assertEquals("111", result.get(2).getResourceId());
+ }
+
+ @Test
+ public void sortVfModulesByBaseLastTest() {
+ List<Resource> resources = new ArrayList<>();
+ Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
+ resource1.setBaseVfModule(true);
+ resources.add(resource1);
+ Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
+ resource2.setBaseVfModule(false);
+ resources.add(resource2);
+ Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
+ resource3.setBaseVfModule(false);
+ resources.add(resource3);
+ List<Resource> result = workflowAction.sortVfModulesByBaseLast(resources);
+ assertEquals("333", result.get(0).getResourceId());
+ assertEquals("222", result.get(1).getResourceId());
+ assertEquals("111", result.get(2).getResourceId());
+ }
@Test
public void findCatalogNetworkCollectionTest() {
@@ -1468,35 +1657,34 @@ public class WorkflowActionTest extends BaseTaskTest {
doReturn(networkCustomization2).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("321");
workflowAction.findCatalogNetworkCollection(execution, service);
assertEquals("Found multiple Network Collections in the Service model, only one per Service is supported.",
- execution.getVariable("WorkflowActionErrorMessage"));
+ execution.getVariable("WorkflowActionErrorMessage"));
}
@Test
- public void verifyLackOfNullPointerExceptionForNullResource(){
- ExecuteBuildingBlock result = null;
- try {
- result = workflowAction
- .buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null, false,
- null, null, null, false, null, true);
- }catch (NullPointerException e){
- fail("NullPointerException should not be thrown when 'resource' is null");
- }
- assertNotNull(result);
+ public void verifyLackOfNullPointerExceptionForNullResource() {
+ ExecuteBuildingBlock result = null;
+ try {
+ result = workflowAction.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null,
+ false, null, null, null, false, null, true);
+ } catch (NullPointerException e) {
+ fail("NullPointerException should not be thrown when 'resource' is null");
+ }
+ assertNotNull(result);
}
- private List<OrchestrationFlow> createFlowList (String... flowNames){
- List<OrchestrationFlow> result = new ArrayList<>();
- for(String flowName : flowNames){
- OrchestrationFlow orchFlow = new OrchestrationFlow();
- orchFlow.setFlowName(flowName);
- result.add(orchFlow);
- }
- return result;
- }
-
- private void assertEqualsBulkFlowName (List<ExecuteBuildingBlock> ebbs, String... flowNames){
- for(int i = 0; i<ebbs.size(); i++){
- assertEquals(ebbs.get(i).getBuildingBlock().getBpmnFlowName(),flowNames[i]);
- }
- }
+ private List<OrchestrationFlow> createFlowList(String... flowNames) {
+ List<OrchestrationFlow> result = new ArrayList<>();
+ for (String flowName : flowNames) {
+ OrchestrationFlow orchFlow = new OrchestrationFlow();
+ orchFlow.setFlowName(flowName);
+ result.add(orchFlow);
+ }
+ return result;
+ }
+
+ private void assertEqualsBulkFlowName(List<ExecuteBuildingBlock> ebbs, String... flowNames) {
+ for (int i = 0; i < ebbs.size(); i++) {
+ assertEquals(ebbs.get(i).getBuildingBlock().getBpmnFlowName(), flowNames[i]);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java
index ada8a237e7..34ad1b0fd4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java
@@ -31,7 +31,6 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -39,7 +38,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -65,57 +63,59 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
@RunWith(MockitoJUnitRunner.class)
public class WorkflowActionUnitTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/Macro/";
-
- @Mock
- private CatalogDbClient catalogDbClient;
- @Mock
- private BBInputSetup bbInputSetup;
- @Mock
- private BBInputSetupUtils bbInputSetupUtils;
- @Mock
- private ExceptionBuilder exceptionBuilder;
- @Mock
- private AAIConfigurationResources aaiConfigurationResources;
-
- @InjectMocks
- @Spy
- private WorkflowAction workflowAction;
-
- @Test
- public void traverseCatalogDbForConfigurationTest() {
-
- CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
- CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization();
- ConfigurationResource configuration = new ConfigurationResource();
- configuration.setToscaNodeType("FabricConfiguration");
- configuration.setModelUUID("my-uuid");
- vfModuleCustomization.setConfigurationResource(configuration);
- cvnfcCustomization.setCvnfcConfigurationCustomization(Collections.singleton(vfModuleCustomization));
- List<CvnfcCustomization> cvnfcCustomizations = Arrays.asList(cvnfcCustomization);
- // when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(any(String.class), any(String.class)))
- // .thenReturn(cvnfcCustomizations);
-
- // List<CvnfcConfigurationCustomization> results = workflowAction.traverseCatalogDbForConfiguration("myVnfCustomizationId", "myVfModuleCustomizationId");
-
- //assertThat(results, is(Arrays.asList(vfModuleCustomization)));
-
- }
-
- private String getJson(String filename) throws IOException {
- return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
- }
-
- private List<OrchestrationFlow> createFlowList(String... myList) {
-
- List<OrchestrationFlow> result = new ArrayList<>();
- for (String name : myList) {
- OrchestrationFlow flow = new OrchestrationFlow();
- flow.setFlowName(name);
- result.add(flow);
- }
-
- return result;
-
- }
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/Macro/";
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+ @Mock
+ private BBInputSetup bbInputSetup;
+ @Mock
+ private BBInputSetupUtils bbInputSetupUtils;
+ @Mock
+ private ExceptionBuilder exceptionBuilder;
+ @Mock
+ private AAIConfigurationResources aaiConfigurationResources;
+
+ @InjectMocks
+ @Spy
+ private WorkflowAction workflowAction;
+
+ @Test
+ public void traverseCatalogDbForConfigurationTest() {
+
+ CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
+ CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization();
+ ConfigurationResource configuration = new ConfigurationResource();
+ configuration.setToscaNodeType("FabricConfiguration");
+ configuration.setModelUUID("my-uuid");
+ vfModuleCustomization.setConfigurationResource(configuration);
+ cvnfcCustomization.setCvnfcConfigurationCustomization(Collections.singleton(vfModuleCustomization));
+ List<CvnfcCustomization> cvnfcCustomizations = Arrays.asList(cvnfcCustomization);
+ // when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(any(String.class),
+ // any(String.class)))
+ // .thenReturn(cvnfcCustomizations);
+
+ // List<CvnfcConfigurationCustomization> results =
+ // workflowAction.traverseCatalogDbForConfiguration("myVnfCustomizationId", "myVfModuleCustomizationId");
+
+ // assertThat(results, is(Arrays.asList(vfModuleCustomization)));
+
+ }
+
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
+ }
+
+ private List<OrchestrationFlow> createFlowList(String... myList) {
+
+ List<OrchestrationFlow> result = new ArrayList<>();
+ for (String name : myList) {
+ OrchestrationFlow flow = new OrchestrationFlow();
+ flow.setFlowName(name);
+ result.add(flow);
+ }
+
+ return result;
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasksTest.java
index 329f2cf8c1..c235902561 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasksTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
@@ -47,62 +46,66 @@ import org.onap.so.client.orchestration.SDNOHealthCheckResources;
@RunWith(MockitoJUnitRunner.Silent.class)
public class SDNOHealthCheckTasksTest extends TestDataSetup {
-
- @InjectMocks
- protected SDNOHealthCheckTasks sdnoHealthCheckTasks = new SDNOHealthCheckTasks();
-
- @Mock
- SDNOHealthCheckResources MOCK_sdnoHealthCheckResources;
-
-
- @Mock
- private ExceptionBuilder exceptionUtil;
-
- @Mock
- private ExtractPojosForBB extractPojosForBB;
-
-
- private RequestContext requestContext;
- private GenericVnf genericVnf;
-
- @Before
- public void before() throws BBObjectNotFoundException {
- genericVnf = setGenericVnf();
- requestContext = setRequestContext();
- when(extractPojosForBB.extractByKey(any(),any())).thenReturn(genericVnf);
-
- }
-
- @Test
- public void sdnoHealthCheckTest() throws Exception {
- doReturn(true).when(MOCK_sdnoHealthCheckResources).healthCheck(genericVnf, requestContext);
- sdnoHealthCheckTasks.sdnoHealthCheck(execution);
- verify(MOCK_sdnoHealthCheckResources, times(1)).healthCheck(genericVnf, requestContext);
- }
-
- @Test
- public void sdnoHealthCheckNoResponseTest() throws Exception {
-
- doReturn(false).when(MOCK_sdnoHealthCheckResources).healthCheck(genericVnf, requestContext);
- try {
- sdnoHealthCheckTasks.sdnoHealthCheck(execution);
- } catch (Exception e) {
- verify(MOCK_sdnoHealthCheckResources, times(1)).healthCheck(genericVnf, requestContext);
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
-
- }
-
- @Test
- public void sdnoHealthCheckExceptionTest() throws Exception {
- doThrow(new Exception("Unknown Error")).when(MOCK_sdnoHealthCheckResources).healthCheck(genericVnf, requestContext);
- doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- try {
- sdnoHealthCheckTasks.sdnoHealthCheck(execution);
- } catch (Exception e) {
- verify(MOCK_sdnoHealthCheckResources, times(1)).healthCheck(genericVnf, requestContext);
- verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- }
-
- }
+
+ @InjectMocks
+ protected SDNOHealthCheckTasks sdnoHealthCheckTasks = new SDNOHealthCheckTasks();
+
+ @Mock
+ SDNOHealthCheckResources MOCK_sdnoHealthCheckResources;
+
+
+ @Mock
+ private ExceptionBuilder exceptionUtil;
+
+ @Mock
+ private ExtractPojosForBB extractPojosForBB;
+
+
+ private RequestContext requestContext;
+ private GenericVnf genericVnf;
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+ genericVnf = setGenericVnf();
+ requestContext = setRequestContext();
+ when(extractPojosForBB.extractByKey(any(), any())).thenReturn(genericVnf);
+
+ }
+
+ @Test
+ public void sdnoHealthCheckTest() throws Exception {
+ doReturn(true).when(MOCK_sdnoHealthCheckResources).healthCheck(genericVnf, requestContext);
+ sdnoHealthCheckTasks.sdnoHealthCheck(execution);
+ verify(MOCK_sdnoHealthCheckResources, times(1)).healthCheck(genericVnf, requestContext);
+ }
+
+ @Test
+ public void sdnoHealthCheckNoResponseTest() throws Exception {
+
+ doReturn(false).when(MOCK_sdnoHealthCheckResources).healthCheck(genericVnf, requestContext);
+ try {
+ sdnoHealthCheckTasks.sdnoHealthCheck(execution);
+ } catch (Exception e) {
+ verify(MOCK_sdnoHealthCheckResources, times(1)).healthCheck(genericVnf, requestContext);
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+
+ }
+
+ @Test
+ public void sdnoHealthCheckExceptionTest() throws Exception {
+ doThrow(new Exception("Unknown Error")).when(MOCK_sdnoHealthCheckResources).healthCheck(genericVnf,
+ requestContext);
+ doThrow(new BpmnError("Unknown Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
+ try {
+ sdnoHealthCheckTasks.sdnoHealthCheck(execution);
+ } catch (Exception e) {
+ verify(MOCK_sdnoHealthCheckResources, times(1)).healthCheck(genericVnf, requestContext);
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000),
+ any(String.class));
+ }
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
index d5b529288f..821e70a8c8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
@@ -24,13 +24,11 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.onap.aai.domain.yang.RouteTargets;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
@@ -60,562 +58,581 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
public class AAIObjectMapperTest {
- private AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
-
-
- @Test
- public void mapConfigurationTest() {
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("configId");
- configuration.setConfigurationName("VNR");
- configuration.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- configuration.setManagementOption("managementOption");
- ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
- modelInfoConfiguration.setModelCustomizationId("modelCustId");
- modelInfoConfiguration.setModelInvariantId("modelInvariantId");
- modelInfoConfiguration.setModelVersionId("modelVersionId");
- modelInfoConfiguration.setConfigurationType("5G");
- modelInfoConfiguration.setConfigurationRole("ConfigurationRole");
- configuration.setModelInfoConfiguration(modelInfoConfiguration);
-
- org.onap.aai.domain.yang.Configuration expectedConfiguration = new org.onap.aai.domain.yang.Configuration();
- expectedConfiguration.setConfigurationId(configuration.getConfigurationId());
- expectedConfiguration.setConfigurationName(configuration.getConfigurationName());
- expectedConfiguration.setConfigurationType(configuration.getModelInfoConfiguration().getConfigurationType());
- expectedConfiguration.setOrchestrationStatus(configuration.getOrchestrationStatus().toString());
- expectedConfiguration.setManagementOption(configuration.getManagementOption());
- expectedConfiguration.setModelInvariantId(configuration.getModelInfoConfiguration().getModelInvariantId());
- expectedConfiguration.setModelVersionId(configuration.getModelInfoConfiguration().getModelVersionId());
- expectedConfiguration.setModelCustomizationId(configuration.getModelInfoConfiguration().getModelCustomizationId());
- expectedConfiguration.setConfigurationSubType(configuration.getModelInfoConfiguration().getConfigurationRole());
- expectedConfiguration.setConfigPolicyName(configuration.getModelInfoConfiguration().getPolicyName());
-
- org.onap.aai.domain.yang.Configuration actualConfiguration = aaiObjectMapper.mapConfiguration(configuration);
-
- assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
- }
-
- @Test
- public void mapVolumeGroupTest() throws Exception {
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setHeatStackId("heatStackId");
- volumeGroup.setModelInfoVfModule(new ModelInfoVfModule());
- volumeGroup.getModelInfoVfModule().setModelCustomizationUUID("modelCustomizationId");
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
- volumeGroup.setVnfType("vnfType");
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setVolumeGroupName("volumeGroupName");
-
- org.onap.aai.domain.yang.VolumeGroup expectedVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
- expectedVolumeGroup.setHeatStackId(volumeGroup.getHeatStackId());
- expectedVolumeGroup.setModelCustomizationId(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
- expectedVolumeGroup.setOrchestrationStatus(volumeGroup.getOrchestrationStatus().toString());
- expectedVolumeGroup.setVfModuleModelCustomizationId(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
- expectedVolumeGroup.setVnfType(volumeGroup.getVnfType());
- expectedVolumeGroup.setVolumeGroupId(volumeGroup.getVolumeGroupId());
- expectedVolumeGroup.setVolumeGroupName(volumeGroup.getVolumeGroupName());
-
- org.onap.aai.domain.yang.VolumeGroup actualVolumeGroup = aaiObjectMapper.mapVolumeGroup(volumeGroup);
-
- assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
- }
-
- @Test
- public void serviceInstanceMap() {
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("SIID");
- serviceInstance.setServiceInstanceName("SINAME");
- serviceInstance.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setServiceType("SITYPE");
- modelInfoServiceInstance.setServiceRole("SIROLE");
- modelInfoServiceInstance.setModelInvariantUuid("MIUUID");
- modelInfoServiceInstance.setModelUuid("MUUID");
- modelInfoServiceInstance.setEnvironmentContext("EC");
- modelInfoServiceInstance.setWorkloadContext("WC");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance = aaiObjectMapper.mapServiceInstance(serviceInstance);
-
- assertEquals(AAIServiceInstance.getServiceInstanceId(),serviceInstance.getServiceInstanceId());
- assertEquals(AAIServiceInstance.getServiceInstanceName(),serviceInstance.getServiceInstanceName());
- assertEquals(AAIServiceInstance.getOrchestrationStatus().toString(),serviceInstance.getOrchestrationStatus().toString());
- assertEquals(AAIServiceInstance.getServiceType(),serviceInstance.getModelInfoServiceInstance().getServiceType());
- assertEquals(AAIServiceInstance.getServiceRole(),serviceInstance.getModelInfoServiceInstance().getServiceRole());
- assertEquals(AAIServiceInstance.getModelInvariantId(),serviceInstance.getModelInfoServiceInstance().getModelInvariantUuid());
- assertEquals(AAIServiceInstance.getModelVersionId(),serviceInstance.getModelInfoServiceInstance().getModelUuid());
- assertEquals(AAIServiceInstance.getEnvironmentContext(),serviceInstance.getModelInfoServiceInstance().getEnvironmentContext());
- assertEquals(AAIServiceInstance.getWorkloadContext(),serviceInstance.getModelInfoServiceInstance().getWorkloadContext());
- }
-
- @Test
- public void projectMap(){
- Project project = new Project();
- project.setProjectName("abc");
-
- org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project);
-
- assertEquals(AAIProject.getProjectName(),project.getProjectName());
- }
-
- @Test
- public void serviceSubscriptionMap(){
+ private AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
+
+
+ @Test
+ public void mapConfigurationTest() {
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("configId");
+ configuration.setConfigurationName("VNR");
+ configuration.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ configuration.setManagementOption("managementOption");
+ ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
+ modelInfoConfiguration.setModelCustomizationId("modelCustId");
+ modelInfoConfiguration.setModelInvariantId("modelInvariantId");
+ modelInfoConfiguration.setModelVersionId("modelVersionId");
+ modelInfoConfiguration.setConfigurationType("5G");
+ modelInfoConfiguration.setConfigurationRole("ConfigurationRole");
+ configuration.setModelInfoConfiguration(modelInfoConfiguration);
+
+ org.onap.aai.domain.yang.Configuration expectedConfiguration = new org.onap.aai.domain.yang.Configuration();
+ expectedConfiguration.setConfigurationId(configuration.getConfigurationId());
+ expectedConfiguration.setConfigurationName(configuration.getConfigurationName());
+ expectedConfiguration.setConfigurationType(configuration.getModelInfoConfiguration().getConfigurationType());
+ expectedConfiguration.setOrchestrationStatus(configuration.getOrchestrationStatus().toString());
+ expectedConfiguration.setManagementOption(configuration.getManagementOption());
+ expectedConfiguration.setModelInvariantId(configuration.getModelInfoConfiguration().getModelInvariantId());
+ expectedConfiguration.setModelVersionId(configuration.getModelInfoConfiguration().getModelVersionId());
+ expectedConfiguration
+ .setModelCustomizationId(configuration.getModelInfoConfiguration().getModelCustomizationId());
+ expectedConfiguration.setConfigurationSubType(configuration.getModelInfoConfiguration().getConfigurationRole());
+ expectedConfiguration.setConfigPolicyName(configuration.getModelInfoConfiguration().getPolicyName());
+
+ org.onap.aai.domain.yang.Configuration actualConfiguration = aaiObjectMapper.mapConfiguration(configuration);
+
+ assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
+ }
+
+ @Test
+ public void mapVolumeGroupTest() throws Exception {
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setHeatStackId("heatStackId");
+ volumeGroup.setModelInfoVfModule(new ModelInfoVfModule());
+ volumeGroup.getModelInfoVfModule().setModelCustomizationUUID("modelCustomizationId");
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
+ volumeGroup.setVnfType("vnfType");
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+
+ org.onap.aai.domain.yang.VolumeGroup expectedVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
+ expectedVolumeGroup.setHeatStackId(volumeGroup.getHeatStackId());
+ expectedVolumeGroup.setModelCustomizationId(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
+ expectedVolumeGroup.setOrchestrationStatus(volumeGroup.getOrchestrationStatus().toString());
+ expectedVolumeGroup
+ .setVfModuleModelCustomizationId(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
+ expectedVolumeGroup.setVnfType(volumeGroup.getVnfType());
+ expectedVolumeGroup.setVolumeGroupId(volumeGroup.getVolumeGroupId());
+ expectedVolumeGroup.setVolumeGroupName(volumeGroup.getVolumeGroupName());
+
+ org.onap.aai.domain.yang.VolumeGroup actualVolumeGroup = aaiObjectMapper.mapVolumeGroup(volumeGroup);
+
+ assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
+ }
+
+ @Test
+ public void serviceInstanceMap() {
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("SIID");
+ serviceInstance.setServiceInstanceName("SINAME");
+ serviceInstance.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setServiceType("SITYPE");
+ modelInfoServiceInstance.setServiceRole("SIROLE");
+ modelInfoServiceInstance.setModelInvariantUuid("MIUUID");
+ modelInfoServiceInstance.setModelUuid("MUUID");
+ modelInfoServiceInstance.setEnvironmentContext("EC");
+ modelInfoServiceInstance.setWorkloadContext("WC");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance =
+ aaiObjectMapper.mapServiceInstance(serviceInstance);
+
+ assertEquals(AAIServiceInstance.getServiceInstanceId(), serviceInstance.getServiceInstanceId());
+ assertEquals(AAIServiceInstance.getServiceInstanceName(), serviceInstance.getServiceInstanceName());
+ assertEquals(AAIServiceInstance.getOrchestrationStatus().toString(),
+ serviceInstance.getOrchestrationStatus().toString());
+ assertEquals(AAIServiceInstance.getServiceType(),
+ serviceInstance.getModelInfoServiceInstance().getServiceType());
+ assertEquals(AAIServiceInstance.getServiceRole(),
+ serviceInstance.getModelInfoServiceInstance().getServiceRole());
+ assertEquals(AAIServiceInstance.getModelInvariantId(),
+ serviceInstance.getModelInfoServiceInstance().getModelInvariantUuid());
+ assertEquals(AAIServiceInstance.getModelVersionId(),
+ serviceInstance.getModelInfoServiceInstance().getModelUuid());
+ assertEquals(AAIServiceInstance.getEnvironmentContext(),
+ serviceInstance.getModelInfoServiceInstance().getEnvironmentContext());
+ assertEquals(AAIServiceInstance.getWorkloadContext(),
+ serviceInstance.getModelInfoServiceInstance().getWorkloadContext());
+ }
+
+ @Test
+ public void projectMap() {
+ Project project = new Project();
+ project.setProjectName("abc");
+
+ org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project);
+
+ assertEquals(AAIProject.getProjectName(), project.getProjectName());
+ }
+
+ @Test
+ public void serviceSubscriptionMap() {
ServiceSubscription serviceSubscription = new ServiceSubscription();
serviceSubscription.setServiceType("IP-FLEX");
serviceSubscription.setTempUbSubAccountId("Account-ID");
- org.onap.aai.domain.yang.ServiceSubscription serviceSubscriptionMapped = aaiObjectMapper.mapServiceSubscription(serviceSubscription);
+ org.onap.aai.domain.yang.ServiceSubscription serviceSubscriptionMapped =
+ aaiObjectMapper.mapServiceSubscription(serviceSubscription);
assertNotNull(serviceSubscriptionMapped);
- assertEquals(serviceSubscription.getTempUbSubAccountId(),serviceSubscriptionMapped.getTempUbSubAccountId());
- assertEquals(serviceSubscription.getServiceType(),serviceSubscriptionMapped.getServiceType());
+ assertEquals(serviceSubscription.getTempUbSubAccountId(), serviceSubscriptionMapped.getTempUbSubAccountId());
+ assertEquals(serviceSubscription.getServiceType(), serviceSubscriptionMapped.getServiceType());
+ }
+
+ @Test
+ public void owningEntityMap() {
+ OwningEntity oe = new OwningEntity();
+ oe.setOwningEntityId("abc");
+ oe.setOwningEntityName("bbb");
+
+ org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(oe);
+
+ assertEquals(AAIOwningEntity.getOwningEntityId(), oe.getOwningEntityId());
+ assertEquals(AAIOwningEntity.getOwningEntityName(), oe.getOwningEntityName());
+
+ }
+
+ @Test
+ public void vnfMap() {
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("a");
+ vnf.setVnfName("b");
+ vnf.setServiceId("c");
+ vnf.setVnfType("d");
+ vnf.setProvStatus("e");
+ vnf.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelCustomizationUuid("f");
+ modelInfoGenericVnf.setModelInvariantUuid("g");
+ modelInfoGenericVnf.setModelUuid("h");
+ modelInfoGenericVnf.setNfRole("i");
+ modelInfoGenericVnf.setNfType("j");
+ modelInfoGenericVnf.setNfFunction("k");
+ modelInfoGenericVnf.setNfNamingCode("l");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ org.onap.aai.domain.yang.GenericVnf AAIVnf = aaiObjectMapper.mapVnf(vnf);
+
+ assertEquals(AAIVnf.getVnfId(), vnf.getVnfId());
+ assertEquals(AAIVnf.getVnfName(), vnf.getVnfName());
+ assertEquals(AAIVnf.getServiceId(), vnf.getServiceId());
+ assertEquals(AAIVnf.getVnfType(), vnf.getVnfType());
+ assertEquals(AAIVnf.getProvStatus(), vnf.getProvStatus());
+ assertEquals(AAIVnf.getOrchestrationStatus().toString(), vnf.getOrchestrationStatus().toString());
+ assertEquals(AAIVnf.getModelCustomizationId(), vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
+ assertEquals(AAIVnf.getModelInvariantId(), vnf.getModelInfoGenericVnf().getModelInvariantUuid());
+ assertEquals(AAIVnf.getModelVersionId(), vnf.getModelInfoGenericVnf().getModelUuid());
+ assertEquals(AAIVnf.getModelVersionId(), vnf.getModelInfoGenericVnf().getModelUuid());
+ assertEquals(AAIVnf.getNfType(), vnf.getModelInfoGenericVnf().getNfType());
+ assertEquals(AAIVnf.getNfFunction(), vnf.getModelInfoGenericVnf().getNfFunction());
+ assertEquals(AAIVnf.getNfNamingCode(), vnf.getModelInfoGenericVnf().getNfNamingCode());
+ }
+
+ @Test
+ public void vfModuleMap() throws Exception {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("a");
+ vfModule.setVfModuleName("b");
+ vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelCustomizationUUID("f");
+ modelInfoVfModule.setModelInvariantUUID("g");
+ modelInfoVfModule.setModelUUID("h");
+ modelInfoVfModule.setIsBaseBoolean(false);
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
+
+ String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleMap.json")));
+
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.VfModule reqMapper1 =
+ omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.VfModule.class);
+
+ assertThat(reqMapper1, sameBeanAs(AAIVfModule));
+
+ }
+
+ @Test
+ public void vfModuleBaseMap() throws Exception {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("a");
+ vfModule.setVfModuleName("b");
+ vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelCustomizationUUID("f");
+ modelInfoVfModule.setModelInvariantUUID("g");
+ modelInfoVfModule.setModelUUID("h");
+ modelInfoVfModule.setIsBaseBoolean(true);
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
+
+ String jsonToCompare =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleBaseMap.json")));
+
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.VfModule reqMapper1 =
+ omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.VfModule.class);
+
+ assertThat(reqMapper1, sameBeanAs(AAIVfModule));
+
+ }
+
+ @Test
+ public void testMapInstanceGroup() {
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroup.setId("test-id");
+ instanceGroup.setDescription("test-description");
+ instanceGroup.setInstanceGroupName("test-instanceGroupName");
+ instanceGroup.setResourceVersion("test-resourceVersion");
+
+ ModelInfoInstanceGroup model = new ModelInfoInstanceGroup();
+ model.setFunction("test-function");
+ model.setInstanceGroupRole("SUB-INTERFACE");
+ model.setType("VNFC");
+ model.setModelInvariantUUID("modelInvariantUUID-000");
+ model.setModelUUID("modelUUID-000");
+ model.setDescription("test-description");
+ model.setInstanceGroupRole("SUB-INTERFACE");
+
+ instanceGroup.setModelInfoInstanceGroup(model);
+
+
+ org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
+
+ try {
+ com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
+ String json = mapper.writeValueAsString(aaiInstanceGroup);
+ System.out.println("GGG - json:\n" + json);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ assertEquals(aaiInstanceGroup.getId(), instanceGroup.getId());
+ assertEquals(aaiInstanceGroup.getDescription(), instanceGroup.getDescription());
+ assertEquals(aaiInstanceGroup.getInstanceGroupRole(),
+ instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
+ assertEquals(aaiInstanceGroup.getModelInvariantId(),
+ instanceGroup.getModelInfoInstanceGroup().getModelInvariantUUID());
+ assertEquals(aaiInstanceGroup.getModelVersionId(), instanceGroup.getModelInfoInstanceGroup().getModelUUID());
+ assertEquals(aaiInstanceGroup.getResourceVersion(), instanceGroup.getResourceVersion());
+ assertEquals(aaiInstanceGroup.getInstanceGroupType(), instanceGroup.getModelInfoInstanceGroup().getType());
+ assertEquals(aaiInstanceGroup.getInstanceGroupRole(),
+ instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
+ }
+
+ @Test
+ public void mapCustomerTest() {
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ customer.setSubscriberName("subscriberName");
+ customer.setSubscriberType("subscriberType");
+
+ org.onap.aai.domain.yang.Customer expectedCustomer = new org.onap.aai.domain.yang.Customer();
+ expectedCustomer.setGlobalCustomerId("globalCustomerId");
+ expectedCustomer.setSubscriberName("subscriberName");
+ expectedCustomer.setSubscriberType("subscriberType");
+
+ org.onap.aai.domain.yang.Customer actualCustomer = aaiObjectMapper.mapCustomer(customer);
+
+ assertThat(actualCustomer, sameBeanAs(expectedCustomer));
+ }
+
+ @Test
+ public void networkMap() throws Exception {
+ L3Network l3Network = new L3Network();
+ l3Network.setNetworkId("networkId");
+ l3Network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ l3Network.setNetworkName("networkName");
+ l3Network.setNetworkRole("networkRole");
+ l3Network.setNetworkTechnology("networkTechnology");
+ l3Network.setNeutronNetworkId("neutronNetworkId");
+ l3Network.setNetworkRoleInstance(0L);
+ l3Network.setContrailNetworkFqdn("contrailNetworkFqdn");
+ l3Network.setIsBoundToVpn(false);
+ l3Network.setIsCascaded(false);
+ l3Network.setIsSharedNetwork(false);
+ l3Network.setHeatStackId("heatStackId");
+ l3Network.setOperationalStatus("operationalStatus");
+ l3Network.setPhysicalNetworkName("physicalNetworkName");
+ l3Network.setIsProviderNetwork(false);
+ l3Network.setSelflink("selflink");
+ l3Network.setServiceId("serviceId");
+
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUUID");
+ modelInfoNetwork.setModelInvariantUUID("modelInvariantUUID");
+ modelInfoNetwork.setModelUUID("modelUUID");
+
+ l3Network.setModelInfoNetwork(modelInfoNetwork);
+
+ org.onap.aai.domain.yang.L3Network aaiL3Network = aaiObjectMapper.mapNetwork(l3Network);
+
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.L3Network network =
+ omapper.readValue(getJson("aaiL3NetworkMapped.json"), org.onap.aai.domain.yang.L3Network.class);
+
+ com.shazam.shazamcrest.MatcherAssert.assertThat(aaiL3Network, sameBeanAs(network));
+
+ }
+
+ @Test
+ public void mapCollectionTest() {
+ Collection networkCollection = new Collection();
+ networkCollection.setId("networkCollectionId");
+ ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
+ modelInfoCollection.setCollectionFunction("networkCollectionFunction");
+ modelInfoCollection.setCollectionRole("networkCollectionRole");
+ modelInfoCollection.setCollectionType("networkCollectionType");
+ modelInfoCollection.setModelCustomizationUUID("modelCustomizationUUID");
+ modelInfoCollection.setModelVersionId("modelVersionId");
+ modelInfoCollection.setModelInvariantUUID("modelInvariantUUID");
+ networkCollection.setModelInfoCollection(modelInfoCollection);
+ networkCollection.setName("networkCollectionName");
+
+ org.onap.aai.domain.yang.Collection expectedCollection = new org.onap.aai.domain.yang.Collection();
+ expectedCollection.setCollectionId("networkCollectionId");
+ expectedCollection.setCollectionType("networkCollectionType");
+ expectedCollection.setCollectionCustomizationId("modelCustomizationUUID");
+ expectedCollection.setModelVersionId("modelVersionId");
+ expectedCollection.setModelInvariantId("modelInvariantUUID");
+ expectedCollection.setCollectionFunction("networkCollectionFunction");
+ expectedCollection.setCollectionRole("networkCollectionRole");
+ expectedCollection.setCollectionName("networkCollectionName");
+
+ org.onap.aai.domain.yang.Collection actualCollection = aaiObjectMapper.mapCollection(networkCollection);
+
+ assertThat(actualCollection, sameBeanAs(expectedCollection));
+ }
+
+ /*
+ * Helper method to load JSON data
+ */
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
+ }
+
+ @Test
+ public void mapNetworkTest() throws Exception {
+ L3Network l3Network = new L3Network();
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setModelCustomizationUUID("modelCustomization_id");
+ modelInfoNetwork.setModelInvariantUUID("modelInvariant_id");
+ modelInfoNetwork.setModelUUID("modelCustomization_id");
+ modelInfoNetwork.setNetworkType("CONTRAIL_EXTERNAL");
+ modelInfoNetwork.setNetworkRole("dmz_direct");
+ modelInfoNetwork.setNetworkTechnology("contrail");
+ l3Network.setModelInfoNetwork(modelInfoNetwork);
+ l3Network.setNetworkId("TESTING_ID");
+ l3Network.setNetworkName("TESTING_NAME");
+ l3Network.setIsBoundToVpn(true);
+ l3Network.setServiceId("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
+ l3Network.setNetworkRoleInstance(1L);
+ l3Network.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ l3Network.setHeatStackId("heatStack_id");
+ l3Network.setContrailNetworkFqdn("contrailNetwork_fqdn");
+ l3Network.setWidgetModelId("widgetModel_id");
+ l3Network.setWidgetModelVersion("widgetModel_version");
+ l3Network.setPhysicalNetworkName("physicalNetwork_name");
+ l3Network.setIsProviderNetwork(true);
+ l3Network.setIsSharedNetwork(false);
+ l3Network.setIsExternalNetwork(true);
+ l3Network.setSelflink("self_link");
+ l3Network.setOperationalStatus("operationalStatus");
+
+ List<Subnet> subnets = new ArrayList<Subnet>();
+ Subnet subnet1 = new Subnet();
+ subnet1.setSubnetId("57e9a1ff-d14f-4071-a828-b19ae98eb2fc");
+ subnet1.setSubnetName("subnetName");
+ subnet1.setGatewayAddress("192.168.52.1");
+ subnet1.setNetworkStartAddress("192.168.52.0");
+ subnet1.setCidrMask("24");
+ subnet1.setIpVersion("4");
+ subnet1.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ subnet1.setIpAssignmentDirection("true");
+ subnet1.setDhcpEnabled(true);
+ subnet1.setDhcpStart("dhcpStart");
+ subnet1.setDhcpEnd("dhcpEnd");
+ subnet1.setSubnetRole("subnetRole");
+ subnet1.setIpAssignmentDirection("true");
+ subnet1.setSubnetSequence(new Integer(3));
+
+ List<HostRoute> hostRoutes = new ArrayList<HostRoute>();
+ HostRoute hostRoute1 = new HostRoute();
+ hostRoute1.setHostRouteId("string");
+ hostRoute1.setRoutePrefix("192.10.16.0/24");
+ hostRoute1.setNextHop("192.10.16.100/24");
+ hostRoute1.setNextHopType("ip-address");
+ HostRoute hostRoute2 = new HostRoute();
+ hostRoute2.setHostRouteId("string");
+ hostRoute2.setRoutePrefix("192.110.17.0/24");
+ hostRoute2.setNextHop("192.110.17.110/24");
+ hostRoute2.setNextHopType("ip-address");
+ hostRoutes.add(hostRoute1);
+ hostRoutes.add(hostRoute2);
+ subnet1.getHostRoutes().addAll(hostRoutes);
+
+ subnets.add(subnet1);
+ subnets.add(subnet1);
+ l3Network.getSubnets().addAll(subnets);
+
+ List<CtagAssignment> ctagAssignments = new ArrayList<CtagAssignment>();
+ CtagAssignment ctagAssignment1 = new CtagAssignment();
+ ctagAssignment1.setVlanIdInner(1L);
+ ctagAssignments.add(ctagAssignment1);
+ l3Network.getCtagAssignments().addAll(ctagAssignments);
+
+ List<SegmentationAssignment> segmentationAssignments = new ArrayList<SegmentationAssignment>();
+ SegmentationAssignment segmentationAssignment1 = new SegmentationAssignment();
+ segmentationAssignment1.setSegmentationId("segmentationId1");
+ SegmentationAssignment segmentationAssignment2 = new SegmentationAssignment();
+ segmentationAssignment2.setSegmentationId("segmentationId2");
+ segmentationAssignments.add(segmentationAssignment1);
+ segmentationAssignments.add(segmentationAssignment2);
+ l3Network.getSegmentationAssignments().addAll(segmentationAssignments);
+
+ AAIObjectMapper l3NetworkMapper = new AAIObjectMapper();
+ org.onap.aai.domain.yang.L3Network v12L3Network = l3NetworkMapper.mapNetwork(l3Network);
+
+ String jsonToCompare =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiL3NetworkMapped_to_aai.json")));
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.L3Network network =
+ omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.L3Network.class);
+
+ ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+ String jsonGenerated = ow.writeValueAsString(v12L3Network);
+ String jsonExpected = ow.writeValueAsString(network);
+ assertEquals(jsonExpected, jsonGenerated);
+
+ }
+
+ @Test
+ public void mapToAAISubNetsTest() throws Exception {
+ List<Subnet> subnets = new ArrayList<Subnet>();
+ Subnet subnet1 = new Subnet();
+ subnet1.setSubnetId("57e9a1ff-d14f-4071-a828-b19ae98eb2fc");
+ subnet1.setSubnetName("subnetName");
+ subnet1.setGatewayAddress("192.168.52.1");
+ subnet1.setNetworkStartAddress("192.168.52.0");
+ subnet1.setCidrMask("24");
+ subnet1.setIpVersion("4");
+ subnet1.setOrchestrationStatus(OrchestrationStatus.CREATED);
+ subnet1.setIpAssignmentDirection("true");
+ subnet1.setDhcpEnabled(true);
+ subnet1.setDhcpStart("dhcpStart");
+ subnet1.setDhcpEnd("dhcpEnd");
+ subnet1.setSubnetRole("subnetRole");
+ subnet1.setIpAssignmentDirection("true");
+ subnet1.setSubnetSequence(new Integer(3));
+
+ List<HostRoute> hostRoutes = new ArrayList<HostRoute>();
+ HostRoute hostRoute1 = new HostRoute();
+ hostRoute1.setHostRouteId("string");
+ hostRoute1.setRoutePrefix("192.10.16.0/24");
+ hostRoute1.setNextHop("192.10.16.100/24");
+ hostRoute1.setNextHopType("ip-address");
+ HostRoute hostRoute2 = new HostRoute();
+ hostRoute2.setHostRouteId("string");
+ hostRoute2.setRoutePrefix("192.110.17.0/24");
+ hostRoute2.setNextHop("192.110.17.110/24");
+ hostRoute2.setNextHopType("ip-address");
+ hostRoutes.add(hostRoute1);
+ hostRoutes.add(hostRoute2);
+ subnet1.getHostRoutes().addAll(hostRoutes);
+
+ subnets.add(subnet1);
+ subnets.add(subnet1);
+
+ AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
+ org.onap.aai.domain.yang.Subnets v12Subnets = aaiObjectMapper.mapToAAISubNets(subnets);
+
+ assertEquals(subnets.get(0).getDhcpEnd(), v12Subnets.getSubnet().get(0).getDhcpEnd());
+ assertEquals(subnets.get(0).getCidrMask(), v12Subnets.getSubnet().get(0).getCidrMask());
+
+ String jsonToCompare =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSubnetsMapped_to_aai.json")));
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.Subnets subnet =
+ omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.Subnets.class);
+ ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+ String jsonGenerated = ow.writeValueAsString(v12Subnets);
+ String jsonExpected = ow.writeValueAsString(subnet);
+ assertEquals(jsonExpected, jsonGenerated);
}
- @Test
- public void owningEntityMap(){
- OwningEntity oe = new OwningEntity();
- oe.setOwningEntityId("abc");
- oe.setOwningEntityName("bbb");
-
- org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(oe);
-
- assertEquals(AAIOwningEntity.getOwningEntityId(),oe.getOwningEntityId());
- assertEquals(AAIOwningEntity.getOwningEntityName(),oe.getOwningEntityName());
-
- }
-
- @Test
- public void vnfMap(){
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("a");
- vnf.setVnfName("b");
- vnf.setServiceId("c");
- vnf.setVnfType("d");
- vnf.setProvStatus("e");
- vnf.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelCustomizationUuid("f");
- modelInfoGenericVnf.setModelInvariantUuid("g");
- modelInfoGenericVnf.setModelUuid("h");
- modelInfoGenericVnf.setNfRole("i");
- modelInfoGenericVnf.setNfType("j");
- modelInfoGenericVnf.setNfFunction("k");
- modelInfoGenericVnf.setNfNamingCode("l");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- org.onap.aai.domain.yang.GenericVnf AAIVnf = aaiObjectMapper.mapVnf(vnf);
-
- assertEquals(AAIVnf.getVnfId(),vnf.getVnfId());
- assertEquals(AAIVnf.getVnfName(),vnf.getVnfName());
- assertEquals(AAIVnf.getServiceId(),vnf.getServiceId());
- assertEquals(AAIVnf.getVnfType(),vnf.getVnfType());
- assertEquals(AAIVnf.getProvStatus(),vnf.getProvStatus());
- assertEquals(AAIVnf.getOrchestrationStatus().toString(),vnf.getOrchestrationStatus().toString());
- assertEquals(AAIVnf.getModelCustomizationId(),vnf.getModelInfoGenericVnf().getModelCustomizationUuid());
- assertEquals(AAIVnf.getModelInvariantId(),vnf.getModelInfoGenericVnf().getModelInvariantUuid());
- assertEquals(AAIVnf.getModelVersionId(),vnf.getModelInfoGenericVnf().getModelUuid());
- assertEquals(AAIVnf.getModelVersionId(),vnf.getModelInfoGenericVnf().getModelUuid());
- assertEquals(AAIVnf.getNfType(),vnf.getModelInfoGenericVnf().getNfType());
- assertEquals(AAIVnf.getNfFunction(),vnf.getModelInfoGenericVnf().getNfFunction());
- assertEquals(AAIVnf.getNfNamingCode(),vnf.getModelInfoGenericVnf().getNfNamingCode());
- }
-
- @Test
- public void vfModuleMap() throws Exception {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("a");
- vfModule.setVfModuleName("b");
- vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelCustomizationUUID("f");
- modelInfoVfModule.setModelInvariantUUID("g");
- modelInfoVfModule.setModelUUID("h");
- modelInfoVfModule.setIsBaseBoolean(false);
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleMap.json")));
-
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.VfModule reqMapper1 = omapper.readValue(
- jsonToCompare,
- org.onap.aai.domain.yang.VfModule.class);
-
- assertThat(reqMapper1, sameBeanAs(AAIVfModule));
-
- }
-
- @Test
- public void vfModuleBaseMap() throws Exception {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("a");
- vfModule.setVfModuleName("b");
- vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelCustomizationUUID("f");
- modelInfoVfModule.setModelInvariantUUID("g");
- modelInfoVfModule.setModelUUID("h");
- modelInfoVfModule.setIsBaseBoolean(true);
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleBaseMap.json")));
-
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.VfModule reqMapper1 = omapper.readValue(
- jsonToCompare,
- org.onap.aai.domain.yang.VfModule.class);
-
- assertThat(reqMapper1, sameBeanAs(AAIVfModule));
-
- }
-
- @Test
- public void testMapInstanceGroup() {
- InstanceGroup instanceGroup = new InstanceGroup();
- instanceGroup.setId("test-id");
- instanceGroup.setDescription("test-description");
- instanceGroup.setInstanceGroupName("test-instanceGroupName");
- instanceGroup.setResourceVersion("test-resourceVersion");
-
- ModelInfoInstanceGroup model = new ModelInfoInstanceGroup();
- model.setFunction("test-function");
- model.setInstanceGroupRole("SUB-INTERFACE");
- model.setType("VNFC");
- model.setModelInvariantUUID("modelInvariantUUID-000");
- model.setModelUUID("modelUUID-000");
- model.setDescription("test-description");
- model.setInstanceGroupRole("SUB-INTERFACE");
-
- instanceGroup.setModelInfoInstanceGroup(model);
-
-
- org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup);
-
- try {
- com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
- String json = mapper.writeValueAsString(aaiInstanceGroup);
- System.out.println("GGG - json:\n" + json);
-
- }
- catch(Exception e) {
- e.printStackTrace();
- }
-
- assertEquals(aaiInstanceGroup.getId(), instanceGroup.getId());
- assertEquals(aaiInstanceGroup.getDescription(), instanceGroup.getDescription());
- assertEquals(aaiInstanceGroup.getInstanceGroupRole(), instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
- assertEquals(aaiInstanceGroup.getModelInvariantId(), instanceGroup.getModelInfoInstanceGroup().getModelInvariantUUID());
- assertEquals(aaiInstanceGroup.getModelVersionId(), instanceGroup.getModelInfoInstanceGroup().getModelUUID());
- assertEquals(aaiInstanceGroup.getResourceVersion(), instanceGroup.getResourceVersion());
- assertEquals(aaiInstanceGroup.getInstanceGroupType(), instanceGroup.getModelInfoInstanceGroup().getType());
- assertEquals(aaiInstanceGroup.getInstanceGroupRole(), instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
- }
-
- @Test
- public void mapCustomerTest() {
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- customer.setSubscriberName("subscriberName");
- customer.setSubscriberType("subscriberType");
-
- org.onap.aai.domain.yang.Customer expectedCustomer = new org.onap.aai.domain.yang.Customer();
- expectedCustomer.setGlobalCustomerId("globalCustomerId");
- expectedCustomer.setSubscriberName("subscriberName");
- expectedCustomer.setSubscriberType("subscriberType");
-
- org.onap.aai.domain.yang.Customer actualCustomer = aaiObjectMapper.mapCustomer(customer);
-
- assertThat(actualCustomer, sameBeanAs(expectedCustomer));
- }
-
- @Test
- public void networkMap() throws Exception {
- L3Network l3Network = new L3Network();
- l3Network.setNetworkId("networkId");
- l3Network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- l3Network.setNetworkName("networkName");
- l3Network.setNetworkRole("networkRole");
- l3Network.setNetworkTechnology("networkTechnology");
- l3Network.setNeutronNetworkId("neutronNetworkId");
- l3Network.setNetworkRoleInstance(0L);
- l3Network.setContrailNetworkFqdn("contrailNetworkFqdn");
- l3Network.setIsBoundToVpn(false);
- l3Network.setIsCascaded(false);
- l3Network.setIsSharedNetwork(false);
- l3Network.setHeatStackId("heatStackId");
- l3Network.setOperationalStatus("operationalStatus");
- l3Network.setPhysicalNetworkName("physicalNetworkName");
- l3Network.setIsProviderNetwork(false);
- l3Network.setSelflink("selflink");
- l3Network.setServiceId("serviceId");
-
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUUID");
- modelInfoNetwork.setModelInvariantUUID("modelInvariantUUID");
- modelInfoNetwork.setModelUUID("modelUUID");
-
- l3Network.setModelInfoNetwork(modelInfoNetwork);
-
- org.onap.aai.domain.yang.L3Network aaiL3Network = aaiObjectMapper.mapNetwork(l3Network);
-
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.L3Network network = omapper.readValue(
- getJson("aaiL3NetworkMapped.json"),
- org.onap.aai.domain.yang.L3Network.class);
-
- com.shazam.shazamcrest.MatcherAssert.assertThat(aaiL3Network, sameBeanAs(network));
-
- }
-
- @Test
- public void mapCollectionTest() {
- Collection networkCollection = new Collection();
- networkCollection.setId("networkCollectionId");
- ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
- modelInfoCollection.setCollectionFunction("networkCollectionFunction");
- modelInfoCollection.setCollectionRole("networkCollectionRole");
- modelInfoCollection.setCollectionType("networkCollectionType");
- modelInfoCollection.setModelCustomizationUUID("modelCustomizationUUID");
- modelInfoCollection.setModelVersionId("modelVersionId");
- modelInfoCollection.setModelInvariantUUID("modelInvariantUUID");
- networkCollection.setModelInfoCollection(modelInfoCollection);
- networkCollection.setName("networkCollectionName");
-
- org.onap.aai.domain.yang.Collection expectedCollection = new org.onap.aai.domain.yang.Collection();
- expectedCollection.setCollectionId("networkCollectionId");
- expectedCollection.setCollectionType("networkCollectionType");
- expectedCollection.setCollectionCustomizationId("modelCustomizationUUID");
- expectedCollection.setModelVersionId("modelVersionId");
- expectedCollection.setModelInvariantId("modelInvariantUUID");
- expectedCollection.setCollectionFunction("networkCollectionFunction");
- expectedCollection.setCollectionRole("networkCollectionRole");
- expectedCollection.setCollectionName("networkCollectionName");
-
- org.onap.aai.domain.yang.Collection actualCollection = aaiObjectMapper.mapCollection(networkCollection);
-
- assertThat(actualCollection, sameBeanAs(expectedCollection));
- }
-
- /*
- * Helper method to load JSON data
- */
- private String getJson(String filename) throws IOException {
- return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
- }
-
- @Test
- public void mapNetworkTest() throws Exception {
- L3Network l3Network = new L3Network();
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setModelCustomizationUUID("modelCustomization_id");
- modelInfoNetwork.setModelInvariantUUID("modelInvariant_id");
- modelInfoNetwork.setModelUUID("modelCustomization_id");
- modelInfoNetwork.setNetworkType("CONTRAIL_EXTERNAL");
- modelInfoNetwork.setNetworkRole("dmz_direct");
- modelInfoNetwork.setNetworkTechnology("contrail");
- l3Network.setModelInfoNetwork(modelInfoNetwork);
- l3Network.setNetworkId("TESTING_ID");
- l3Network.setNetworkName("TESTING_NAME");
- l3Network.setIsBoundToVpn(true);
- l3Network.setServiceId("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
- l3Network.setNetworkRoleInstance(1L);
- l3Network.setOrchestrationStatus(OrchestrationStatus.CREATED);
- l3Network.setHeatStackId("heatStack_id");
- l3Network.setContrailNetworkFqdn("contrailNetwork_fqdn");
- l3Network.setWidgetModelId("widgetModel_id");
- l3Network.setWidgetModelVersion("widgetModel_version");
- l3Network.setPhysicalNetworkName("physicalNetwork_name");
- l3Network.setIsProviderNetwork(true);
- l3Network.setIsSharedNetwork(false);
- l3Network.setIsExternalNetwork(true);
- l3Network.setSelflink("self_link");
- l3Network.setOperationalStatus("operationalStatus");
-
- List<Subnet> subnets = new ArrayList<Subnet>();
- Subnet subnet1 = new Subnet();
- subnet1.setSubnetId("57e9a1ff-d14f-4071-a828-b19ae98eb2fc");
- subnet1.setSubnetName("subnetName");
- subnet1.setGatewayAddress("192.168.52.1");
- subnet1.setNetworkStartAddress("192.168.52.0");
- subnet1.setCidrMask("24");
- subnet1.setIpVersion("4");
- subnet1.setOrchestrationStatus(OrchestrationStatus.CREATED);
- subnet1.setIpAssignmentDirection("true");
- subnet1.setDhcpEnabled(true);
- subnet1.setDhcpStart("dhcpStart");
- subnet1.setDhcpEnd("dhcpEnd");
- subnet1.setSubnetRole("subnetRole");
- subnet1.setIpAssignmentDirection("true");
- subnet1.setSubnetSequence(new Integer(3));
-
- List<HostRoute> hostRoutes = new ArrayList<HostRoute>();
- HostRoute hostRoute1 = new HostRoute();
- hostRoute1.setHostRouteId("string");
- hostRoute1.setRoutePrefix("192.10.16.0/24");
- hostRoute1.setNextHop("192.10.16.100/24");
- hostRoute1.setNextHopType("ip-address");
- HostRoute hostRoute2 = new HostRoute();
- hostRoute2.setHostRouteId("string");
- hostRoute2.setRoutePrefix("192.110.17.0/24");
- hostRoute2.setNextHop("192.110.17.110/24");
- hostRoute2.setNextHopType("ip-address");
- hostRoutes.add(hostRoute1);
- hostRoutes.add(hostRoute2);
- subnet1.getHostRoutes().addAll(hostRoutes);
-
- subnets.add(subnet1);
- subnets.add(subnet1);
- l3Network.getSubnets().addAll(subnets);
-
- List<CtagAssignment> ctagAssignments = new ArrayList<CtagAssignment>();
- CtagAssignment ctagAssignment1 = new CtagAssignment();
- ctagAssignment1.setVlanIdInner(1L);
- ctagAssignments.add(ctagAssignment1);
- l3Network.getCtagAssignments().addAll(ctagAssignments);
-
- List<SegmentationAssignment> segmentationAssignments = new ArrayList<SegmentationAssignment>();
- SegmentationAssignment segmentationAssignment1 = new SegmentationAssignment();
- segmentationAssignment1.setSegmentationId("segmentationId1");
- SegmentationAssignment segmentationAssignment2 = new SegmentationAssignment();
- segmentationAssignment2.setSegmentationId("segmentationId2");
- segmentationAssignments.add(segmentationAssignment1);
- segmentationAssignments.add(segmentationAssignment2);
- l3Network.getSegmentationAssignments().addAll(segmentationAssignments);
-
- AAIObjectMapper l3NetworkMapper = new AAIObjectMapper();
- org.onap.aai.domain.yang.L3Network v12L3Network = l3NetworkMapper.mapNetwork(l3Network);
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiL3NetworkMapped_to_aai.json")));
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.L3Network network = omapper.readValue(jsonToCompare,
- org.onap.aai.domain.yang.L3Network.class);
-
- ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
- String jsonGenerated = ow.writeValueAsString(v12L3Network);
- String jsonExpected = ow.writeValueAsString(network);
- assertEquals(jsonExpected, jsonGenerated);
-
- }
-
- @Test
- public void mapToAAISubNetsTest() throws Exception {
- List<Subnet> subnets = new ArrayList<Subnet>();
- Subnet subnet1 = new Subnet();
- subnet1.setSubnetId("57e9a1ff-d14f-4071-a828-b19ae98eb2fc");
- subnet1.setSubnetName("subnetName");
- subnet1.setGatewayAddress("192.168.52.1");
- subnet1.setNetworkStartAddress("192.168.52.0");
- subnet1.setCidrMask("24");
- subnet1.setIpVersion("4");
- subnet1.setOrchestrationStatus(OrchestrationStatus.CREATED);
- subnet1.setIpAssignmentDirection("true");
- subnet1.setDhcpEnabled(true);
- subnet1.setDhcpStart("dhcpStart");
- subnet1.setDhcpEnd("dhcpEnd");
- subnet1.setSubnetRole("subnetRole");
- subnet1.setIpAssignmentDirection("true");
- subnet1.setSubnetSequence(new Integer(3));
-
- List<HostRoute> hostRoutes = new ArrayList<HostRoute>();
- HostRoute hostRoute1 = new HostRoute();
- hostRoute1.setHostRouteId("string");
- hostRoute1.setRoutePrefix("192.10.16.0/24");
- hostRoute1.setNextHop("192.10.16.100/24");
- hostRoute1.setNextHopType("ip-address");
- HostRoute hostRoute2 = new HostRoute();
- hostRoute2.setHostRouteId("string");
- hostRoute2.setRoutePrefix("192.110.17.0/24");
- hostRoute2.setNextHop("192.110.17.110/24");
- hostRoute2.setNextHopType("ip-address");
- hostRoutes.add(hostRoute1);
- hostRoutes.add(hostRoute2);
- subnet1.getHostRoutes().addAll(hostRoutes);
-
- subnets.add(subnet1);
- subnets.add(subnet1);
-
- AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
- org.onap.aai.domain.yang.Subnets v12Subnets = aaiObjectMapper.mapToAAISubNets(subnets);
-
- assertEquals(subnets.get(0).getDhcpEnd(), v12Subnets.getSubnet().get(0).getDhcpEnd());
- assertEquals(subnets.get(0).getCidrMask(), v12Subnets.getSubnet().get(0).getCidrMask());
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSubnetsMapped_to_aai.json")));
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.Subnets subnet = omapper.readValue(jsonToCompare,
- org.onap.aai.domain.yang.Subnets.class);
- ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
- String jsonGenerated = ow.writeValueAsString(v12Subnets);
- String jsonExpected = ow.writeValueAsString(subnet);
- assertEquals(jsonExpected, jsonGenerated);
- }
-
- @Test
- public void mapToAAICtagAssignmentListTest() throws Exception {
- List<CtagAssignment> ctagAssignments = new ArrayList<CtagAssignment>();
- CtagAssignment ctagAssignment1 = new CtagAssignment();
- ctagAssignment1.setVlanIdInner(1L);
- ctagAssignments.add(ctagAssignment1);
-
- AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
- org.onap.aai.domain.yang.CtagAssignments v12CtagAssingments = aaiObjectMapper.mapToAAICtagAssignmentList(ctagAssignments);
-
- assertEquals(new Long(ctagAssignments.get(0).getVlanIdInner().longValue()), new Long(v12CtagAssingments.getCtagAssignment().get(0).getVlanIdInner()));
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiCtagAssingmentsMapped_to_aai.json")));
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.CtagAssignments ctagAssignment = omapper.readValue(jsonToCompare,
- org.onap.aai.domain.yang.CtagAssignments.class);
- ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
- String jsonGenerated = ow.writeValueAsString(v12CtagAssingments);
- String jsonExpected = ow.writeValueAsString(ctagAssignment);
- assertEquals(jsonExpected, jsonGenerated);
- }
-
- @Test
- public void mapToAAISegmentationAssignmentListTest() throws Exception {
- List<SegmentationAssignment> segmentationAssignments = new ArrayList<SegmentationAssignment>();
- SegmentationAssignment segmentationAssignment1 = new SegmentationAssignment();
- segmentationAssignment1.setSegmentationId("segmentationId1");
- SegmentationAssignment segmentationAssignment2 = new SegmentationAssignment();
- segmentationAssignment2.setSegmentationId("segmentationId2");
- segmentationAssignments.add(segmentationAssignment1);
- segmentationAssignments.add(segmentationAssignment2);
-
- AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
- org.onap.aai.domain.yang.SegmentationAssignments v12SegmentationAssignments = aaiObjectMapper.mapToAAISegmentationAssignmentList(segmentationAssignments);
-
- assertEquals(segmentationAssignments.get(0).getSegmentationId(), v12SegmentationAssignments.getSegmentationAssignment().get(0).getSegmentationId());
- assertEquals(segmentationAssignments.get(1).getSegmentationId(), v12SegmentationAssignments.getSegmentationAssignment().get(1).getSegmentationId());
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSegmentationAssignmentsMapped_to_aai.json")));
- ObjectMapper omapper = new ObjectMapper();
- org.onap.aai.domain.yang.SegmentationAssignments segmentationAssignment = omapper.readValue(jsonToCompare,
- org.onap.aai.domain.yang.SegmentationAssignments.class);
- ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
- String jsonGenerated = ow.writeValueAsString(v12SegmentationAssignments);
- String jsonExpected = ow.writeValueAsString(segmentationAssignment);
- assertEquals(jsonExpected, jsonGenerated);
-
- }
+ @Test
+ public void mapToAAICtagAssignmentListTest() throws Exception {
+ List<CtagAssignment> ctagAssignments = new ArrayList<CtagAssignment>();
+ CtagAssignment ctagAssignment1 = new CtagAssignment();
+ ctagAssignment1.setVlanIdInner(1L);
+ ctagAssignments.add(ctagAssignment1);
+
+ AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
+ org.onap.aai.domain.yang.CtagAssignments v12CtagAssingments =
+ aaiObjectMapper.mapToAAICtagAssignmentList(ctagAssignments);
+
+ assertEquals(new Long(ctagAssignments.get(0).getVlanIdInner().longValue()),
+ new Long(v12CtagAssingments.getCtagAssignment().get(0).getVlanIdInner()));
+
+ String jsonToCompare =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiCtagAssingmentsMapped_to_aai.json")));
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.CtagAssignments ctagAssignment =
+ omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.CtagAssignments.class);
+ ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+ String jsonGenerated = ow.writeValueAsString(v12CtagAssingments);
+ String jsonExpected = ow.writeValueAsString(ctagAssignment);
+ assertEquals(jsonExpected, jsonGenerated);
+ }
+
+ @Test
+ public void mapToAAISegmentationAssignmentListTest() throws Exception {
+ List<SegmentationAssignment> segmentationAssignments = new ArrayList<SegmentationAssignment>();
+ SegmentationAssignment segmentationAssignment1 = new SegmentationAssignment();
+ segmentationAssignment1.setSegmentationId("segmentationId1");
+ SegmentationAssignment segmentationAssignment2 = new SegmentationAssignment();
+ segmentationAssignment2.setSegmentationId("segmentationId2");
+ segmentationAssignments.add(segmentationAssignment1);
+ segmentationAssignments.add(segmentationAssignment2);
+
+ AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
+ org.onap.aai.domain.yang.SegmentationAssignments v12SegmentationAssignments =
+ aaiObjectMapper.mapToAAISegmentationAssignmentList(segmentationAssignments);
+
+ assertEquals(segmentationAssignments.get(0).getSegmentationId(),
+ v12SegmentationAssignments.getSegmentationAssignment().get(0).getSegmentationId());
+ assertEquals(segmentationAssignments.get(1).getSegmentationId(),
+ v12SegmentationAssignments.getSegmentationAssignment().get(1).getSegmentationId());
+
+ String jsonToCompare = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSegmentationAssignmentsMapped_to_aai.json")));
+ ObjectMapper omapper = new ObjectMapper();
+ org.onap.aai.domain.yang.SegmentationAssignments segmentationAssignment =
+ omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.SegmentationAssignments.class);
+ ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
+ String jsonGenerated = ow.writeValueAsString(v12SegmentationAssignments);
+ String jsonExpected = ow.writeValueAsString(segmentationAssignment);
+ assertEquals(jsonExpected, jsonGenerated);
+
+ }
@Test
public void mapVpnBindingTest() {
- VpnBinding vpnBinding = new VpnBinding();
- vpnBinding.setVpnId("testVpnId");
- vpnBinding.setVpnName("testVpn");
- vpnBinding.setVpnPlatform("AVPN");
- vpnBinding.setCustomerVpnId("testCustomerVpnId");
- vpnBinding.setVpnType("testVpnType");
- vpnBinding.setVpnRegion("testVpnRegion");
- vpnBinding.setRouteDistinguisher("testRD");
+ VpnBinding vpnBinding = new VpnBinding();
+ vpnBinding.setVpnId("testVpnId");
+ vpnBinding.setVpnName("testVpn");
+ vpnBinding.setVpnPlatform("AVPN");
+ vpnBinding.setCustomerVpnId("testCustomerVpnId");
+ vpnBinding.setVpnType("testVpnType");
+ vpnBinding.setVpnRegion("testVpnRegion");
+ vpnBinding.setRouteDistinguisher("testRD");
RouteTarget routeTarget = new RouteTarget();
routeTarget.setRouteTargetRole("testRtRole");
routeTarget.setGlobalRouteTarget("testGrt");
@@ -659,7 +676,7 @@ public class AAIObjectMapperTest {
assertThat(actualRouteTarget, sameBeanAs(expectedRouteTarget));
}
-
+
@Test
public void mapSubnetTest() {
Subnet subnet = new Subnet();
@@ -671,24 +688,24 @@ public class AAIObjectMapperTest {
expectedSubnet.setSubnetId("testSubnetId");
expectedSubnet.setOrchestrationStatus("Pending");
expectedSubnet.setNeutronSubnetId("testNeutronSubnetId");
-
+
org.onap.aai.domain.yang.Subnet actualSubnet = aaiObjectMapper.mapSubnet(subnet);
assertThat(actualSubnet, sameBeanAs(expectedSubnet));
}
-
+
@Test
public void mapNetworkPolicyTest() {
NetworkPolicy networkPolicy = new NetworkPolicy();
networkPolicy.setNetworkPolicyId("testNetworkPolicyId");
networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn");
- networkPolicy.setHeatStackId("testHeatStackId");
+ networkPolicy.setHeatStackId("testHeatStackId");
org.onap.aai.domain.yang.NetworkPolicy expectedNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
expectedNetworkPolicy.setNetworkPolicyId("testNetworkPolicyId");
expectedNetworkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn");
- expectedNetworkPolicy.setHeatStackId("testHeatStackId");
-
+ expectedNetworkPolicy.setHeatStackId("testHeatStackId");
+
org.onap.aai.domain.yang.NetworkPolicy actualNetworkPolicy = aaiObjectMapper.mapNetworkPolicy(networkPolicy);
assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java
index fe9e1c1608..251ab2cb74 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java
@@ -29,9 +29,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.put;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import javax.ws.rs.core.Response;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -51,197 +49,196 @@ import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
import org.onap.so.client.policy.JettisonStyleMapperProvider;
import org.onap.so.openstack.beans.NetworkRollback;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class NetworkAdapterClientIT extends BaseIntegrationTest{
-
- private static final String TESTING_ID = "___TESTING___";
- private static final String AAI_NETWORK_ID = "test";
- private static final String REST_ENDPOINT = "/networks/rest/v1/networks";
-
- private NetworkAdapterClientImpl client = new NetworkAdapterClientImpl();
- private ObjectMapper mapper = new JettisonStyleMapperProvider().getMapper();
-
- @BeforeClass
- public static void setUp() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void createNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
- CreateNetworkRequest request = new CreateNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
-
- CreateNetworkResponse mockResponse = new CreateNetworkResponse();
- mockResponse.setNetworkCreated(true);
- wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- CreateNetworkResponse response = client.createNetwork(request);
- assertEquals("Testing CreateVfModule response", true, response.getNetworkCreated());
- }
-
- @Test(expected = NetworkAdapterClientException.class)
- public void createNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
- CreateNetworkRequest request = new CreateNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
-
- CreateNetworkError mockResponse = new CreateNetworkError();
- mockResponse.setMessage("Error in create network");
- wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.createNetwork(request);
- }
-
- @Test
- public void deleteNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
- DeleteNetworkRequest request = new DeleteNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
-
- DeleteNetworkResponse mockResponse = new DeleteNetworkResponse();
- mockResponse.setNetworkDeleted(true);
-
- wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- DeleteNetworkResponse response = client.deleteNetwork(AAI_NETWORK_ID, request);
- assertEquals("Testing DeleteVfModule response", true, response.getNetworkDeleted());
- }
-
- @Test(expected = NetworkAdapterClientException.class)
- public void deleteNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
- DeleteNetworkRequest request = new DeleteNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
-
- DeleteNetworkError mockResponse = new DeleteNetworkError();
- mockResponse.setMessage("Error in delete network");
- wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.deleteNetwork(AAI_NETWORK_ID, request);
- }
-
- @Test
- public void rollbackNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
- RollbackNetworkRequest request = new RollbackNetworkRequest();
- NetworkRollback rollback = new NetworkRollback();
- rollback.setCloudId(TESTING_ID);
- request.setNetworkRollback(rollback);
-
- RollbackNetworkResponse mockResponse = new RollbackNetworkResponse();
- mockResponse.setNetworkRolledBack(true);
-
- wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- RollbackNetworkResponse response = client.rollbackNetwork(AAI_NETWORK_ID, request);
- assertEquals("Testing DeleteVfModule response", true, response.getNetworkRolledBack());
- }
-
- @Test(expected = NetworkAdapterClientException.class)
- public void rollbackNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
- RollbackNetworkRequest request = new RollbackNetworkRequest();
- NetworkRollback rollback = new NetworkRollback();
- rollback.setCloudId(TESTING_ID);
- request.setNetworkRollback(rollback);
-
- RollbackNetworkError mockResponse = new RollbackNetworkError();
- mockResponse.setMessage("Error in rollback network");
-
- wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.rollbackNetwork(AAI_NETWORK_ID, request);
- }
-
- @Test
- public void queryNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
- QueryNetworkResponse mockResponse = new QueryNetworkResponse();
- mockResponse.setNetworkExists(true);
-
- wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).withQueryParam("cloudSiteId", equalTo(TESTING_ID))
- .withQueryParam("tenantId", equalTo(TESTING_ID))
- .withQueryParam("networkStackId", equalTo("networkStackId")).withQueryParam("skipAAI", equalTo("true"))
- .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
- .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- QueryNetworkResponse response = client.queryNetwork(AAI_NETWORK_ID, TESTING_ID, TESTING_ID, "networkStackId",
- true, "testRequestId", "serviceInstanceId");
- assertEquals("Testing QueryVfModule response", true, response.getNetworkExists());
- }
-
- @Test(expected = NetworkAdapterClientException.class)
- public void queryNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
- QueryNetworkError mockResponse = new QueryNetworkError();
- mockResponse.setMessage("Error in query network");
-
- wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).withQueryParam("cloudSiteId", equalTo(TESTING_ID))
- .withQueryParam("tenantId", equalTo(TESTING_ID))
- .withQueryParam("networkStackId", equalTo("networkStackId")).withQueryParam("skipAAI", equalTo("true"))
- .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
- .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.queryNetwork(AAI_NETWORK_ID, TESTING_ID, TESTING_ID, "networkStackId",
- true, "testRequestId", "serviceInstanceId");
- }
-
- @Test
- public void updateNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
- UpdateNetworkRequest request = new UpdateNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
- request.setNetworkId("test1");
-
- UpdateNetworkResponse mockResponse = new UpdateNetworkResponse();
- mockResponse.setNetworkId("test1");
- wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- UpdateNetworkResponse response = client.updateNetwork(AAI_NETWORK_ID, request);
- assertEquals("Testing UpdateVfModule response", "test1", response.getNetworkId());
- }
-
- @Test
- public void updateNetworkTestAsync() throws NetworkAdapterClientException, JsonProcessingException {
- UpdateNetworkRequest request = new UpdateNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
- request.setNetworkId("test1");
-
- UpdateNetworkResponse mockResponse = new UpdateNetworkResponse();
- mockResponse.setNetworkId("test1");
- wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- Response response = client.updateNetworkAsync(AAI_NETWORK_ID, request);
- assertNotNull(response.getEntity());
- }
-
- @Test(expected = NetworkAdapterClientException.class)
- public void updateNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
- UpdateNetworkRequest request = new UpdateNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
- request.setNetworkId("test1");
-
- UpdateNetworkError mockResponse = new UpdateNetworkError();
- mockResponse.setMessage("Error in update network");
- wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.updateNetwork(AAI_NETWORK_ID, request);
- }
+public class NetworkAdapterClientIT extends BaseIntegrationTest {
+
+ private static final String TESTING_ID = "___TESTING___";
+ private static final String AAI_NETWORK_ID = "test";
+ private static final String REST_ENDPOINT = "/networks/rest/v1/networks";
+
+ private NetworkAdapterClientImpl client = new NetworkAdapterClientImpl();
+ private ObjectMapper mapper = new JettisonStyleMapperProvider().getMapper();
+
+ @BeforeClass
+ public static void setUp() {
+ System.setProperty("mso.config.path", "src/test/resources");
+ }
+
+ @Test
+ public void createNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
+ CreateNetworkRequest request = new CreateNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ CreateNetworkResponse mockResponse = new CreateNetworkResponse();
+ mockResponse.setNetworkCreated(true);
+ wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ CreateNetworkResponse response = client.createNetwork(request);
+ assertEquals("Testing CreateVfModule response", true, response.getNetworkCreated());
+ }
+
+ @Test(expected = NetworkAdapterClientException.class)
+ public void createNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
+ CreateNetworkRequest request = new CreateNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ CreateNetworkError mockResponse = new CreateNetworkError();
+ mockResponse.setMessage("Error in create network");
+ wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.createNetwork(request);
+ }
+
+ @Test
+ public void deleteNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
+ DeleteNetworkRequest request = new DeleteNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ DeleteNetworkResponse mockResponse = new DeleteNetworkResponse();
+ mockResponse.setNetworkDeleted(true);
+
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ DeleteNetworkResponse response = client.deleteNetwork(AAI_NETWORK_ID, request);
+ assertEquals("Testing DeleteVfModule response", true, response.getNetworkDeleted());
+ }
+
+ @Test(expected = NetworkAdapterClientException.class)
+ public void deleteNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
+ DeleteNetworkRequest request = new DeleteNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ DeleteNetworkError mockResponse = new DeleteNetworkError();
+ mockResponse.setMessage("Error in delete network");
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.deleteNetwork(AAI_NETWORK_ID, request);
+ }
+
+ @Test
+ public void rollbackNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
+ RollbackNetworkRequest request = new RollbackNetworkRequest();
+ NetworkRollback rollback = new NetworkRollback();
+ rollback.setCloudId(TESTING_ID);
+ request.setNetworkRollback(rollback);
+
+ RollbackNetworkResponse mockResponse = new RollbackNetworkResponse();
+ mockResponse.setNetworkRolledBack(true);
+
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ RollbackNetworkResponse response = client.rollbackNetwork(AAI_NETWORK_ID, request);
+ assertEquals("Testing DeleteVfModule response", true, response.getNetworkRolledBack());
+ }
+
+ @Test(expected = NetworkAdapterClientException.class)
+ public void rollbackNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
+ RollbackNetworkRequest request = new RollbackNetworkRequest();
+ NetworkRollback rollback = new NetworkRollback();
+ rollback.setCloudId(TESTING_ID);
+ request.setNetworkRollback(rollback);
+
+ RollbackNetworkError mockResponse = new RollbackNetworkError();
+ mockResponse.setMessage("Error in rollback network");
+
+ wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.rollbackNetwork(AAI_NETWORK_ID, request);
+ }
+
+ @Test
+ public void queryNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
+ QueryNetworkResponse mockResponse = new QueryNetworkResponse();
+ mockResponse.setNetworkExists(true);
+
+ wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .withQueryParam("cloudSiteId", equalTo(TESTING_ID)).withQueryParam("tenantId", equalTo(TESTING_ID))
+ .withQueryParam("networkStackId", equalTo("networkStackId")).withQueryParam("skipAAI", equalTo("true"))
+ .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
+ .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ QueryNetworkResponse response = client.queryNetwork(AAI_NETWORK_ID, TESTING_ID, TESTING_ID, "networkStackId",
+ true, "testRequestId", "serviceInstanceId");
+ assertEquals("Testing QueryVfModule response", true, response.getNetworkExists());
+ }
+
+ @Test(expected = NetworkAdapterClientException.class)
+ public void queryNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
+ QueryNetworkError mockResponse = new QueryNetworkError();
+ mockResponse.setMessage("Error in query network");
+
+ wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .withQueryParam("cloudSiteId", equalTo(TESTING_ID)).withQueryParam("tenantId", equalTo(TESTING_ID))
+ .withQueryParam("networkStackId", equalTo("networkStackId")).withQueryParam("skipAAI", equalTo("true"))
+ .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
+ .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.queryNetwork(AAI_NETWORK_ID, TESTING_ID, TESTING_ID, "networkStackId", true, "testRequestId",
+ "serviceInstanceId");
+ }
+
+ @Test
+ public void updateNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
+ UpdateNetworkRequest request = new UpdateNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+ request.setNetworkId("test1");
+
+ UpdateNetworkResponse mockResponse = new UpdateNetworkResponse();
+ mockResponse.setNetworkId("test1");
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ UpdateNetworkResponse response = client.updateNetwork(AAI_NETWORK_ID, request);
+ assertEquals("Testing UpdateVfModule response", "test1", response.getNetworkId());
+ }
+
+ @Test
+ public void updateNetworkTestAsync() throws NetworkAdapterClientException, JsonProcessingException {
+ UpdateNetworkRequest request = new UpdateNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+ request.setNetworkId("test1");
+
+ UpdateNetworkResponse mockResponse = new UpdateNetworkResponse();
+ mockResponse.setNetworkId("test1");
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ Response response = client.updateNetworkAsync(AAI_NETWORK_ID, request);
+ assertNotNull(response.getEntity());
+ }
+
+ @Test(expected = NetworkAdapterClientException.class)
+ public void updateNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
+ UpdateNetworkRequest request = new UpdateNetworkRequest();
+ request.setCloudSiteId(TESTING_ID);
+ request.setNetworkId("test1");
+
+ UpdateNetworkError mockResponse = new UpdateNetworkError();
+ mockResponse.setMessage("Error in update network");
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.updateNetwork(AAI_NETWORK_ID, request);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
index 4bdbd1a846..ccd677c80e 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
@@ -24,7 +24,6 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
-
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -33,7 +32,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
@@ -62,314 +60,329 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
import org.onap.so.entity.MsoRequest;
import org.onap.so.openstack.beans.NetworkRollback;
-
import com.fasterxml.jackson.databind.ObjectMapper;
-public class NetworkAdapterObjectMapperTest extends TestDataSetup{
-
- private NetworkAdapterObjectMapper SPY_networkAdapterObjectMapper = Mockito.spy(NetworkAdapterObjectMapper.class);
-
- private L3Network l3Network;
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
- private Customer customer;
- Map<String, String> userInput;
-
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/NetworkMapper/";
-
- @Before
- public void before() {
- requestContext = setRequestContext();
-
- customer = buildCustomer();
-
- serviceInstance = setServiceInstance();
-
- cloudRegion = setCloudRegion();
-
- orchestrationContext = setOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- userInput = setUserInput();
-
- l3Network = setL3Network();
-
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- }
-
- @Test
- public void buildCreateNetworkRequestFromBbobjectTest() throws Exception {
-
- String cloudRegionPo = "cloudRegionPo";
- CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
-
- expectedCreateNetworkRequest.setCloudSiteId(cloudRegionPo);
- expectedCreateNetworkRequest.setTenantId(cloudRegion.getTenantId());
- expectedCreateNetworkRequest.setNetworkId(l3Network.getNetworkId());
- expectedCreateNetworkRequest.setNetworkName(l3Network.getNetworkName());
- expectedCreateNetworkRequest.setNetworkType(l3Network.getNetworkType());
- expectedCreateNetworkRequest.setBackout(false);
- expectedCreateNetworkRequest.setFailIfExists(true);
- expectedCreateNetworkRequest.setNetworkTechnology("CONTRAIL");
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedCreateNetworkRequest.setMsoRequest(msoRequest);
- expectedCreateNetworkRequest.setSkipAAI(true);
- HashMap<String, String> networkParams = new HashMap<String, String>();
- networkParams.put("shared", "true");
- networkParams.put("external", "false");
- networkParams.put("testUserInputKey", "testUserInputValue");
- expectedCreateNetworkRequest.setNetworkParams(networkParams);
-
- expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
-
- Subnet openstackSubnet = new Subnet();
- HostRoute hostRoute = new HostRoute();
- hostRoute.setHostRouteId("hostRouteId");
- hostRoute.setNextHop("nextHop");
- hostRoute.setRoutePrefix("routePrefix");
- openstackSubnet.getHostRoutes().add(hostRoute);
- List<Subnet> subnetList = new ArrayList<Subnet>();
- subnetList.add(openstackSubnet);
- l3Network.getSubnets().add(openstackSubnet);
- l3Network.setNetworkTechnology("Contrail");
- l3Network.setIsSharedNetwork(true);
- l3Network.setIsExternalNetwork(false);
-
- doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
- doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
-
- CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
-
- assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailRequest").ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("messageId"));
- }
-
- @Test
- public void createNetworkRollbackRequestMapperTest() throws Exception {
-
- String cloudRegionPo = "cloudRegionPo";
- RollbackNetworkRequest expectedRollbackNetworkRequest = new RollbackNetworkRequest();
-
- expectedRollbackNetworkRequest.setMessageId(requestContext.getMsoRequestId());
- NetworkRollback networkRollback = new NetworkRollback();
- networkRollback.setCloudId(cloudRegionPo);
- networkRollback.setNetworkCreated(true);
- networkRollback.setNetworkId(l3Network.getNetworkId());
- networkRollback.setNetworkType(l3Network.getNetworkType());
- networkRollback.setTenantId(cloudRegion.getTenantId());
- expectedRollbackNetworkRequest.setNetworkRollback(networkRollback);
- expectedRollbackNetworkRequest.setSkipAAI(true);
-
- CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
- createNetworkResponse.setNetworkCreated(true);
-
- RollbackNetworkRequest rollbackNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRollbackRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
-
- assertThat(rollbackNetworkRequest, sameBeanAs(expectedRollbackNetworkRequest).ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("networkParams").ignoring("messageId"));
- }
-
- @Test
- public void updateNetworkRequestMapperTest() throws UnsupportedEncodingException {
- org.onap.so.openstack.beans.Subnet subnet = new org.onap.so.openstack.beans.Subnet();
- subnet.setSubnetId("subnetId");
- subnet.setHostRoutes(new ArrayList<org.onap.so.openstack.beans.HostRoute>());
-
- List<org.onap.so.openstack.beans.Subnet> subnets = new ArrayList<>();
- subnets.add(subnet);
-
- ProviderVlanNetwork providerVlanNetwork = new ProviderVlanNetwork("physicalNetworkName", new ArrayList<Integer>());
-
- List<String> policyFqdns = Arrays.asList("networkPolicyFqdn");
-
- org.onap.so.openstack.beans.RouteTarget expectedRouteTarget = new org.onap.so.openstack.beans.RouteTarget();
- expectedRouteTarget.setRouteTarget("globalRouteTarget");
-
- ContrailNetwork contrailNetwork = new ContrailNetwork();
- contrailNetwork.setPolicyFqdns(policyFqdns);
- contrailNetwork.setRouteTableFqdns(new ArrayList<String>());
- contrailNetwork.setRouteTargets(new ArrayList<org.onap.so.openstack.beans.RouteTarget>());
- contrailNetwork.getRouteTargets().add(expectedRouteTarget);
- contrailNetwork.getRouteTableFqdns().add("routeTableReferenceFqdn");
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setServiceInstanceId("testServiceInstanceId1");
-
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setNetworkType("networkType");
- modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
- modelInfoNetwork.setModelVersion("modelVersion");
-
- Subnet actualSubnet = new Subnet();
- actualSubnet.setSubnetId("subnetId");
- actualSubnet.setDhcpEnabled(false);
- actualSubnet.setIpVersion("4");
-
- RouteTarget routeTarget = new RouteTarget();
- routeTarget.setGlobalRouteTarget("globalRouteTarget");
-
- VpnBinding vpnBinding = new VpnBinding();
- vpnBinding.setVpnId("vpnId");
- vpnBinding.getRouteTargets().add(routeTarget);
-
- Customer customer = new Customer();
- customer.getVpnBindings().add(vpnBinding);
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- customer.setServiceSubscription(serviceSubscription);
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
-
- NetworkPolicy networkPolicy = new NetworkPolicy();
- networkPolicy.setNetworkPolicyId("networkPolicyId");
- networkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
-
- RouteTableReference routeTableReference = new RouteTableReference();
- routeTableReference.setRouteTableReferenceFqdn("routeTableReferenceFqdn");
-
- l3Network.setModelInfoNetwork(modelInfoNetwork);
- l3Network.setPhysicalNetworkName("physicalNetworkName");
- l3Network.getSubnets().add(actualSubnet);
- l3Network.getNetworkPolicies().add(networkPolicy);
- l3Network.getContrailNetworkRouteTableReferences().add(routeTableReference);
- l3Network.setIsSharedNetwork(false);
- l3Network.setIsExternalNetwork(false);
- HashMap<String, String> networkParams = new HashMap<String, String>();
- networkParams.put("shared", "false");
- networkParams.put("external", "false");
- networkParams.put("testUserInputKey", "testUserInputValue");
-
- UpdateNetworkRequest expectedUpdateNetworkRequest = new UpdateNetworkRequest();
- expectedUpdateNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
- expectedUpdateNetworkRequest.setTenantId(cloudRegion.getTenantId());
- expectedUpdateNetworkRequest.setNetworkId(l3Network.getNetworkId());
- expectedUpdateNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
- expectedUpdateNetworkRequest.setNetworkName(l3Network.getNetworkName());
- expectedUpdateNetworkRequest.setNetworkType(l3Network.getModelInfoNetwork().getNetworkType());
- expectedUpdateNetworkRequest.setNetworkTypeVersion(l3Network.getModelInfoNetwork().getModelVersion());
- expectedUpdateNetworkRequest.setModelCustomizationUuid(l3Network.getModelInfoNetwork().getModelCustomizationUUID());
- expectedUpdateNetworkRequest.setSubnets(subnets);
- expectedUpdateNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
- expectedUpdateNetworkRequest.setContrailNetwork(contrailNetwork);
- expectedUpdateNetworkRequest.setNetworkParams(networkParams);
- expectedUpdateNetworkRequest.setMsoRequest(msoRequest);
- expectedUpdateNetworkRequest.setSkipAAI(true);
- expectedUpdateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
- expectedUpdateNetworkRequest.setMessageId("messageId");
- expectedUpdateNetworkRequest.setNotificationUrl("http://localhost:28080/mso/WorkflowMesssage/NetworkAResponse/messageId");
-
- doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
- doReturn("http://localhost:28080/mso/WorkflowMesssage").when(SPY_networkAdapterObjectMapper).getEndpoint();
- UpdateNetworkRequest actualUpdateNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
-
- assertThat(actualUpdateNetworkRequest, sameBeanAs(expectedUpdateNetworkRequest).ignoring("msoRequest.requestId"));
- }
-
- @Test
- public void deleteNetworkRequestMapperTest() throws Exception {
- DeleteNetworkRequest expectedDeleteNetworkRequest = new DeleteNetworkRequest();
-
- String messageId = "messageId";
- expectedDeleteNetworkRequest.setMessageId(messageId);
- doReturn(messageId).when(SPY_networkAdapterObjectMapper).getRandomUuid();
-
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- l3Network.setModelInfoNetwork(modelInfoNetwork);
- modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
- expectedDeleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedDeleteNetworkRequest.setMsoRequest(msoRequest);
-
- expectedDeleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
-
- l3Network.setHeatStackId("heatStackId");
- expectedDeleteNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
-
- expectedDeleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
-
- expectedDeleteNetworkRequest.setSkipAAI(true);
-
- expectedDeleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
-
- expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
-
- expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
-
- doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
- doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
-
- DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper.deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
-
- assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest));
- }
-
- @Test
- public void deleteNetworkRequestNoHeatIdMapperTest() throws Exception {
- DeleteNetworkRequest expectedDeleteNetworkRequest = new DeleteNetworkRequest();
-
- String messageId = "messageId";
- expectedDeleteNetworkRequest.setMessageId(messageId);
- doReturn(messageId).when(SPY_networkAdapterObjectMapper).getRandomUuid();
-
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- l3Network.setModelInfoNetwork(modelInfoNetwork);
- modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
- expectedDeleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedDeleteNetworkRequest.setMsoRequest(msoRequest);
-
- expectedDeleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
-
- l3Network.setNetworkName("heatStackId");
- expectedDeleteNetworkRequest.setNetworkStackId("heatStackId");
-
- expectedDeleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
-
- expectedDeleteNetworkRequest.setSkipAAI(true);
-
- expectedDeleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
-
- expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
-
- expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
-
- doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
- doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
- DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper.deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
-
- assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest));
- }
-
- @Test
- public void buildOpenstackSubnetListTest() throws Exception {
-
- ObjectMapper omapper = new ObjectMapper();
- String bbJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "generalBB.json")));
- org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock gbb = omapper.readValue(
- bbJson,
- org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock.class);
- L3Network myNetwork = gbb.getServiceInstance().getNetworks().get(0);
-
- String expectedCreateNetworkRequestJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "createNetworkRequest.json")));
- org.onap.so.adapters.nwrest.CreateNetworkRequest expectedCreateNetworkRequest = omapper.readValue(
- expectedCreateNetworkRequestJson,
- org.onap.so.adapters.nwrest.CreateNetworkRequest.class);
-
- String cloudRegionPo = "cloudRegionPo";
-
- expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
-
- doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
- doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
- CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, myNetwork, userInput, cloudRegionPo, customer);
- //ignoring dynamic fields and networkParams that throws parsing exception on json file load
- assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("messageId").ignoring("msoRequest.requestId").ignoring("networkParams"));
- }
+public class NetworkAdapterObjectMapperTest extends TestDataSetup {
+
+ private NetworkAdapterObjectMapper SPY_networkAdapterObjectMapper = Mockito.spy(NetworkAdapterObjectMapper.class);
+
+ private L3Network l3Network;
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+ private Customer customer;
+ Map<String, String> userInput;
+
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/NetworkMapper/";
+
+ @Before
+ public void before() {
+ requestContext = setRequestContext();
+
+ customer = buildCustomer();
+
+ serviceInstance = setServiceInstance();
+
+ cloudRegion = setCloudRegion();
+
+ orchestrationContext = setOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ userInput = setUserInput();
+
+ l3Network = setL3Network();
+
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ }
+
+ @Test
+ public void buildCreateNetworkRequestFromBbobjectTest() throws Exception {
+
+ String cloudRegionPo = "cloudRegionPo";
+ CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
+
+ expectedCreateNetworkRequest.setCloudSiteId(cloudRegionPo);
+ expectedCreateNetworkRequest.setTenantId(cloudRegion.getTenantId());
+ expectedCreateNetworkRequest.setNetworkId(l3Network.getNetworkId());
+ expectedCreateNetworkRequest.setNetworkName(l3Network.getNetworkName());
+ expectedCreateNetworkRequest.setNetworkType(l3Network.getNetworkType());
+ expectedCreateNetworkRequest.setBackout(false);
+ expectedCreateNetworkRequest.setFailIfExists(true);
+ expectedCreateNetworkRequest.setNetworkTechnology("CONTRAIL");
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedCreateNetworkRequest.setMsoRequest(msoRequest);
+ expectedCreateNetworkRequest.setSkipAAI(true);
+ HashMap<String, String> networkParams = new HashMap<String, String>();
+ networkParams.put("shared", "true");
+ networkParams.put("external", "false");
+ networkParams.put("testUserInputKey", "testUserInputValue");
+ expectedCreateNetworkRequest.setNetworkParams(networkParams);
+
+ expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
+
+ Subnet openstackSubnet = new Subnet();
+ HostRoute hostRoute = new HostRoute();
+ hostRoute.setHostRouteId("hostRouteId");
+ hostRoute.setNextHop("nextHop");
+ hostRoute.setRoutePrefix("routePrefix");
+ openstackSubnet.getHostRoutes().add(hostRoute);
+ List<Subnet> subnetList = new ArrayList<Subnet>();
+ subnetList.add(openstackSubnet);
+ l3Network.getSubnets().add(openstackSubnet);
+ l3Network.setNetworkTechnology("Contrail");
+ l3Network.setIsSharedNetwork(true);
+ l3Network.setIsExternalNetwork(false);
+
+ doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
+ doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
+
+ CreateNetworkRequest createNetworkRequest =
+ SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
+
+ assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailRequest")
+ .ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("messageId"));
+ }
+
+ @Test
+ public void createNetworkRollbackRequestMapperTest() throws Exception {
+
+ String cloudRegionPo = "cloudRegionPo";
+ RollbackNetworkRequest expectedRollbackNetworkRequest = new RollbackNetworkRequest();
+
+ expectedRollbackNetworkRequest.setMessageId(requestContext.getMsoRequestId());
+ NetworkRollback networkRollback = new NetworkRollback();
+ networkRollback.setCloudId(cloudRegionPo);
+ networkRollback.setNetworkCreated(true);
+ networkRollback.setNetworkId(l3Network.getNetworkId());
+ networkRollback.setNetworkType(l3Network.getNetworkType());
+ networkRollback.setTenantId(cloudRegion.getTenantId());
+ expectedRollbackNetworkRequest.setNetworkRollback(networkRollback);
+ expectedRollbackNetworkRequest.setSkipAAI(true);
+
+ CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
+ createNetworkResponse.setNetworkCreated(true);
+
+ RollbackNetworkRequest rollbackNetworkRequest = SPY_networkAdapterObjectMapper
+ .createNetworkRollbackRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance,
+ l3Network, userInput, cloudRegionPo, createNetworkResponse);
+
+ assertThat(rollbackNetworkRequest, sameBeanAs(expectedRollbackNetworkRequest).ignoring("contrailNetwork")
+ .ignoring("providerVlanNetwork").ignoring("subnets").ignoring("networkParams").ignoring("messageId"));
+ }
+
+ @Test
+ public void updateNetworkRequestMapperTest() throws UnsupportedEncodingException {
+ org.onap.so.openstack.beans.Subnet subnet = new org.onap.so.openstack.beans.Subnet();
+ subnet.setSubnetId("subnetId");
+ subnet.setHostRoutes(new ArrayList<org.onap.so.openstack.beans.HostRoute>());
+
+ List<org.onap.so.openstack.beans.Subnet> subnets = new ArrayList<>();
+ subnets.add(subnet);
+
+ ProviderVlanNetwork providerVlanNetwork =
+ new ProviderVlanNetwork("physicalNetworkName", new ArrayList<Integer>());
+
+ List<String> policyFqdns = Arrays.asList("networkPolicyFqdn");
+
+ org.onap.so.openstack.beans.RouteTarget expectedRouteTarget = new org.onap.so.openstack.beans.RouteTarget();
+ expectedRouteTarget.setRouteTarget("globalRouteTarget");
+
+ ContrailNetwork contrailNetwork = new ContrailNetwork();
+ contrailNetwork.setPolicyFqdns(policyFqdns);
+ contrailNetwork.setRouteTableFqdns(new ArrayList<String>());
+ contrailNetwork.setRouteTargets(new ArrayList<org.onap.so.openstack.beans.RouteTarget>());
+ contrailNetwork.getRouteTargets().add(expectedRouteTarget);
+ contrailNetwork.getRouteTableFqdns().add("routeTableReferenceFqdn");
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setServiceInstanceId("testServiceInstanceId1");
+
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setNetworkType("networkType");
+ modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
+ modelInfoNetwork.setModelVersion("modelVersion");
+
+ Subnet actualSubnet = new Subnet();
+ actualSubnet.setSubnetId("subnetId");
+ actualSubnet.setDhcpEnabled(false);
+ actualSubnet.setIpVersion("4");
+
+ RouteTarget routeTarget = new RouteTarget();
+ routeTarget.setGlobalRouteTarget("globalRouteTarget");
+
+ VpnBinding vpnBinding = new VpnBinding();
+ vpnBinding.setVpnId("vpnId");
+ vpnBinding.getRouteTargets().add(routeTarget);
+
+ Customer customer = new Customer();
+ customer.getVpnBindings().add(vpnBinding);
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ customer.setServiceSubscription(serviceSubscription);
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ networkPolicy.setNetworkPolicyId("networkPolicyId");
+ networkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
+
+ RouteTableReference routeTableReference = new RouteTableReference();
+ routeTableReference.setRouteTableReferenceFqdn("routeTableReferenceFqdn");
+
+ l3Network.setModelInfoNetwork(modelInfoNetwork);
+ l3Network.setPhysicalNetworkName("physicalNetworkName");
+ l3Network.getSubnets().add(actualSubnet);
+ l3Network.getNetworkPolicies().add(networkPolicy);
+ l3Network.getContrailNetworkRouteTableReferences().add(routeTableReference);
+ l3Network.setIsSharedNetwork(false);
+ l3Network.setIsExternalNetwork(false);
+ HashMap<String, String> networkParams = new HashMap<String, String>();
+ networkParams.put("shared", "false");
+ networkParams.put("external", "false");
+ networkParams.put("testUserInputKey", "testUserInputValue");
+
+ UpdateNetworkRequest expectedUpdateNetworkRequest = new UpdateNetworkRequest();
+ expectedUpdateNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+ expectedUpdateNetworkRequest.setTenantId(cloudRegion.getTenantId());
+ expectedUpdateNetworkRequest.setNetworkId(l3Network.getNetworkId());
+ expectedUpdateNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
+ expectedUpdateNetworkRequest.setNetworkName(l3Network.getNetworkName());
+ expectedUpdateNetworkRequest.setNetworkType(l3Network.getModelInfoNetwork().getNetworkType());
+ expectedUpdateNetworkRequest.setNetworkTypeVersion(l3Network.getModelInfoNetwork().getModelVersion());
+ expectedUpdateNetworkRequest
+ .setModelCustomizationUuid(l3Network.getModelInfoNetwork().getModelCustomizationUUID());
+ expectedUpdateNetworkRequest.setSubnets(subnets);
+ expectedUpdateNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
+ expectedUpdateNetworkRequest.setContrailNetwork(contrailNetwork);
+ expectedUpdateNetworkRequest.setNetworkParams(networkParams);
+ expectedUpdateNetworkRequest.setMsoRequest(msoRequest);
+ expectedUpdateNetworkRequest.setSkipAAI(true);
+ expectedUpdateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
+ expectedUpdateNetworkRequest.setMessageId("messageId");
+ expectedUpdateNetworkRequest
+ .setNotificationUrl("http://localhost:28080/mso/WorkflowMesssage/NetworkAResponse/messageId");
+
+ doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
+ doReturn("http://localhost:28080/mso/WorkflowMesssage").when(SPY_networkAdapterObjectMapper).getEndpoint();
+ UpdateNetworkRequest actualUpdateNetworkRequest =
+ SPY_networkAdapterObjectMapper.createNetworkUpdateRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, l3Network, userInput, customer);
+
+ assertThat(actualUpdateNetworkRequest,
+ sameBeanAs(expectedUpdateNetworkRequest).ignoring("msoRequest.requestId"));
+ }
+
+ @Test
+ public void deleteNetworkRequestMapperTest() throws Exception {
+ DeleteNetworkRequest expectedDeleteNetworkRequest = new DeleteNetworkRequest();
+
+ String messageId = "messageId";
+ expectedDeleteNetworkRequest.setMessageId(messageId);
+ doReturn(messageId).when(SPY_networkAdapterObjectMapper).getRandomUuid();
+
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ l3Network.setModelInfoNetwork(modelInfoNetwork);
+ modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
+ expectedDeleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedDeleteNetworkRequest.setMsoRequest(msoRequest);
+
+ expectedDeleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
+
+ l3Network.setHeatStackId("heatStackId");
+ expectedDeleteNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
+
+ expectedDeleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
+
+ expectedDeleteNetworkRequest.setSkipAAI(true);
+
+ expectedDeleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
+
+ expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+
+ expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
+
+ doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
+ doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
+
+ DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper
+ .deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
+
+ assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest));
+ }
+
+ @Test
+ public void deleteNetworkRequestNoHeatIdMapperTest() throws Exception {
+ DeleteNetworkRequest expectedDeleteNetworkRequest = new DeleteNetworkRequest();
+
+ String messageId = "messageId";
+ expectedDeleteNetworkRequest.setMessageId(messageId);
+ doReturn(messageId).when(SPY_networkAdapterObjectMapper).getRandomUuid();
+
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ l3Network.setModelInfoNetwork(modelInfoNetwork);
+ modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
+ expectedDeleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedDeleteNetworkRequest.setMsoRequest(msoRequest);
+
+ expectedDeleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
+
+ l3Network.setNetworkName("heatStackId");
+ expectedDeleteNetworkRequest.setNetworkStackId("heatStackId");
+
+ expectedDeleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
+
+ expectedDeleteNetworkRequest.setSkipAAI(true);
+
+ expectedDeleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
+
+ expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+
+ expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
+
+ doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
+ doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
+ DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper
+ .deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
+
+ assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest));
+ }
+
+ @Test
+ public void buildOpenstackSubnetListTest() throws Exception {
+
+ ObjectMapper omapper = new ObjectMapper();
+ String bbJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "generalBB.json")));
+ org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock gbb =
+ omapper.readValue(bbJson, org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock.class);
+ L3Network myNetwork = gbb.getServiceInstance().getNetworks().get(0);
+
+ String expectedCreateNetworkRequestJson =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "createNetworkRequest.json")));
+ org.onap.so.adapters.nwrest.CreateNetworkRequest expectedCreateNetworkRequest = omapper
+ .readValue(expectedCreateNetworkRequestJson, org.onap.so.adapters.nwrest.CreateNetworkRequest.class);
+
+ String cloudRegionPo = "cloudRegionPo";
+
+ expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
+
+ doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
+ doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
+ CreateNetworkRequest createNetworkRequest =
+ SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, myNetwork, userInput, cloudRegionPo, customer);
+ // ignoring dynamic fields and networkParams that throws parsing exception on json file load
+ assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("messageId")
+ .ignoring("msoRequest.requestId").ignoring("networkParams"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java
index 90e99eb0ad..7fb1db9d98 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java
@@ -28,7 +28,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -44,182 +43,179 @@ import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse;
import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse;
import org.onap.so.adapters.vnfrest.VfModuleRollback;
import org.onap.so.client.policy.JettisonStyleMapperProvider;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class VnfAdapterClientIT extends BaseIntegrationTest{
-
- private static final String TESTING_ID = "___TESTING___";
- private static final String AAI_VNF_ID = "test";
- private static final String AAI_VF_MODULE_ID = "test";
- private static final String REST_ENDPOINT = "/services/rest/v1/vnfs";
-
- private VnfAdapterClientImpl client = new VnfAdapterClientImpl();
- private ObjectMapper mapper = new JettisonStyleMapperProvider().getMapper();
-
- @BeforeClass
- public static void setUp() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void createVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
- CreateVfModuleRequest request = new CreateVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
-
- CreateVfModuleResponse mockResponse = new CreateVfModuleResponse();
- mockResponse.setVfModuleCreated(true);
- wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- CreateVfModuleResponse response = client.createVfModule(AAI_VNF_ID, request);
- assertEquals("Testing CreateVfModule response", true, response.getVfModuleCreated());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void createVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
- CreateVfModuleRequest request = new CreateVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
-
- VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
- mockResponse.setMessage("Error in create Vf module");
- wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.createVfModule(AAI_VNF_ID, request);
- }
-
- @Test
- public void rollbackVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
- RollbackVfModuleRequest request = new RollbackVfModuleRequest();
- VfModuleRollback rollback = new VfModuleRollback();
- rollback.setCloudSiteId(TESTING_ID);
- request.setVfModuleRollback(rollback);
-
- RollbackVfModuleResponse mockResponse = new RollbackVfModuleResponse();
- mockResponse.setVfModuleRolledback(true);
- wireMockServer.stubFor(
- delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- RollbackVfModuleResponse response = client.rollbackVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- assertEquals("Testing RollbackVfModule response", true, response.getVfModuleRolledback());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void rollbackVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
- RollbackVfModuleRequest request = new RollbackVfModuleRequest();
- VfModuleRollback rollback = new VfModuleRollback();
- rollback.setCloudSiteId(TESTING_ID);
- request.setVfModuleRollback(rollback);
-
- VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
- mockResponse.setMessage("Error in rollback Vf module");
- wireMockServer.stubFor(
- delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.rollbackVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- }
-
- @Test
- public void deleteVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
- DeleteVfModuleRequest request = new DeleteVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
-
- DeleteVfModuleResponse mockResponse = new DeleteVfModuleResponse();
- mockResponse.setVfModuleDeleted(true);
- wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- DeleteVfModuleResponse response = client.deleteVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- assertEquals("Testing DeleteVfModule response", true, response.getVfModuleDeleted());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void deleteVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
- DeleteVfModuleRequest request = new DeleteVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
-
- VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
- mockResponse.setMessage("Error in delete Vf module");
- wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.deleteVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- }
-
- @Test
- public void updateVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
- UpdateVfModuleRequest request = new UpdateVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
- request.setVfModuleId("test1");
-
- UpdateVfModuleResponse mockResponse = new UpdateVfModuleResponse();
- mockResponse.setVfModuleId("test1");
- wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
-
- UpdateVfModuleResponse response = client.updateVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- assertEquals("Testing UpdateVfModule response", "test1", response.getVfModuleId());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void updateVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
- UpdateVfModuleRequest request = new UpdateVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
- request.setVfModuleId("test1");
-
- VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
- mockResponse.setMessage("Error in update Vf module");
- wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
-
- client.updateVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- }
-
- @Test
- public void queryVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
- QueryVfModuleResponse mockResponse = new QueryVfModuleResponse();
- mockResponse.setVnfId(AAI_VNF_ID);
- mockResponse.setVfModuleId(AAI_VF_MODULE_ID);
- wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .withQueryParam("cloudSiteId", equalTo(TESTING_ID))
- .withQueryParam("tenantId", equalTo(TESTING_ID))
- .withQueryParam("vfModuleName", equalTo("someName"))
- .withQueryParam("skipAAI", equalTo("true"))
- .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
- .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
- QueryVfModuleResponse response = client.queryVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, TESTING_ID, TESTING_ID,
- "someName", true, "testRequestId", "serviceInstanceId");
- assertEquals("Testing QueryVfModule response", AAI_VF_MODULE_ID, response.getVfModuleId());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void queryVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
- VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
- mockResponse.setMessage("Error in update Vf module");
- wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .withQueryParam("cloudSiteId", equalTo(TESTING_ID))
- .withQueryParam("tenantId", equalTo(TESTING_ID))
- .withQueryParam("vfModuleName", equalTo("someName"))
- .withQueryParam("skipAAI", equalTo("true"))
- .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
- .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
- client.queryVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, TESTING_ID, TESTING_ID,
- "someName", true, "testRequestId", "serviceInstanceId");
- }
+public class VnfAdapterClientIT extends BaseIntegrationTest {
+
+ private static final String TESTING_ID = "___TESTING___";
+ private static final String AAI_VNF_ID = "test";
+ private static final String AAI_VF_MODULE_ID = "test";
+ private static final String REST_ENDPOINT = "/services/rest/v1/vnfs";
+
+ private VnfAdapterClientImpl client = new VnfAdapterClientImpl();
+ private ObjectMapper mapper = new JettisonStyleMapperProvider().getMapper();
+
+ @BeforeClass
+ public static void setUp() {
+ System.setProperty("mso.config.path", "src/test/resources");
+ }
+
+ @Test
+ public void createVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
+ CreateVfModuleRequest request = new CreateVfModuleRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ CreateVfModuleResponse mockResponse = new CreateVfModuleResponse();
+ mockResponse.setVfModuleCreated(true);
+ wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ CreateVfModuleResponse response = client.createVfModule(AAI_VNF_ID, request);
+ assertEquals("Testing CreateVfModule response", true, response.getVfModuleCreated());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void createVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
+ CreateVfModuleRequest request = new CreateVfModuleRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
+ mockResponse.setMessage("Error in create Vf module");
+ wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.createVfModule(AAI_VNF_ID, request);
+ }
+
+ @Test
+ public void rollbackVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
+ RollbackVfModuleRequest request = new RollbackVfModuleRequest();
+ VfModuleRollback rollback = new VfModuleRollback();
+ rollback.setCloudSiteId(TESTING_ID);
+ request.setVfModuleRollback(rollback);
+
+ RollbackVfModuleResponse mockResponse = new RollbackVfModuleResponse();
+ mockResponse.setVfModuleRolledback(true);
+ wireMockServer.stubFor(delete(
+ urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ RollbackVfModuleResponse response = client.rollbackVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
+ assertEquals("Testing RollbackVfModule response", true, response.getVfModuleRolledback());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void rollbackVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
+ RollbackVfModuleRequest request = new RollbackVfModuleRequest();
+ VfModuleRollback rollback = new VfModuleRollback();
+ rollback.setCloudSiteId(TESTING_ID);
+ request.setVfModuleRollback(rollback);
+
+ VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
+ mockResponse.setMessage("Error in rollback Vf module");
+ wireMockServer.stubFor(delete(
+ urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.rollbackVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
+ }
+
+ @Test
+ public void deleteVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
+ DeleteVfModuleRequest request = new DeleteVfModuleRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ DeleteVfModuleResponse mockResponse = new DeleteVfModuleResponse();
+ mockResponse.setVfModuleDeleted(true);
+ wireMockServer
+ .stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ DeleteVfModuleResponse response = client.deleteVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
+ assertEquals("Testing DeleteVfModule response", true, response.getVfModuleDeleted());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void deleteVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
+ DeleteVfModuleRequest request = new DeleteVfModuleRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
+ mockResponse.setMessage("Error in delete Vf module");
+ wireMockServer
+ .stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.deleteVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
+ }
+
+ @Test
+ public void updateVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
+ UpdateVfModuleRequest request = new UpdateVfModuleRequest();
+ request.setCloudSiteId(TESTING_ID);
+ request.setVfModuleId("test1");
+
+ UpdateVfModuleResponse mockResponse = new UpdateVfModuleResponse();
+ mockResponse.setVfModuleId("test1");
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+
+ UpdateVfModuleResponse response = client.updateVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
+ assertEquals("Testing UpdateVfModule response", "test1", response.getVfModuleId());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void updateVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
+ UpdateVfModuleRequest request = new UpdateVfModuleRequest();
+ request.setCloudSiteId(TESTING_ID);
+ request.setVfModuleId("test1");
+
+ VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
+ mockResponse.setMessage("Error in update Vf module");
+ wireMockServer.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+
+ client.updateVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
+ }
+
+ @Test
+ public void queryVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
+ QueryVfModuleResponse mockResponse = new QueryVfModuleResponse();
+ mockResponse.setVnfId(AAI_VNF_ID);
+ mockResponse.setVfModuleId(AAI_VF_MODULE_ID);
+ wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ .withQueryParam("cloudSiteId", equalTo(TESTING_ID)).withQueryParam("tenantId", equalTo(TESTING_ID))
+ .withQueryParam("vfModuleName", equalTo("someName")).withQueryParam("skipAAI", equalTo("true"))
+ .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
+ .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
+ QueryVfModuleResponse response = client.queryVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, TESTING_ID, TESTING_ID,
+ "someName", true, "testRequestId", "serviceInstanceId");
+ assertEquals("Testing QueryVfModule response", AAI_VF_MODULE_ID, response.getVfModuleId());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void queryVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
+ VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
+ mockResponse.setMessage("Error in update Vf module");
+ wireMockServer.stubFor(get(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
+ .withQueryParam("cloudSiteId", equalTo(TESTING_ID)).withQueryParam("tenantId", equalTo(TESTING_ID))
+ .withQueryParam("vfModuleName", equalTo("someName")).withQueryParam("skipAAI", equalTo("true"))
+ .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
+ .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
+ client.queryVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, TESTING_ID, TESTING_ID, "someName", true, "testRequestId",
+ "serviceInstanceId");
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java
index 4a006f8b66..282d7a04f9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java
@@ -25,10 +25,8 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
-
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.core.UriBuilder;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
@@ -44,169 +42,170 @@ import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse;
import org.onap.so.client.adapter.rest.AdapterRestClient;
import org.onap.so.BaseIntegrationTest;
-public class VnfVolumeAdapterClientIT extends BaseIntegrationTest{
-
- private static final String TESTING_ID = "___TESTING___";
- private static final String AAI_VOLUME_GROUP_ID = "test";
- private static final String CLOUD_SITE_ID = "test";
- private static final String TENANT_ID = "test";
- private static final String VOLUME_GROUP_STACK_ID = "test";
- private static final boolean SKIP_AAI = true;
- private static final String REQUEST_ID = "test";
- private static final String SERVICE_INSTANCE_ID = "test";
-
- @Test
- public void createVolumeGroupTest() throws VnfAdapterClientException {
- CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
- request.setCloudSiteId(TESTING_ID);
-
- CreateVolumeGroupResponse mockResponse = new CreateVolumeGroupResponse();
- mockResponse.setVolumeGroupCreated(true);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
-
- doReturn(mockClient).when(client).getAdapterRestClient("");
- when(mockClient.post(request, CreateVolumeGroupResponse.class)).thenReturn(mockResponse);
-
- CreateVolumeGroupResponse response = client.createVNFVolumes(request);
- assertEquals("Testing CreateVolumeGroup response", mockResponse.getVolumeGroupCreated(),
- response.getVolumeGroupCreated());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void createVolumeGroupTestThrowException() throws VnfAdapterClientException {
- CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
- request.setCloudSiteId(TESTING_ID);
-
- CreateVolumeGroupResponse mockResponse = new CreateVolumeGroupResponse();
- mockResponse.setVolumeGroupCreated(true);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
-
- doReturn(mockClient).when(client).getAdapterRestClient("");
- when(mockClient.post(request, CreateVolumeGroupResponse.class)).thenThrow(new InternalServerErrorException("Error in create volume group"));
-
- client.createVNFVolumes(request);
- }
-
- @Test
- public void deleteVolumeGroupTest() throws VnfAdapterClientException {
- DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest();
- request.setCloudSiteId(TESTING_ID);
-
- DeleteVolumeGroupResponse mockResponse = new DeleteVolumeGroupResponse();
- mockResponse.setVolumeGroupDeleted(true);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
- doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
- when(mockClient.delete(request, DeleteVolumeGroupResponse.class)).thenReturn(mockResponse);
- MockitoAnnotations.initMocks(this);
-
- DeleteVolumeGroupResponse response = client.deleteVNFVolumes(AAI_VOLUME_GROUP_ID, request);
- assertEquals("Testing DeleteVolumeGroup response", mockResponse.getVolumeGroupDeleted(),
- response.getVolumeGroupDeleted());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void deleteVolumeGroupTestThrowException() throws VnfAdapterClientException {
- DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest();
- request.setCloudSiteId(TESTING_ID);
-
- DeleteVolumeGroupResponse mockResponse = new DeleteVolumeGroupResponse();
- mockResponse.setVolumeGroupDeleted(true);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
- doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
- when(mockClient.delete(request, DeleteVolumeGroupResponse.class))
- .thenThrow(new InternalServerErrorException("Error in delete volume group"));
- MockitoAnnotations.initMocks(this);
-
- client.deleteVNFVolumes(AAI_VOLUME_GROUP_ID, request);
- }
-
- @Test
- public void rollbackVolumeGroupTest() throws VnfAdapterClientException {
- RollbackVolumeGroupRequest request = new RollbackVolumeGroupRequest();
-
- RollbackVolumeGroupResponse mockResponse = new RollbackVolumeGroupResponse();
- mockResponse.setVolumeGroupRolledBack(true);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
- doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID + "/rollback");
- when(mockClient.delete(request, RollbackVolumeGroupResponse.class)).thenReturn(mockResponse);
- MockitoAnnotations.initMocks(this);
-
- RollbackVolumeGroupResponse response = client.rollbackVNFVolumes(AAI_VOLUME_GROUP_ID, request);
- assertEquals("Testing RollbackVolumeGroup response", mockResponse.getVolumeGroupRolledBack(),
- response.getVolumeGroupRolledBack());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void rollbackVolumeGroupTestThrowException() throws VnfAdapterClientException {
- RollbackVolumeGroupRequest request = new RollbackVolumeGroupRequest();
-
- RollbackVolumeGroupResponse mockResponse = new RollbackVolumeGroupResponse();
- mockResponse.setVolumeGroupRolledBack(true);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
- doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID + "/rollback");
- when(mockClient.delete(request, RollbackVolumeGroupResponse.class))
- .thenThrow(new InternalServerErrorException("Error in rollback volume group"));
- MockitoAnnotations.initMocks(this);
-
- client.rollbackVNFVolumes(AAI_VOLUME_GROUP_ID, request);
- }
-
- @Test
- public void updateVolumeGroupTest() throws VnfAdapterClientException {
- UpdateVolumeGroupRequest request = new UpdateVolumeGroupRequest();
-
- UpdateVolumeGroupResponse mockResponse = new UpdateVolumeGroupResponse();
- mockResponse.setVolumeGroupId(AAI_VOLUME_GROUP_ID);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
- doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
- when(mockClient.put(request, UpdateVolumeGroupResponse.class)).thenReturn(mockResponse);
- MockitoAnnotations.initMocks(this);
-
- UpdateVolumeGroupResponse response = client.updateVNFVolumes(AAI_VOLUME_GROUP_ID, request);
- assertEquals("Testing DeleteVfModule response", mockResponse.getVolumeGroupId(), response.getVolumeGroupId());
- }
-
- @Test(expected = VnfAdapterClientException.class)
- public void updateVolumeGroupTestThrowException() throws VnfAdapterClientException {
- UpdateVolumeGroupRequest request = new UpdateVolumeGroupRequest();
-
- UpdateVolumeGroupResponse mockResponse = new UpdateVolumeGroupResponse();
- mockResponse.setVolumeGroupId(AAI_VOLUME_GROUP_ID);
-
- VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
- AdapterRestClient mockClient = mock(AdapterRestClient.class);
- doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
- when(mockClient.put(request, UpdateVolumeGroupResponse.class))
- .thenThrow(new InternalServerErrorException("Error in update volume group"));
- MockitoAnnotations.initMocks(this);
-
- client.updateVNFVolumes(AAI_VOLUME_GROUP_ID, request);
- }
-
- public void buildQueryPathTest() {
- String expectedOutput = "/" + AAI_VOLUME_GROUP_ID + "?cloudSiteId=" + CLOUD_SITE_ID + "&tenantId=" + TENANT_ID
- + "&volumeGroupStackId=" + VOLUME_GROUP_STACK_ID + "&skipAAI=" + SKIP_AAI + "&msoRequest.requestId="
- + REQUEST_ID + "&msoRequest.serviceInstanceId=" + SERVICE_INSTANCE_ID;
- VnfVolumeAdapterClientImpl client = new VnfVolumeAdapterClientImpl();
- assertEquals("Test build query path", expectedOutput, client.buildQueryPath(AAI_VOLUME_GROUP_ID, CLOUD_SITE_ID,
- TENANT_ID, VOLUME_GROUP_STACK_ID, SKIP_AAI, REQUEST_ID, SERVICE_INSTANCE_ID));
- }
-
- protected UriBuilder getUri(String path) {
- return UriBuilder.fromPath(path);
- }
+public class VnfVolumeAdapterClientIT extends BaseIntegrationTest {
+
+ private static final String TESTING_ID = "___TESTING___";
+ private static final String AAI_VOLUME_GROUP_ID = "test";
+ private static final String CLOUD_SITE_ID = "test";
+ private static final String TENANT_ID = "test";
+ private static final String VOLUME_GROUP_STACK_ID = "test";
+ private static final boolean SKIP_AAI = true;
+ private static final String REQUEST_ID = "test";
+ private static final String SERVICE_INSTANCE_ID = "test";
+
+ @Test
+ public void createVolumeGroupTest() throws VnfAdapterClientException {
+ CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ CreateVolumeGroupResponse mockResponse = new CreateVolumeGroupResponse();
+ mockResponse.setVolumeGroupCreated(true);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+
+ doReturn(mockClient).when(client).getAdapterRestClient("");
+ when(mockClient.post(request, CreateVolumeGroupResponse.class)).thenReturn(mockResponse);
+
+ CreateVolumeGroupResponse response = client.createVNFVolumes(request);
+ assertEquals("Testing CreateVolumeGroup response", mockResponse.getVolumeGroupCreated(),
+ response.getVolumeGroupCreated());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void createVolumeGroupTestThrowException() throws VnfAdapterClientException {
+ CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ CreateVolumeGroupResponse mockResponse = new CreateVolumeGroupResponse();
+ mockResponse.setVolumeGroupCreated(true);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+
+ doReturn(mockClient).when(client).getAdapterRestClient("");
+ when(mockClient.post(request, CreateVolumeGroupResponse.class))
+ .thenThrow(new InternalServerErrorException("Error in create volume group"));
+
+ client.createVNFVolumes(request);
+ }
+
+ @Test
+ public void deleteVolumeGroupTest() throws VnfAdapterClientException {
+ DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ DeleteVolumeGroupResponse mockResponse = new DeleteVolumeGroupResponse();
+ mockResponse.setVolumeGroupDeleted(true);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+ doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
+ when(mockClient.delete(request, DeleteVolumeGroupResponse.class)).thenReturn(mockResponse);
+ MockitoAnnotations.initMocks(this);
+
+ DeleteVolumeGroupResponse response = client.deleteVNFVolumes(AAI_VOLUME_GROUP_ID, request);
+ assertEquals("Testing DeleteVolumeGroup response", mockResponse.getVolumeGroupDeleted(),
+ response.getVolumeGroupDeleted());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void deleteVolumeGroupTestThrowException() throws VnfAdapterClientException {
+ DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest();
+ request.setCloudSiteId(TESTING_ID);
+
+ DeleteVolumeGroupResponse mockResponse = new DeleteVolumeGroupResponse();
+ mockResponse.setVolumeGroupDeleted(true);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+ doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
+ when(mockClient.delete(request, DeleteVolumeGroupResponse.class))
+ .thenThrow(new InternalServerErrorException("Error in delete volume group"));
+ MockitoAnnotations.initMocks(this);
+
+ client.deleteVNFVolumes(AAI_VOLUME_GROUP_ID, request);
+ }
+
+ @Test
+ public void rollbackVolumeGroupTest() throws VnfAdapterClientException {
+ RollbackVolumeGroupRequest request = new RollbackVolumeGroupRequest();
+
+ RollbackVolumeGroupResponse mockResponse = new RollbackVolumeGroupResponse();
+ mockResponse.setVolumeGroupRolledBack(true);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+ doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID + "/rollback");
+ when(mockClient.delete(request, RollbackVolumeGroupResponse.class)).thenReturn(mockResponse);
+ MockitoAnnotations.initMocks(this);
+
+ RollbackVolumeGroupResponse response = client.rollbackVNFVolumes(AAI_VOLUME_GROUP_ID, request);
+ assertEquals("Testing RollbackVolumeGroup response", mockResponse.getVolumeGroupRolledBack(),
+ response.getVolumeGroupRolledBack());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void rollbackVolumeGroupTestThrowException() throws VnfAdapterClientException {
+ RollbackVolumeGroupRequest request = new RollbackVolumeGroupRequest();
+
+ RollbackVolumeGroupResponse mockResponse = new RollbackVolumeGroupResponse();
+ mockResponse.setVolumeGroupRolledBack(true);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+ doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID + "/rollback");
+ when(mockClient.delete(request, RollbackVolumeGroupResponse.class))
+ .thenThrow(new InternalServerErrorException("Error in rollback volume group"));
+ MockitoAnnotations.initMocks(this);
+
+ client.rollbackVNFVolumes(AAI_VOLUME_GROUP_ID, request);
+ }
+
+ @Test
+ public void updateVolumeGroupTest() throws VnfAdapterClientException {
+ UpdateVolumeGroupRequest request = new UpdateVolumeGroupRequest();
+
+ UpdateVolumeGroupResponse mockResponse = new UpdateVolumeGroupResponse();
+ mockResponse.setVolumeGroupId(AAI_VOLUME_GROUP_ID);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+ doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
+ when(mockClient.put(request, UpdateVolumeGroupResponse.class)).thenReturn(mockResponse);
+ MockitoAnnotations.initMocks(this);
+
+ UpdateVolumeGroupResponse response = client.updateVNFVolumes(AAI_VOLUME_GROUP_ID, request);
+ assertEquals("Testing DeleteVfModule response", mockResponse.getVolumeGroupId(), response.getVolumeGroupId());
+ }
+
+ @Test(expected = VnfAdapterClientException.class)
+ public void updateVolumeGroupTestThrowException() throws VnfAdapterClientException {
+ UpdateVolumeGroupRequest request = new UpdateVolumeGroupRequest();
+
+ UpdateVolumeGroupResponse mockResponse = new UpdateVolumeGroupResponse();
+ mockResponse.setVolumeGroupId(AAI_VOLUME_GROUP_ID);
+
+ VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
+ AdapterRestClient mockClient = mock(AdapterRestClient.class);
+ doReturn(mockClient).when(client).getAdapterRestClient("/" + AAI_VOLUME_GROUP_ID);
+ when(mockClient.put(request, UpdateVolumeGroupResponse.class))
+ .thenThrow(new InternalServerErrorException("Error in update volume group"));
+ MockitoAnnotations.initMocks(this);
+
+ client.updateVNFVolumes(AAI_VOLUME_GROUP_ID, request);
+ }
+
+ public void buildQueryPathTest() {
+ String expectedOutput = "/" + AAI_VOLUME_GROUP_ID + "?cloudSiteId=" + CLOUD_SITE_ID + "&tenantId=" + TENANT_ID
+ + "&volumeGroupStackId=" + VOLUME_GROUP_STACK_ID + "&skipAAI=" + SKIP_AAI + "&msoRequest.requestId="
+ + REQUEST_ID + "&msoRequest.serviceInstanceId=" + SERVICE_INSTANCE_ID;
+ VnfVolumeAdapterClientImpl client = new VnfVolumeAdapterClientImpl();
+ assertEquals("Test build query path", expectedOutput, client.buildQueryPath(AAI_VOLUME_GROUP_ID, CLOUD_SITE_ID,
+ TENANT_ID, VOLUME_GROUP_STACK_ID, SKIP_AAI, REQUEST_ID, SERVICE_INSTANCE_ID));
+ }
+
+ protected UriBuilder getUri(String path) {
+ return UriBuilder.fromPath(path);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestPropertiesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestPropertiesTest.java
index df48596893..63c73322a5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestPropertiesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterRestPropertiesTest.java
@@ -21,26 +21,24 @@
package org.onap.so.client.adapter.vnf;
import static org.junit.Assert.assertEquals;
-
import java.net.MalformedURLException;
-
import org.junit.Test;
-public class VnfVolumeAdapterRestPropertiesTest{
- private VnfVolumeAdapterRestProperties props = new VnfVolumeAdapterRestProperties();
-
- @Test
- public void testGetAuth(){
- assertEquals("mso.adapters.po.auth", VnfVolumeAdapterRestProperties.authProp);
- }
-
- @Test
- public void testGetKey(){
- assertEquals("mso.msoKey", VnfVolumeAdapterRestProperties.keyProp);
- }
-
- @Test
- public void testGetUrl() throws MalformedURLException{
- assertEquals("mso.adapters.volume-groups.rest.endpoint", VnfVolumeAdapterRestProperties.endpointProp);
- }
+public class VnfVolumeAdapterRestPropertiesTest {
+ private VnfVolumeAdapterRestProperties props = new VnfVolumeAdapterRestProperties();
+
+ @Test
+ public void testGetAuth() {
+ assertEquals("mso.adapters.po.auth", VnfVolumeAdapterRestProperties.authProp);
+ }
+
+ @Test
+ public void testGetKey() {
+ assertEquals("mso.msoKey", VnfVolumeAdapterRestProperties.keyProp);
+ }
+
+ @Test
+ public void testGetUrl() throws MalformedURLException {
+ assertEquals("mso.adapters.volume-groups.rest.endpoint", VnfVolumeAdapterRestProperties.endpointProp);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java
index 5169663add..4450e4a9f4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java
@@ -26,14 +26,12 @@ import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -55,282 +53,294 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.entity.MsoRequest;
public class VnfAdapterObjectMapperTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/";
-
- @Spy
- private VnfAdapterObjectMapper vnfAdapterObjectMapper = new VnfAdapterObjectMapper();
-
- @Before
- public void before() {
- MockitoAnnotations.initMocks(this);
-
- }
-
- @After
- public void after() {
- reset(vnfAdapterObjectMapper);
- }
-
- @Test
- public void test_createVolumeGroupRequestMapper() throws Exception {
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("msoRequestId");
-
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelVersion("modelVersion");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("vnfId");
- genericVnf.setVnfName("vnfName");
- genericVnf.setVnfType("vnfType");
- serviceInstance.getVnfs().add(genericVnf);
-
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelName("modelName");
- modelInfoVfModule.setModelCustomizationUUID("modelCustomizationUUID");
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setVolumeGroupName("volumeGroupName");
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- volumeGroup.setModelInfoVfModule(modelInfoVfModule);
-
- serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
-
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVolumeGroupRequest expectedCreateVolumeGroupRequest = new CreateVolumeGroupRequest();
-
- expectedCreateVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
- expectedCreateVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
- expectedCreateVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
- expectedCreateVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
- expectedCreateVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
- expectedCreateVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
- expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
- expectedCreateVolumeGroupRequest.setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
-
- Map<String, Object> volumeGroupParams = new HashMap<>();
- volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
- volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
- volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
- volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
- volumeGroupParams.put("paramOne", "paramOneValue");
- volumeGroupParams.put("paramTwo", "paramTwoValue");
- volumeGroupParams.put("paramThree", "paramThreeValue");
- expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams);
-
- expectedCreateVolumeGroupRequest.setSkipAAI(true);
- expectedCreateVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
- expectedCreateVolumeGroupRequest.setFailIfExists(true);
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedCreateVolumeGroupRequest.setMsoRequest(msoRequest);
-
- expectedCreateVolumeGroupRequest.setMessageId("messageId");
- expectedCreateVolumeGroupRequest.setNotificationUrl("endpoint/VNFAResponse/messageId");
-
- doReturn("endpoint/").when(vnfAdapterObjectMapper).getProperty(isA(String.class));
- doReturn("messageId").when(vnfAdapterObjectMapper).getRandomUuid();
-
- CreateVolumeGroupRequest actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
-
- assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
- }
-
- @Test
- public void test_createVolumeGroupRequestMapper_for_alaCarte_flow() throws Exception {
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("msoRequestId");
-
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelVersion("modelVersion");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("vnfId");
- genericVnf.setVnfName("vnfName");
- genericVnf.setVnfType("vnfType");
- serviceInstance.getVnfs().add(genericVnf);
-
-
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelName("modelName");
- modelInfoVfModule.setModelCustomizationUUID("modelCustomizationUUID");
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setVolumeGroupName("volumeGroupName");
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- volumeGroup.setModelInfoVfModule(modelInfoVfModule);
- serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- CreateVolumeGroupRequest expectedCreateVolumeGroupRequest = new CreateVolumeGroupRequest();
-
- expectedCreateVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
- expectedCreateVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
- expectedCreateVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
- expectedCreateVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
- expectedCreateVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
- expectedCreateVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
- expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
- expectedCreateVolumeGroupRequest.setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
-
- Map<String, Object> volumeGroupParams = new HashMap<>();
- volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
- volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
- volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
- volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
-
- expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams);
-
- expectedCreateVolumeGroupRequest.setSkipAAI(true);
- expectedCreateVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
- expectedCreateVolumeGroupRequest.setFailIfExists(true);
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedCreateVolumeGroupRequest.setMsoRequest(msoRequest);
-
- expectedCreateVolumeGroupRequest.setMessageId("messageId");
- expectedCreateVolumeGroupRequest.setNotificationUrl("endpoint/VNFAResponse/messageId");
-
- doReturn("endpoint/").when(vnfAdapterObjectMapper).getProperty(isA(String.class));
- doReturn("messageId").when(vnfAdapterObjectMapper).getRandomUuid();
-
- CreateVolumeGroupRequest actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
-
- assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
- }
-
- @Test
- public void test_deleteVolumeGroupHeatIdRequestMapper() throws Exception{
- this.test_deleteVolumeGroupRequestMapper("heatStackId");
- }
-
- @Test
- public void test_deleteVolumeGroupNoHeatIdRequestMapper() throws Exception{
- this.test_deleteVolumeGroupRequestMapper(null);
- }
-
- private void test_deleteVolumeGroupRequestMapper(String heatStackId) throws Exception {
- DeleteVolumeGroupRequest expectedDeleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
- expectedDeleteVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
-
- cloudRegion.setTenantId("tenantId");
- expectedDeleteVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- expectedDeleteVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
-
- if (heatStackId != null){
- volumeGroup.setHeatStackId("heatStackId");
- expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
- } else {
- volumeGroup.setVolumeGroupName("volumeGroupName");
- expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getVolumeGroupName());
- }
-
- expectedDeleteVolumeGroupRequest.setSkipAAI(true);
-
- MsoRequest msoRequest = new MsoRequest();
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("msoRequestId");
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedDeleteVolumeGroupRequest.setMsoRequest(msoRequest);
-
- String messageId = "messageId";
- String endpoint = "endpoint";
- doReturn(messageId).when(vnfAdapterObjectMapper).getRandomUuid();
- doReturn(endpoint).when(vnfAdapterObjectMapper).getProperty(isA(String.class));
- expectedDeleteVolumeGroupRequest.setMessageId(messageId);
- expectedDeleteVolumeGroupRequest.setNotificationUrl(endpoint + "/VNFAResponse/" + messageId);
-
- DeleteVolumeGroupRequest actualDeleteVolumeGroupRequest = vnfAdapterObjectMapper.deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance, volumeGroup);
-
- assertThat(actualDeleteVolumeGroupRequest, sameBeanAs(expectedDeleteVolumeGroupRequest));
- }
-
- @Test
- public void test_createVolumeGroupParams() throws Exception {
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("vnfId");
- genericVnf.setVnfName("vnfName");
-
- RequestContext requestContext = new RequestContext();
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setVolumeGroupName("volumeGroupName");
-
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- Map<String, String> expectedVolumeGroupParams = new HashMap<>();
- expectedVolumeGroupParams.put("vnf_id", genericVnf.getVnfId());
- expectedVolumeGroupParams.put("vnf_name", genericVnf.getVnfName());
- expectedVolumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
- expectedVolumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
- expectedVolumeGroupParams.put("paramOne", "paramOneValue");
- expectedVolumeGroupParams.put("paramTwo", "paramTwoValue");
- expectedVolumeGroupParams.put("paramThree", "paramThreeValue");
-
- Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,genericVnf, volumeGroup, sdncVfModuleQueryResponse);
-
- assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams);
- }
-
- @Test
- public void test_createVolumeGroupParams_without_sdncResponse() throws Exception {
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("vnfId");
- genericVnf.setVnfName("vnfName");
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setVolumeGroupName("volumeGroupName");
-
- Map<String, String> expectedVolumeGroupParams = new HashMap<>();
- expectedVolumeGroupParams.put("vnf_id", genericVnf.getVnfId());
- expectedVolumeGroupParams.put("vnf_name", genericVnf.getVnfName());
- expectedVolumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
- expectedVolumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
- RequestContext requestContext = new RequestContext();
- Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,genericVnf, volumeGroup, null);
-
- assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams);
- }
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/";
+
+ @Spy
+ private VnfAdapterObjectMapper vnfAdapterObjectMapper = new VnfAdapterObjectMapper();
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+
+ }
+
+ @After
+ public void after() {
+ reset(vnfAdapterObjectMapper);
+ }
+
+ @Test
+ public void test_createVolumeGroupRequestMapper() throws Exception {
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("msoRequestId");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelVersion("modelVersion");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("vnfId");
+ genericVnf.setVnfName("vnfName");
+ genericVnf.setVnfType("vnfType");
+ serviceInstance.getVnfs().add(genericVnf);
+
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelName("modelName");
+ modelInfoVfModule.setModelCustomizationUUID("modelCustomizationUUID");
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ volumeGroup.setModelInfoVfModule(modelInfoVfModule);
+
+ serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
+
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVolumeGroupRequest expectedCreateVolumeGroupRequest = new CreateVolumeGroupRequest();
+
+ expectedCreateVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+ expectedCreateVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
+ expectedCreateVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
+ expectedCreateVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
+ expectedCreateVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
+ expectedCreateVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
+ expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
+ expectedCreateVolumeGroupRequest
+ .setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
+
+ Map<String, Object> volumeGroupParams = new HashMap<>();
+ volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
+ volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
+ volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
+ volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
+ volumeGroupParams.put("paramOne", "paramOneValue");
+ volumeGroupParams.put("paramTwo", "paramTwoValue");
+ volumeGroupParams.put("paramThree", "paramThreeValue");
+ expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams);
+
+ expectedCreateVolumeGroupRequest.setSkipAAI(true);
+ expectedCreateVolumeGroupRequest
+ .setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
+ expectedCreateVolumeGroupRequest.setFailIfExists(true);
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedCreateVolumeGroupRequest.setMsoRequest(msoRequest);
+
+ expectedCreateVolumeGroupRequest.setMessageId("messageId");
+ expectedCreateVolumeGroupRequest.setNotificationUrl("endpoint/VNFAResponse/messageId");
+
+ doReturn("endpoint/").when(vnfAdapterObjectMapper).getProperty(isA(String.class));
+ doReturn("messageId").when(vnfAdapterObjectMapper).getRandomUuid();
+
+ CreateVolumeGroupRequest actualCreateVolumeGroupRequest =
+ vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
+
+ assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
+ }
+
+ @Test
+ public void test_createVolumeGroupRequestMapper_for_alaCarte_flow() throws Exception {
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("msoRequestId");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelVersion("modelVersion");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("vnfId");
+ genericVnf.setVnfName("vnfName");
+ genericVnf.setVnfType("vnfType");
+ serviceInstance.getVnfs().add(genericVnf);
+
+
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelName("modelName");
+ modelInfoVfModule.setModelCustomizationUUID("modelCustomizationUUID");
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ volumeGroup.setModelInfoVfModule(modelInfoVfModule);
+ serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ CreateVolumeGroupRequest expectedCreateVolumeGroupRequest = new CreateVolumeGroupRequest();
+
+ expectedCreateVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+ expectedCreateVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
+ expectedCreateVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
+ expectedCreateVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
+ expectedCreateVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
+ expectedCreateVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
+ expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
+ expectedCreateVolumeGroupRequest
+ .setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
+
+ Map<String, Object> volumeGroupParams = new HashMap<>();
+ volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
+ volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
+ volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
+ volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
+
+ expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams);
+
+ expectedCreateVolumeGroupRequest.setSkipAAI(true);
+ expectedCreateVolumeGroupRequest
+ .setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
+ expectedCreateVolumeGroupRequest.setFailIfExists(true);
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedCreateVolumeGroupRequest.setMsoRequest(msoRequest);
+
+ expectedCreateVolumeGroupRequest.setMessageId("messageId");
+ expectedCreateVolumeGroupRequest.setNotificationUrl("endpoint/VNFAResponse/messageId");
+
+ doReturn("endpoint/").when(vnfAdapterObjectMapper).getProperty(isA(String.class));
+ doReturn("messageId").when(vnfAdapterObjectMapper).getRandomUuid();
+
+ CreateVolumeGroupRequest actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
+
+ assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
+ }
+
+ @Test
+ public void test_deleteVolumeGroupHeatIdRequestMapper() throws Exception {
+ this.test_deleteVolumeGroupRequestMapper("heatStackId");
+ }
+
+ @Test
+ public void test_deleteVolumeGroupNoHeatIdRequestMapper() throws Exception {
+ this.test_deleteVolumeGroupRequestMapper(null);
+ }
+
+ private void test_deleteVolumeGroupRequestMapper(String heatStackId) throws Exception {
+ DeleteVolumeGroupRequest expectedDeleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
+ expectedDeleteVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+
+ cloudRegion.setTenantId("tenantId");
+ expectedDeleteVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ expectedDeleteVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
+
+ if (heatStackId != null) {
+ volumeGroup.setHeatStackId("heatStackId");
+ expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
+ } else {
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+ expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getVolumeGroupName());
+ }
+
+ expectedDeleteVolumeGroupRequest.setSkipAAI(true);
+
+ MsoRequest msoRequest = new MsoRequest();
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("msoRequestId");
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedDeleteVolumeGroupRequest.setMsoRequest(msoRequest);
+
+ String messageId = "messageId";
+ String endpoint = "endpoint";
+ doReturn(messageId).when(vnfAdapterObjectMapper).getRandomUuid();
+ doReturn(endpoint).when(vnfAdapterObjectMapper).getProperty(isA(String.class));
+ expectedDeleteVolumeGroupRequest.setMessageId(messageId);
+ expectedDeleteVolumeGroupRequest.setNotificationUrl(endpoint + "/VNFAResponse/" + messageId);
+
+ DeleteVolumeGroupRequest actualDeleteVolumeGroupRequest = vnfAdapterObjectMapper
+ .deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance, volumeGroup);
+
+ assertThat(actualDeleteVolumeGroupRequest, sameBeanAs(expectedDeleteVolumeGroupRequest));
+ }
+
+ @Test
+ public void test_createVolumeGroupParams() throws Exception {
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("vnfId");
+ genericVnf.setVnfName("vnfName");
+
+ RequestContext requestContext = new RequestContext();
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ Map<String, String> expectedVolumeGroupParams = new HashMap<>();
+ expectedVolumeGroupParams.put("vnf_id", genericVnf.getVnfId());
+ expectedVolumeGroupParams.put("vnf_name", genericVnf.getVnfName());
+ expectedVolumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
+ expectedVolumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
+ expectedVolumeGroupParams.put("paramOne", "paramOneValue");
+ expectedVolumeGroupParams.put("paramTwo", "paramTwoValue");
+ expectedVolumeGroupParams.put("paramThree", "paramThreeValue");
+
+ Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,
+ genericVnf, volumeGroup, sdncVfModuleQueryResponse);
+
+ assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams);
+ }
+
+ @Test
+ public void test_createVolumeGroupParams_without_sdncResponse() throws Exception {
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("vnfId");
+ genericVnf.setVnfName("vnfName");
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+
+ Map<String, String> expectedVolumeGroupParams = new HashMap<>();
+ expectedVolumeGroupParams.put("vnf_id", genericVnf.getVnfId());
+ expectedVolumeGroupParams.put("vnf_name", genericVnf.getVnfName());
+ expectedVolumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
+ expectedVolumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> actualVolumeGroupParams =
+ vnfAdapterObjectMapper.createVolumeGroupParams(requestContext, genericVnf, volumeGroup, null);
+
+ assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams);
+ }
@Test
public void test_createVolumeGroupParams_with_user_params() throws Exception {
@@ -351,7 +361,8 @@ public class VnfAdapterObjectMapperTest {
volumeGroup.setVolumeGroupId("volumeGroupId");
volumeGroup.setVolumeGroupName("volumeGroupName");
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
Map<String, String> expectedVolumeGroupParams = new HashMap<>();
expectedVolumeGroupParams.put("vnf_id", genericVnf.getVnfId());
@@ -363,25 +374,26 @@ public class VnfAdapterObjectMapperTest {
expectedVolumeGroupParams.put("paramThree", "paramThreeValue");
expectedVolumeGroupParams.put("userParamKey", "userParamValue");
- Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,genericVnf, volumeGroup, sdncVfModuleQueryResponse);
+ Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext,
+ genericVnf, volumeGroup, sdncVfModuleQueryResponse);
assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams);
}
- @Test
- public void test_createMsoRequest() {
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("msoRequestId");
-
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- MsoRequest expectedMsoRequest = new MsoRequest();
- expectedMsoRequest.setRequestId(requestContext.getMsoRequestId());
- expectedMsoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
-
- MsoRequest actualMsoRequest = vnfAdapterObjectMapper.createMsoRequest(requestContext, serviceInstance);
-
- assertThat(expectedMsoRequest, sameBeanAs(actualMsoRequest));
- }
+ @Test
+ public void test_createMsoRequest() {
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("msoRequestId");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ MsoRequest expectedMsoRequest = new MsoRequest();
+ expectedMsoRequest.setRequestId(requestContext.getMsoRequestId());
+ expectedMsoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+
+ MsoRequest actualMsoRequest = vnfAdapterObjectMapper.createMsoRequest(requestContext, serviceInstance);
+
+ assertThat(expectedMsoRequest, sameBeanAs(actualMsoRequest));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java
index 00e5c10f73..5a8e57135a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java
@@ -23,13 +23,11 @@ package org.onap.so.client.adapter.vnf.mapper;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVmNetworkData;
@@ -45,820 +43,831 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
-
import com.fasterxml.jackson.databind.ObjectMapper;
public class VnfAdapterVfModuleObjectMapperPayloadTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/";
-
- private VnfAdapterVfModuleObjectMapper vfModuleObjectMapper = new VnfAdapterVfModuleObjectMapper();
- private ObjectMapper omapper = new ObjectMapper();
- @Before
- public void setUp() {
- vfModuleObjectMapper.vnfAdapterObjectMapperUtils = new VnfAdapterObjectMapperUtils();
- vfModuleObjectMapper.init();
-
- }
- @Test
- public void createVfModuleRequestMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value2");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
- HashMap<String, String> cloudParams = new HashMap<String, String>();
- cloudParams.put("key3", "value3");
- vfModule.setCloudParams(cloudParams);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequest.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleWithFalseRollbackRequestMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value2");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
- HashMap<String, String> cloudParams = new HashMap<String, String>();
- cloudParams.put("key3", "value3");
- vfModule.setCloudParams(cloudParams);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestTrueBackout.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleRequestWithNoEnvironmentAndWorkloadContextMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext(null);
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value2");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleAddonRequestMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- //
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value2");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- VfModule baseVfModule = new VfModule();
- baseVfModule.setVfModuleId("baseVfModuleId");
- baseVfModule.setHeatStackId("baseVfModuleStackId");
- ModelInfoVfModule baseModelInfoVfModule = new ModelInfoVfModule();
- baseModelInfoVfModule.setIsBaseBoolean(true);
- baseVfModule.setModelInfoVfModule(baseModelInfoVfModule);
- vnf.getVfModules().add(baseVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleAddonRequest.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleWithVolumeGroupRequestMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- //
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value2");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setHeatStackId("volumeGroupStackId");
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleWithVolumeGroupRequest.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleWithSingleAvailabilityZoneRequestMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value2");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologyWithSingletonArray.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleRequestMapperWithCloudResourcesTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologyWithCloudResources.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopologyWithCloudResources.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestWithCloudResources.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleRequestMapperDhcpDisabledTest() throws Exception {
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologySubnetDhcpDisabled.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestDhcpDisabled.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleRequestMapperMultipleDhcpTest() throws Exception {
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologySubnetMultipleDhcp.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestMultipleDhcp.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void createVfModuleRequestMapperWithNullUserParamsTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("requestId");
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- Integer vfModuleIndex = 1;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- vfModule.setModuleIndex(vfModuleIndex);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
- String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
-
- CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(
- requestContext, cloudRegion, orchestrationContext, serviceInstance,
- vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestNoUserParams.json")));
-
- CreateVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- CreateVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
- }
-
- @Test
- public void DeleteVfModuleRequestMapperTest() throws Exception {
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- modelInfoServiceInstance.setEnvironmentContext("environmentContext");
- modelInfoServiceInstance.setWorkloadContext("workloadContext");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setMsoRequestId("requestId");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.setVnfName("vnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- vfModule.setVfModuleName("vfModuleName");
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setTenantId("tenantId");
-
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- DeleteVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.deleteVfModuleRequestMapper(
- requestContext, cloudRegion, serviceInstance,
- vnf, vfModule);
-
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterDeleteVfModuleRequest.json")));
-
- DeleteVfModuleRequest reqMapper1 = omapper.readValue(
- jsonToCompare,
- DeleteVfModuleRequest.class);
-
- assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl").ignoring("vfModuleStackId"));
- }
-
- @Test
- public void networkCloudParamsTest() throws IOException {
-
- String json = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "grApiVmNetworkSubSectionWith5GParams.json")));
- GenericResourceApiVmNetworkData network = omapper.readValue(json, GenericResourceApiVmNetworkData.class);
- Map<String, Object> paramsMap = new HashMap<>();
- vfModuleObjectMapper.buildVlanInformation(paramsMap, network, "testKey", "testType");
-
- assertEquals("1,3", paramsMap.get("testKey_testType_private_vlans"));
- assertEquals("2,3", paramsMap.get("testKey_testType_public_vlans"));
- assertEquals("1,2,3", paramsMap.get("testKey_testType_guest_vlans"));
- assertEquals("my-segemntation-id", paramsMap.get("testKey_testType_vlan_filter"));
- }
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/";
+
+ private VnfAdapterVfModuleObjectMapper vfModuleObjectMapper = new VnfAdapterVfModuleObjectMapper();
+ private ObjectMapper omapper = new ObjectMapper();
+
+ @Before
+ public void setUp() {
+ vfModuleObjectMapper.vnfAdapterObjectMapperUtils = new VnfAdapterObjectMapperUtils();
+ vfModuleObjectMapper.init();
+
+ }
+
+ @Test
+ public void createVfModuleRequestMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value2");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+ HashMap<String, String> cloudParams = new HashMap<String, String>();
+ cloudParams.put("key3", "value3");
+ vfModule.setCloudParams(cloudParams);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequest.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleWithFalseRollbackRequestMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value2");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+ HashMap<String, String> cloudParams = new HashMap<String, String>();
+ cloudParams.put("key3", "value3");
+ vfModule.setCloudParams(cloudParams);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ String sdncVnfQueryResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestTrueBackout.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleRequestWithNoEnvironmentAndWorkloadContextMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext(null);
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value2");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(Files.readAllBytes(Paths
+ .get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleAddonRequestMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ //
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value2");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ VfModule baseVfModule = new VfModule();
+ baseVfModule.setVfModuleId("baseVfModuleId");
+ baseVfModule.setHeatStackId("baseVfModuleStackId");
+ ModelInfoVfModule baseModelInfoVfModule = new ModelInfoVfModule();
+ baseModelInfoVfModule.setIsBaseBoolean(true);
+ baseVfModule.setModelInfoVfModule(baseModelInfoVfModule);
+ vnf.getVfModules().add(baseVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleAddonRequest.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleWithVolumeGroupRequestMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ //
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value2");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setHeatStackId("volumeGroupStackId");
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleWithVolumeGroupRequest.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleWithSingleAvailabilityZoneRequestMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value2");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologyWithSingletonArray.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleRequestMapperWithCloudResourcesTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologyWithCloudResources.json")));
+ String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths
+ .get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopologyWithCloudResources.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestWithCloudResources.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleRequestMapperDhcpDisabledTest() throws Exception {
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologySubnetDhcpDisabled.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestDhcpDisabled.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleRequestMapperMultipleDhcpTest() throws Exception {
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologySubnetMultipleDhcp.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestMultipleDhcp.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void createVfModuleRequestMapperWithNullUserParamsTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ Integer vfModuleIndex = 1;
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ vfModule.setModuleIndex(vfModuleIndex);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ String sdncVnfQueryResponse = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
+ String sdncVfModuleQueryResponse = new String(Files
+ .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
+
+ CreateVfModuleRequest vfModuleVNFAdapterRequest =
+ vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+
+ String jsonToCompare = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestNoUserParams.json")));
+
+ CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
+ @Test
+ public void DeleteVfModuleRequestMapperTest() throws Exception {
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ modelInfoServiceInstance.setEnvironmentContext("environmentContext");
+ modelInfoServiceInstance.setWorkloadContext("workloadContext");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setMsoRequestId("requestId");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.setVnfName("vnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ vfModule.setVfModuleName("vfModuleName");
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setTenantId("tenantId");
+
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ DeleteVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper
+ .deleteVfModuleRequestMapper(requestContext, cloudRegion, serviceInstance, vnf, vfModule);
+
+
+ String jsonToCompare =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterDeleteVfModuleRequest.json")));
+
+ DeleteVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, DeleteVfModuleRequest.class);
+
+ assertThat(vfModuleVNFAdapterRequest,
+ sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl").ignoring("vfModuleStackId"));
+ }
+
+ @Test
+ public void networkCloudParamsTest() throws IOException {
+
+ String json = new String(
+ Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "grApiVmNetworkSubSectionWith5GParams.json")));
+ GenericResourceApiVmNetworkData network = omapper.readValue(json, GenericResourceApiVmNetworkData.class);
+ Map<String, Object> paramsMap = new HashMap<>();
+ vfModuleObjectMapper.buildVlanInformation(paramsMap, network, "testKey", "testType");
+
+ assertEquals("1,3", paramsMap.get("testKey_testType_private_vlans"));
+ assertEquals("2,3", paramsMap.get("testKey_testType_public_vlans"));
+ assertEquals("1,2,3", paramsMap.get("testKey_testType_guest_vlans"));
+ assertEquals("my-segemntation-id", paramsMap.get("testKey_testType_vlan_filter"));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java
index 81d30e33c5..d6ab3db094 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java
@@ -26,11 +26,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
-
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
@@ -45,80 +43,81 @@ import org.onap.so.entity.MsoRequest;
public class VnfAdapterVfModuleObjectMapperTest {
- @Spy
- private VnfAdapterVfModuleObjectMapper mapper = new VnfAdapterVfModuleObjectMapper();
-
- @Before
- public void before() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void createVnfcSubInterfaceKeyTest() {
-
- assertEquals("type_0_subint_role_port_0", mapper.createVnfcSubInterfaceKey("type", 0, "role", 0));
- }
-
- @Test
- public void createGlobalVnfcSubInterfaceKeyTest() {
-
- assertEquals("type_subint_role_port_0", mapper.createGlobalVnfcSubInterfaceKey("type", "role", 0));
- }
-
- @Test
- public void addPairToMapTest() {
- Map<String, Object> map = new HashMap<>();
-
- mapper.addPairToMap(map, "test", "_key", Arrays.asList("a", "b"));
-
- assertEquals("a,b", map.get("test_key"));
-
- mapper.addPairToMap(map, "test", "_key2", Arrays.asList());
-
- assertThat(map.containsKey("test_key2"), equalTo(false));
-
- mapper.addPairToMap(map, "test", "_key3", "myVal");
-
- assertEquals("myVal", map.get("test_key3"));
-
- }
-
- @Test
- public void test_deleteVfModuleNoHeatIdRequestMapper() throws Exception {
- DeleteVfModuleRequest expectedDeleteVfModuleRequest = new DeleteVfModuleRequest();
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
- expectedDeleteVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
-
- cloudRegion.setTenantId("tenantId");
- expectedDeleteVfModuleRequest.setTenantId(cloudRegion.getTenantId());
-
- GenericVnf genericVnf = new GenericVnf();
- VfModule vfModule = new VfModule();
- vfModule.setHeatStackId("heatStackId");
- expectedDeleteVfModuleRequest.setVfModuleStackId("heatStackId");
- expectedDeleteVfModuleRequest.setSkipAAI(true);
-
- MsoRequest msoRequest = new MsoRequest();
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("msoRequestId");
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedDeleteVfModuleRequest.setMsoRequest(msoRequest);
-
- String messageId = "messageId";
- String endpoint = "endpoint";
- doNothing().when(mapper).setIdAndUrl(any());
- expectedDeleteVfModuleRequest.setMessageId(messageId);
- expectedDeleteVfModuleRequest.setNotificationUrl(endpoint + "/VNFAResponse/" + messageId);
-
- DeleteVfModuleRequest actualDeleteVfModuleRequest = mapper.deleteVfModuleRequestMapper(requestContext, cloudRegion,
- serviceInstance, genericVnf, vfModule);
-
- assertThat(actualDeleteVfModuleRequest, sameBeanAs(expectedDeleteVfModuleRequest).ignoring("messageId").ignoring("notificationUrl"));
- }
-
+ @Spy
+ private VnfAdapterVfModuleObjectMapper mapper = new VnfAdapterVfModuleObjectMapper();
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void createVnfcSubInterfaceKeyTest() {
+
+ assertEquals("type_0_subint_role_port_0", mapper.createVnfcSubInterfaceKey("type", 0, "role", 0));
+ }
+
+ @Test
+ public void createGlobalVnfcSubInterfaceKeyTest() {
+
+ assertEquals("type_subint_role_port_0", mapper.createGlobalVnfcSubInterfaceKey("type", "role", 0));
+ }
+
+ @Test
+ public void addPairToMapTest() {
+ Map<String, Object> map = new HashMap<>();
+
+ mapper.addPairToMap(map, "test", "_key", Arrays.asList("a", "b"));
+
+ assertEquals("a,b", map.get("test_key"));
+
+ mapper.addPairToMap(map, "test", "_key2", Arrays.asList());
+
+ assertThat(map.containsKey("test_key2"), equalTo(false));
+
+ mapper.addPairToMap(map, "test", "_key3", "myVal");
+
+ assertEquals("myVal", map.get("test_key3"));
+
+ }
+
+ @Test
+ public void test_deleteVfModuleNoHeatIdRequestMapper() throws Exception {
+ DeleteVfModuleRequest expectedDeleteVfModuleRequest = new DeleteVfModuleRequest();
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
+ expectedDeleteVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
+
+ cloudRegion.setTenantId("tenantId");
+ expectedDeleteVfModuleRequest.setTenantId(cloudRegion.getTenantId());
+
+ GenericVnf genericVnf = new GenericVnf();
+ VfModule vfModule = new VfModule();
+ vfModule.setHeatStackId("heatStackId");
+ expectedDeleteVfModuleRequest.setVfModuleStackId("heatStackId");
+ expectedDeleteVfModuleRequest.setSkipAAI(true);
+
+ MsoRequest msoRequest = new MsoRequest();
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("msoRequestId");
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedDeleteVfModuleRequest.setMsoRequest(msoRequest);
+
+ String messageId = "messageId";
+ String endpoint = "endpoint";
+ doNothing().when(mapper).setIdAndUrl(any());
+ expectedDeleteVfModuleRequest.setMessageId(messageId);
+ expectedDeleteVfModuleRequest.setNotificationUrl(endpoint + "/VNFAResponse/" + messageId);
+
+ DeleteVfModuleRequest actualDeleteVfModuleRequest =
+ mapper.deleteVfModuleRequestMapper(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
+
+ assertThat(actualDeleteVfModuleRequest,
+ sameBeanAs(expectedDeleteVfModuleRequest).ignoring("messageId").ignoring("notificationUrl"));
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java
index 7c58038f65..f50916c0be 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java
@@ -21,10 +21,8 @@
package org.onap.so.client.namingservice;
import static org.junit.Assert.assertEquals;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.onap.namingservice.model.NameGenDeleteResponse;
import org.onap.namingservice.model.NameGenResponse;
@@ -35,70 +33,70 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
public class NamingClientResponseValidatorTest extends TestDataSetup {
-
- private NamingClientResponseValidator responseValidator = new NamingClientResponseValidator();
- private String instanceGroupName = "generatedInstanceGroupName";
-
- @Test
- public void validateNameGenResponseSuccessTest() throws BadResponseException {
- NameGenResponse name = new NameGenResponse();
- Respelement respElement = new Respelement();
- respElement.setResourceName("instance-group-name");
- respElement.setResourceValue(instanceGroupName);
- List<Respelement> respList = new ArrayList<Respelement>();
- respList.add(respElement);
- name.setElements(respList);
- ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
-
- String actual = responseValidator.validateNameGenResponse(resp);
-
- assertEquals(actual, "generatedInstanceGroupName");
- }
-
- @Test
- public void validateNameGenResponseNoNameGeneratedTest() throws BadResponseException {
- NameGenResponse name = new NameGenResponse();
- Respelement respElement = new Respelement();
- respElement.setResourceName("instance-group");
- respElement.setResourceValue(instanceGroupName);
- List<Respelement> respList = new ArrayList<Respelement>();
- respList.add(respElement);
- name.setElements(respList);
- ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
-
- String actual = responseValidator.validateNameGenResponse(resp);
-
- assertEquals(actual, "");
- }
-
- @Test
- public void validateNameGenResponseBadStatusTest() throws BadResponseException {
- NameGenResponse name = new NameGenResponse();
-
- ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.NOT_FOUND);
-
- expectedException.expect(BadResponseException.class);
- responseValidator.validateNameGenResponse(resp);
- }
-
- @Test
- public void validateNameGenDeleteResponseSuccessTest() throws BadResponseException {
- NameGenDeleteResponse name = new NameGenDeleteResponse();
- ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
-
- String actual = responseValidator.validateNameGenDeleteResponse(resp);
-
- assertEquals(actual, "");
- }
-
- @Test
- public void validateNameGenDeleteResponseBadStatusTest() throws BadResponseException {
- NameGenDeleteResponse name = new NameGenDeleteResponse();
-
- ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.NOT_FOUND);
-
- expectedException.expect(BadResponseException.class);
- responseValidator.validateNameGenDeleteResponse(resp);
- }
-
+
+ private NamingClientResponseValidator responseValidator = new NamingClientResponseValidator();
+ private String instanceGroupName = "generatedInstanceGroupName";
+
+ @Test
+ public void validateNameGenResponseSuccessTest() throws BadResponseException {
+ NameGenResponse name = new NameGenResponse();
+ Respelement respElement = new Respelement();
+ respElement.setResourceName("instance-group-name");
+ respElement.setResourceValue(instanceGroupName);
+ List<Respelement> respList = new ArrayList<Respelement>();
+ respList.add(respElement);
+ name.setElements(respList);
+ ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+
+ String actual = responseValidator.validateNameGenResponse(resp);
+
+ assertEquals(actual, "generatedInstanceGroupName");
+ }
+
+ @Test
+ public void validateNameGenResponseNoNameGeneratedTest() throws BadResponseException {
+ NameGenResponse name = new NameGenResponse();
+ Respelement respElement = new Respelement();
+ respElement.setResourceName("instance-group");
+ respElement.setResourceValue(instanceGroupName);
+ List<Respelement> respList = new ArrayList<Respelement>();
+ respList.add(respElement);
+ name.setElements(respList);
+ ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+
+ String actual = responseValidator.validateNameGenResponse(resp);
+
+ assertEquals(actual, "");
+ }
+
+ @Test
+ public void validateNameGenResponseBadStatusTest() throws BadResponseException {
+ NameGenResponse name = new NameGenResponse();
+
+ ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.NOT_FOUND);
+
+ expectedException.expect(BadResponseException.class);
+ responseValidator.validateNameGenResponse(resp);
+ }
+
+ @Test
+ public void validateNameGenDeleteResponseSuccessTest() throws BadResponseException {
+ NameGenDeleteResponse name = new NameGenDeleteResponse();
+ ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+
+ String actual = responseValidator.validateNameGenDeleteResponse(resp);
+
+ assertEquals(actual, "");
+ }
+
+ @Test
+ public void validateNameGenDeleteResponseBadStatusTest() throws BadResponseException {
+ NameGenDeleteResponse name = new NameGenDeleteResponse();
+
+ ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.NOT_FOUND);
+
+ expectedException.expect(BadResponseException.class);
+ responseValidator.validateNameGenDeleteResponse(resp);
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java
index 4bae5b40e4..8a387a88a4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java
@@ -25,11 +25,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-
import org.apache.http.HttpStatus;
import org.junit.Rule;
import org.junit.Test;
@@ -41,78 +39,78 @@ import org.onap.namingservice.model.NameGenRequest;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.client.exception.BadResponseException;
import org.springframework.beans.factory.annotation.Autowired;
-
import com.fasterxml.jackson.core.JsonProcessingException;
-public class NamingClientTest extends BaseIntegrationTest{
- @Autowired
- NamingClient client;
- @Autowired
- NamingRequestObjectBuilder requestBuilder;
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void assignNameGenRequest() throws BadResponseException, IOException{
- wireMockServer.stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("NamingClient/AssignResponse.json")
- .withStatus(HttpStatus.SC_ACCEPTED)));
-
- NameGenRequest request = assignSetup();
- String response = client.postNameGenRequest(request);
- assertTrue(response.equals("$vnf-name"));
- }
- @Test
- public void assignNameGenRequestError() throws BadResponseException, IOException{
- wireMockServer.stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("NamingClient/ErrorResponse.json")
- .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
-
- thrown.expect(BadResponseException.class);
- thrown.expectMessage("Error from Naming Service: External Key is required and must be unique");
- NameGenRequest request = assignSetup();
- client.postNameGenRequest(request);
- }
- @Test
- public void unassignNameGenRequest() throws BadResponseException, IOException{
- wireMockServer.stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("NamingClient/UnassignResponse.json")
- .withStatus(HttpStatus.SC_ACCEPTED)));
-
- String response = client.deleteNameGenRequest(unassignSetup());
- assertTrue(response.equals(""));
- }
- @Test
- public void unassignNameGenRequestError() throws BadResponseException, IOException{
- wireMockServer.stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("NamingClient/ErrorResponse.json")
- .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
-
- thrown.expect(BadResponseException.class);
- thrown.expectMessage("Error from Naming Service: External Key is required and must be unique");
- client.deleteNameGenRequest(unassignSetup());
- }
-
- public NameGenRequest assignSetup() throws JsonProcessingException{
- NameGenRequest request = new NameGenRequest();
- List<Element> elements = new ArrayList<>();
- Element testElement = new Element();
- testElement = requestBuilder.elementMapper("SomeUniqueValue", "SDNC_Policy.Config_MS_1806SRIOV_VNATJson.4.xml", "VNF", "nfNamingCode", "vnf_name");
- elements.add(testElement);
- request = requestBuilder.nameGenRequestMapper(elements);
- return request;
- }
- public NameGenDeleteRequest unassignSetup() throws JsonProcessingException{
- NameGenDeleteRequest request = new NameGenDeleteRequest();
- List<Deleteelement> deleteElements = new ArrayList<>();
- Deleteelement testElement = new Deleteelement();
- testElement = requestBuilder.deleteElementMapper("instanceGroupId");
- deleteElements.add(testElement);
- request = requestBuilder.nameGenDeleteRequestMapper(deleteElements);
- return request;
- }
+public class NamingClientTest extends BaseIntegrationTest {
+ @Autowired
+ NamingClient client;
+ @Autowired
+ NamingRequestObjectBuilder requestBuilder;
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void assignNameGenRequest() throws BadResponseException, IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("NamingClient/AssignResponse.json").withStatus(HttpStatus.SC_ACCEPTED)));
+
+ NameGenRequest request = assignSetup();
+ String response = client.postNameGenRequest(request);
+ assertTrue(response.equals("$vnf-name"));
+ }
+
+ @Test
+ public void assignNameGenRequestError() throws BadResponseException, IOException {
+ wireMockServer.stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName")).willReturn(aResponse()
+ .withHeader("Content-Type", "application/json").withBodyFile("NamingClient/ErrorResponse.json")
+ .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
+
+ thrown.expect(BadResponseException.class);
+ thrown.expectMessage("Error from Naming Service: External Key is required and must be unique");
+ NameGenRequest request = assignSetup();
+ client.postNameGenRequest(request);
+ }
+
+ @Test
+ public void unassignNameGenRequest() throws BadResponseException, IOException {
+ wireMockServer.stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("NamingClient/UnassignResponse.json").withStatus(HttpStatus.SC_ACCEPTED)));
+
+ String response = client.deleteNameGenRequest(unassignSetup());
+ assertTrue(response.equals(""));
+ }
+
+ @Test
+ public void unassignNameGenRequestError() throws BadResponseException, IOException {
+ wireMockServer.stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName")).willReturn(aResponse()
+ .withHeader("Content-Type", "application/json").withBodyFile("NamingClient/ErrorResponse.json")
+ .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
+
+ thrown.expect(BadResponseException.class);
+ thrown.expectMessage("Error from Naming Service: External Key is required and must be unique");
+ client.deleteNameGenRequest(unassignSetup());
+ }
+
+ public NameGenRequest assignSetup() throws JsonProcessingException {
+ NameGenRequest request = new NameGenRequest();
+ List<Element> elements = new ArrayList<>();
+ Element testElement = new Element();
+ testElement = requestBuilder.elementMapper("SomeUniqueValue", "SDNC_Policy.Config_MS_1806SRIOV_VNATJson.4.xml",
+ "VNF", "nfNamingCode", "vnf_name");
+ elements.add(testElement);
+ request = requestBuilder.nameGenRequestMapper(elements);
+ return request;
+ }
+
+ public NameGenDeleteRequest unassignSetup() throws JsonProcessingException {
+ NameGenDeleteRequest request = new NameGenDeleteRequest();
+ List<Deleteelement> deleteElements = new ArrayList<>();
+ Deleteelement testElement = new Deleteelement();
+ testElement = requestBuilder.deleteElementMapper("instanceGroupId");
+ deleteElements.add(testElement);
+ request = requestBuilder.nameGenDeleteRequestMapper(deleteElements);
+ return request;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java
index 6cb4987bee..bec588b6d3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java
@@ -22,10 +22,8 @@ package org.onap.so.client.namingservice;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertThat;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.onap.namingservice.model.Deleteelement;
import org.onap.namingservice.model.Element;
@@ -34,72 +32,76 @@ import org.onap.namingservice.model.NameGenRequest;
import org.onap.so.client.namingservice.NamingRequestObjectBuilder;
public class NamingRequestObjectBuilderTest {
-
- private NamingRequestObjectBuilder mapper = new NamingRequestObjectBuilder();
- private String instanceGroupId = "95cbbe59-1017-4c13-b4e8-d824e54def3e";
- private String policyInstanceName = "MSO_Policy.Config_MS_VNFInstanceGroup";
- private String namingType = "InstanceGroup";
- private String nfNamingCode = "NamingCode";
- private String instanceGroupName = "InstanceGroupName";
-
- @Test
- public void elementMapperTest(){
- // Expected element
- Element expected = new Element();
- expected.put("external-key", instanceGroupId);
- expected.put("policy-instance-name", policyInstanceName);
- expected.put("naming-type", namingType);
- expected.put("resource-name", instanceGroupName);
- expected.put("nf-naming-code", nfNamingCode);
-
- // Actual element
- Element actual = mapper.elementMapper(instanceGroupId, policyInstanceName, namingType, nfNamingCode, instanceGroupName);
-
- assertThat(actual, sameBeanAs(expected));
- }
- @Test
- public void deleteElementMapperTest(){
- // Expected Deleteelement
- Deleteelement expected = new Deleteelement();
- expected.setExternalKey(instanceGroupId);
-
- // Actual Deleteelement
- Deleteelement actual = mapper.deleteElementMapper(instanceGroupId);
-
- assertThat(actual, sameBeanAs(expected));
- }
- @Test
- public void nameGenRequestMapper(){
- // Expected NameGenRequest
- NameGenRequest expected = new NameGenRequest();
- List<Element> elements = new ArrayList<>();
- Element element = new Element();
- element.setExternalKey(instanceGroupId);
- element.setPolicyInstanceName(policyInstanceName);
- element.setNamingType(namingType);
- element.setResourceName(instanceGroupName);
- element.setNamingIngredientsZeroOrMore(nfNamingCode);
- elements.add(element);
- expected.setElements(elements);
-
- //Actual NameGenRequest
- NameGenRequest actual = mapper.nameGenRequestMapper(elements);
-
- assertThat(actual, sameBeanAs(expected));
- }
- @Test
- public void nameGenDeleteRequestMapper(){
- // Expected NameGenDeleteRequest
- NameGenDeleteRequest expected = new NameGenDeleteRequest();
- List<Deleteelement> deleteElements = new ArrayList<>();
- Deleteelement deleteElement = new Deleteelement();
- deleteElement.setExternalKey(instanceGroupId);
- deleteElements.add(deleteElement);
- expected.setElements(deleteElements);
-
- // Actual NameGenDeleteRequest
- NameGenDeleteRequest actual = mapper.nameGenDeleteRequestMapper(deleteElements);
-
- assertThat(actual, sameBeanAs(expected));
- }
+
+ private NamingRequestObjectBuilder mapper = new NamingRequestObjectBuilder();
+ private String instanceGroupId = "95cbbe59-1017-4c13-b4e8-d824e54def3e";
+ private String policyInstanceName = "MSO_Policy.Config_MS_VNFInstanceGroup";
+ private String namingType = "InstanceGroup";
+ private String nfNamingCode = "NamingCode";
+ private String instanceGroupName = "InstanceGroupName";
+
+ @Test
+ public void elementMapperTest() {
+ // Expected element
+ Element expected = new Element();
+ expected.put("external-key", instanceGroupId);
+ expected.put("policy-instance-name", policyInstanceName);
+ expected.put("naming-type", namingType);
+ expected.put("resource-name", instanceGroupName);
+ expected.put("nf-naming-code", nfNamingCode);
+
+ // Actual element
+ Element actual =
+ mapper.elementMapper(instanceGroupId, policyInstanceName, namingType, nfNamingCode, instanceGroupName);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void deleteElementMapperTest() {
+ // Expected Deleteelement
+ Deleteelement expected = new Deleteelement();
+ expected.setExternalKey(instanceGroupId);
+
+ // Actual Deleteelement
+ Deleteelement actual = mapper.deleteElementMapper(instanceGroupId);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void nameGenRequestMapper() {
+ // Expected NameGenRequest
+ NameGenRequest expected = new NameGenRequest();
+ List<Element> elements = new ArrayList<>();
+ Element element = new Element();
+ element.setExternalKey(instanceGroupId);
+ element.setPolicyInstanceName(policyInstanceName);
+ element.setNamingType(namingType);
+ element.setResourceName(instanceGroupName);
+ element.setNamingIngredientsZeroOrMore(nfNamingCode);
+ elements.add(element);
+ expected.setElements(elements);
+
+ // Actual NameGenRequest
+ NameGenRequest actual = mapper.nameGenRequestMapper(elements);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void nameGenDeleteRequestMapper() {
+ // Expected NameGenDeleteRequest
+ NameGenDeleteRequest expected = new NameGenDeleteRequest();
+ List<Deleteelement> deleteElements = new ArrayList<>();
+ Deleteelement deleteElement = new Deleteelement();
+ deleteElement.setExternalKey(instanceGroupId);
+ deleteElements.add(deleteElement);
+ expected.setElements(deleteElements);
+
+ // Actual NameGenDeleteRequest
+ NameGenDeleteRequest actual = mapper.nameGenDeleteRequestMapper(deleteElements);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
index c4e50412a9..ce7d557254 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
@@ -24,7 +24,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.client.exception.BadResponseException;
@@ -38,9 +37,7 @@ import org.onap.so.client.oof.beans.ResourceModelInfo;
import org.onap.so.client.oof.beans.ServiceInfo;
import org.onap.so.client.oof.beans.SubscriberInfo;
import org.springframework.beans.factory.annotation.Autowired;
-
import com.fasterxml.jackson.core.JsonProcessingException;
-
import java.util.ArrayList;
import java.util.List;
@@ -52,7 +49,8 @@ public class OofClientTestIT extends BaseIntegrationTest {
@Test
public void testPostDemands_success() throws BadResponseException, JsonProcessingException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationName("modelCustomizationName-Service");
@@ -118,102 +116,73 @@ public class OofClientTestIT extends BaseIntegrationTest {
oofRequest.setServiceInformation(serviceInfo);
oofRequest.setLicenseInformation("");
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(oofRequest);
String oofRequestOutput = oofRequest.toJsonString();
- assertEquals("{\n" +
- " \"requestInfo\" : {\n" +
- " \"transactionId\" : \"transactionId\",\n" +
- " \"requestId\" : \"requestId\",\n" +
- " \"callbackUrl\" : \"callBackUrl\",\n" +
- " \"sourceId\" : \"sourceId\",\n" +
- " \"requestType\" : \"requestType\",\n" +
- " \"numSolutions\" : 1,\n" +
- " \"optimizers\" : [ \"optimizer1\", \"optimizer2\" ],\n" +
- " \"timeout\" : 30\n" +
- " },\n" +
- " \"serviceInfo\" : {\n" +
- " \"serviceInstanceId\" : \"serviceInstanceId\",\n" +
- " \"serviceName\" : \"serviceName\",\n" +
- " \"modelInfo\" : {\n" +
- " \"modelType\" : \"modelType-Service\",\n" +
- " \"modelInvariantId\" : \"modelInvariantId-Service\",\n" +
- " \"modelVersionId\" : \"modelVersionId-Service\",\n" +
- " \"modelName\" : \"modelName-Service\",\n" +
- " \"modelVersion\" : \"modelVersion-Service\",\n" +
- " \"modelCustomizationName\" : \"modelCustomizationName-Service\"\n" +
- " }\n" +
- " },\n" +
- " \"placementInfo\" : {\n" +
- " \"requestParameters\" : {\n" +
- " \"customerLatitude\" : \"customerLatitude\",\n" +
- " \"customerLongitude\" : \"customerLongitude\",\n" +
- " \"customerName\" : \"customerName\"\n" +
- " },\n" +
- " \"subscriberInfo\" : {\n" +
- " \"globalSubscriberId\" : \"globalSubscriberId\",\n" +
- " \"subscriberName\" : \"subscriberName\",\n" +
- " \"subscriberCommonSiteId\" : \"subscriberCommonSiteId\"\n" +
- " },\n" +
- " \"placementDemands\" : [ {\n" +
- " \"resourceModuleName\" : \"resourceModuleName\",\n" +
- " \"serviceResourceId\" : \"serviceResourceId\",\n" +
- " \"tenantId\" : \"tenantId\",\n" +
- " \"resourceModelInfo\" : {\n" +
- " \"modelType\" : \"modelType\",\n" +
- " \"modelInvariantId\" : \"invarianteId\",\n" +
- " \"modelVersionId\" : \"versionId\",\n" +
- " \"modelName\" : \"modelName\",\n" +
- " \"modelVersion\" : \"version\",\n" +
- " \"modelCustomizationName\" : \"modelCustomizationName\"\n" +
- " }\n" +
- " } ]\n" +
- " },\n" +
- " \"licenseInfo\" : \"\"\n" +
- "}", oofRequestOutput);
+ assertEquals("{\n" + " \"requestInfo\" : {\n" + " \"transactionId\" : \"transactionId\",\n"
+ + " \"requestId\" : \"requestId\",\n" + " \"callbackUrl\" : \"callBackUrl\",\n"
+ + " \"sourceId\" : \"sourceId\",\n" + " \"requestType\" : \"requestType\",\n"
+ + " \"numSolutions\" : 1,\n" + " \"optimizers\" : [ \"optimizer1\", \"optimizer2\" ],\n"
+ + " \"timeout\" : 30\n" + " },\n" + " \"serviceInfo\" : {\n"
+ + " \"serviceInstanceId\" : \"serviceInstanceId\",\n" + " \"serviceName\" : \"serviceName\",\n"
+ + " \"modelInfo\" : {\n" + " \"modelType\" : \"modelType-Service\",\n"
+ + " \"modelInvariantId\" : \"modelInvariantId-Service\",\n"
+ + " \"modelVersionId\" : \"modelVersionId-Service\",\n"
+ + " \"modelName\" : \"modelName-Service\",\n"
+ + " \"modelVersion\" : \"modelVersion-Service\",\n"
+ + " \"modelCustomizationName\" : \"modelCustomizationName-Service\"\n" + " }\n" + " },\n"
+ + " \"placementInfo\" : {\n" + " \"requestParameters\" : {\n"
+ + " \"customerLatitude\" : \"customerLatitude\",\n"
+ + " \"customerLongitude\" : \"customerLongitude\",\n"
+ + " \"customerName\" : \"customerName\"\n" + " },\n" + " \"subscriberInfo\" : {\n"
+ + " \"globalSubscriberId\" : \"globalSubscriberId\",\n"
+ + " \"subscriberName\" : \"subscriberName\",\n"
+ + " \"subscriberCommonSiteId\" : \"subscriberCommonSiteId\"\n" + " },\n"
+ + " \"placementDemands\" : [ {\n" + " \"resourceModuleName\" : \"resourceModuleName\",\n"
+ + " \"serviceResourceId\" : \"serviceResourceId\",\n" + " \"tenantId\" : \"tenantId\",\n"
+ + " \"resourceModelInfo\" : {\n" + " \"modelType\" : \"modelType\",\n"
+ + " \"modelInvariantId\" : \"invarianteId\",\n" + " \"modelVersionId\" : \"versionId\",\n"
+ + " \"modelName\" : \"modelName\",\n" + " \"modelVersion\" : \"version\",\n"
+ + " \"modelCustomizationName\" : \"modelCustomizationName\"\n" + " }\n" + " } ]\n"
+ + " },\n" + " \"licenseInfo\" : \"\"\n" + "}", oofRequestOutput);
}
@Test
public void testAsyncResponse_success() throws BadResponseException, JsonProcessingException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
}
@Test(expected = BadResponseException.class)
public void testPostDemands_error_failed() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}";
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
- //TODO assertEquals("missing data", );
+ // TODO assertEquals("missing data", );
}
@Test(expected = BadResponseException.class)
public void testPostDemands_error_noMessage() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
@@ -222,12 +191,11 @@ public class OofClientTestIT extends BaseIntegrationTest {
@Test(expected = BadResponseException.class)
public void testPostDemands_error_noStatus() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}";
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
@@ -238,10 +206,8 @@ public class OofClientTestIT extends BaseIntegrationTest {
public void testPostDemands_error_empty() throws JsonProcessingException, BadResponseException {
String mockResponse = "{ }";
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
client.postDemands(new OofRequest());
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java
index 8bf3de5c4e..7c40995d48 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java
@@ -26,7 +26,6 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -43,42 +42,47 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-public class AAICollectionResourcesTest extends BaseTaskTest{
-
- @InjectMocks
- private AAICollectionResources aaiCollectionResources = new AAICollectionResources();
-
-
- private Collection networkCollection;
-
- @Before
- public void before() {
- networkCollection = buildCollection();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
- @Test
- public void createCollectionTest() throws Exception {
- networkCollection.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection);
-
- aaiCollectionResources.createCollection(networkCollection);
-
- assertEquals(OrchestrationStatus.INVENTORIED, networkCollection.getOrchestrationStatus());
- verify(MOCK_aaiResourcesClient, times(1)).create(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())), isA(org.onap.aai.domain.yang.Collection.class));
- }
-
- @Test
- public void updateCollectionTest() throws Exception {
- doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection);
- aaiCollectionResources.updateCollection(networkCollection);
- verify(MOCK_aaiResourcesClient, times(1)).update(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())), isA(org.onap.aai.domain.yang.Collection.class));
- }
-
- @Test
- public void deleteCollectionTest() throws Exception {
- aaiCollectionResources.deleteCollection(networkCollection);
- verify(MOCK_aaiResourcesClient, times(1)).delete(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())));
- }
-
+public class AAICollectionResourcesTest extends BaseTaskTest {
+
+ @InjectMocks
+ private AAICollectionResources aaiCollectionResources = new AAICollectionResources();
+
+
+ private Collection networkCollection;
+
+ @Before
+ public void before() {
+ networkCollection = buildCollection();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+ @Test
+ public void createCollectionTest() throws Exception {
+ networkCollection.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection);
+
+ aaiCollectionResources.createCollection(networkCollection);
+
+ assertEquals(OrchestrationStatus.INVENTORIED, networkCollection.getOrchestrationStatus());
+ verify(MOCK_aaiResourcesClient, times(1)).create(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())),
+ isA(org.onap.aai.domain.yang.Collection.class));
+ }
+
+ @Test
+ public void updateCollectionTest() throws Exception {
+ doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection);
+ aaiCollectionResources.updateCollection(networkCollection);
+ verify(MOCK_aaiResourcesClient, times(1)).update(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())),
+ isA(org.onap.aai.domain.yang.Collection.class));
+ }
+
+ @Test
+ public void deleteCollectionTest() throws Exception {
+ aaiCollectionResources.deleteCollection(networkCollection);
+ verify(MOCK_aaiResourcesClient, times(1))
+ .delete(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())));
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java
index 4bf445949a..2e1a40dd22 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java
@@ -27,9 +27,7 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -57,32 +55,32 @@ import org.onap.so.bpmn.common.data.TestDataSetup;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class AAIConfigurationResourcesTest extends TestDataSetup{
-
-
-
- private Configuration configuration;
+public class AAIConfigurationResourcesTest extends TestDataSetup {
+
+
+
+ private Configuration configuration;
private ServiceProxy serviceProxy;
private ServiceInstance serviceInstance;
private GenericVnf genericVnf;
private VpnBinding vpnBinding;
private VfModule vfModule;
-
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
@Mock
protected AAIObjectMapper MOCK_aaiObjectMapper;
-
+
@Mock
protected InjectionHelper MOCK_injectionHelper;
-
+
@InjectMocks
- private AAIConfigurationResources aaiConfigurationResources = new AAIConfigurationResources();
-
+ private AAIConfigurationResources aaiConfigurationResources = new AAIConfigurationResources();
+
@Before
public void before() {
- configuration = buildConfiguration();
+ configuration = buildConfiguration();
serviceProxy = buildServiceProxy();
serviceInstance = buildServiceInstance();
genericVnf = buildGenericVnf();
@@ -90,62 +88,73 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{
vpnBinding = buildVpnBinding();
doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
}
-
+
@Test
public void createConfigurationTest() {
- doReturn(new org.onap.aai.domain.yang.Configuration()).when(MOCK_aaiObjectMapper).mapConfiguration(configuration);
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Configuration.class));
-
+ doReturn(new org.onap.aai.domain.yang.Configuration()).when(MOCK_aaiObjectMapper)
+ .mapConfiguration(configuration);
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Configuration.class));
+
aaiConfigurationResources.createConfiguration(configuration);
-
+
assertEquals(OrchestrationStatus.ASSIGNED, configuration.getOrchestrationStatus());
- verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Configuration.class));
+ verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Configuration.class));
}
@Test
- public void updateConfigurationTest() {
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Configuration.class));
+ public void updateConfigurationTest() {
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Configuration.class));
configuration.setConfigurationType("VNR");
configuration.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
aaiConfigurationResources.updateConfiguration(configuration);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull());
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
}
@Test
public void connectConfigurationToServiceInstanceTest() {
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiConfigurationResources.connectConfigurationToServiceInstance(configuration.getConfigurationId(), serviceInstance.getServiceInstanceId());
+ aaiConfigurationResources.connectConfigurationToServiceInstance(configuration.getConfigurationId(),
+ serviceInstance.getServiceInstanceId());
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
-
+
@Test
public void connectConfigurationToServiceInstanceWithEdgeTest() {
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class), any(AAIEdgeLabel.class));
- aaiConfigurationResources.connectConfigurationToServiceInstance(configuration.getConfigurationId(), serviceInstance.getServiceInstanceId(), AAIEdgeLabel.USES);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class), any(AAIEdgeLabel.class));
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class),
+ any(AAIEdgeLabel.class));
+ aaiConfigurationResources.connectConfigurationToServiceInstance(configuration.getConfigurationId(),
+ serviceInstance.getServiceInstanceId(), AAIEdgeLabel.USES);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class),
+ any(AAIEdgeLabel.class));
}
-
+
@Test
- public void disconnectConfigurationToServiceInstanceTest(){
+ public void disconnectConfigurationToServiceInstanceTest() {
doNothing().when(MOCK_aaiResourcesClient).disconnect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiConfigurationResources.disconnectConfigurationToServiceInstance("TEST_CONFIGURATION_ID", "TEST_SERVICE_INSTANCE_ID");
+ aaiConfigurationResources.disconnectConfigurationToServiceInstance("TEST_CONFIGURATION_ID",
+ "TEST_SERVICE_INSTANCE_ID");
verify(MOCK_aaiResourcesClient, times(1)).disconnect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
@Test
public void connectConfigurationToGenericVnfTest() {
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiConfigurationResources.connectConfigurationToGenericVnf(configuration.getConfigurationId(), genericVnf.getVnfId());
+ aaiConfigurationResources.connectConfigurationToGenericVnf(configuration.getConfigurationId(),
+ genericVnf.getVnfId());
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
-
+
@Test
public void connectConfigurationToVfModuleTest() {
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiConfigurationResources.connectConfigurationToVfModule(configuration.getConfigurationId(), vfModule.getVfModuleId(),genericVnf.getVnfId());
+ aaiConfigurationResources.connectConfigurationToVfModule(configuration.getConfigurationId(),
+ vfModule.getVfModuleId(), genericVnf.getVnfId());
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
-
+
@Test
public void connectConfigurationToVnfcTest() {
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
@@ -156,17 +165,22 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{
@Test
public void connectConfigurationToVpnBindingTest() {
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiConfigurationResources.connectConfigurationToVpnBinding(configuration.getConfigurationId(), vpnBinding.getVpnId());
+ aaiConfigurationResources.connectConfigurationToVpnBinding(configuration.getConfigurationId(),
+ vpnBinding.getVpnId());
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
@Test
- public void getConfigurationFromRelatedLinkTest () {
- Optional<org.onap.aai.domain.yang.Configuration> configuration = Optional.of(new org.onap.aai.domain.yang.Configuration());
+ public void getConfigurationFromRelatedLinkTest() {
+ Optional<org.onap.aai.domain.yang.Configuration> configuration =
+ Optional.of(new org.onap.aai.domain.yang.Configuration());
configuration.get().setConfigurationId("config1");
- doReturn(configuration).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.Configuration.class),isA(AAIResourceUri.class));
- aaiConfigurationResources.getConfigurationFromRelatedLink("http://localhost:8090/aai/v12/network/configurations/configuration/config1");
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.Configuration.class),isA(AAIResourceUri.class));
+ doReturn(configuration).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.Configuration.class),
+ isA(AAIResourceUri.class));
+ aaiConfigurationResources.getConfigurationFromRelatedLink(
+ "http://localhost:8090/aai/v12/network/configurations/configuration/config1");
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.Configuration.class),
+ isA(AAIResourceUri.class));
}
@Test
@@ -174,24 +188,28 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{
Configuration vrfConfiguration = buildConfiguration();
Configuration vnrConfiguration = buildConfiguration();
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiConfigurationResources.connectVrfConfigurationToVnrConfiguration(vrfConfiguration.getConfigurationId(),vnrConfiguration.getConfigurationId());
+ aaiConfigurationResources.connectVrfConfigurationToVnrConfiguration(vrfConfiguration.getConfigurationId(),
+ vnrConfiguration.getConfigurationId());
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
@Test
public void connectConfigurationToPnfObjectTest() throws Exception {
doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
-
- Pnf primaryPnf = serviceProxy.getServiceInstance().getPnfs().stream().filter(o -> o.getRole().equals("Primary")).findFirst().get();
-
- aaiConfigurationResources.connectConfigurationToPnfObject(primaryPnf.getPnfId(), configuration.getConfigurationId());
+
+ Pnf primaryPnf = serviceProxy.getServiceInstance().getPnfs().stream().filter(o -> o.getRole().equals("Primary"))
+ .findFirst().get();
+
+ aaiConfigurationResources.connectConfigurationToPnfObject(primaryPnf.getPnfId(),
+ configuration.getConfigurationId());
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
@Test
public void getConfigurationTest() {
AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "configurationId");
- doReturn(Optional.of(new org.onap.aai.domain.yang.Configuration())).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.Configuration.class, aaiResourceUri);
+ doReturn(Optional.of(new org.onap.aai.domain.yang.Configuration())).when(MOCK_aaiResourcesClient)
+ .get(org.onap.aai.domain.yang.Configuration.class, aaiResourceUri);
aaiConfigurationResources.getConfiguration("configurationId");
verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.Configuration.class, aaiResourceUri);
}
@@ -203,13 +221,14 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{
aaiConfigurationResources.deleteConfiguration("configurationId");
verify(MOCK_aaiResourcesClient, times(1)).delete(aaiResourceUri);
}
-
+
@Test
- public void updateOrchestrationStatusConfigurationTest() throws Exception {
- configuration.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Configuration.class));
- aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration,OrchestrationStatus.ACTIVE);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
- assertEquals(OrchestrationStatus.ACTIVE, configuration.getOrchestrationStatus());
- }
-} \ No newline at end of file
+ public void updateOrchestrationStatusConfigurationTest() throws Exception {
+ configuration.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Configuration.class));
+ aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+ assertEquals(OrchestrationStatus.ACTIVE, configuration.getOrchestrationStatus());
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java
index 58bcc8b1aa..8c0d27f799 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java
@@ -28,9 +28,7 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -49,75 +47,88 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
+
@RunWith(MockitoJUnitRunner.Silent.class)
-public class AAIInstanceGroupResourcesTest extends TestDataSetup{
-
- @InjectMocks
- private AAIInstanceGroupResources aaiInstanceGroupResources = new AAIInstanceGroupResources();
-
- private InstanceGroup instanceGroup;
- private GenericVnf vnf;
- private ServiceInstance serviceInstance;
-
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
+public class AAIInstanceGroupResourcesTest extends TestDataSetup {
+
+ @InjectMocks
+ private AAIInstanceGroupResources aaiInstanceGroupResources = new AAIInstanceGroupResources();
+
+ private InstanceGroup instanceGroup;
+ private GenericVnf vnf;
+ private ServiceInstance serviceInstance;
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
@Mock
protected AAIObjectMapper MOCK_aaiObjectMapper;
-
+
@Mock
protected InjectionHelper MOCK_injectionHelper;
-
- @Before
- public void before() {
- instanceGroup = buildInstanceGroup();
- vnf = buildGenericVnf();
- serviceInstance = buildServiceInstance();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
- @Test
- public void createInstanceGroupTest() throws Exception {
- doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper).mapInstanceGroup(instanceGroup);
- aaiInstanceGroupResources.createInstanceGroup(instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), isA(Optional.class));
- }
-
- @Test
- public void deleteInstanceGroupTest() throws Exception {
- aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).delete(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
- }
-
- @Test
- public void connectInstanceGroupTest() throws Exception {
- aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())));
- }
-
- @Test
- public void connectInstanceGroupWithEdgeTest() throws Exception {
- aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())), eq(AAIEdgeLabel.BELONGS_TO));
- }
-
- @Test
- public void existsTest() throws Exception {
- aaiInstanceGroupResources.exists(instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).exists(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
- }
-
- @Test
- public void createInstanceGroupandConnectServiceInstanceTest() {
- doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper).mapInstanceGroup(instanceGroup);
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), any(Optional.class));
- doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
-
- aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
-
- verify(MOCK_aaiObjectMapper, times(1)).mapInstanceGroup(instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
+
+ @Before
+ public void before() {
+ instanceGroup = buildInstanceGroup();
+ vnf = buildGenericVnf();
+ serviceInstance = buildServiceInstance();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+ @Test
+ public void createInstanceGroupTest() throws Exception {
+ doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper)
+ .mapInstanceGroup(instanceGroup);
+ aaiInstanceGroupResources.createInstanceGroup(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
+ isA(Optional.class));
+ }
+
+ @Test
+ public void deleteInstanceGroupTest() throws Exception {
+ aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1))
+ .delete(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
+ }
+
+ @Test
+ public void connectInstanceGroupTest() throws Exception {
+ aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())));
+ }
+
+ @Test
+ public void connectInstanceGroupWithEdgeTest() throws Exception {
+ aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())),
+ eq(AAIEdgeLabel.BELONGS_TO));
+ }
+
+ @Test
+ public void existsTest() throws Exception {
+ aaiInstanceGroupResources.exists(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1))
+ .exists(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
+ }
+
+ @Test
+ public void createInstanceGroupandConnectServiceInstanceTest() {
+ doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper)
+ .mapInstanceGroup(instanceGroup);
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class),
+ any(Optional.class));
+ doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+
+ aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
+
+ verify(MOCK_aaiObjectMapper, times(1)).mapInstanceGroup(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
index 8632a6afdd..d41148d784 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
@@ -32,13 +32,11 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -68,328 +66,363 @@ import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class AAINetworkResourcesTest extends TestDataSetup{
-
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
-
- private L3Network network;
- private Collection collection;
- private InstanceGroup instanceGroup;
- private ServiceInstance serviceInstance;
- private CloudRegion cloudRegion;
- private Subnet subnet;
- private NetworkPolicy networkPolicy;
-
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
+public class AAINetworkResourcesTest extends TestDataSetup {
+
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
+
+ private L3Network network;
+ private Collection collection;
+ private InstanceGroup instanceGroup;
+ private ServiceInstance serviceInstance;
+ private CloudRegion cloudRegion;
+ private Subnet subnet;
+ private NetworkPolicy networkPolicy;
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
@Mock
protected AAIObjectMapper MOCK_aaiObjectMapper;
-
+
@Mock
protected InjectionHelper MOCK_injectionHelper;
-
- @InjectMocks
- private AAINetworkResources aaiNetworkResources = new AAINetworkResources();
-
- @Before
- public void before() {
- network = buildL3Network();
-
- collection = buildCollection();
-
- List<L3Network> l3NetworkList = new ArrayList<L3Network>();
- l3NetworkList.add(network);
-
- instanceGroup = buildInstanceGroup();
-
- serviceInstance = buildServiceInstance();
-
- cloudRegion = buildCloudRegion();
-
- subnet = buildSubnet();
-
- networkPolicy = buildNetworkPolicy();
-
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
-
- @Test
- public void updateNetworkTest() throws Exception {
-
- network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- doReturn(new org.onap.aai.domain.yang.L3Network()).when(MOCK_aaiObjectMapper).mapNetwork(network);
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.L3Network.class));
-
- aaiNetworkResources.updateNetwork(network);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.L3Network.class));
- assertEquals(OrchestrationStatus.ASSIGNED, network.getOrchestrationStatus());
- }
-
- @Test
- public void createNetworkConnectToServiceInstanceTest() throws Exception {
-
- network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
- doReturn(new org.onap.aai.domain.yang.L3Network()).when(MOCK_aaiObjectMapper).mapNetwork(network);
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), any(AAIResourceUri.class));
-
- aaiNetworkResources.createNetworkConnectToServiceInstance(network, serviceInstance);
-
- assertEquals(OrchestrationStatus.INVENTORIED, network.getOrchestrationStatus());
+
+ @InjectMocks
+ private AAINetworkResources aaiNetworkResources = new AAINetworkResources();
+
+ @Before
+ public void before() {
+ network = buildL3Network();
+
+ collection = buildCollection();
+
+ List<L3Network> l3NetworkList = new ArrayList<L3Network>();
+ l3NetworkList.add(network);
+
+ instanceGroup = buildInstanceGroup();
+
+ serviceInstance = buildServiceInstance();
+
+ cloudRegion = buildCloudRegion();
+
+ subnet = buildSubnet();
+
+ networkPolicy = buildNetworkPolicy();
+
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+
+ @Test
+ public void updateNetworkTest() throws Exception {
+
+ network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ doReturn(new org.onap.aai.domain.yang.L3Network()).when(MOCK_aaiObjectMapper).mapNetwork(network);
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.L3Network.class));
+
+ aaiNetworkResources.updateNetwork(network);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.L3Network.class));
+ assertEquals(OrchestrationStatus.ASSIGNED, network.getOrchestrationStatus());
+ }
+
+ @Test
+ public void createNetworkConnectToServiceInstanceTest() throws Exception {
+
+ network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+
+ doReturn(new org.onap.aai.domain.yang.L3Network()).when(MOCK_aaiObjectMapper).mapNetwork(network);
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(any(AAIResourceUri.class),
+ any(Optional.class));
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), any(AAIResourceUri.class));
+
+ aaiNetworkResources.createNetworkConnectToServiceInstance(network, serviceInstance);
+
+ assertEquals(OrchestrationStatus.INVENTORIED, network.getOrchestrationStatus());
verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
- @Test
- public void deleteNetworkTest() throws Exception {
-
- network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
-
- aaiNetworkResources.deleteNetwork(network);
-
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
- @Test
- public void getVpnBindingTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiVpnBinding.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- Optional<VpnBinding> oVpnBinding = Optional.empty();
- AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, "ModelInvariantUUID");
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- oVpnBinding = aaiNetworkResources.getVpnBinding(aaiUri);
- verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
-
- if (oVpnBinding.isPresent()) {
- VpnBinding vpnBinding = oVpnBinding.get();
- assertThat(aaiResultWrapper.asBean(VpnBinding.class).get(), sameBeanAs(vpnBinding));
- }
- }
-
- @Test
- public void getNetworkPolicyTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicy.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = Optional.empty();
- AAIResourceUri netPolicyUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "ModelInvariantUUID");
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri);
- verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
- if (oNetPolicy.isPresent()) {
- org.onap.aai.domain.yang.NetworkPolicy networkPolicy = oNetPolicy.get();
- assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicy.class).get(), sameBeanAs(networkPolicy));
- }
- }
-
- @Test
- public void getNetworkPoliciesTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicies.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- Optional<org.onap.aai.domain.yang.NetworkPolicies> oNetPolicies = Optional.empty();
- AAIResourceUri netPoliciesUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY);
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- oNetPolicies = aaiNetworkResources.getNetworkPolicies(netPoliciesUri);
- verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
- if (oNetPolicies.isPresent()) {
- org.onap.aai.domain.yang.NetworkPolicies networkPolicies = oNetPolicies.get();
- assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicies.class).get(), sameBeanAs(networkPolicies));
- }
- }
-
- @Test
- public void getRouteTableTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkTableRefs.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- Optional<RouteTableReference> oRtref = Optional.empty();
- AAIResourceUri rTRefUri = AAIUriFactory.createResourceUri(AAIObjectType.ROUTE_TABLE_REFERENCE, "ModelInvariantUUID");
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- oRtref = aaiNetworkResources.getRouteTable(rTRefUri);
- verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
-
- if (oRtref.isPresent()) {
- RouteTableReference rTref = oRtref.get();
- assertThat(aaiResultWrapper.asBean(RouteTableReference.class).get(), sameBeanAs(rTref));
- }
- }
-
- @Test
- public void queryNetworkByIdTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiQueryAAIResponse-Wrapper.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- L3Network network = new L3Network();
- network.setNetworkId("0384d743-f69b-4cc8-9aa8-c3ae66662c44");
- network.setNetworkName("Dev_Bindings_1802_020118");
- network.setOrchestrationStatus(OrchestrationStatus.CREATED);
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- Optional<org.onap.aai.domain.yang.L3Network> l3NetworkOpt = aaiNetworkResources.queryNetworkById(network);
- org.onap.aai.domain.yang.L3Network l3Network = l3NetworkOpt.isPresent() ? l3NetworkOpt.get() : null;
-
- verify(MOCK_aaiResourcesClient, times(1)).get(isA(AAIResourceUri.class));
- assertNotNull(l3Network);
- assertEquals("0384d743-f69b-4cc8-9aa8-c3ae66662c44", l3Network.getNetworkId());
- assertEquals("Dev_Bindings_1802_020118", l3Network.getNetworkName());
- }
-
- @Test
- public void queryNetworkWrapperByIdTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiQueryAAIResponse-Wrapper.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- L3Network network = new L3Network();
- network.setNetworkId("0384d743-f69b-4cc8-9aa8-c3ae66662c44");
- network.setNetworkName("Dev_Bindings_1802_020118");
- network.setOrchestrationStatus(OrchestrationStatus.CREATED);
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- AAIResultWrapper result = aaiNetworkResources.queryNetworkWrapperById(network);
-
- verify(MOCK_aaiResourcesClient, times(1)).get(isA(AAIResourceUri.class));
- assertEquals(aaiResultWrapper.getJson(), result.getJson());
- assertNotNull(result);
- Optional<Relationships> resultNetworkRelationships = result.getRelationships();
- assertTrue(resultNetworkRelationships.isPresent());
- Optional<org.onap.aai.domain.yang.L3Network> aaiL3Network = result.asBean(org.onap.aai.domain.yang.L3Network.class);
- assertEquals(network.getNetworkId(),aaiL3Network.get().getNetworkId());
- assertEquals(network.getNetworkName(),aaiL3Network.get().getNetworkName());
-
-
- }
-
- @Test
- public void createNetworkCollectionTest() throws Exception {
-
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Collection.class));
- doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(collection);
- collection.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
- aaiNetworkResources.createNetworkCollection(collection);
- assertEquals(OrchestrationStatus.INVENTORIED, collection.getOrchestrationStatus());
- verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Collection.class));
- }
-
- @Test
- public void createNetworkInstanceGroupTest() throws Exception {
- doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper).mapInstanceGroup(instanceGroup);
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.InstanceGroup.class));
- aaiNetworkResources.createNetworkInstanceGroup(instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.InstanceGroup.class));
- }
-
- @Test
- public void connectNetworkToNetworkCollectionInstanceGroupTest() throws Exception {
- aaiNetworkResources.connectNetworkToNetworkCollectionInstanceGroup(network, instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
- }
-
- @Test
- public void connectNetworkToNetworkCollectionServiceInstanceTest() throws Exception {
- aaiNetworkResources.connectNetworkToNetworkCollectionServiceInstance(network, serviceInstance);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
- }
-
- @Test
- public void connectNetworkToCloudRegionTest() throws Exception {
- aaiNetworkResources.connectNetworkToCloudRegion(network, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())),eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())));
- }
-
- @Test
- public void connectNetworkToTenantTest() throws Exception {
- aaiNetworkResources.connectNetworkToTenant(network, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId())),
- eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
- }
-
- @Test
- public void connectNetworkCollectionInstanceGroupToNetworkCollectionTest() throws Exception {
- aaiNetworkResources.connectNetworkCollectionInstanceGroupToNetworkCollection(instanceGroup, collection);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
- }
-
- @Test
- public void connectNetworkCollectionToServiceInstanceTest() throws Exception {
- aaiNetworkResources.connectNetworkCollectionToServiceInstance(collection, serviceInstance);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
- @Test
- public void deleteCollectionTest() throws Exception {
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
- aaiNetworkResources.deleteCollection(collection);
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
- @Test
- public void deleteInstanceGroupTest() throws Exception {
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
- aaiNetworkResources.deleteNetworkInstanceGroup(instanceGroup);
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
- @Test
- public void updateSubnetTest() throws Exception {
-
- doReturn(new org.onap.aai.domain.yang.Subnet()).when(MOCK_aaiObjectMapper).mapSubnet(subnet);
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Subnet.class));
-
- aaiNetworkResources.updateSubnet(network, subnet);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Subnet.class));
- }
-
- @Test
- public void connectInstanceGroupToCloudRegionTest() throws Exception {
- aaiNetworkResources.connectInstanceGroupToCloudRegion(instanceGroup, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(
- eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
- eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())),
- eq(AAIEdgeLabel.USES));
- }
-
- @Test
- public void getSubnetTest() throws Exception {
- final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSubnetsMapped_to_aai.json")));
- AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- Optional<org.onap.aai.domain.yang.Subnet> oSubnet = Optional.empty();
- AAIResourceUri subnetUri = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, "ModelInvariantUUID", "serviceModelVersionId");
-
- doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
- oSubnet = aaiNetworkResources.getSubnet(subnetUri);
- verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
-
- if (oSubnet.isPresent()) {
- org.onap.aai.domain.yang.Subnet subnet = oSubnet.get();
- assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.Subnet.class).get(), sameBeanAs(subnet));
- }
- }
-
- @Test
- public void createNetworkPolicyTest() throws Exception {
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.NetworkPolicy.class));
- doReturn(new org.onap.aai.domain.yang.NetworkPolicy()).when(MOCK_aaiObjectMapper).mapNetworkPolicy(networkPolicy);
- aaiNetworkResources.createNetworkPolicy(networkPolicy);
- verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.NetworkPolicy.class));
- }
-
- @Test
- public void deleteNetworkPolicyTest() throws Exception {
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
- aaiNetworkResources.deleteNetworkPolicy(networkPolicy.getNetworkPolicyId());
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
+ }
+
+ @Test
+ public void deleteNetworkTest() throws Exception {
+
+ network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
+
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+
+ aaiNetworkResources.deleteNetwork(network);
+
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void getVpnBindingTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiVpnBinding.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ Optional<VpnBinding> oVpnBinding = Optional.empty();
+ AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, "ModelInvariantUUID");
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ oVpnBinding = aaiNetworkResources.getVpnBinding(aaiUri);
+ verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
+
+ if (oVpnBinding.isPresent()) {
+ VpnBinding vpnBinding = oVpnBinding.get();
+ assertThat(aaiResultWrapper.asBean(VpnBinding.class).get(), sameBeanAs(vpnBinding));
+ }
+ }
+
+ @Test
+ public void getNetworkPolicyTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicy.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = Optional.empty();
+ AAIResourceUri netPolicyUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "ModelInvariantUUID");
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri);
+ verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
+ if (oNetPolicy.isPresent()) {
+ org.onap.aai.domain.yang.NetworkPolicy networkPolicy = oNetPolicy.get();
+ assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicy.class).get(),
+ sameBeanAs(networkPolicy));
+ }
+ }
+
+ @Test
+ public void getNetworkPoliciesTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicies.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ Optional<org.onap.aai.domain.yang.NetworkPolicies> oNetPolicies = Optional.empty();
+ AAIResourceUri netPoliciesUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY);
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ oNetPolicies = aaiNetworkResources.getNetworkPolicies(netPoliciesUri);
+ verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
+ if (oNetPolicies.isPresent()) {
+ org.onap.aai.domain.yang.NetworkPolicies networkPolicies = oNetPolicies.get();
+ assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicies.class).get(),
+ sameBeanAs(networkPolicies));
+ }
+ }
+
+ @Test
+ public void getRouteTableTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkTableRefs.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ Optional<RouteTableReference> oRtref = Optional.empty();
+ AAIResourceUri rTRefUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.ROUTE_TABLE_REFERENCE, "ModelInvariantUUID");
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ oRtref = aaiNetworkResources.getRouteTable(rTRefUri);
+ verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
+
+ if (oRtref.isPresent()) {
+ RouteTableReference rTref = oRtref.get();
+ assertThat(aaiResultWrapper.asBean(RouteTableReference.class).get(), sameBeanAs(rTref));
+ }
+ }
+
+ @Test
+ public void queryNetworkByIdTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiQueryAAIResponse-Wrapper.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ L3Network network = new L3Network();
+ network.setNetworkId("0384d743-f69b-4cc8-9aa8-c3ae66662c44");
+ network.setNetworkName("Dev_Bindings_1802_020118");
+ network.setOrchestrationStatus(OrchestrationStatus.CREATED);
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ Optional<org.onap.aai.domain.yang.L3Network> l3NetworkOpt = aaiNetworkResources.queryNetworkById(network);
+ org.onap.aai.domain.yang.L3Network l3Network = l3NetworkOpt.isPresent() ? l3NetworkOpt.get() : null;
+
+ verify(MOCK_aaiResourcesClient, times(1)).get(isA(AAIResourceUri.class));
+ assertNotNull(l3Network);
+ assertEquals("0384d743-f69b-4cc8-9aa8-c3ae66662c44", l3Network.getNetworkId());
+ assertEquals("Dev_Bindings_1802_020118", l3Network.getNetworkName());
+ }
+
+ @Test
+ public void queryNetworkWrapperByIdTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiQueryAAIResponse-Wrapper.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ L3Network network = new L3Network();
+ network.setNetworkId("0384d743-f69b-4cc8-9aa8-c3ae66662c44");
+ network.setNetworkName("Dev_Bindings_1802_020118");
+ network.setOrchestrationStatus(OrchestrationStatus.CREATED);
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ AAIResultWrapper result = aaiNetworkResources.queryNetworkWrapperById(network);
+
+ verify(MOCK_aaiResourcesClient, times(1)).get(isA(AAIResourceUri.class));
+ assertEquals(aaiResultWrapper.getJson(), result.getJson());
+ assertNotNull(result);
+ Optional<Relationships> resultNetworkRelationships = result.getRelationships();
+ assertTrue(resultNetworkRelationships.isPresent());
+ Optional<org.onap.aai.domain.yang.L3Network> aaiL3Network =
+ result.asBean(org.onap.aai.domain.yang.L3Network.class);
+ assertEquals(network.getNetworkId(), aaiL3Network.get().getNetworkId());
+ assertEquals(network.getNetworkName(), aaiL3Network.get().getNetworkName());
+
+
+ }
+
+ @Test
+ public void createNetworkCollectionTest() throws Exception {
+
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Collection.class));
+ doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(collection);
+ collection.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+
+ aaiNetworkResources.createNetworkCollection(collection);
+ assertEquals(OrchestrationStatus.INVENTORIED, collection.getOrchestrationStatus());
+ verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Collection.class));
+ }
+
+ @Test
+ public void createNetworkInstanceGroupTest() throws Exception {
+ doReturn(new org.onap.aai.domain.yang.InstanceGroup()).when(MOCK_aaiObjectMapper)
+ .mapInstanceGroup(instanceGroup);
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.InstanceGroup.class));
+ aaiNetworkResources.createNetworkInstanceGroup(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.InstanceGroup.class));
+ }
+
+ @Test
+ public void connectNetworkToNetworkCollectionInstanceGroupTest() throws Exception {
+ aaiNetworkResources.connectNetworkToNetworkCollectionInstanceGroup(network, instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
+ }
+
+ @Test
+ public void connectNetworkToNetworkCollectionServiceInstanceTest() throws Exception {
+ aaiNetworkResources.connectNetworkToNetworkCollectionServiceInstance(network, serviceInstance);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
+ }
+
+ @Test
+ public void connectNetworkToCloudRegionTest() throws Exception {
+ aaiNetworkResources.connectNetworkToCloudRegion(network, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId())));
+ }
+
+ @Test
+ public void connectNetworkToTenantTest() throws Exception {
+ aaiNetworkResources.connectNetworkToTenant(network, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
+ }
+
+ @Test
+ public void connectNetworkCollectionInstanceGroupToNetworkCollectionTest() throws Exception {
+ aaiNetworkResources.connectNetworkCollectionInstanceGroupToNetworkCollection(instanceGroup, collection);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())));
+ }
+
+ @Test
+ public void connectNetworkCollectionToServiceInstanceTest() throws Exception {
+ aaiNetworkResources.connectNetworkCollectionToServiceInstance(collection, serviceInstance);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void deleteCollectionTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+ aaiNetworkResources.deleteCollection(collection);
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void deleteInstanceGroupTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+ aaiNetworkResources.deleteNetworkInstanceGroup(instanceGroup);
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void updateSubnetTest() throws Exception {
+
+ doReturn(new org.onap.aai.domain.yang.Subnet()).when(MOCK_aaiObjectMapper).mapSubnet(subnet);
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Subnet.class));
+
+ aaiNetworkResources.updateSubnet(network, subnet);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Subnet.class));
+ }
+
+ @Test
+ public void connectInstanceGroupToCloudRegionTest() throws Exception {
+ aaiNetworkResources.connectInstanceGroupToCloudRegion(instanceGroup, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId())),
+ eq(AAIEdgeLabel.USES));
+ }
+
+ @Test
+ public void getSubnetTest() throws Exception {
+ final String content =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSubnetsMapped_to_aai.json")));
+ AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
+ Optional<org.onap.aai.domain.yang.Subnet> oSubnet = Optional.empty();
+ AAIResourceUri subnetUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, "ModelInvariantUUID", "serviceModelVersionId");
+
+ doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
+ oSubnet = aaiNetworkResources.getSubnet(subnetUri);
+ verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
+
+ if (oSubnet.isPresent()) {
+ org.onap.aai.domain.yang.Subnet subnet = oSubnet.get();
+ assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.Subnet.class).get(), sameBeanAs(subnet));
+ }
+ }
+
+ @Test
+ public void createNetworkPolicyTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.NetworkPolicy.class));
+ doReturn(new org.onap.aai.domain.yang.NetworkPolicy()).when(MOCK_aaiObjectMapper)
+ .mapNetworkPolicy(networkPolicy);
+ aaiNetworkResources.createNetworkPolicy(networkPolicy);
+ verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.NetworkPolicy.class));
+ }
+
+ @Test
+ public void deleteNetworkPolicyTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+ aaiNetworkResources.deleteNetworkPolicy(networkPolicy.getNetworkPolicyId());
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java
index a4b59f1f81..14df832754 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java
@@ -28,9 +28,7 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -51,36 +49,36 @@ import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class AAIServiceInstanceResourcesTest extends TestDataSetup{
-
+public class AAIServiceInstanceResourcesTest extends TestDataSetup {
+
@InjectMocks
private AAIServiceInstanceResources aaiServiceInstanceResources = new AAIServiceInstanceResources();
-
+
@Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
@Mock
protected AAIObjectMapper MOCK_aaiObjectMapper;
-
+
@Mock
protected InjectionHelper MOCK_injectionHelper;
-
+
private ServiceInstance serviceInstance;
private ServiceSubscription serviceSubscription;
private Customer customer;
private Project project;
private OwningEntity owningEntity;
-
+
@Before
public void before() {
- serviceInstance = buildServiceInstance();
- serviceSubscription = buildServiceSubscription();
- customer = buildCustomer();
- project = buildProject();
- owningEntity = buildOwningEntity();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ serviceInstance = buildServiceInstance();
+ serviceSubscription = buildServiceSubscription();
+ customer = buildCustomer();
+ project = buildProject();
+ owningEntity = buildOwningEntity();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
}
-
+
@Test
public void deleteServiceInstanceSuccessTest() throws Exception {
aaiServiceInstanceResources.deleteServiceInstance(serviceInstance);
@@ -104,34 +102,37 @@ public class AAIServiceInstanceResourcesTest extends TestDataSetup{
public void createServiceSubscriptionTest() {
serviceSubscription.setServiceType("IP-FLEX");
customer.setServiceSubscription(serviceSubscription);
- doReturn(new org.onap.aai.domain.yang.ServiceSubscription()).when(MOCK_aaiObjectMapper).mapServiceSubscription(customer.getServiceSubscription());
+ doReturn(new org.onap.aai.domain.yang.ServiceSubscription()).when(MOCK_aaiObjectMapper)
+ .mapServiceSubscription(customer.getServiceSubscription());
aaiServiceInstanceResources.createServiceSubscription(customer);
verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
}
@Test
public void createServiceInstanceTest() {
- serviceSubscription.setServiceType("testSubscriberType");
+ serviceSubscription.setServiceType("testSubscriberType");
customer.setServiceSubscription(serviceSubscription);
- doReturn(new org.onap.aai.domain.yang.ServiceInstance()).when(MOCK_aaiObjectMapper).mapServiceInstance(serviceInstance);
+ doReturn(new org.onap.aai.domain.yang.ServiceInstance()).when(MOCK_aaiObjectMapper)
+ .mapServiceInstance(serviceInstance);
serviceInstance.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
+
aaiServiceInstanceResources.createServiceInstance(serviceInstance, customer);
-
+
assertEquals(OrchestrationStatus.INVENTORIED, serviceInstance.getOrchestrationStatus());
verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
}
@Test
public void createProjectTest() {
- doReturn(new org.onap.aai.domain.yang.Project()).when(MOCK_aaiObjectMapper).mapProject(project);
+ doReturn(new org.onap.aai.domain.yang.Project()).when(MOCK_aaiObjectMapper).mapProject(project);
aaiServiceInstanceResources.createProject(project);
verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
}
@Test
public void createProjectandConnectServiceInstanceTest() {
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(any(AAIResourceUri.class),
+ any(Optional.class));
doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
doReturn(new org.onap.aai.domain.yang.Project()).when(MOCK_aaiObjectMapper).mapProject(project);
aaiServiceInstanceResources.createProjectandConnectServiceInstance(project, serviceInstance);
@@ -141,7 +142,7 @@ public class AAIServiceInstanceResourcesTest extends TestDataSetup{
@Test
public void createOwningEntityTest() {
- doReturn(new org.onap.aai.domain.yang.OwningEntity()).when(MOCK_aaiObjectMapper).mapOwningEntity(owningEntity);
+ doReturn(new org.onap.aai.domain.yang.OwningEntity()).when(MOCK_aaiObjectMapper).mapOwningEntity(owningEntity);
aaiServiceInstanceResources.createOwningEntity(owningEntity);
verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
}
@@ -160,7 +161,8 @@ public class AAIServiceInstanceResourcesTest extends TestDataSetup{
@Test
public void createOwningEntityandConnectServiceInstanceTest() {
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(any(AAIResourceUri.class),
+ any(Optional.class));
doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
doReturn(new org.onap.aai.domain.yang.OwningEntity()).when(MOCK_aaiObjectMapper).mapOwningEntity(owningEntity);
aaiServiceInstanceResources.createOwningEntityandConnectServiceInstance(owningEntity, serviceInstance);
@@ -171,14 +173,17 @@ public class AAIServiceInstanceResourcesTest extends TestDataSetup{
@Test
@Ignore
public void updateOrchestrationStatusServiceInstanceTest() {
- aaiServiceInstanceResources.updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.ServiceInstance.class));
+ aaiServiceInstanceResources.updateOrchestrationStatusServiceInstance(serviceInstance,
+ OrchestrationStatus.ACTIVE);
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),
+ any(org.onap.aai.domain.yang.ServiceInstance.class));
}
@Test
@Ignore
public void test_updateServiceInstance() {
aaiServiceInstanceResources.updateServiceInstance(serviceInstance);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.ServiceInstance.class));
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),
+ any(org.onap.aai.domain.yang.ServiceInstance.class));
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java
index a8200caf79..ae3ebeddbd 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java
@@ -27,9 +27,7 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -49,106 +47,111 @@ import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class AAIVfModuleResourcesTest extends TestDataSetup{
- @InjectMocks
- private AAIVfModuleResources aaiVfModuleResources = new AAIVfModuleResources();
-
- private VfModule vfModule;
- private GenericVnf vnf;
-
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
- @Mock
- protected AAIObjectMapper MOCK_aaiObjectMapper;
-
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
-
- @Before
- public void before() {
- vfModule = buildVfModule();
- vnf = buildGenericVnf();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
- @Test
- public void updateOrchestrationStatusVfModuleTest() throws Exception {
- vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VfModule.class));
-
- aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ACTIVE);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull());
-
- assertEquals(OrchestrationStatus.ACTIVE, vfModule.getOrchestrationStatus());
- }
-
- @Test
- public void createVfModuleTest() throws Exception {
- vfModule.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
- doReturn(new org.onap.aai.domain.yang.VfModule()).when(MOCK_aaiObjectMapper).mapVfModule(vfModule);
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), any(Optional.class));
- aaiVfModuleResources.createVfModule(vfModule, vnf);
-
- verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
- assertEquals(OrchestrationStatus.INVENTORIED, vfModule.getOrchestrationStatus());
- }
-
- @Test
- public void deleteVfModuleTest() throws Exception {
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
-
- aaiVfModuleResources.deleteVfModule(vfModule, vnf);
-
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
- @Test
- public void changeAssignVfModuleTest() throws Exception {
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VfModule.class));
-
- aaiVfModuleResources.changeAssignVfModule(vfModule, vnf);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
- }
-
- @Test
- public void connectVfModuleToVolumeGroupTest() throws Exception {
- VolumeGroup volumeGroup = buildVolumeGroup();
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- CloudRegion cloudRegion = buildCloudRegion();
-
- aaiVfModuleResources.connectVfModuleToVolumeGroup(vnf, vfModule, volumeGroup, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
- @Test
- public void updateHeatStackIdVfModuleTest() throws Exception {
- vfModule.setHeatStackId("testHeatStackId");
-
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VfModule.class));
-
- aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull());
-
- assertEquals("testHeatStackId", vfModule.getHeatStackId());
- }
-
- @Test
- public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception {
- vfModule.setContrailServiceInstanceFqdn("testContrailServiceInstanceFqdn");
-
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VfModule.class));
-
- aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull());
-
- assertEquals("testContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn());
- }
+public class AAIVfModuleResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private AAIVfModuleResources aaiVfModuleResources = new AAIVfModuleResources();
+
+ private VfModule vfModule;
+ private GenericVnf vnf;
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
+ @Mock
+ protected AAIObjectMapper MOCK_aaiObjectMapper;
+
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
+
+ @Before
+ public void before() {
+ vfModule = buildVfModule();
+ vnf = buildGenericVnf();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+ @Test
+ public void updateOrchestrationStatusVfModuleTest() throws Exception {
+ vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VfModule.class));
+
+ aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ACTIVE);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+
+ assertEquals(OrchestrationStatus.ACTIVE, vfModule.getOrchestrationStatus());
+ }
+
+ @Test
+ public void createVfModuleTest() throws Exception {
+ vfModule.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+
+ doReturn(new org.onap.aai.domain.yang.VfModule()).when(MOCK_aaiObjectMapper).mapVfModule(vfModule);
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class),
+ any(Optional.class));
+ aaiVfModuleResources.createVfModule(vfModule, vnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ assertEquals(OrchestrationStatus.INVENTORIED, vfModule.getOrchestrationStatus());
+ }
+
+ @Test
+ public void deleteVfModuleTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+
+ aaiVfModuleResources.deleteVfModule(vfModule, vnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void changeAssignVfModuleTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VfModule.class));
+
+ aaiVfModuleResources.changeAssignVfModule(vfModule, vnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+ }
+
+ @Test
+ public void connectVfModuleToVolumeGroupTest() throws Exception {
+ VolumeGroup volumeGroup = buildVolumeGroup();
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ CloudRegion cloudRegion = buildCloudRegion();
+
+ aaiVfModuleResources.connectVfModuleToVolumeGroup(vnf, vfModule, volumeGroup, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void updateHeatStackIdVfModuleTest() throws Exception {
+ vfModule.setHeatStackId("testHeatStackId");
+
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VfModule.class));
+
+ aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+
+ assertEquals("testHeatStackId", vfModule.getHeatStackId());
+ }
+
+ @Test
+ public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception {
+ vfModule.setContrailServiceInstanceFqdn("testContrailServiceInstanceFqdn");
+
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VfModule.class));
+
+ aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+
+ assertEquals("testContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java
index d499bcd36e..cdc601c1e4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java
@@ -29,10 +29,8 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.IOException;
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -58,159 +56,175 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
@RunWith(MockitoJUnitRunner.Silent.class)
public class AAIVnfResourcesTest extends TestDataSetup {
- private GenericVnf genericVnf;
-
- private ServiceInstance serviceInstance;
-
- private CloudRegion cloudRegion;
-
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
- @Mock
- protected AAIObjectMapper MOCK_aaiObjectMapper;
-
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
-
- @Mock
- protected AAIValidatorImpl MOCK_aaiValidatorImpl;
-
- @InjectMocks
- AAIVnfResources aaiVnfResources = new AAIVnfResources();
-
- @Before
- public void before() {
- serviceInstance = buildServiceInstance();
- genericVnf = buildGenericVnf();
- cloudRegion = buildCloudRegion();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
- @Test
- public void createVnfandConnectServiceInstanceTest() {
- doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(MOCK_aaiObjectMapper).mapVnf(genericVnf);
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), any(Optional.class));
- doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- genericVnf.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
-
- aaiVnfResources.createVnfandConnectServiceInstance(genericVnf, serviceInstance);
-
- assertEquals(OrchestrationStatus.INVENTORIED, genericVnf.getOrchestrationStatus());
- verify(MOCK_aaiObjectMapper, times(1)).mapVnf(genericVnf);
- verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
- @Test
- public void createPlatformandConnectVnfTest() {
- Platform platform = new Platform();
- platform.setPlatformName("a123");
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class),isA(AAIResourceUri.class));
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), any(Optional.class));
- aaiVnfResources.createPlatformandConnectVnf(platform, genericVnf);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class),isA(AAIResourceUri.class));
- }
-
- @Test
- public void createLineOfBusinessandConnectVnfTest() {
- LineOfBusiness lob = new LineOfBusiness();
- lob.setLineOfBusinessName("a123");
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class),isA(AAIResourceUri.class));
- doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), any(Optional.class));
- aaiVnfResources.createLineOfBusinessandConnectVnf(lob, genericVnf);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class),isA(AAIResourceUri.class));
- }
-
- @Test
- public void deleteVnfTest() {
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
-
- aaiVnfResources.deleteVnf(genericVnf);
-
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
- @Test
- public void updateOrchestrationStatusVnfTest() {
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Vnf.class));
-
- aaiVnfResources.updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
-
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
-
- assertEquals(OrchestrationStatus.ACTIVE, genericVnf.getOrchestrationStatus());
- }
-
- @Test
- public void updateObjectVnfTest() {
- doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(MOCK_aaiObjectMapper).mapVnf(genericVnf);
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.GenericVnf.class));
-
- aaiVnfResources.updateObjectVnf(genericVnf);
-
- verify(MOCK_aaiObjectMapper, times(1)).mapVnf(genericVnf);
- verify(MOCK_aaiResourcesClient, times(1)).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.GenericVnf.class));
- }
-
- @Test
- public void getGenericVnfTest () {
- Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
- vnf.get().setVnfId("vnfId");
- doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- aaiVnfResources.getGenericVnf("vnfId");
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- }
-
- @Test
- public void checkInMaintFlagTest () {
- Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
- vnf.get().setVnfId("vnfId");
- vnf.get().setInMaint(true);
- doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- boolean inMaintFlag = aaiVnfResources.checkInMaintFlag("vnfId");
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- assertEquals(inMaintFlag, true);
- }
-
- @Test
- public void connectVnfToTenantTest() throws Exception {
- aaiVnfResources.connectVnfToTenant(genericVnf, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId())),
- eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())));
- }
-
- @Test
- public void connectVnfToCloudRegionTest() throws Exception {
- aaiVnfResources.connectVnfToCloudRegion(genericVnf, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())),
- eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())));
- }
-
-
- @Test
- public void checkVnfClosedLoopDisabledFlagTest () {
- Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
- vnf.get().setVnfId("vnfId");
- vnf.get().setIsClosedLoopDisabled(true);
- doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- boolean isCheckVnfClosedLoopDisabledFlag = aaiVnfResources.checkVnfClosedLoopDisabledFlag("vnfId");
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- assertEquals(isCheckVnfClosedLoopDisabledFlag, true);
- }
-
- @Test
- public void checkVnfPserversLockedFlagTest () throws IOException {
-
- Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
- vnf.get().setVnfId("vnfId");
- doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- doReturn(true).when(MOCK_aaiValidatorImpl).isPhysicalServerLocked("vnfId");
- boolean isVnfPserversLockedFlag = aaiVnfResources.checkVnfPserversLockedFlag("vnfId");
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
- verify(MOCK_aaiValidatorImpl, times(1)).isPhysicalServerLocked(isA(String.class));
- assertTrue(isVnfPserversLockedFlag);
- }
+ private GenericVnf genericVnf;
+
+ private ServiceInstance serviceInstance;
+
+ private CloudRegion cloudRegion;
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
+ @Mock
+ protected AAIObjectMapper MOCK_aaiObjectMapper;
+
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
+
+ @Mock
+ protected AAIValidatorImpl MOCK_aaiValidatorImpl;
+
+ @InjectMocks
+ AAIVnfResources aaiVnfResources = new AAIVnfResources();
+
+ @Before
+ public void before() {
+ serviceInstance = buildServiceInstance();
+ genericVnf = buildGenericVnf();
+ cloudRegion = buildCloudRegion();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+ @Test
+ public void createVnfandConnectServiceInstanceTest() {
+ doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(MOCK_aaiObjectMapper).mapVnf(genericVnf);
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class),
+ any(Optional.class));
+ doNothing().when(MOCK_aaiResourcesClient).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ genericVnf.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+
+ aaiVnfResources.createVnfandConnectServiceInstance(genericVnf, serviceInstance);
+
+ assertEquals(OrchestrationStatus.INVENTORIED, genericVnf.getOrchestrationStatus());
+ verify(MOCK_aaiObjectMapper, times(1)).mapVnf(genericVnf);
+ verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void createPlatformandConnectVnfTest() {
+ Platform platform = new Platform();
+ platform.setPlatformName("a123");
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class),
+ any(Optional.class));
+ aaiVnfResources.createPlatformandConnectVnf(platform, genericVnf);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), isA(AAIResourceUri.class));
+ }
+
+ @Test
+ public void createLineOfBusinessandConnectVnfTest() {
+ LineOfBusiness lob = new LineOfBusiness();
+ lob.setLineOfBusinessName("a123");
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class),
+ any(Optional.class));
+ aaiVnfResources.createLineOfBusinessandConnectVnf(lob, genericVnf);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), isA(AAIResourceUri.class));
+ }
+
+ @Test
+ public void deleteVnfTest() {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+
+ aaiVnfResources.deleteVnf(genericVnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
+ @Test
+ public void updateOrchestrationStatusVnfTest() {
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Vnf.class));
+
+ aaiVnfResources.updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+
+ assertEquals(OrchestrationStatus.ACTIVE, genericVnf.getOrchestrationStatus());
+ }
+
+ @Test
+ public void updateObjectVnfTest() {
+ doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(MOCK_aaiObjectMapper).mapVnf(genericVnf);
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.GenericVnf.class));
+
+ aaiVnfResources.updateObjectVnf(genericVnf);
+
+ verify(MOCK_aaiObjectMapper, times(1)).mapVnf(genericVnf);
+ verify(MOCK_aaiResourcesClient, times(1)).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.GenericVnf.class));
+ }
+
+ @Test
+ public void getGenericVnfTest() {
+ Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
+ vnf.get().setVnfId("vnfId");
+ doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ aaiVnfResources.getGenericVnf("vnfId");
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ }
+
+ @Test
+ public void checkInMaintFlagTest() {
+ Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
+ vnf.get().setVnfId("vnfId");
+ vnf.get().setInMaint(true);
+ doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ boolean inMaintFlag = aaiVnfResources.checkInMaintFlag("vnfId");
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ assertEquals(inMaintFlag, true);
+ }
+
+ @Test
+ public void connectVnfToTenantTest() throws Exception {
+ aaiVnfResources.connectVnfToTenant(genericVnf, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())));
+ }
+
+ @Test
+ public void connectVnfToCloudRegionTest() throws Exception {
+ aaiVnfResources.connectVnfToCloudRegion(genericVnf, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId())));
+ }
+
+
+ @Test
+ public void checkVnfClosedLoopDisabledFlagTest() {
+ Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
+ vnf.get().setVnfId("vnfId");
+ vnf.get().setIsClosedLoopDisabled(true);
+ doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ boolean isCheckVnfClosedLoopDisabledFlag = aaiVnfResources.checkVnfClosedLoopDisabledFlag("vnfId");
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ assertEquals(isCheckVnfClosedLoopDisabledFlag, true);
+ }
+
+ @Test
+ public void checkVnfPserversLockedFlagTest() throws IOException {
+
+ Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf());
+ vnf.get().setVnfId("vnfId");
+ doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ doReturn(true).when(MOCK_aaiValidatorImpl).isPhysicalServerLocked("vnfId");
+ boolean isVnfPserversLockedFlag = aaiVnfResources.checkVnfPserversLockedFlag("vnfId");
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),
+ isA(AAIResourceUri.class));
+ verify(MOCK_aaiValidatorImpl, times(1)).isPhysicalServerLocked(isA(String.class));
+ assertTrue(isVnfPserversLockedFlag);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java
index 6a44ed649e..2bdcf30a4c 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,101 +45,105 @@ import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class AAIVolumeGroupResourcesTest extends TestDataSetup{
- @InjectMocks
- private AAIVolumeGroupResources aaiVolumeGroupResources = new AAIVolumeGroupResources();
+public class AAIVolumeGroupResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private AAIVolumeGroupResources aaiVolumeGroupResources = new AAIVolumeGroupResources();
+
+ private CloudRegion cloudRegion;
+ private VolumeGroup volumeGroup;
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
+ @Mock
+ protected AAIObjectMapper MOCK_aaiObjectMapper;
+
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
+
+ @Before
+ public void before() {
+ cloudRegion = buildCloudRegion();
+ volumeGroup = buildVolumeGroup();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+
- private CloudRegion cloudRegion;
- private VolumeGroup volumeGroup;
+ @Test
+ public void updateOrchestrationStatusVolumeGroupTest() throws Exception {
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VolumeGroup.class));
- @Mock
- protected AAIObjectMapper MOCK_aaiObjectMapper;
+ aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
+ OrchestrationStatus.ACTIVE);
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
- @Before
- public void before() {
- cloudRegion = buildCloudRegion();
- volumeGroup = buildVolumeGroup();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
+ assertEquals(OrchestrationStatus.ACTIVE, volumeGroup.getOrchestrationStatus());
+ }
+ @Test
+ public void createVolumeGroupTest() throws Exception {
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VolumeGroup.class));
- @Test
- public void updateOrchestrationStatusVolumeGroupTest() throws Exception {
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion);
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VolumeGroup.class));
+ verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), ArgumentMatchers.isNull());
- aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
+ assertEquals(OrchestrationStatus.ASSIGNED, volumeGroup.getOrchestrationStatus());
+ }
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+ @Test
+ public void connectVolumeGroupToVnfTest() throws Exception {
- assertEquals(OrchestrationStatus.ACTIVE, volumeGroup.getOrchestrationStatus());
- }
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- @Test
- public void createVolumeGroupTest() throws Exception {
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VolumeGroup.class));
+ aaiVolumeGroupResources.connectVolumeGroupToTenant(volumeGroup, cloudRegion);
- aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
- verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), ArgumentMatchers.isNull());
+ @Test
+ public void connectVolumeGroupToTenantTest() throws Exception {
+ GenericVnf genericVnf = buildGenericVnf();
- assertEquals(OrchestrationStatus.ASSIGNED, volumeGroup.getOrchestrationStatus());
- }
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
- @Test
- public void connectVolumeGroupToVnfTest() throws Exception {
-
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiVolumeGroupResources.connectVolumeGroupToTenant(volumeGroup, cloudRegion);
+ aaiVolumeGroupResources.connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
-
- @Test
- public void connectVolumeGroupToTenantTest() throws Exception {
- GenericVnf genericVnf = buildGenericVnf();
+ verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+ @Test
+ public void deleteVolumeGroupTest() {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+ aaiVolumeGroupResources.deleteVolumeGroup(volumeGroup, cloudRegion);
- aaiVolumeGroupResources.connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
- verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
- }
+ @Test
+ public void updateHeatStackIdVolumeGroupTest() throws Exception {
+ volumeGroup.setHeatStackId("testVolumeHeatStackId");
- @Test
- public void deleteVolumeGroupTest() {
- doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VolumeGroup.class));
- aaiVolumeGroupResources.deleteVolumeGroup(volumeGroup, cloudRegion);
+ aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
- }
-
- @Test
- public void updateHeatStackIdVolumeGroupTest() throws Exception {
- volumeGroup.setHeatStackId("testVolumeHeatStackId");
-
- doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VolumeGroup.class));
-
- aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
-
- assertEquals("testVolumeHeatStackId", volumeGroup.getHeatStackId());
- }
+ assertEquals("testVolumeHeatStackId", volumeGroup.getHeatStackId());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVpnBindingResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVpnBindingResourcesTest.java
index c50b084df2..0cbdee396f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVpnBindingResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVpnBindingResourcesTest.java
@@ -29,9 +29,7 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -42,76 +40,84 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-public class AAIVpnBindingResourcesTest extends BaseTaskTest{
-
- @InjectMocks
- private AAIVpnBindingResources aaiVpnBindingResources = new AAIVpnBindingResources();
-
- private Customer customer;
-
- @Before
- public void before() {
- customer = buildCustomer();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
- @Test
- public void createCustomerTest() {
- org.onap.aai.domain.yang.Customer mappedCustomer = new org.onap.aai.domain.yang.Customer();
- mappedCustomer.setGlobalCustomerId(customer.getGlobalCustomerId());
-
- doReturn(mappedCustomer).when(MOCK_aaiObjectMapper).mapCustomer(customer);
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Customer.class));
-
- aaiVpnBindingResources.createCustomer(customer);
-
- verify(MOCK_aaiResourcesClient, times(1)).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Customer.class));
- verify(MOCK_aaiObjectMapper, times(1)).mapCustomer(customer);
- }
-
- @Test
- public void getVpnBindingTest () {
- org.onap.aai.domain.yang.VpnBinding vpnBinding = new org.onap.aai.domain.yang.VpnBinding();
- vpnBinding.setVpnId("vnfId");
- when(MOCK_aaiResourcesClient.get(eq(org.onap.aai.domain.yang.VpnBinding.class),isA(AAIResourceUri.class))).thenReturn(Optional.of(vpnBinding));
- aaiVpnBindingResources.getVpnBinding("vpnId");
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.VpnBinding.class),isA(AAIResourceUri.class));
- }
+public class AAIVpnBindingResourcesTest extends BaseTaskTest {
+
+ @InjectMocks
+ private AAIVpnBindingResources aaiVpnBindingResources = new AAIVpnBindingResources();
+
+ private Customer customer;
+
+ @Before
+ public void before() {
+ customer = buildCustomer();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+ @Test
+ public void createCustomerTest() {
+ org.onap.aai.domain.yang.Customer mappedCustomer = new org.onap.aai.domain.yang.Customer();
+ mappedCustomer.setGlobalCustomerId(customer.getGlobalCustomerId());
+
+ doReturn(mappedCustomer).when(MOCK_aaiObjectMapper).mapCustomer(customer);
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Customer.class));
+
+ aaiVpnBindingResources.createCustomer(customer);
+
+ verify(MOCK_aaiResourcesClient, times(1)).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.Customer.class));
+ verify(MOCK_aaiObjectMapper, times(1)).mapCustomer(customer);
+ }
+
+ @Test
+ public void getVpnBindingTest() {
+ org.onap.aai.domain.yang.VpnBinding vpnBinding = new org.onap.aai.domain.yang.VpnBinding();
+ vpnBinding.setVpnId("vnfId");
+ when(MOCK_aaiResourcesClient.get(eq(org.onap.aai.domain.yang.VpnBinding.class), isA(AAIResourceUri.class)))
+ .thenReturn(Optional.of(vpnBinding));
+ aaiVpnBindingResources.getVpnBinding("vpnId");
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.VpnBinding.class),
+ isA(AAIResourceUri.class));
+ }
@Test
public void existsCustomerTest() {
- when(MOCK_aaiResourcesClient.exists(isA(AAIResourceUri.class))).thenReturn(true);
- boolean isCustomerExist = aaiVpnBindingResources.existsCustomer(customer);
- verify(MOCK_aaiResourcesClient, times(1)).exists(isA(AAIResourceUri.class));
- assertEquals(true,isCustomerExist);
- }
+ when(MOCK_aaiResourcesClient.exists(isA(AAIResourceUri.class))).thenReturn(true);
+ boolean isCustomerExist = aaiVpnBindingResources.existsCustomer(customer);
+ verify(MOCK_aaiResourcesClient, times(1)).exists(isA(AAIResourceUri.class));
+ assertEquals(true, isCustomerExist);
+ }
@Test
public void getVpnBindingByCustomerVpnIdTest() {
- when(MOCK_aaiResourcesClient.get(eq(VpnBindings.class),isA(AAIResourceUri.class))).thenReturn(Optional.of(new VpnBindings()));
- Optional<VpnBindings> vpnBindings = aaiVpnBindingResources.getVpnBindingByCustomerVpnId("testCustomerVpnId");
- assertNotNull(vpnBindings.get());
- verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.VpnBindings.class),isA(AAIResourceUri.class));
- }
-
- @Test
- public void createVpnBindingTest() {
- doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VpnBinding.class));
- org.onap.aai.domain.yang.VpnBinding mappedVpnBinding = new org.onap.aai.domain.yang.VpnBinding();
- mappedVpnBinding.setVpnName("test");
-
- doReturn(mappedVpnBinding).when(MOCK_aaiObjectMapper).mapVpnBinding(isA(VpnBinding.class));
- VpnBinding vpnBinding = buildVpnBinding();
- aaiVpnBindingResources.createVpnBinding(vpnBinding);
-
- verify(MOCK_aaiResourcesClient, times(1)).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VpnBinding.class));
- verify(MOCK_aaiObjectMapper, times(1)).mapVpnBinding(isA(VpnBinding.class));
- }
-
- @Test
- public void connectCustomerToVpnBinding() {
- doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- aaiVpnBindingResources.connectCustomerToVpnBinding("testCustId","testVpnId");
- verify(MOCK_aaiResourcesClient,times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- }
+ when(MOCK_aaiResourcesClient.get(eq(VpnBindings.class), isA(AAIResourceUri.class)))
+ .thenReturn(Optional.of(new VpnBindings()));
+ Optional<VpnBindings> vpnBindings = aaiVpnBindingResources.getVpnBindingByCustomerVpnId("testCustomerVpnId");
+ assertNotNull(vpnBindings.get());
+ verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.VpnBindings.class),
+ isA(AAIResourceUri.class));
+ }
+
+ @Test
+ public void createVpnBindingTest() {
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VpnBinding.class));
+ org.onap.aai.domain.yang.VpnBinding mappedVpnBinding = new org.onap.aai.domain.yang.VpnBinding();
+ mappedVpnBinding.setVpnName("test");
+
+ doReturn(mappedVpnBinding).when(MOCK_aaiObjectMapper).mapVpnBinding(isA(VpnBinding.class));
+ VpnBinding vpnBinding = buildVpnBinding();
+ aaiVpnBindingResources.createVpnBinding(vpnBinding);
+
+ verify(MOCK_aaiResourcesClient, times(1)).create(isA(AAIResourceUri.class),
+ isA(org.onap.aai.domain.yang.VpnBinding.class));
+ verify(MOCK_aaiObjectMapper, times(1)).mapVpnBinding(isA(VpnBinding.class));
+ }
+
+ @Test
+ public void connectCustomerToVpnBinding() {
+ doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+ aaiVpnBindingResources.connectCustomerToVpnBinding("testCustId", "testVpnId");
+ verify(MOCK_aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java
index 629e98abb2..195c89a651 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java
@@ -26,9 +26,7 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.List;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -49,57 +47,58 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class NamingServiceResourcesTest extends TestDataSetup{
- @InjectMocks
- private NamingServiceResources namingServiceResources = new NamingServiceResources();
-
- private InstanceGroup instanceGroup;
-
- @Mock
- protected NamingRequestObjectBuilder MOCK_namingRequestObjectBuilder;
-
- @Mock
- protected NamingClient MOCK_namingClient;
-
- @Before
- public void before() {
- instanceGroup = buildInstanceGroup();
- }
-
- @Test
- public void generateInstanceGroupNameTest() throws Exception {
- NameGenResponse name = new NameGenResponse();
- ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
- Element element = new Element();
-
- NameGenRequest req = new NameGenRequest();
- doReturn(element).when(MOCK_namingRequestObjectBuilder).elementMapper(isA(String.class), isA(String.class),
- isA(String.class), isA(String.class), isA(String.class));
- doReturn("generatedInstanceGroupName").when(MOCK_namingClient).postNameGenRequest(isA(NameGenRequest.class));
- doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenRequestMapper(isA(List.class));
-
- String generatedName = namingServiceResources.generateInstanceGroupName(instanceGroup, "policyInstanceName", "nfNamingCode");
-
- verify(MOCK_namingClient, times(1)).postNameGenRequest(any(NameGenRequest.class));
- assertEquals(generatedName, "generatedInstanceGroupName");
- }
-
- @Test
- public void deleteInstanceGroupNameTest() throws Exception {
- NameGenDeleteResponse name = new NameGenDeleteResponse();
- ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
- Deleteelement deleteElement = new Deleteelement();
- deleteElement.setExternalKey(instanceGroup.getId());
- NameGenDeleteRequest req = new NameGenDeleteRequest();
- doReturn(deleteElement).when(MOCK_namingRequestObjectBuilder).deleteElementMapper(isA(String.class));
- doReturn("").when(MOCK_namingClient).deleteNameGenRequest(isA(NameGenDeleteRequest.class));
- doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenDeleteRequestMapper(isA(List.class));
-
- namingServiceResources.deleteInstanceGroupName(instanceGroup);
-
- verify(MOCK_namingClient, times(1)).deleteNameGenRequest(any(NameGenDeleteRequest.class));
-
- }
-
-
+public class NamingServiceResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private NamingServiceResources namingServiceResources = new NamingServiceResources();
+
+ private InstanceGroup instanceGroup;
+
+ @Mock
+ protected NamingRequestObjectBuilder MOCK_namingRequestObjectBuilder;
+
+ @Mock
+ protected NamingClient MOCK_namingClient;
+
+ @Before
+ public void before() {
+ instanceGroup = buildInstanceGroup();
+ }
+
+ @Test
+ public void generateInstanceGroupNameTest() throws Exception {
+ NameGenResponse name = new NameGenResponse();
+ ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+ Element element = new Element();
+
+ NameGenRequest req = new NameGenRequest();
+ doReturn(element).when(MOCK_namingRequestObjectBuilder).elementMapper(isA(String.class), isA(String.class),
+ isA(String.class), isA(String.class), isA(String.class));
+ doReturn("generatedInstanceGroupName").when(MOCK_namingClient).postNameGenRequest(isA(NameGenRequest.class));
+ doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenRequestMapper(isA(List.class));
+
+ String generatedName =
+ namingServiceResources.generateInstanceGroupName(instanceGroup, "policyInstanceName", "nfNamingCode");
+
+ verify(MOCK_namingClient, times(1)).postNameGenRequest(any(NameGenRequest.class));
+ assertEquals(generatedName, "generatedInstanceGroupName");
+ }
+
+ @Test
+ public void deleteInstanceGroupNameTest() throws Exception {
+ NameGenDeleteResponse name = new NameGenDeleteResponse();
+ ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
+ Deleteelement deleteElement = new Deleteelement();
+ deleteElement.setExternalKey(instanceGroup.getId());
+ NameGenDeleteRequest req = new NameGenDeleteRequest();
+ doReturn(deleteElement).when(MOCK_namingRequestObjectBuilder).deleteElementMapper(isA(String.class));
+ doReturn("").when(MOCK_namingClient).deleteNameGenRequest(isA(NameGenDeleteRequest.class));
+ doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenDeleteRequestMapper(isA(List.class));
+
+ namingServiceResources.deleteInstanceGroupName(instanceGroup);
+
+ verify(MOCK_namingClient, times(1)).deleteNameGenRequest(any(NameGenDeleteRequest.class));
+
+ }
+
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NetworkAdapterResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NetworkAdapterResourcesTest.java
index 1ff9d2af2d..96e2a74297 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NetworkAdapterResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NetworkAdapterResourcesTest.java
@@ -26,13 +26,11 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -61,159 +59,182 @@ import org.onap.so.client.adapter.network.NetworkAdapterClientImpl;
import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.entity.MsoRequest;
-
import com.shazam.shazamcrest.matcher.Matchers;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class NetworkAdapterResourcesTest extends TestDataSetup{
-
- @InjectMocks
- private NetworkAdapterResources networkAdapterResources = new NetworkAdapterResources();
-
- @Mock
- protected NetworkAdapterClientImpl MOCK_networkAdapterClient;
-
- @Mock
- protected NetworkAdapterObjectMapper MOCK_networkAdapterObjectMapper;
-
- private L3Network l3Network;
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
- private Customer customer;
- Map<String, String> userInput;
-
- @Before
- public void before() {
- requestContext = buildRequestContext();
-
- customer = buildCustomer();
-
- serviceInstance = buildServiceInstance();
-
- cloudRegion = buildCloudRegion();
-
- orchestrationContext = buildOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- userInput = buildUserInput();
-
- l3Network = buildL3Network();
- }
-
- @Test
- public void createNetworTest() throws Exception {
- String cloudRegionPo = "cloudRegionPo";
- CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
-
- expectedCreateNetworkRequest.setCloudSiteId(cloudRegionPo);
- expectedCreateNetworkRequest.setTenantId(cloudRegion.getTenantId());
- expectedCreateNetworkRequest.setNetworkId(l3Network.getNetworkId());
- expectedCreateNetworkRequest.setNetworkName(l3Network.getNetworkName());
- expectedCreateNetworkRequest.setBackout(false);
- expectedCreateNetworkRequest.setFailIfExists(true);
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestContext.getMsoRequestId());
- msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
- expectedCreateNetworkRequest.setMsoRequest(msoRequest);
- expectedCreateNetworkRequest.setSkipAAI(true);
-
- Subnet openstackSubnet = new Subnet();
- HostRoute hostRoute = new HostRoute();
- hostRoute.setHostRouteId("hostRouteId");
- hostRoute.setNextHop("nextHop");
- hostRoute.setRoutePrefix("routePrefix");
- openstackSubnet.getHostRoutes().add(hostRoute);
- List<Subnet> subnetList = new ArrayList<Subnet>();
- subnetList.add(openstackSubnet);
- l3Network.getSubnets().add(openstackSubnet);
-
- l3Network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
- createNetworkRequest.setCloudSiteId("cloudSiteId");
-
- CreateNetworkResponse expectedCreateNetworkResponse = new CreateNetworkResponse();
- expectedCreateNetworkResponse.setNetworkStackId("networkStackId");
- expectedCreateNetworkResponse.setNetworkCreated(true);
-
-
- doReturn(expectedCreateNetworkResponse).when(MOCK_networkAdapterClient).createNetwork(isA(CreateNetworkRequest.class));
-
- doReturn(createNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(Customer.class));
-
- CreateNetworkResponse actualCreateNetwrokResponse = (networkAdapterResources.createNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer)).get();
-
- verify(MOCK_networkAdapterClient, times(1)).createNetwork(createNetworkRequest);
-
- verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
-
- assertThat(expectedCreateNetworkResponse, Matchers.sameBeanAs(actualCreateNetwrokResponse));
- }
-
- @Test
- public void rollbackCreateNetworkTest() throws Exception {
- String cloudRegionPo = "cloudRegionPo";
- RollbackNetworkResponse expectedRollbackNetworkResponse = new RollbackNetworkResponse();
- expectedRollbackNetworkResponse.setMessageId("messageId");
- expectedRollbackNetworkResponse.setNetworkRolledBack(true);
-
- RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest();
- rollbackNetworkRequest.setMessageId("messageId");
-
- RollbackNetworkResponse rollbackNetworkResponse = new RollbackNetworkResponse();
- rollbackNetworkResponse.setMessageId("messageId");
- rollbackNetworkResponse.setNetworkRolledBack(true);
-
- CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
- createNetworkResponse.setMessageId("messageId");
-
- doReturn(rollbackNetworkResponse).when(MOCK_networkAdapterClient).rollbackNetwork(isA(String.class), isA(RollbackNetworkRequest.class));
-
- doReturn(rollbackNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRollbackRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(CreateNetworkResponse.class));
-
- RollbackNetworkResponse actualRollbackCreateNetwrokResponse = (networkAdapterResources.rollbackCreateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse)).get();
-
- verify(MOCK_networkAdapterClient, times(1)).rollbackNetwork(l3Network.getNetworkId(), rollbackNetworkRequest);
-
- verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRollbackRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
-
- assertThat(expectedRollbackNetworkResponse, Matchers.sameBeanAs(actualRollbackCreateNetwrokResponse));
- }
-
- @Test
- public void updateNetworkTest() throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- doReturn(new UpdateNetworkRequest()).when(MOCK_networkAdapterObjectMapper).createNetworkUpdateRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(Customer.class));
-
- doReturn(new UpdateNetworkResponse()).when(MOCK_networkAdapterClient).updateNetwork(isA(String.class), isA(UpdateNetworkRequest.class));
-
- Optional<UpdateNetworkResponse> actualUpdateNetworkResponse = networkAdapterResources.updateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
-
-
- verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
- verify(MOCK_networkAdapterClient, times(1)).updateNetwork(isA(String.class), isA(UpdateNetworkRequest.class));
- assertNotNull(actualUpdateNetworkResponse);
- }
-
- @Test
- public void deleteNetwork_DeleteAction_Test() throws UnsupportedEncodingException, NetworkAdapterClientException {
-
- DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
- doReturn(deleteNetworkRequest).when(MOCK_networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
-
- DeleteNetworkResponse expectedDeleteNetworkResponse = new DeleteNetworkResponse();
-
- doReturn(expectedDeleteNetworkResponse).when(MOCK_networkAdapterClient).deleteNetwork(l3Network.getNetworkId(), deleteNetworkRequest);
-
- Optional<DeleteNetworkResponse> actualODeleteNetworkResponse = networkAdapterResources.deleteNetwork(requestContext, cloudRegion, serviceInstance, l3Network);
- DeleteNetworkResponse actualDeleteNetworkResponse = actualODeleteNetworkResponse.get();
-
- verify(MOCK_networkAdapterObjectMapper, times(1)).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
- verify(MOCK_networkAdapterClient, times(1)).deleteNetwork(l3Network.getNetworkId(), deleteNetworkRequest);
- assertThat(expectedDeleteNetworkResponse, Matchers.sameBeanAs(actualDeleteNetworkResponse));
- }
+public class NetworkAdapterResourcesTest extends TestDataSetup {
+
+ @InjectMocks
+ private NetworkAdapterResources networkAdapterResources = new NetworkAdapterResources();
+
+ @Mock
+ protected NetworkAdapterClientImpl MOCK_networkAdapterClient;
+
+ @Mock
+ protected NetworkAdapterObjectMapper MOCK_networkAdapterObjectMapper;
+
+ private L3Network l3Network;
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+ private Customer customer;
+ Map<String, String> userInput;
+
+ @Before
+ public void before() {
+ requestContext = buildRequestContext();
+
+ customer = buildCustomer();
+
+ serviceInstance = buildServiceInstance();
+
+ cloudRegion = buildCloudRegion();
+
+ orchestrationContext = buildOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ userInput = buildUserInput();
+
+ l3Network = buildL3Network();
+ }
+
+ @Test
+ public void createNetworTest() throws Exception {
+ String cloudRegionPo = "cloudRegionPo";
+ CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
+
+ expectedCreateNetworkRequest.setCloudSiteId(cloudRegionPo);
+ expectedCreateNetworkRequest.setTenantId(cloudRegion.getTenantId());
+ expectedCreateNetworkRequest.setNetworkId(l3Network.getNetworkId());
+ expectedCreateNetworkRequest.setNetworkName(l3Network.getNetworkName());
+ expectedCreateNetworkRequest.setBackout(false);
+ expectedCreateNetworkRequest.setFailIfExists(true);
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestContext.getMsoRequestId());
+ msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
+ expectedCreateNetworkRequest.setMsoRequest(msoRequest);
+ expectedCreateNetworkRequest.setSkipAAI(true);
+
+ Subnet openstackSubnet = new Subnet();
+ HostRoute hostRoute = new HostRoute();
+ hostRoute.setHostRouteId("hostRouteId");
+ hostRoute.setNextHop("nextHop");
+ hostRoute.setRoutePrefix("routePrefix");
+ openstackSubnet.getHostRoutes().add(hostRoute);
+ List<Subnet> subnetList = new ArrayList<Subnet>();
+ subnetList.add(openstackSubnet);
+ l3Network.getSubnets().add(openstackSubnet);
+
+ l3Network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
+ createNetworkRequest.setCloudSiteId("cloudSiteId");
+
+ CreateNetworkResponse expectedCreateNetworkResponse = new CreateNetworkResponse();
+ expectedCreateNetworkResponse.setNetworkStackId("networkStackId");
+ expectedCreateNetworkResponse.setNetworkCreated(true);
+
+
+ doReturn(expectedCreateNetworkResponse).when(MOCK_networkAdapterClient)
+ .createNetwork(isA(CreateNetworkRequest.class));
+
+ doReturn(createNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRequestMapper(
+ isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class),
+ isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class),
+ isA(Customer.class));
+
+ CreateNetworkResponse actualCreateNetwrokResponse =
+ (networkAdapterResources.createNetwork(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, l3Network, userInput, cloudRegionPo, customer)).get();
+
+ verify(MOCK_networkAdapterClient, times(1)).createNetwork(createNetworkRequest);
+
+ verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
+
+ assertThat(expectedCreateNetworkResponse, Matchers.sameBeanAs(actualCreateNetwrokResponse));
+ }
+
+ @Test
+ public void rollbackCreateNetworkTest() throws Exception {
+ String cloudRegionPo = "cloudRegionPo";
+ RollbackNetworkResponse expectedRollbackNetworkResponse = new RollbackNetworkResponse();
+ expectedRollbackNetworkResponse.setMessageId("messageId");
+ expectedRollbackNetworkResponse.setNetworkRolledBack(true);
+
+ RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest();
+ rollbackNetworkRequest.setMessageId("messageId");
+
+ RollbackNetworkResponse rollbackNetworkResponse = new RollbackNetworkResponse();
+ rollbackNetworkResponse.setMessageId("messageId");
+ rollbackNetworkResponse.setNetworkRolledBack(true);
+
+ CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
+ createNetworkResponse.setMessageId("messageId");
+
+ doReturn(rollbackNetworkResponse).when(MOCK_networkAdapterClient).rollbackNetwork(isA(String.class),
+ isA(RollbackNetworkRequest.class));
+
+ doReturn(rollbackNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRollbackRequestMapper(
+ isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class),
+ isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class),
+ isA(CreateNetworkResponse.class));
+
+ RollbackNetworkResponse actualRollbackCreateNetwrokResponse =
+ (networkAdapterResources.rollbackCreateNetwork(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse)).get();
+
+ verify(MOCK_networkAdapterClient, times(1)).rollbackNetwork(l3Network.getNetworkId(), rollbackNetworkRequest);
+
+ verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRollbackRequestMapper(requestContext,
+ cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo,
+ createNetworkResponse);
+
+ assertThat(expectedRollbackNetworkResponse, Matchers.sameBeanAs(actualRollbackCreateNetwrokResponse));
+ }
+
+ @Test
+ public void updateNetworkTest() throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ doReturn(new UpdateNetworkRequest()).when(MOCK_networkAdapterObjectMapper).createNetworkUpdateRequestMapper(
+ isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class),
+ isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(Customer.class));
+
+ doReturn(new UpdateNetworkResponse()).when(MOCK_networkAdapterClient).updateNetwork(isA(String.class),
+ isA(UpdateNetworkRequest.class));
+
+ Optional<UpdateNetworkResponse> actualUpdateNetworkResponse = networkAdapterResources.updateNetwork(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
+
+
+ verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, l3Network, userInput, customer);
+ verify(MOCK_networkAdapterClient, times(1)).updateNetwork(isA(String.class), isA(UpdateNetworkRequest.class));
+ assertNotNull(actualUpdateNetworkResponse);
+ }
+
+ @Test
+ public void deleteNetwork_DeleteAction_Test() throws UnsupportedEncodingException, NetworkAdapterClientException {
+
+ DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
+ doReturn(deleteNetworkRequest).when(MOCK_networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext,
+ cloudRegion, serviceInstance, l3Network);
+
+ DeleteNetworkResponse expectedDeleteNetworkResponse = new DeleteNetworkResponse();
+
+ doReturn(expectedDeleteNetworkResponse).when(MOCK_networkAdapterClient).deleteNetwork(l3Network.getNetworkId(),
+ deleteNetworkRequest);
+
+ Optional<DeleteNetworkResponse> actualODeleteNetworkResponse =
+ networkAdapterResources.deleteNetwork(requestContext, cloudRegion, serviceInstance, l3Network);
+ DeleteNetworkResponse actualDeleteNetworkResponse = actualODeleteNetworkResponse.get();
+
+ verify(MOCK_networkAdapterObjectMapper, times(1)).deleteNetworkRequestMapper(requestContext, cloudRegion,
+ serviceInstance, l3Network);
+ verify(MOCK_networkAdapterClient, times(1)).deleteNetwork(l3Network.getNetworkId(), deleteNetworkRequest);
+ assertThat(expectedDeleteNetworkResponse, Matchers.sameBeanAs(actualDeleteNetworkResponse));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java
index 0023066949..9049fe1965 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java
@@ -24,10 +24,8 @@ import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
-
import java.net.URI;
import java.net.URISyntaxException;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -50,17 +48,17 @@ import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class SDNCConfigurationResourcesTest extends TestDataSetup{
-
- @InjectMocks
+public class SDNCConfigurationResourcesTest extends TestDataSetup {
+
+ @InjectMocks
private SDNCConfigurationResources sdncConfigurationResources = new SDNCConfigurationResources();
-
- @Mock
- private GCTopologyOperationRequestMapper MOCK_gcTopologyMapper ;
-
- @Mock
- protected SDNCClient MOCK_sdncClient;
-
+
+ @Mock
+ private GCTopologyOperationRequestMapper MOCK_gcTopologyMapper;
+
+ @Mock
+ protected SDNCClient MOCK_sdncClient;
+
private RequestContext requestContext;
private ServiceInstance serviceInstance;
private VpnBondingLink vpnBondingLink;
@@ -68,45 +66,55 @@ public class SDNCConfigurationResourcesTest extends TestDataSetup{
private Customer customer;
@Before
- public void setUp(){
- customer = buildCustomer();
+ public void setUp() {
+ customer = buildCustomer();
requestContext = buildRequestContext();
serviceInstance = buildServiceInstance();
- vpnBondingLink = buildVpnBondingLink();
+ vpnBondingLink = buildVpnBondingLink();
vnf = vpnBondingLink.getInfrastructureServiceProxy().getServiceInstance().getVnfs().get(0);
}
@Test
public void activateVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
- GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.activateVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf,"uuid",new URI("http://localhost"));
- verify(MOCK_gcTopologyMapper).assignOrActivateVnrReqMapper(
- eq(SDNCSvcAction.ACTIVATE), eq(GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE),
- eq(serviceInstance), eq(requestContext), eq(customer), any(Configuration.class), any(GenericVnf.class), any(String.class), any(URI.class));
+ GenericResourceApiGcTopologyOperationInformation response =
+ sdncConfigurationResources.activateVnrConfiguration(serviceInstance, requestContext, customer,
+ vpnBondingLink.getVnrConfiguration(), vnf, "uuid", new URI("http://localhost"));
+ verify(MOCK_gcTopologyMapper).assignOrActivateVnrReqMapper(eq(SDNCSvcAction.ACTIVATE),
+ eq(GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE), eq(serviceInstance),
+ eq(requestContext), eq(customer), any(Configuration.class), any(GenericVnf.class), any(String.class),
+ any(URI.class));
}
@Test
public void assignVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
- GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.assignVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf,"uuid",new URI("http://localhost"));
- verify(MOCK_gcTopologyMapper).assignOrActivateVnrReqMapper(
- eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE),
- eq(serviceInstance), eq(requestContext), eq(customer), any(Configuration.class), any(GenericVnf.class), any(String.class), any(URI.class));
+ GenericResourceApiGcTopologyOperationInformation response =
+ sdncConfigurationResources.assignVnrConfiguration(serviceInstance, requestContext, customer,
+ vpnBondingLink.getVnrConfiguration(), vnf, "uuid", new URI("http://localhost"));
+ verify(MOCK_gcTopologyMapper).assignOrActivateVnrReqMapper(eq(SDNCSvcAction.ASSIGN),
+ eq(GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE), eq(serviceInstance),
+ eq(requestContext), eq(customer), any(Configuration.class), any(GenericVnf.class), any(String.class),
+ any(URI.class));
}
@Test
- public void unAssignVnrConfigurationTest() throws BadResponseException, MapperException , URISyntaxException{
- GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.unAssignVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration(),"uuid",new URI("http://localhost"));
- verify(MOCK_gcTopologyMapper).deactivateOrUnassignVnrReqMapper(
- eq(SDNCSvcAction.UNASSIGN), eq(serviceInstance), eq(requestContext), any(Configuration.class), any(String.class), any(URI.class));
+ public void unAssignVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
+ GenericResourceApiGcTopologyOperationInformation response =
+ sdncConfigurationResources.unAssignVnrConfiguration(serviceInstance, requestContext,
+ vpnBondingLink.getVnrConfiguration(), "uuid", new URI("http://localhost"));
+ verify(MOCK_gcTopologyMapper).deactivateOrUnassignVnrReqMapper(eq(SDNCSvcAction.UNASSIGN), eq(serviceInstance),
+ eq(requestContext), any(Configuration.class), any(String.class), any(URI.class));
}
@Test
- public void deactivateVnrConfigurationTest() throws BadResponseException, MapperException , URISyntaxException{
- GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.deactivateVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration(),"uuid",new URI("http://localhost"));
- verify(MOCK_gcTopologyMapper).deactivateOrUnassignVnrReqMapper(
- eq(SDNCSvcAction.DEACTIVATE), eq(serviceInstance), eq(requestContext), any(Configuration.class), any(String.class), any(URI.class));
+ public void deactivateVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
+ GenericResourceApiGcTopologyOperationInformation response =
+ sdncConfigurationResources.deactivateVnrConfiguration(serviceInstance, requestContext,
+ vpnBondingLink.getVnrConfiguration(), "uuid", new URI("http://localhost"));
+ verify(MOCK_gcTopologyMapper).deactivateOrUnassignVnrReqMapper(eq(SDNCSvcAction.DEACTIVATE),
+ eq(serviceInstance), eq(requestContext), any(Configuration.class), any(String.class), any(URI.class));
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java
index f275f3c484..327bae5749 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java
@@ -23,7 +23,6 @@ package org.onap.so.client.orchestration;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,122 +47,122 @@ import org.onap.so.client.sdnc.mapper.NetworkTopologyOperationRequestMapper;
@RunWith(MockitoJUnitRunner.Silent.class)
public class SDNCNetworkResourcesTest extends TestDataSetup {
- @InjectMocks
- private SDNCNetworkResources sdncNetworkResources;
-
- @Mock
- protected SDNCClient MOCK_sdncClient;
-
- @Mock
- protected NetworkTopologyOperationRequestMapper MOCK_networkTopologyOperationRequestMapper;
-
- private L3Network network;
- private ServiceInstance serviceInstance;
- private Customer customer;
- private RequestContext requestContext;
- private CloudRegion cloudRegion;
-
- @Before
- public void before() {
- network = buildL3Network();
-
- customer = buildCustomer();
-
- serviceInstance = buildServiceInstance();
-
- requestContext = buildRequestContext();
-
- cloudRegion = new CloudRegion();
- }
-
- @Test
- public void assignNetworkTest() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-
- @Test
- public void rollbackAssignNetworkTest() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.rollbackAssignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-
- @Test
- public void activateNetworkTest() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.activateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-
- @Test
- public void deleteNetworkTest() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.deleteNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-
- @Test
- public void test_deactivateNetwork() throws MapperException, BadResponseException {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-
- @Test
- public void changeAssignNetworkTest() throws MapperException, BadResponseException {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.changeAssignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
- GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-
- @Test
- public void unassignNetwork_Test() throws Exception {
- doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
- .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
- customer, requestContext, cloudRegion);
- sdncNetworkResources.unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
- GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
- }
-} \ No newline at end of file
+ @InjectMocks
+ private SDNCNetworkResources sdncNetworkResources;
+
+ @Mock
+ protected SDNCClient MOCK_sdncClient;
+
+ @Mock
+ protected NetworkTopologyOperationRequestMapper MOCK_networkTopologyOperationRequestMapper;
+
+ private L3Network network;
+ private ServiceInstance serviceInstance;
+ private Customer customer;
+ private RequestContext requestContext;
+ private CloudRegion cloudRegion;
+
+ @Before
+ public void before() {
+ network = buildL3Network();
+
+ customer = buildCustomer();
+
+ serviceInstance = buildServiceInstance();
+
+ requestContext = buildRequestContext();
+
+ cloudRegion = new CloudRegion();
+ }
+
+ @Test
+ public void assignNetworkTest() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+
+ @Test
+ public void rollbackAssignNetworkTest() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.rollbackAssignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+
+ @Test
+ public void activateNetworkTest() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.activateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+
+ @Test
+ public void deleteNetworkTest() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.deleteNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DELETE,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+
+ @Test
+ public void test_deactivateNetwork() throws MapperException, BadResponseException {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+
+ @Test
+ public void changeAssignNetworkTest() throws MapperException, BadResponseException {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.changeAssignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+
+ @Test
+ public void unassignNetwork_Test() throws Exception {
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(MOCK_networkTopologyOperationRequestMapper)
+ .reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+ sdncNetworkResources.unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
+ verify(MOCK_networkTopologyOperationRequestMapper, times(1)).reqMapper(
+ SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
+ requestContext, cloudRegion);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java
index 509dc1de0d..ad05ac0072 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,84 +45,121 @@ import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class SDNCServiceInstanceResourcesTest extends TestDataSetup{
-
- @InjectMocks
+public class SDNCServiceInstanceResourcesTest extends TestDataSetup {
+
+ @InjectMocks
private SDNCServiceInstanceResources sdncServiceInstanceResources;
- @Mock
- protected ServiceTopologyOperationMapper MOCK_serviceTopologyOperationMapper;
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private Customer customer;
-
- @Before
- public void before() {
- requestContext = buildRequestContext();
- serviceInstance = buildServiceInstance();
- customer = buildCustomer();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- }
-
- @Test
- public void assignServiceInstanceSuccessTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
-
- @Test
- public void assignServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
- }
-
- @Test
- public void deleteServiceInstanceSuccessTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
-
- @Test
- public void deleteServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
- }
-
- @Test
- public void unassignServiceInstanceSuccessTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.unassignServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
-
- @Test
- public void unassignServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.unassignServiceInstance(serviceInstance,customer, requestContext);
- }
+ @Mock
+ protected ServiceTopologyOperationMapper MOCK_serviceTopologyOperationMapper;
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private Customer customer;
+
+ @Before
+ public void before() {
+ requestContext = buildRequestContext();
+ serviceInstance = buildServiceInstance();
+ customer = buildCustomer();
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ }
+
+ @Test
+ public void assignServiceInstanceSuccessTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN),
+ eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
+
+ @Test
+ public void assignServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(
+ eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN),
+ eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class),
+ any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
+ }
+
+ @Test
+ public void deleteServiceInstanceSuccessTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
+
+ @Test
+ public void deleteServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(
+ eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class),
+ any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
+ }
+
+ @Test
+ public void unassignServiceInstanceSuccessTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.unassignServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
+
+ @Test
+ public void unassignServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(
+ eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class),
+ any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.unassignServiceInstance(serviceInstance, customer, requestContext);
+ }
+
+ @Test
+ public void deactivateServiceInstanceSuccessTest() throws Exception {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
- @Test
- public void deactivateServiceInstanceSuccessTest() throws Exception {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
-
- @Test
- public void deactivateServiceInstanceExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
- }
+ @Test
+ public void deactivateServiceInstanceExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_serviceTopologyOperationMapper).reqMapper(
+ eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),
+ eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class),
+ any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.deactivateServiceInstance(serviceInstance, customer, requestContext);
+ }
- @Test
- public void test_changeModelServiceInstance() throws MapperException, BadResponseException {
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- }
+ @Test
+ public void test_changeModelServiceInstance() throws MapperException, BadResponseException {
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper)
+ .reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.CHANGE_ASSIGN),
+ eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, customer, requestContext);
+ verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE),
+ any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java
index 7d05758129..2b45a3302c 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java
@@ -23,7 +23,6 @@ package org.onap.so.client.orchestration;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,77 +45,87 @@ import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper;;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class SDNCVfModuleResourcesTest extends TestDataSetup{
+public class SDNCVfModuleResourcesTest extends TestDataSetup {
+
+ @InjectMocks
+ private SDNCVfModuleResources sdncVfModuleResources;
+
+ @Mock
+ protected VfModuleTopologyOperationRequestMapper vfModuleTopologyMapper;
+
+ private VfModule vfModule;
+ private GenericVnf vnf;
+ private ServiceInstance serviceInstance;
+ private VolumeGroup volumeGroup;
+ private Customer customer;
+ private CloudRegion cloudRegion;
+ private RequestContext requestContext;
+ private GenericResourceApiVfModuleOperationInformation sdncReq;
+
+ @Before
+ public void before() {
+ vfModule = buildVfModule();
+ vnf = buildGenericVnf();
+ serviceInstance = buildServiceInstance();
+ volumeGroup = buildVolumeGroup();
+ customer = buildCustomer();
+ cloudRegion = buildCloudRegion();
+ requestContext = buildRequestContext();
+ sdncReq = new GenericResourceApiVfModuleOperationInformation();
+ }
+
+ @Test
+ public void assignVfModuleTest() throws MapperException {
+ doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion,
+ requestContext, null);
+ sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion,
+ requestContext);
+ verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion,
+ requestContext, null);
+ }
+
+ @Test
+ public void unassignVfModuleTest() throws MapperException {
+ doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null, null, null, null);
+ sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance);
+ verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null, null, null, null);
+ }
+
+ @Test
+ public void activateVfModuleTest() throws MapperException {
+ doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.ACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext,
+ null);
+ sdncVfModuleResources.activateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.ACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext,
+ null);
+ }
+
+ @Test
+ public void deactivateVfModuleTest() throws MapperException {
+ doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.DEACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext,
+ null);
+ sdncVfModuleResources.deactivateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.DEACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext,
+ null);
+ }
- @InjectMocks
- private SDNCVfModuleResources sdncVfModuleResources;
-
- @Mock
- protected VfModuleTopologyOperationRequestMapper vfModuleTopologyMapper;
-
- private VfModule vfModule;
- private GenericVnf vnf;
- private ServiceInstance serviceInstance;
- private VolumeGroup volumeGroup;
- private Customer customer;
- private CloudRegion cloudRegion;
- private RequestContext requestContext;
- private GenericResourceApiVfModuleOperationInformation sdncReq;
-
- @Before
- public void before() {
- vfModule = buildVfModule();
- vnf = buildGenericVnf();
- serviceInstance = buildServiceInstance();
- volumeGroup = buildVolumeGroup();
- customer = buildCustomer();
- cloudRegion = buildCloudRegion();
- requestContext = buildRequestContext();
- sdncReq = new GenericResourceApiVfModuleOperationInformation();
- }
-
- @Test
- public void assignVfModuleTest() throws MapperException {
- doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule,
- volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule,
- volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- }
-
- @Test
- public void unassignVfModuleTest() throws MapperException {
- doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null,
- vnf, serviceInstance, null, null, null, null);
- sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance);
- verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null,
- vnf, serviceInstance, null, null, null, null);
- }
-
- @Test
- public void activateVfModuleTest() throws MapperException {
- doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null,
- vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- sdncVfModuleResources.activateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null,
- vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- }
-
- @Test
- public void deactivateVfModuleTest() throws MapperException {
- doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null,
- vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- sdncVfModuleResources.deactivateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null,
- vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- }
-
- @Test
- public void changeAssignVfModuleTest() throws MapperException, BadResponseException {
- doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule,
- null, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- sdncVfModuleResources.changeAssignVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule,
- null, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
- }
+ @Test
+ public void changeAssignVfModuleTest() throws MapperException, BadResponseException {
+ doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.CHANGE_ASSIGN, vfModule, null, vnf, serviceInstance, customer, cloudRegion,
+ requestContext, null);
+ sdncVfModuleResources.changeAssignVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion,
+ requestContext);
+ verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION,
+ SDNCSvcAction.CHANGE_ASSIGN, vfModule, null, vnf, serviceInstance, customer, cloudRegion,
+ requestContext, null);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java
index 9bbf790ecb..4c0e2b873f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -51,103 +50,148 @@ import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class SDNCVnfResourcesTest extends TestDataSetup{
- @InjectMocks
- private SDNCVnfResources sdncVnfResources;
-
- @Mock
- protected VnfTopologyOperationRequestMapper MOCK_vnfTopologyOperationRequestMapper;
-
- @Mock
- protected SDNCClient MOCK_sdncClient;
-
- private GenericVnf genericVnf;
- private ServiceInstance serviceInstance;
- private Customer customer;
- private CloudRegion cloudRegion;
- private RequestContext requestContext;
- private GenericResourceApiVnfOperationInformation sdncReq;
-
- @Before
- public void before() {
- serviceInstance = buildServiceInstance();
- genericVnf = buildGenericVnf();
- customer = buildCustomer();
- cloudRegion = buildCloudRegion();
- requestContext = buildRequestContext();
- sdncReq = new GenericResourceApiVnfOperationInformation();
- }
-
- @Test
- public void assignVnfTest() {
- doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- sdncVnfResources.assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- }
-
- @Test
- public void activateVnfTest() {
- doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- sdncVnfResources.activateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- }
-
- @Test
- public void deleteVnfTest() {
- doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- sdncVnfResources.deleteVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- }
-
- @Test
- public void queryVnfTest() throws MapperException, BadResponseException {
- doReturn("test").when(MOCK_sdncClient).get(isA(String.class));
- genericVnf.setSelflink("testSelflink");
- sdncVnfResources.queryVnf(genericVnf);
- verify(MOCK_sdncClient, times(1)).get(isA(String.class));
- }
-
- @Test
- public void queryVnfWithResourcePrefixTest() throws MapperException, BadResponseException {
- doReturn("test").when(MOCK_sdncClient).get(isA(String.class));
- genericVnf.setSelflink("restconf/test:testSelflink");
- sdncVnfResources.queryVnf(genericVnf);
- verify(MOCK_sdncClient, times(1)).get(isA(String.class));
- }
-
- @Test
- public void changeModelVnfTest() {
- doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
- sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
- }
-
- @Test
- public void deactivateVnfSuccessTest() {
- doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean());
- sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean());
-
- }
-
- @Test
- public void deactivateVnfExceptionTest() {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean());
- sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- }
-
- @Test
- public void unassignVnfSuccessTest() throws Exception {
- doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean());
- sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean());
- }
-
- @Test
- public void unassignVnfExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- doThrow(Exception.class).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),any(RequestContext.class), anyBoolean());
- sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- }
+public class SDNCVnfResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private SDNCVnfResources sdncVnfResources;
+
+ @Mock
+ protected VnfTopologyOperationRequestMapper MOCK_vnfTopologyOperationRequestMapper;
+
+ @Mock
+ protected SDNCClient MOCK_sdncClient;
+
+ private GenericVnf genericVnf;
+ private ServiceInstance serviceInstance;
+ private Customer customer;
+ private CloudRegion cloudRegion;
+ private RequestContext requestContext;
+ private GenericResourceApiVnfOperationInformation sdncReq;
+
+ @Before
+ public void before() {
+ serviceInstance = buildServiceInstance();
+ genericVnf = buildGenericVnf();
+ customer = buildCustomer();
+ cloudRegion = buildCloudRegion();
+ requestContext = buildRequestContext();
+ sdncReq = new GenericResourceApiVnfOperationInformation();
+ }
+
+ @Test
+ public void assignVnfTest() {
+ doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ }
+
+ @Test
+ public void activateVnfTest() {
+ doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.activateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ }
+
+ @Test
+ public void deleteVnfTest() {
+ doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.deleteVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ }
+
+ @Test
+ public void queryVnfTest() throws MapperException, BadResponseException {
+ doReturn("test").when(MOCK_sdncClient).get(isA(String.class));
+ genericVnf.setSelflink("testSelflink");
+ sdncVnfResources.queryVnf(genericVnf);
+ verify(MOCK_sdncClient, times(1)).get(isA(String.class));
+ }
+
+ @Test
+ public void queryVnfWithResourcePrefixTest() throws MapperException, BadResponseException {
+ doReturn("test").when(MOCK_sdncClient).get(isA(String.class));
+ genericVnf.setSelflink("restconf/test:testSelflink");
+ sdncVnfResources.queryVnf(genericVnf);
+ verify(MOCK_sdncClient, times(1)).get(isA(String.class));
+ }
+
+ @Test
+ public void changeModelVnfTest() {
+ doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class),
+ isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class),
+ isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
+ SDNCSvcAction.CHANGE_ASSIGN, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, genericVnf,
+ serviceInstance, customer, cloudRegion, requestContext, false);
+ }
+
+ @Test
+ public void deactivateVnfSuccessTest() {
+ doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(
+ eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),
+ isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),
+ any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.DEACTIVATE), isA(GenericResourceApiRequestActionEnumeration.class),
+ any(GenericVnf.class), any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),
+ any(RequestContext.class), anyBoolean());
+
+ }
+
+ @Test
+ public void deactivateVnfExceptionTest() {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(
+ eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE),
+ isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),
+ any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ }
+
+ @Test
+ public void unassignVnfSuccessTest() throws Exception {
+ doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(
+ eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),
+ isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),
+ any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION),
+ eq(SDNCSvcAction.UNASSIGN), isA(GenericResourceApiRequestActionEnumeration.class),
+ any(GenericVnf.class), any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class),
+ any(RequestContext.class), anyBoolean());
+ }
+
+ @Test
+ public void unassignVnfExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ doThrow(Exception.class).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(
+ eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN),
+ isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class),
+ any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class),
+ anyBoolean());
+ sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java
index 46d87c7ca3..265bb5d3b5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java
@@ -24,9 +24,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.ArgumentMatchers.any;
-
import java.util.UUID;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,29 +38,29 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.client.sdno.SDNOValidator;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class SDNOHealthCheckResourcesTest extends TestDataSetup{
- @InjectMocks
- private SDNOHealthCheckResources sdnoHealthCheckResources = new SDNOHealthCheckResources();
-
- private GenericVnf genericVnf;
- private RequestContext requestContext;
-
- @Mock
- protected SDNOValidator MOCK_sdnoValidator;
-
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
-
- @Before
- public void before() {
- genericVnf = buildGenericVnf();
- requestContext = buildRequestContext();
- doReturn(MOCK_sdnoValidator).when(MOCK_injectionHelper).getSdnoValidator();
- }
-
- @Test
- public void healthCheckTest() throws Exception {
- doReturn(true).when(MOCK_sdnoValidator).healthDiagnostic(any(String.class), any(UUID.class), any(String.class));
- assertTrue(sdnoHealthCheckResources.healthCheck(genericVnf, requestContext));
- }
+public class SDNOHealthCheckResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private SDNOHealthCheckResources sdnoHealthCheckResources = new SDNOHealthCheckResources();
+
+ private GenericVnf genericVnf;
+ private RequestContext requestContext;
+
+ @Mock
+ protected SDNOValidator MOCK_sdnoValidator;
+
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
+
+ @Before
+ public void before() {
+ genericVnf = buildGenericVnf();
+ requestContext = buildRequestContext();
+ doReturn(MOCK_sdnoValidator).when(MOCK_injectionHelper).getSdnoValidator();
+ }
+
+ @Test
+ public void healthCheckTest() throws Exception {
+ doReturn(true).when(MOCK_sdnoValidator).healthDiagnostic(any(String.class), any(UUID.class), any(String.class));
+ assertTrue(sdnoHealthCheckResources.healthCheck(genericVnf, requestContext));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResourcesTest.java
index 2de4f11801..4cebd2cde5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResourcesTest.java
@@ -26,7 +26,6 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,94 +47,102 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.so.client.adapter.vnf.mapper.VnfAdapterVfModuleObjectMapper;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class VnfAdapterVfModuleResourcesTest extends TestDataSetup{
- @InjectMocks
- private VnfAdapterVfModuleResources vnfAdapterVfModuleResources = new VnfAdapterVfModuleResources();
-
- @Mock
- protected VnfAdapterVfModuleObjectMapper MOCK_vnfAdapterVfModuleObjectMapper;
-
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private ModelInfoServiceInstance modelInfoServiceInstance;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private VolumeGroup volumeGroup;
- private ModelInfoVfModule modelInfoVfModule;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
- private CreateVfModuleRequest createVfModuleRequest;
- private String sdncVnfQueryResponse;
- private String sdncVfModuleQueryResponse;
- private DeleteVfModuleRequest deleteVfModuleRequest;
-
- @Before
- public void before() {
- requestContext = buildRequestContext();
-
- serviceInstance = buildServiceInstance();
-
- genericVnf = buildGenericVnf();
-
- vfModule = buildVfModule();
-
- cloudRegion = buildCloudRegion();
-
- orchestrationContext = buildOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
-
- sdncVnfQueryResponse = new String();
- sdncVfModuleQueryResponse = new String();
-
- createVfModuleRequest = new CreateVfModuleRequest();
- createVfModuleRequest.setCloudSiteId("cloudSiteId");
-
- deleteVfModuleRequest = new DeleteVfModuleRequest();
- deleteVfModuleRequest.setCloudSiteId("cloudSiteId");
- }
-
- @Test
- public void test_createVfModule() throws Exception {
- doReturn(createVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- CreateVfModuleRequest actualCreateVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- assertNotNull(createVfModuleRequest);
- assertNotNull(actualCreateVfModuleRequest);
- assertEquals(createVfModuleRequest, actualCreateVfModuleRequest);
- }
-
- @Test
- public void test_createVfModuleWithVolumeGroup() throws Exception {
- volumeGroup = buildVolumeGroup();
- doReturn(createVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- CreateVfModuleRequest actualCreateVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance,
- genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
-
- assertNotNull(createVfModuleRequest);
- assertNotNull(actualCreateVfModuleRequest);
- assertEquals(createVfModuleRequest, actualCreateVfModuleRequest);
- }
-
- @Test
- public void test_deleteVfModule() throws Exception {
- doReturn(deleteVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).deleteVfModuleRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(ServiceInstance.class),
- isA(GenericVnf.class), isA(VfModule.class));
-
- DeleteVfModuleRequest actualDeleteVfModuleRequest = vnfAdapterVfModuleResources.deleteVfModuleRequest(requestContext, cloudRegion, serviceInstance,
- genericVnf, vfModule);
-
- verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).deleteVfModuleRequestMapper(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
- assertEquals(deleteVfModuleRequest, actualDeleteVfModuleRequest);
- }
+public class VnfAdapterVfModuleResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private VnfAdapterVfModuleResources vnfAdapterVfModuleResources = new VnfAdapterVfModuleResources();
+
+ @Mock
+ protected VnfAdapterVfModuleObjectMapper MOCK_vnfAdapterVfModuleObjectMapper;
+
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private ModelInfoServiceInstance modelInfoServiceInstance;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private VolumeGroup volumeGroup;
+ private ModelInfoVfModule modelInfoVfModule;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+ private CreateVfModuleRequest createVfModuleRequest;
+ private String sdncVnfQueryResponse;
+ private String sdncVfModuleQueryResponse;
+ private DeleteVfModuleRequest deleteVfModuleRequest;
+
+ @Before
+ public void before() {
+ requestContext = buildRequestContext();
+
+ serviceInstance = buildServiceInstance();
+
+ genericVnf = buildGenericVnf();
+
+ vfModule = buildVfModule();
+
+ cloudRegion = buildCloudRegion();
+
+ orchestrationContext = buildOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+
+ sdncVnfQueryResponse = new String();
+ sdncVfModuleQueryResponse = new String();
+
+ createVfModuleRequest = new CreateVfModuleRequest();
+ createVfModuleRequest.setCloudSiteId("cloudSiteId");
+
+ deleteVfModuleRequest = new DeleteVfModuleRequest();
+ deleteVfModuleRequest.setCloudSiteId("cloudSiteId");
+ }
+
+ @Test
+ public void test_createVfModule() throws Exception {
+ doReturn(createVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).createVfModuleRequestMapper(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, null,
+ sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+ CreateVfModuleRequest actualCreateVfModuleRequest =
+ vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext,
+ serviceInstance, genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+ verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).createVfModuleRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, vfModule, null, sdncVnfQueryResponse,
+ sdncVfModuleQueryResponse);
+
+ assertNotNull(createVfModuleRequest);
+ assertNotNull(actualCreateVfModuleRequest);
+ assertEquals(createVfModuleRequest, actualCreateVfModuleRequest);
+ }
+
+ @Test
+ public void test_createVfModuleWithVolumeGroup() throws Exception {
+ volumeGroup = buildVolumeGroup();
+ doReturn(createVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).createVfModuleRequestMapper(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup,
+ sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+ CreateVfModuleRequest actualCreateVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup,
+ sdncVnfQueryResponse, sdncVfModuleQueryResponse);
+
+ verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).createVfModuleRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse,
+ sdncVfModuleQueryResponse);
+
+ assertNotNull(createVfModuleRequest);
+ assertNotNull(actualCreateVfModuleRequest);
+ assertEquals(createVfModuleRequest, actualCreateVfModuleRequest);
+ }
+
+ @Test
+ public void test_deleteVfModule() throws Exception {
+ doReturn(deleteVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).deleteVfModuleRequestMapper(
+ isA(RequestContext.class), isA(CloudRegion.class), isA(ServiceInstance.class), isA(GenericVnf.class),
+ isA(VfModule.class));
+
+ DeleteVfModuleRequest actualDeleteVfModuleRequest = vnfAdapterVfModuleResources
+ .deleteVfModuleRequest(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
+
+ verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).deleteVfModuleRequestMapper(requestContext, cloudRegion,
+ serviceInstance, genericVnf, vfModule);
+ assertEquals(deleteVfModuleRequest, actualDeleteVfModuleRequest);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResourcesTest.java
index b1812a3da9..b23c5bca87 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResourcesTest.java
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,74 +45,81 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.client.adapter.vnf.VnfVolumeAdapterClientImpl;
import org.onap.so.client.adapter.vnf.mapper.VnfAdapterObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-
import com.shazam.shazamcrest.matcher.Matchers;
@RunWith(MockitoJUnitRunner.Silent.class)
-public class VnfAdapterVolumeGroupResourcesTest extends TestDataSetup {
- @InjectMocks
- private VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
-
- @Mock
- protected VnfAdapterObjectMapper MOCK_vnfAdapterObjectMapper;
-
- @Mock
- protected VnfVolumeAdapterClientImpl MOCK_vnfVolumeAdapterClient;
-
- private RequestContext requestContext;
- private ServiceInstance serviceInstance;
- private GenericVnf genericVnf;
- private VfModule vfModule;
- private VolumeGroup volumeGroup;
- private CloudRegion cloudRegion;
- private OrchestrationContext orchestrationContext;
-
- @Before
- public void before() {
- requestContext = buildRequestContext();
- serviceInstance = buildServiceInstance();
- genericVnf = buildGenericVnf();
- serviceInstance.getVnfs().add(genericVnf);
- vfModule = buildVfModule();
- genericVnf.getVfModules().add(vfModule);
- volumeGroup = buildVolumeGroup();
- serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
- cloudRegion = buildCloudRegion();
- orchestrationContext = buildOrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(true);
- }
-
- @Test
- public void test_createVolumeGroup() throws Exception {
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- CreateVolumeGroupRequest createVolumeGroupRequest = new CreateVolumeGroupRequest();
- createVolumeGroupRequest.setCloudSiteId("cloudSiteId");
-
- CreateVolumeGroupResponse expectedCreateVolumeGroupResponse = new CreateVolumeGroupResponse();
- expectedCreateVolumeGroupResponse.setVolumeGroupStackId("volumeGroupStackId");
- expectedCreateVolumeGroupResponse.setVolumeGroupCreated(true);
-
- String sdncVfModuleQueryResponse = "sdncVfModuleQueryResponse";
-
- doReturn(createVolumeGroupRequest).when(MOCK_vnfAdapterObjectMapper).createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
-
- CreateVolumeGroupRequest actualCreateVolumeGroupResponse = vnfAdapterVolumeGroupResources.createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
-
- verify(MOCK_vnfAdapterObjectMapper, times(1)).createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
-
- assertThat(createVolumeGroupRequest, Matchers.sameBeanAs(actualCreateVolumeGroupResponse));
- }
-
- @Test
- public void test_deleteVolumeGroup() throws Exception {
- DeleteVolumeGroupRequest deleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
- doReturn(deleteVolumeGroupRequest).when(MOCK_vnfAdapterObjectMapper).deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance, volumeGroup);
-
- DeleteVolumeGroupRequest expectedDeleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
- DeleteVolumeGroupRequest actualDeleteVolumeGroupRequest = vnfAdapterVolumeGroupResources.deleteVolumeGroupRequest(requestContext, cloudRegion, serviceInstance, volumeGroup);
-
- verify(MOCK_vnfAdapterObjectMapper, times(1)).deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance, volumeGroup);
- assertThat(expectedDeleteVolumeGroupRequest, Matchers.sameBeanAs(actualDeleteVolumeGroupRequest));
- }
+public class VnfAdapterVolumeGroupResourcesTest extends TestDataSetup {
+ @InjectMocks
+ private VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
+
+ @Mock
+ protected VnfAdapterObjectMapper MOCK_vnfAdapterObjectMapper;
+
+ @Mock
+ protected VnfVolumeAdapterClientImpl MOCK_vnfVolumeAdapterClient;
+
+ private RequestContext requestContext;
+ private ServiceInstance serviceInstance;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private VolumeGroup volumeGroup;
+ private CloudRegion cloudRegion;
+ private OrchestrationContext orchestrationContext;
+
+ @Before
+ public void before() {
+ requestContext = buildRequestContext();
+ serviceInstance = buildServiceInstance();
+ genericVnf = buildGenericVnf();
+ serviceInstance.getVnfs().add(genericVnf);
+ vfModule = buildVfModule();
+ genericVnf.getVfModules().add(vfModule);
+ volumeGroup = buildVolumeGroup();
+ serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
+ cloudRegion = buildCloudRegion();
+ orchestrationContext = buildOrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(true);
+ }
+
+ @Test
+ public void test_createVolumeGroup() throws Exception {
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ CreateVolumeGroupRequest createVolumeGroupRequest = new CreateVolumeGroupRequest();
+ createVolumeGroupRequest.setCloudSiteId("cloudSiteId");
+
+ CreateVolumeGroupResponse expectedCreateVolumeGroupResponse = new CreateVolumeGroupResponse();
+ expectedCreateVolumeGroupResponse.setVolumeGroupStackId("volumeGroupStackId");
+ expectedCreateVolumeGroupResponse.setVolumeGroupCreated(true);
+
+ String sdncVfModuleQueryResponse = "sdncVfModuleQueryResponse";
+
+ doReturn(createVolumeGroupRequest).when(MOCK_vnfAdapterObjectMapper).createVolumeGroupRequestMapper(
+ requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup,
+ sdncVfModuleQueryResponse);
+
+ CreateVolumeGroupRequest actualCreateVolumeGroupResponse =
+ vnfAdapterVolumeGroupResources.createVolumeGroupRequest(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
+
+ verify(MOCK_vnfAdapterObjectMapper, times(1)).createVolumeGroupRequestMapper(requestContext, cloudRegion,
+ orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
+
+ assertThat(createVolumeGroupRequest, Matchers.sameBeanAs(actualCreateVolumeGroupResponse));
+ }
+
+ @Test
+ public void test_deleteVolumeGroup() throws Exception {
+ DeleteVolumeGroupRequest deleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
+ doReturn(deleteVolumeGroupRequest).when(MOCK_vnfAdapterObjectMapper)
+ .deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance, volumeGroup);
+
+ DeleteVolumeGroupRequest expectedDeleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
+ DeleteVolumeGroupRequest actualDeleteVolumeGroupRequest = vnfAdapterVolumeGroupResources
+ .deleteVolumeGroupRequest(requestContext, cloudRegion, serviceInstance, volumeGroup);
+
+ verify(MOCK_vnfAdapterObjectMapper, times(1)).deleteVolumeGroupRequestMapper(requestContext, cloudRegion,
+ serviceInstance, volumeGroup);
+ assertThat(expectedDeleteVolumeGroupRequest, Matchers.sameBeanAs(actualDeleteVolumeGroupRequest));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/policy/CommonObjectMapperProviderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/policy/CommonObjectMapperProviderTest.java
index e3f6a1829e..2ff0d1d281 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/policy/CommonObjectMapperProviderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/policy/CommonObjectMapperProviderTest.java
@@ -22,9 +22,7 @@ package org.onap.so.client.policy;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-
import org.junit.Test;
-
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -43,4 +41,4 @@ public class CommonObjectMapperProviderTest {
assertFalse(context.isEnabled(SerializationFeature.WRAP_ROOT_VALUE));
assertFalse(context.isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE));
}
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
index 2636aec4a7..9c736b7634 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
@@ -21,9 +21,7 @@
package org.onap.so.client.sdn.common;
import static org.junit.Assert.assertEquals;
-
import java.util.LinkedHashMap;
-
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
@@ -33,9 +31,9 @@ import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.SdnCommonTasks;
-public class SdnCommonTasksTest{
+public class SdnCommonTasksTest {
+
-
SdnCommonTasks sdnCommonTasks = new SdnCommonTasks();
@Rule
@@ -60,7 +58,7 @@ public class SdnCommonTasksTest{
@Test
public void validateSDNResponseTest() throws BadResponseException {
- String jsonResponse = "{\"output\":{\"response-code\":\"0\",\"response-message\":\"success\"}}";
+ String jsonResponse = "{\"output\":{\"response-code\":\"0\",\"response-message\":\"success\"}}";
LinkedHashMap<String, Object> responseMap = new LinkedHashMap<>();
LinkedHashMap<String, Object> output = new LinkedHashMap<>();
output.put("response-code", "0");
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
index 70f196db8c..0b338bde1d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
@@ -25,11 +25,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
-
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.client.exception.BadResponseException;
@@ -38,43 +36,43 @@ import org.onap.so.client.sdnc.endpoint.SDNCTopology;
import org.skyscreamer.jsonassert.JSONAssert;
public class SDNCClientIT extends BaseIntegrationTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/";
-
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/";
+
@Test
public void getTest() throws BadResponseException, MapperException, IOException {
- String responseJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientGetResponse.json")));
- String queryLink = "/topologyQuery";
-
- wireMockServer.stubFor(get(urlEqualTo(queryLink))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json").withBody(responseJson)));
+ String responseJson =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientGetResponse.json")));
+ String queryLink = "/topologyQuery";
+
+ wireMockServer.stubFor(get(urlEqualTo(queryLink)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson)));
String response = SPY_sdncClient.get(queryLink);
JSONAssert.assertEquals(responseJson, response, false);
}
-
+
@Test(expected = BadResponseException.class)
public void post404Test() throws BadResponseException, MapperException, IOException {
- String responseJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut404Response.json")));
-
- String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
-
- wireMockServer.stubFor(post(urlMatching(queryLink))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json").withBody(responseJson)));
-
+ String responseJson =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut404Response.json")));
+
+ String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
+
+ wireMockServer.stubFor(post(urlMatching(queryLink)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson)));
+
SPY_sdncClient.post("", SDNCTopology.NETWORK);
}
-
+
@Test
public void post200Test() throws BadResponseException, MapperException, IOException {
- String responseJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut200Response.json")));
-
- String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
-
- wireMockServer.stubFor(post(urlMatching(queryLink))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json").withBody(responseJson)));
-
+ String responseJson =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut200Response.json")));
+
+ String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
+
+ wireMockServer.stubFor(post(urlMatching(queryLink)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson)));
+
String response = SPY_sdncClient.post("", SDNCTopology.NETWORK);
JSONAssert.assertEquals(responseJson, response, true);
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java
index 302bb551c3..0eb0304cdf 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java
@@ -25,7 +25,6 @@ import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -47,11 +46,11 @@ import org.onap.so.client.sdnc.beans.SDNCSvcAction;
@RunWith(MockitoJUnitRunner.Silent.class)
public class GCTopologyOperationRequestMapperTest extends TestDataSetup {
-
- @Spy
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
-
- @InjectMocks
+
+ @Spy
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ @InjectMocks
private GCTopologyOperationRequestMapper genObjMapper = new GCTopologyOperationRequestMapper();
@Test
@@ -63,8 +62,9 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup {
Configuration Configuration = new Configuration();
Configuration.setConfigurationId("ConfigurationId");
Configuration.setConfigurationType("VLAN-NETWORK-RECEPTOR");
- GenericResourceApiGcTopologyOperationInformation genericInfo = genObjMapper.deactivateOrUnassignVnrReqMapper
- (SDNCSvcAction.UNASSIGN, serviceInstance, requestContext, Configuration,"uuid",new URI("http://localhost"));
+ GenericResourceApiGcTopologyOperationInformation genericInfo =
+ genObjMapper.deactivateOrUnassignVnrReqMapper(SDNCSvcAction.UNASSIGN, serviceInstance, requestContext,
+ Configuration, "uuid", new URI("http://localhost"));
Assert.assertNotNull(genericInfo);
Assert.assertNotNull(genericInfo.getRequestInformation());
@@ -73,9 +73,9 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup {
Assert.assertNotNull(genericInfo.getServiceInformation());
Assert.assertEquals("ConfigurationId", genericInfo.getConfigurationInformation().getConfigurationId());
Assert.assertEquals("VLAN-NETWORK-RECEPTOR", genericInfo.getConfigurationInformation().getConfigurationType());
- Assert.assertEquals("uuid",genericInfo.getSdncRequestHeader().getSvcRequestId());
- Assert.assertEquals("http://localhost",genericInfo.getSdncRequestHeader().getSvcNotificationUrl());
- Assert.assertEquals("MsoRequestId",genericInfo.getRequestInformation().getRequestId());
+ Assert.assertEquals("uuid", genericInfo.getSdncRequestHeader().getSvcRequestId());
+ Assert.assertEquals("http://localhost", genericInfo.getSdncRequestHeader().getSvcNotificationUrl());
+ Assert.assertEquals("MsoRequestId", genericInfo.getRequestInformation().getRequestId());
}
@@ -99,8 +99,8 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup {
}
private Map<String, Object> getUserParams() {
- Map<String,Object> userParams = new HashMap<>();
- userParams.put("lppCustomerId","lppCustomerId");
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("lppCustomerId", "lppCustomerId");
return userParams;
}
@@ -148,7 +148,7 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup {
return ipv4subnet;
}
- private ServiceInstance buildServiceInstance(GenericVnf vnf) {
+ private ServiceInstance buildServiceInstance(GenericVnf vnf) {
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("ServiceInstanceId");
List<GenericVnf> vnfs = serviceInstance.getVnfs();
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java
index 630bccee9d..88a291e68b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java
@@ -27,10 +27,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-
import java.util.HashMap;
import java.util.Map;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -66,365 +64,383 @@ import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
-public class GeneralTopologyObjectMapperTest extends TestDataSetup {
- @InjectMocks
- private GeneralTopologyObjectMapper genObjMapper = new GeneralTopologyObjectMapper();
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void before() {
-
- }
-
- @After
- public void after() {
-
- }
-
- @Test
- public void testBuildServiceInformation() {
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
-
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- // prepare Customer object
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("productFamilyId");
- customer.setServiceSubscription(serviceSubscription);
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- //
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericResourceApiServiceinformationServiceInformation serviceInfo = genObjMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
-
- assertEquals("serviceModelInvariantUuid", serviceInfo.getOnapModelInformation().getModelInvariantUuid());
- assertEquals("serviceModelName", serviceInfo.getOnapModelInformation().getModelName());
- assertEquals("serviceModelUuid", serviceInfo.getOnapModelInformation().getModelUuid());
- assertEquals("serviceModelVersion", serviceInfo.getOnapModelInformation().getModelVersion());
- assertNull(serviceInfo.getOnapModelInformation().getModelCustomizationUuid());
- assertEquals("serviceInstanceId", serviceInfo.getServiceInstanceId());
- assertEquals("serviceInstanceId", serviceInfo.getServiceId());
- assertEquals("globalCustomerId", serviceInfo.getGlobalCustomerId());
- assertEquals("productFamilyId", serviceInfo.getSubscriptionServiceType());
- }
-
- @Test
- public void buildSdncRequestHeaderActivateTest() {
- GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = genObjMapper.buildSdncRequestHeader(SDNCSvcAction.ACTIVATE, "sdncReqId");
-
- assertEquals(GenericResourceApiSvcActionEnumeration.ACTIVATE, requestHeader.getSvcAction());
- assertEquals("sdncReqId", requestHeader.getSvcRequestId());
- }
-
- @Test
- public void buildSdncRequestHeaderAssignTest() {
- GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = genObjMapper.buildSdncRequestHeader(SDNCSvcAction.ASSIGN, "sdncReqId");
-
- assertEquals(GenericResourceApiSvcActionEnumeration.ASSIGN, requestHeader.getSvcAction());
- assertEquals("sdncReqId", requestHeader.getSvcRequestId());
- }
-
- @Test
- public void buildSdncRequestHeaderDeactivateTest() {
- GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = genObjMapper.buildSdncRequestHeader(SDNCSvcAction.DEACTIVATE, "sdncReqId");
-
- assertEquals(GenericResourceApiSvcActionEnumeration.DEACTIVATE, requestHeader.getSvcAction());
- assertEquals("sdncReqId", requestHeader.getSvcRequestId());
- }
-
- @Test
- public void buildSdncRequestHeaderDeleteTest() {
- GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = genObjMapper.buildSdncRequestHeader(SDNCSvcAction.DELETE, "sdncReqId");
-
- assertEquals(GenericResourceApiSvcActionEnumeration.DELETE, requestHeader.getSvcAction());
- assertEquals("sdncReqId", requestHeader.getSvcRequestId());
- }
-
- @Test
- public void buildSdncRequestHeaderChangeAssignTest() {
- GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = genObjMapper.buildSdncRequestHeader(SDNCSvcAction.CHANGE_ASSIGN, "sdncReqId");
-
- assertEquals(GenericResourceApiSvcActionEnumeration.CHANGEASSIGN, requestHeader.getSvcAction());
- assertEquals("sdncReqId", requestHeader.getSvcRequestId());
- }
-
- @Test
- public void buildConfigurationInformationTest_excludesOnapModelInfo() {
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("testConfigurationId");
- configuration.setConfigurationType("VNR");
- configuration.setConfigurationName("VNRCONF");
- GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =genObjMapper.buildConfigurationInformation(configuration,false);
- assertEquals(configuration.getConfigurationId(),configurationInformation.getConfigurationId());
- assertEquals(configuration.getConfigurationType(),configurationInformation.getConfigurationType());
- assertEquals(configuration.getConfigurationName(),configurationInformation.getConfigurationName());
- assertNull(configurationInformation.getOnapModelInformation());
- }
-
- @Test
- public void buildConfigurationInformationTest_includesOnapModelInfo() {
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("testConfigurationId");
- configuration.setConfigurationType("VNR");
- configuration.setConfigurationName("VNRCONF");
- ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
- modelInfoConfiguration.setModelVersionId("modelVersionId");
- modelInfoConfiguration.setModelInvariantId("modelInvariantId");
- modelInfoConfiguration.setModelCustomizationId("modelCustomizationId");
- configuration.setModelInfoConfiguration(modelInfoConfiguration);
-
- GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = genObjMapper.buildConfigurationInformation(configuration,true);
-
- assertEquals(configuration.getConfigurationId(),configurationInformation.getConfigurationId());
- assertEquals(configuration.getConfigurationType(),configurationInformation.getConfigurationType());
- assertEquals(configuration.getConfigurationName(),configurationInformation.getConfigurationName());
- assertNotNull(configurationInformation.getOnapModelInformation());
- assertEquals(configuration.getModelInfoConfiguration().getModelVersionId(),configurationInformation.getOnapModelInformation().getModelUuid());
- assertEquals(configuration.getModelInfoConfiguration().getModelInvariantId(),configurationInformation.getOnapModelInformation().getModelInvariantUuid());
- assertEquals(configuration.getModelInfoConfiguration().getModelCustomizationId(),configurationInformation.getOnapModelInformation().getModelCustomizationUuid());
-
- }
-
- @Test
- public void buildGcRequestInformationTest() {
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("TestVnfId");
- GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = genObjMapper.buildGcRequestInformation(vnf,null);
- assertNotNull(gcRequestInput);
- assertEquals(vnf.getVnfId(),gcRequestInput.getVnfId());
- assertNull(gcRequestInput.getInputParameters());
- }
-
- @Test
- public void buildGcRequestInformationTest_withInputParams() {
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("TestVnfId");
- GenericResourceApiParam genericResourceApiParam =new GenericResourceApiParam();
- genericResourceApiParam.addParamItem(new GenericResourceApiParamParam());
- GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = genObjMapper.buildGcRequestInformation(vnf,genericResourceApiParam);
- assertNotNull(gcRequestInput);
- assertEquals(vnf.getVnfId(),gcRequestInput.getVnfId());
- assertNotNull(gcRequestInput.getInputParameters());
- }
-
- @Test
- public void buildVnfInformationTest_withNullData() {
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("TestVnfId");
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- GenericResourceApiVnfinformationVnfInformation gcRequestInput = genObjMapper.buildVnfInformation(vnf,serviceInstance,true);
- assertNotNull(gcRequestInput);
- assertNull(vnf.getModelInfoGenericVnf());
- assertNull(gcRequestInput.getOnapModelInformation());
- assertEquals(vnf.getVnfId(),gcRequestInput.getVnfId());
- assertNotNull(gcRequestInput.getVnfId());
- }
-
- @Test
- public void buildNetworkInformationTest() {
-
- L3Network network = new L3Network();
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setModelInvariantUUID("my-uuid");
- modelInfoNetwork.setModelName("my-model-name");
- modelInfoNetwork.setModelVersion("my-model-version");
- modelInfoNetwork.setModelUUID("my-model-uuid");
- modelInfoNetwork.setModelCustomizationUUID("my-customization-uuid");
- network.setModelInfoNetwork(modelInfoNetwork);
- network.setNetworkId("my-network-id");
- network.setNetworkType("my-network-type");
- network.setNetworkTechnology("my-network-technology");
-
- GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation();
- GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
- networkInformation.setNetworkId("my-network-id");
- networkInformation.setNetworkType("my-network-type");
- networkInformation.networkTechnology("my-network-technology");
- networkInformation.setFromPreload(null);
- onapModelInformation.setModelInvariantUuid("my-uuid");
- onapModelInformation.setModelName("my-model-name");
- onapModelInformation.setModelVersion("my-model-version");
- onapModelInformation.setModelUuid("my-model-uuid");
- onapModelInformation.setModelCustomizationUuid("my-customization-uuid");
- networkInformation.setOnapModelInformation(onapModelInformation);
-
- assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network)));
-
- }
-
- @Test
- public void buildNetworkInformationNoModelTest() {
-
- L3Network network = new L3Network();
- network.setNetworkId("my-network-id");
- network.setNetworkType("my-network-type");
- network.setNetworkTechnology("my-network-technology");
-
- GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation();
- networkInformation.setNetworkId("my-network-id");
- networkInformation.setNetworkType("my-network-type");
- networkInformation.networkTechnology("my-network-technology");
- networkInformation.setFromPreload(null);
-
-
- assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network)));
-
- }
-
-
- @Test
- public void buildVfModuleInformationTest_withNoModelIsFromPreload() {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("TestVfModuleId");
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("TestVnfId");
- RequestContext requestContext = new RequestContext();
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setUsePreload(true);
- requestContext.setRequestParameters(requestParameters);
- GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
- try {
- gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
- }
- catch (MapperException ex) {
-
- }
- assertNotNull(gcRequestInput);
- assertNull(vfModule.getModelInfoVfModule());
- assertNull(gcRequestInput.getOnapModelInformation());
- assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
- assertNotNull(gcRequestInput.getVfModuleId());
- assertTrue(gcRequestInput.getFromPreload());
- }
-
- @Test
- public void buildVfModuleInformationTest_withNoModelIsNotFromPreload() {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("TestVfModuleId");
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("TestVnfId");
- RequestContext requestContext = new RequestContext();
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setUsePreload(false);
- requestContext.setRequestParameters(requestParameters);
- GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
- try {
- gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
- }
- catch (MapperException ex) {
-
- }
- assertNotNull(gcRequestInput);
- assertNull(vfModule.getModelInfoVfModule());
- assertNull(gcRequestInput.getOnapModelInformation());
- assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
- assertNotNull(gcRequestInput.getVfModuleId());
- assertFalse(gcRequestInput.getFromPreload());
- }
-
- @Test
- public void buildVfModuleInformationTest_withNoModelNoRequestContext() {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("TestVfModuleId");
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("TestVnfId");
- GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
- try {
- gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, null, false);
- }
- catch (MapperException ex) {
-
- }
- assertNotNull(gcRequestInput);
- assertNull(vfModule.getModelInfoVfModule());
- assertNull(gcRequestInput.getOnapModelInformation());
- assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
- assertNotNull(gcRequestInput.getVfModuleId());
- assertTrue(gcRequestInput.getFromPreload());
- }
-
- @Test
- public void buildVfModuleInformationTest_withNoModelNoRequestParameters() {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("TestVfModuleId");
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("TestVnfId");
- RequestContext requestContext = new RequestContext();
- GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
- try {
- gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
- }
- catch (MapperException ex) {
-
- }
- assertNotNull(gcRequestInput);
- assertNull(vfModule.getModelInfoVfModule());
- assertNull(gcRequestInput.getOnapModelInformation());
- assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
- assertNotNull(gcRequestInput.getVfModuleId());
- assertTrue(gcRequestInput.getFromPreload());
- }
-
- @Test
- public void buildVfModuleInformationTest_withModel() {
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("TestVfModuleId");
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID");
- modelInfoVfModule.setModelName("testModelName");
- modelInfoVfModule.setModelVersion("testModelVersion");
- modelInfoVfModule.setModelUUID("testModelUUID");
- modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("TestVnfId");
- RequestContext requestContext = new RequestContext();
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setUsePreload(true);
- requestContext.setRequestParameters(requestParameters);
- GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
- try {
- gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, true);
- }
- catch (MapperException ex) {
-
- }
- assertNotNull(gcRequestInput);
- assertNotNull(vfModule.getModelInfoVfModule());
- assertNotNull(gcRequestInput.getOnapModelInformation());
- assertEquals(modelInfoVfModule.getModelInvariantUUID(), gcRequestInput.getOnapModelInformation().getModelInvariantUuid());
- assertEquals(modelInfoVfModule.getModelName(), gcRequestInput.getOnapModelInformation().getModelName());
- assertEquals(modelInfoVfModule.getModelVersion(), gcRequestInput.getOnapModelInformation().getModelVersion());
- assertEquals(modelInfoVfModule.getModelUUID(), gcRequestInput.getOnapModelInformation().getModelUuid());
- assertEquals(modelInfoVfModule.getModelCustomizationUUID(), gcRequestInput.getOnapModelInformation().getModelCustomizationUuid());
- assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
- assertNotNull(gcRequestInput.getVfModuleId());
- assertTrue(gcRequestInput.getFromPreload());
- }
+public class GeneralTopologyObjectMapperTest extends TestDataSetup {
+ @InjectMocks
+ private GeneralTopologyObjectMapper genObjMapper = new GeneralTopologyObjectMapper();
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void before() {
+
+ }
+
+ @After
+ public void after() {
+
+ }
+
+ @Test
+ public void testBuildServiceInformation() {
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ // prepare Customer object
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("productFamilyId");
+ customer.setServiceSubscription(serviceSubscription);
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ //
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericResourceApiServiceinformationServiceInformation serviceInfo =
+ genObjMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
+
+ assertEquals("serviceModelInvariantUuid", serviceInfo.getOnapModelInformation().getModelInvariantUuid());
+ assertEquals("serviceModelName", serviceInfo.getOnapModelInformation().getModelName());
+ assertEquals("serviceModelUuid", serviceInfo.getOnapModelInformation().getModelUuid());
+ assertEquals("serviceModelVersion", serviceInfo.getOnapModelInformation().getModelVersion());
+ assertNull(serviceInfo.getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("serviceInstanceId", serviceInfo.getServiceInstanceId());
+ assertEquals("serviceInstanceId", serviceInfo.getServiceId());
+ assertEquals("globalCustomerId", serviceInfo.getGlobalCustomerId());
+ assertEquals("productFamilyId", serviceInfo.getSubscriptionServiceType());
+ }
+
+ @Test
+ public void buildSdncRequestHeaderActivateTest() {
+ GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader =
+ genObjMapper.buildSdncRequestHeader(SDNCSvcAction.ACTIVATE, "sdncReqId");
+
+ assertEquals(GenericResourceApiSvcActionEnumeration.ACTIVATE, requestHeader.getSvcAction());
+ assertEquals("sdncReqId", requestHeader.getSvcRequestId());
+ }
+
+ @Test
+ public void buildSdncRequestHeaderAssignTest() {
+ GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader =
+ genObjMapper.buildSdncRequestHeader(SDNCSvcAction.ASSIGN, "sdncReqId");
+
+ assertEquals(GenericResourceApiSvcActionEnumeration.ASSIGN, requestHeader.getSvcAction());
+ assertEquals("sdncReqId", requestHeader.getSvcRequestId());
+ }
+
+ @Test
+ public void buildSdncRequestHeaderDeactivateTest() {
+ GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader =
+ genObjMapper.buildSdncRequestHeader(SDNCSvcAction.DEACTIVATE, "sdncReqId");
+
+ assertEquals(GenericResourceApiSvcActionEnumeration.DEACTIVATE, requestHeader.getSvcAction());
+ assertEquals("sdncReqId", requestHeader.getSvcRequestId());
+ }
+
+ @Test
+ public void buildSdncRequestHeaderDeleteTest() {
+ GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader =
+ genObjMapper.buildSdncRequestHeader(SDNCSvcAction.DELETE, "sdncReqId");
+
+ assertEquals(GenericResourceApiSvcActionEnumeration.DELETE, requestHeader.getSvcAction());
+ assertEquals("sdncReqId", requestHeader.getSvcRequestId());
+ }
+
+ @Test
+ public void buildSdncRequestHeaderChangeAssignTest() {
+ GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader =
+ genObjMapper.buildSdncRequestHeader(SDNCSvcAction.CHANGE_ASSIGN, "sdncReqId");
+
+ assertEquals(GenericResourceApiSvcActionEnumeration.CHANGEASSIGN, requestHeader.getSvcAction());
+ assertEquals("sdncReqId", requestHeader.getSvcRequestId());
+ }
+
+ @Test
+ public void buildConfigurationInformationTest_excludesOnapModelInfo() {
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("testConfigurationId");
+ configuration.setConfigurationType("VNR");
+ configuration.setConfigurationName("VNRCONF");
+ GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =
+ genObjMapper.buildConfigurationInformation(configuration, false);
+ assertEquals(configuration.getConfigurationId(), configurationInformation.getConfigurationId());
+ assertEquals(configuration.getConfigurationType(), configurationInformation.getConfigurationType());
+ assertEquals(configuration.getConfigurationName(), configurationInformation.getConfigurationName());
+ assertNull(configurationInformation.getOnapModelInformation());
+ }
+
+ @Test
+ public void buildConfigurationInformationTest_includesOnapModelInfo() {
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("testConfigurationId");
+ configuration.setConfigurationType("VNR");
+ configuration.setConfigurationName("VNRCONF");
+ ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
+ modelInfoConfiguration.setModelVersionId("modelVersionId");
+ modelInfoConfiguration.setModelInvariantId("modelInvariantId");
+ modelInfoConfiguration.setModelCustomizationId("modelCustomizationId");
+ configuration.setModelInfoConfiguration(modelInfoConfiguration);
+
+ GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation =
+ genObjMapper.buildConfigurationInformation(configuration, true);
+
+ assertEquals(configuration.getConfigurationId(), configurationInformation.getConfigurationId());
+ assertEquals(configuration.getConfigurationType(), configurationInformation.getConfigurationType());
+ assertEquals(configuration.getConfigurationName(), configurationInformation.getConfigurationName());
+ assertNotNull(configurationInformation.getOnapModelInformation());
+ assertEquals(configuration.getModelInfoConfiguration().getModelVersionId(),
+ configurationInformation.getOnapModelInformation().getModelUuid());
+ assertEquals(configuration.getModelInfoConfiguration().getModelInvariantId(),
+ configurationInformation.getOnapModelInformation().getModelInvariantUuid());
+ assertEquals(configuration.getModelInfoConfiguration().getModelCustomizationId(),
+ configurationInformation.getOnapModelInformation().getModelCustomizationUuid());
+
+ }
+
+ @Test
+ public void buildGcRequestInformationTest() {
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("TestVnfId");
+ GenericResourceApiGcrequestinputGcRequestInput gcRequestInput =
+ genObjMapper.buildGcRequestInformation(vnf, null);
+ assertNotNull(gcRequestInput);
+ assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId());
+ assertNull(gcRequestInput.getInputParameters());
+ }
+
+ @Test
+ public void buildGcRequestInformationTest_withInputParams() {
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("TestVnfId");
+ GenericResourceApiParam genericResourceApiParam = new GenericResourceApiParam();
+ genericResourceApiParam.addParamItem(new GenericResourceApiParamParam());
+ GenericResourceApiGcrequestinputGcRequestInput gcRequestInput =
+ genObjMapper.buildGcRequestInformation(vnf, genericResourceApiParam);
+ assertNotNull(gcRequestInput);
+ assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId());
+ assertNotNull(gcRequestInput.getInputParameters());
+ }
+
+ @Test
+ public void buildVnfInformationTest_withNullData() {
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("TestVnfId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericResourceApiVnfinformationVnfInformation gcRequestInput =
+ genObjMapper.buildVnfInformation(vnf, serviceInstance, true);
+ assertNotNull(gcRequestInput);
+ assertNull(vnf.getModelInfoGenericVnf());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId());
+ assertNotNull(gcRequestInput.getVnfId());
+ }
+
+ @Test
+ public void buildNetworkInformationTest() {
+
+ L3Network network = new L3Network();
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setModelInvariantUUID("my-uuid");
+ modelInfoNetwork.setModelName("my-model-name");
+ modelInfoNetwork.setModelVersion("my-model-version");
+ modelInfoNetwork.setModelUUID("my-model-uuid");
+ modelInfoNetwork.setModelCustomizationUUID("my-customization-uuid");
+ network.setModelInfoNetwork(modelInfoNetwork);
+ network.setNetworkId("my-network-id");
+ network.setNetworkType("my-network-type");
+ network.setNetworkTechnology("my-network-technology");
+
+ GenericResourceApiNetworkinformationNetworkInformation networkInformation =
+ new GenericResourceApiNetworkinformationNetworkInformation();
+ GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation =
+ new GenericResourceApiOnapmodelinformationOnapModelInformation();
+ networkInformation.setNetworkId("my-network-id");
+ networkInformation.setNetworkType("my-network-type");
+ networkInformation.networkTechnology("my-network-technology");
+ networkInformation.setFromPreload(null);
+ onapModelInformation.setModelInvariantUuid("my-uuid");
+ onapModelInformation.setModelName("my-model-name");
+ onapModelInformation.setModelVersion("my-model-version");
+ onapModelInformation.setModelUuid("my-model-uuid");
+ onapModelInformation.setModelCustomizationUuid("my-customization-uuid");
+ networkInformation.setOnapModelInformation(onapModelInformation);
+
+ assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network)));
+
+ }
+
+ @Test
+ public void buildNetworkInformationNoModelTest() {
+
+ L3Network network = new L3Network();
+ network.setNetworkId("my-network-id");
+ network.setNetworkType("my-network-type");
+ network.setNetworkTechnology("my-network-technology");
+
+ GenericResourceApiNetworkinformationNetworkInformation networkInformation =
+ new GenericResourceApiNetworkinformationNetworkInformation();
+ networkInformation.setNetworkId("my-network-id");
+ networkInformation.setNetworkType("my-network-type");
+ networkInformation.networkTechnology("my-network-technology");
+ networkInformation.setFromPreload(null);
+
+
+ assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network)));
+
+ }
+
+
+ @Test
+ public void buildVfModuleInformationTest_withNoModelIsFromPreload() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUsePreload(true);
+ requestContext.setRequestParameters(requestParameters);
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput =
+ genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
+ } catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNull(vfModule.getModelInfoVfModule());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertTrue(gcRequestInput.getFromPreload());
+ }
+
+ @Test
+ public void buildVfModuleInformationTest_withNoModelIsNotFromPreload() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUsePreload(false);
+ requestContext.setRequestParameters(requestParameters);
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput =
+ genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
+ } catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNull(vfModule.getModelInfoVfModule());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertFalse(gcRequestInput.getFromPreload());
+ }
+
+ @Test
+ public void buildVfModuleInformationTest_withNoModelNoRequestContext() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, null, false);
+ } catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNull(vfModule.getModelInfoVfModule());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertTrue(gcRequestInput.getFromPreload());
+ }
+
+ @Test
+ public void buildVfModuleInformationTest_withNoModelNoRequestParameters() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ RequestContext requestContext = new RequestContext();
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput =
+ genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
+ } catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNull(vfModule.getModelInfoVfModule());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertTrue(gcRequestInput.getFromPreload());
+ }
+
+ @Test
+ public void buildVfModuleInformationTest_withModel() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID");
+ modelInfoVfModule.setModelName("testModelName");
+ modelInfoVfModule.setModelVersion("testModelVersion");
+ modelInfoVfModule.setModelUUID("testModelUUID");
+ modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUsePreload(true);
+ requestContext.setRequestParameters(requestParameters);
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput =
+ genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, true);
+ } catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNotNull(vfModule.getModelInfoVfModule());
+ assertNotNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(modelInfoVfModule.getModelInvariantUUID(),
+ gcRequestInput.getOnapModelInformation().getModelInvariantUuid());
+ assertEquals(modelInfoVfModule.getModelName(), gcRequestInput.getOnapModelInformation().getModelName());
+ assertEquals(modelInfoVfModule.getModelVersion(), gcRequestInput.getOnapModelInformation().getModelVersion());
+ assertEquals(modelInfoVfModule.getModelUUID(), gcRequestInput.getOnapModelInformation().getModelUuid());
+ assertEquals(modelInfoVfModule.getModelCustomizationUUID(),
+ gcRequestInput.getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertTrue(gcRequestInput.getFromPreload());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java
index 1bfa78ad6d..76e915781f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java
@@ -25,13 +25,11 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -52,174 +50,183 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-
import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
public class NetworkTopologyOperationRequestMapperTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
-
- private ServiceInstance serviceInstance;
- private ServiceInstance serviceInstanceNoCollection;
- private Customer customer;
- private RequestContext requestContext;
- private L3Network network;
- private CloudRegion cloudRegion;
-
- @Spy
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
-
- @InjectMocks
- private NetworkTopologyOperationRequestMapper mapper = new NetworkTopologyOperationRequestMapper();
-
- @Before
- public void before() {
- // prepare and set service instance
- serviceInstance = new ServiceInstance();
- serviceInstanceNoCollection = new ServiceInstance();
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
- modelInfoServiceInstance.setModelName("modelName");
- modelInfoServiceInstance.setModelUuid("modelUuid");
- modelInfoServiceInstance.setModelVersion("modelVersion");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- serviceInstanceNoCollection.setModelInfoServiceInstance(modelInfoServiceInstance);
- // prepare Customer object
- customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- //serviceInstance.setCustomer(customer);
- // set Customer on service instance
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("productFamilyId");
- customer.setServiceSubscription(serviceSubscription);
-
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- customer.getServiceSubscription().getServiceInstances().add(serviceInstanceNoCollection);
- //
- InstanceGroup networkInstanceGroup = new InstanceGroup();
- networkInstanceGroup.setId("networkInstanceGroupId");
- networkInstanceGroup.setInstanceGroupFunction("instanceGroupFunction");
- Collection networkCollection = new Collection();
- networkCollection.setInstanceGroup(networkInstanceGroup);
- serviceInstance.setCollection(networkCollection);
- //
- requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
- requestContext.setMsoRequestId("MsoRequestId");
-
- network = new L3Network();
- network.setNetworkId("TEST_NETWORK_ID");
- network.setNetworkName("TEST_NETWORK_NAME");
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setModelInvariantUUID("modelInvariantUuid");
- modelInfoNetwork.setModelName("modelName");
- modelInfoNetwork.setModelVersion("modelVersion");
- modelInfoNetwork.setModelUUID("modelUuid");
- modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUUID");
- network.setModelInfoNetwork(modelInfoNetwork);
-
- cloudRegion = new CloudRegion();
- }
-
- @Test
- public void createGenericResourceApiNetworkOperationInformationTest() throws Exception {
-
- GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
-
- ObjectMapper omapper = new ObjectMapper();
- GenericResourceApiNetworkOperationInformation reqMapper1 = omapper.readValue(
- getJson("genericResourceApiNetworkOperationInformation.json"),
- GenericResourceApiNetworkOperationInformation.class);
-
- assertThat(networkSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId")
- .ignoring("requestInformation.requestId"));
- assertEquals("MsoRequestId", networkSDNCrequest.getRequestInformation().getRequestId());
- }
-
- @Test
- public void createGenericResourceApiNetworkOperationInformationReqContextNullTest() throws Exception {
-
- RequestContext rc = new RequestContext();
- rc.setMsoRequestId(null);
- GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- rc, cloudRegion);
- assertNotNull(networkSDNCrequest.getRequestInformation().getRequestId());
- GenericResourceApiNetworkOperationInformation networkSDNCrequest2 = mapper.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- null, cloudRegion);
- assertNotNull(networkSDNCrequest2.getRequestInformation().getRequestId());
- }
-
- @Test
- public void reqMapperTest() throws Exception {
-
- GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
-
- assertNull(networkSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
- assertEquals("modelCustomizationUUID", networkSDNCrequest.getNetworkInformation().getOnapModelInformation().getModelCustomizationUuid());
- }
-
- @Test
- public void reqMapperNoCollectionTest() throws Exception {
- GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstanceNoCollection, customer,
- requestContext, cloudRegion);
-
- assertNull(networkSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
- assertEquals("modelCustomizationUUID", networkSDNCrequest.getNetworkInformation().getOnapModelInformation().getModelCustomizationUuid());
- }
- @Test
- public void createGenericResourceApiNetworkOperationInformation_UnassignTest() throws Exception {
-
- NetworkTopologyOperationRequestMapper mapperUnassign = mapper;
- GenericResourceApiNetworkOperationInformation networkSDNCrequestUnassign = mapperUnassign.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
-
- ObjectMapper omapperUnassign = new ObjectMapper();
- GenericResourceApiNetworkOperationInformation reqMapperUnassign = omapperUnassign.readValue(
- getJson("genericResourceApiNetworkOperationInformationUnAssign.json"),
- GenericResourceApiNetworkOperationInformation.class);
-
- assertThat(reqMapperUnassign, sameBeanAs(networkSDNCrequestUnassign).ignoring("sdncRequestHeader.svcRequestId")
- .ignoring("requestInformation.requestId"));
- assertEquals("MsoRequestId", networkSDNCrequestUnassign.getRequestInformation().getRequestId());
-
- }
-
- @Test
- public void createGenericResourceApiNetworkOperationInformationNoNetworkNameTest() throws Exception {
-
- //set network name NULL
- network.setNetworkName(null);
- GenericResourceApiNetworkOperationInformation networkSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, customer,
- requestContext, cloudRegion);
-
- ObjectMapper omapper = new ObjectMapper();
- GenericResourceApiNetworkOperationInformation reqMapper1 = omapper.readValue(
- getJson("genericResourceApiNetworkOperationInformationNoNetworkName.json"),
- GenericResourceApiNetworkOperationInformation.class);
-
- assertThat(reqMapper1, sameBeanAs(networkSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
- .ignoring("requestInformation.requestId"));
- }
-
- /*
- * Helper method to load JSON data
- */
- private String getJson(String filename) throws IOException {
- return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
- }
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
+
+ private ServiceInstance serviceInstance;
+ private ServiceInstance serviceInstanceNoCollection;
+ private Customer customer;
+ private RequestContext requestContext;
+ private L3Network network;
+ private CloudRegion cloudRegion;
+
+ @Spy
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ @InjectMocks
+ private NetworkTopologyOperationRequestMapper mapper = new NetworkTopologyOperationRequestMapper();
+
+ @Before
+ public void before() {
+ // prepare and set service instance
+ serviceInstance = new ServiceInstance();
+ serviceInstanceNoCollection = new ServiceInstance();
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
+ modelInfoServiceInstance.setModelName("modelName");
+ modelInfoServiceInstance.setModelUuid("modelUuid");
+ modelInfoServiceInstance.setModelVersion("modelVersion");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ serviceInstanceNoCollection.setModelInfoServiceInstance(modelInfoServiceInstance);
+ // prepare Customer object
+ customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ // serviceInstance.setCustomer(customer);
+ // set Customer on service instance
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("productFamilyId");
+ customer.setServiceSubscription(serviceSubscription);
+
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstanceNoCollection);
+ //
+ InstanceGroup networkInstanceGroup = new InstanceGroup();
+ networkInstanceGroup.setId("networkInstanceGroupId");
+ networkInstanceGroup.setInstanceGroupFunction("instanceGroupFunction");
+ Collection networkCollection = new Collection();
+ networkCollection.setInstanceGroup(networkInstanceGroup);
+ serviceInstance.setCollection(networkCollection);
+ //
+ requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+ requestContext.setMsoRequestId("MsoRequestId");
+
+ network = new L3Network();
+ network.setNetworkId("TEST_NETWORK_ID");
+ network.setNetworkName("TEST_NETWORK_NAME");
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setModelInvariantUUID("modelInvariantUuid");
+ modelInfoNetwork.setModelName("modelName");
+ modelInfoNetwork.setModelVersion("modelVersion");
+ modelInfoNetwork.setModelUUID("modelUuid");
+ modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUUID");
+ network.setModelInfoNetwork(modelInfoNetwork);
+
+ cloudRegion = new CloudRegion();
+ }
+
+ @Test
+ public void createGenericResourceApiNetworkOperationInformationTest() throws Exception {
+
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+
+ ObjectMapper omapper = new ObjectMapper();
+ GenericResourceApiNetworkOperationInformation reqMapper1 =
+ omapper.readValue(getJson("genericResourceApiNetworkOperationInformation.json"),
+ GenericResourceApiNetworkOperationInformation.class);
+
+ assertThat(networkSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId")
+ .ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", networkSDNCrequest.getRequestInformation().getRequestId());
+ }
+
+ @Test
+ public void createGenericResourceApiNetworkOperationInformationReqContextNullTest() throws Exception {
+
+ RequestContext rc = new RequestContext();
+ rc.setMsoRequestId(null);
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, rc, cloudRegion);
+ assertNotNull(networkSDNCrequest.getRequestInformation().getRequestId());
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest2 =
+ mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, null, cloudRegion);
+ assertNotNull(networkSDNCrequest2.getRequestInformation().getRequestId());
+ }
+
+ @Test
+ public void reqMapperTest() throws Exception {
+
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+
+ assertNull(networkSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("modelCustomizationUUID",
+ networkSDNCrequest.getNetworkInformation().getOnapModelInformation().getModelCustomizationUuid());
+ }
+
+ @Test
+ public void reqMapperNoCollectionTest() throws Exception {
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network,
+ serviceInstanceNoCollection, customer, requestContext, cloudRegion);
+
+ assertNull(networkSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("modelCustomizationUUID",
+ networkSDNCrequest.getNetworkInformation().getOnapModelInformation().getModelCustomizationUuid());
+ }
+
+ @Test
+ public void createGenericResourceApiNetworkOperationInformation_UnassignTest() throws Exception {
+
+ NetworkTopologyOperationRequestMapper mapperUnassign = mapper;
+ GenericResourceApiNetworkOperationInformation networkSDNCrequestUnassign =
+ mapperUnassign.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN,
+ GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+
+ ObjectMapper omapperUnassign = new ObjectMapper();
+ GenericResourceApiNetworkOperationInformation reqMapperUnassign =
+ omapperUnassign.readValue(getJson("genericResourceApiNetworkOperationInformationUnAssign.json"),
+ GenericResourceApiNetworkOperationInformation.class);
+
+ assertThat(reqMapperUnassign, sameBeanAs(networkSDNCrequestUnassign).ignoring("sdncRequestHeader.svcRequestId")
+ .ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", networkSDNCrequestUnassign.getRequestInformation().getRequestId());
+
+ }
+
+ @Test
+ public void createGenericResourceApiNetworkOperationInformationNoNetworkNameTest() throws Exception {
+
+ // set network name NULL
+ network.setNetworkName(null);
+ GenericResourceApiNetworkOperationInformation networkSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance,
+ customer, requestContext, cloudRegion);
+
+ ObjectMapper omapper = new ObjectMapper();
+ GenericResourceApiNetworkOperationInformation reqMapper1 =
+ omapper.readValue(getJson("genericResourceApiNetworkOperationInformationNoNetworkName.json"),
+ GenericResourceApiNetworkOperationInformation.class);
+
+ assertThat(reqMapper1, sameBeanAs(networkSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
+ .ignoring("requestInformation.requestId"));
+ }
+
+ /*
+ * Helper method to load JSON data
+ */
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename)));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java
index 1919ef437b..f4006ab5d5 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java
@@ -24,12 +24,10 @@ import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -42,7 +40,6 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-
import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
@@ -51,54 +48,56 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
public class ServiceTopologyOperationMapperTest {
- @Spy
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
-
- @InjectMocks
- private ServiceTopologyOperationMapper mapper = new ServiceTopologyOperationMapper();
+ @Spy
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ @InjectMocks
+ private ServiceTopologyOperationMapper mapper = new ServiceTopologyOperationMapper();
- @Test
- public void reqMapperTest() throws Exception {
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
- modelInfoServiceInstance.setModelName("modelName");
- modelInfoServiceInstance.setModelUuid("modelUuid");
- modelInfoServiceInstance.setModelVersion("modelVersion");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ @Test
+ public void reqMapperTest() throws Exception {
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
+ modelInfoServiceInstance.setModelName("modelName");
+ modelInfoServiceInstance.setModelUuid("modelUuid");
+ modelInfoServiceInstance.setModelVersion("modelVersion");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- // prepare Customer object
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
+ // prepare Customer object
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
- customer.setServiceSubscription(new ServiceSubscription());
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ customer.setServiceSubscription(new ServiceSubscription());
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- //prepare RequestContext
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
- requestContext.setMsoRequestId("MsoRequestId");
+ // prepare RequestContext
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+ requestContext.setMsoRequestId("MsoRequestId");
- GenericResourceApiServiceOperationInformation serviceOpInformation = mapper.reqMapper(
- SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
- requestContext);
- GenericResourceApiServiceOperationInformation serviceOpInformationNullReqContext = mapper.reqMapper(
- SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
- null);
+ GenericResourceApiServiceOperationInformation serviceOpInformation =
+ mapper.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
+ requestContext);
+ GenericResourceApiServiceOperationInformation serviceOpInformationNullReqContext = mapper.reqMapper(
+ SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer, null);
- String jsonToCompare = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json")));
+ String jsonToCompare = new String(Files.readAllBytes(
+ Paths.get("src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json")));
- ObjectMapper omapper = new ObjectMapper();
- GenericResourceApiOnapmodelinformationOnapModelInformation reqMapper1 = omapper.readValue(jsonToCompare,
- GenericResourceApiOnapmodelinformationOnapModelInformation.class);
+ ObjectMapper omapper = new ObjectMapper();
+ GenericResourceApiOnapmodelinformationOnapModelInformation reqMapper1 =
+ omapper.readValue(jsonToCompare, GenericResourceApiOnapmodelinformationOnapModelInformation.class);
- assertThat(reqMapper1, sameBeanAs(serviceOpInformation.getServiceInformation().getOnapModelInformation()));
- assertEquals("MsoRequestId", serviceOpInformation.getRequestInformation().getRequestId());
- assertNotNull(serviceOpInformationNullReqContext.getRequestInformation().getRequestId());
- }
+ assertThat(reqMapper1, sameBeanAs(serviceOpInformation.getServiceInformation().getOnapModelInformation()));
+ assertEquals("MsoRequestId", serviceOpInformation.getRequestInformation().getRequestId());
+ assertNotNull(serviceOpInformationNullReqContext.getRequestInformation().getRequestId());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
index 7fce8c48c8..275e9f7dbb 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
@@ -25,14 +25,12 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -55,283 +53,284 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-
import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
public class VfModuleTopologyOperationRequestMapperTest {
- private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
- private final static String ERRORMESSAGE = "VF Module model info is null for testVfModuleId";
-
- @Spy
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
-
- @InjectMocks
- private VfModuleTopologyOperationRequestMapper mapper = new VfModuleTopologyOperationRequestMapper();
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Test
- public void assignGenericResourceApiVfModuleInformationTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- // prepare Customer object
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("productFamilyId");
- customer.setServiceSubscription(serviceSubscription);
-
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- //
- RequestContext requestContext = new RequestContext();
- Map<String,Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setUsePreload(true);
- requestContext.setRequestParameters(requestParameters);
- requestContext.setMsoRequestId("MsoRequestId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("testVnfId");
- vnf.setVnfType("testVnfType");
- vnf.setVnfName("testVnfName");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId");
- vfModule.setVfModuleName("testVfModuleName");
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
- HashMap<String, String> cloudParams = new HashMap<String, String>();
- cloudParams.put("key2", "value2");
- vfModule.setCloudParams(cloudParams);
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- volumeGroup.setVolumeGroupName("volumeGroupName");
-
- CloudRegion cloudRegion = new CloudRegion();
-
- GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer,
- cloudRegion, requestContext, null);
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationAssign.json")));
-
- ObjectMapper omapper = new ObjectMapper();
- GenericResourceApiVfModuleOperationInformation reqMapper1 = omapper.readValue(
- jsonToCompare,
- GenericResourceApiVfModuleOperationInformation.class);
-
- assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
- .ignoring("requestInformation.requestId"));
- assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
- }
-
- @Test
- public void unassignGenericResourceApiVfModuleInformationTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- // prepare and set vnf instance
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("testVnfId");
- vnf.setVnfType("testVnfType");
-
- // prepare and set vf module instance
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId");
- vfModule.setVfModuleName("testVfModuleName");
-
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId("MsoRequestId");
-
- GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null,
- null, requestContext, null);
-
- String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationUnassign.json")));
-
- ObjectMapper omapper = new ObjectMapper();
- GenericResourceApiVfModuleOperationInformation reqMapper1 = omapper.readValue(
- jsonToCompare,
- GenericResourceApiVfModuleOperationInformation.class);
-
- assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
- .ignoring("requestInformation.requestId"));
- assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
- }
-
- @Test
- public void unassignGenericResourceApiVfModuleInformationNullMsoReqIdTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- // prepare and set vnf instance
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("testVnfId");
- vnf.setVnfType("testVnfType");
-
- // prepare and set vf module instance
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId");
- vfModule.setVfModuleName("testVfModuleName");
-
- RequestContext requestContext = new RequestContext();
-
- GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null,
- null, requestContext, null);
-
- assertNotNull(vfModuleSDNCrequest.getRequestInformation().getRequestId());
- }
-
- @Test
- public void reqMapperTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
-
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- // prepare Customer object
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- customer.setServiceSubscription(new ServiceSubscription());
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- //
- RequestContext requestContext = new RequestContext();
- RequestParameters requestParameters = new RequestParameters();
- HashMap<String,Object> userParams1 = new HashMap<>();
- userParams1.put("key1", "value1");
- List<Map<String,Object>> userParams = new ArrayList<>();
- userParams.add(userParams1);
-
- requestParameters.setUserParams(userParams);
- requestContext.setRequestParameters(requestParameters);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("testVnfId");
- vnf.setVnfType("testVnfType");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId");
- vfModule.setVfModuleName("testVfModuleName");
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
- modelInfoVfModule.setModelName("vfModuleModelName");
- modelInfoVfModule.setModelVersion("vfModuleModelVersion");
- modelInfoVfModule.setModelUUID("vfModuleModelUuid");
- modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
- vfModule.setModelInfoVfModule(modelInfoVfModule);
-
- CloudRegion cloudRegion = new CloudRegion();
-
- GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(
- SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, serviceInstance, customer,
- cloudRegion, requestContext, null);
-
- assertNull(vfModuleSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
- assertEquals("vnfModelCustomizationUuid", vfModuleSDNCrequest.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
- assertEquals("vfModuleModelCustomizationUuid", vfModuleSDNCrequest.getVfModuleInformation().getOnapModelInformation().getModelCustomizationUuid());
- }
-
- @Test
- public void reqMapperNoModelInfoTest() throws Exception {
-
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
- modelInfoServiceInstance.setModelName("serviceModelName");
- modelInfoServiceInstance.setModelUuid("serviceModelUuid");
- modelInfoServiceInstance.setModelVersion("serviceModelVersion");
-
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- // prepare Customer object
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- customer.setServiceSubscription(new ServiceSubscription());
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- //
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<String, Object>();
- userParams.put("key1", "value1");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("testVnfId");
- vnf.setVnfType("testVnfType");
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
- modelInfoGenericVnf.setModelName("vnfModelName");
- modelInfoGenericVnf.setModelVersion("vnfModelVersion");
- modelInfoGenericVnf.setModelUuid("vnfModelUuid");
- modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
- vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId");
- vfModule.setVfModuleName("testVfModuleName");
- vfModule.setModelInfoVfModule(null);
-
- CloudRegion cloudRegion = new CloudRegion();
-
- expectedException.expect(MapperException.class);
- expectedException.expectMessage(ERRORMESSAGE);
-
- mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, serviceInstance, customer,
- cloudRegion, requestContext, null);
- }
+ private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
+ private final static String ERRORMESSAGE = "VF Module model info is null for testVfModuleId";
+
+ @Spy
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ @InjectMocks
+ private VfModuleTopologyOperationRequestMapper mapper = new VfModuleTopologyOperationRequestMapper();
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void assignGenericResourceApiVfModuleInformationTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ // prepare Customer object
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("productFamilyId");
+ customer.setServiceSubscription(serviceSubscription);
+
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ //
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUsePreload(true);
+ requestContext.setRequestParameters(requestParameters);
+ requestContext.setMsoRequestId("MsoRequestId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("testVnfId");
+ vnf.setVnfType("testVnfType");
+ vnf.setVnfName("testVnfName");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId");
+ vfModule.setVfModuleName("testVfModuleName");
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+ HashMap<String, String> cloudParams = new HashMap<String, String>();
+ cloudParams.put("key2", "value2");
+ vfModule.setCloudParams(cloudParams);
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ volumeGroup.setVolumeGroupName("volumeGroupName");
+
+ CloudRegion cloudRegion = new CloudRegion();
+
+ GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule,
+ volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null);
+
+ String jsonToCompare = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationAssign.json")));
+
+ ObjectMapper omapper = new ObjectMapper();
+ GenericResourceApiVfModuleOperationInformation reqMapper1 =
+ omapper.readValue(jsonToCompare, GenericResourceApiVfModuleOperationInformation.class);
+
+ assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
+ .ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
+ }
+
+ @Test
+ public void unassignGenericResourceApiVfModuleInformationTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ // prepare and set vnf instance
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("testVnfId");
+ vnf.setVnfType("testVnfType");
+
+ // prepare and set vf module instance
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId");
+ vfModule.setVfModuleName("testVfModuleName");
+
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId("MsoRequestId");
+
+ GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null,
+ vnf, serviceInstance, null, null, requestContext, null);
+
+ String jsonToCompare = new String(Files.readAllBytes(
+ Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationUnassign.json")));
+
+ ObjectMapper omapper = new ObjectMapper();
+ GenericResourceApiVfModuleOperationInformation reqMapper1 =
+ omapper.readValue(jsonToCompare, GenericResourceApiVfModuleOperationInformation.class);
+
+ assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId")
+ .ignoring("requestInformation.requestId"));
+ assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId());
+ }
+
+ @Test
+ public void unassignGenericResourceApiVfModuleInformationNullMsoReqIdTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ // prepare and set vnf instance
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("testVnfId");
+ vnf.setVnfType("testVnfType");
+
+ // prepare and set vf module instance
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId");
+ vfModule.setVfModuleName("testVfModuleName");
+
+ RequestContext requestContext = new RequestContext();
+
+ GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null,
+ vnf, serviceInstance, null, null, requestContext, null);
+
+ assertNotNull(vfModuleSDNCrequest.getRequestInformation().getRequestId());
+ }
+
+ @Test
+ public void reqMapperTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ // prepare Customer object
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ customer.setServiceSubscription(new ServiceSubscription());
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ //
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ HashMap<String, Object> userParams1 = new HashMap<>();
+ userParams1.put("key1", "value1");
+ List<Map<String, Object>> userParams = new ArrayList<>();
+ userParams.add(userParams1);
+
+ requestParameters.setUserParams(userParams);
+ requestContext.setRequestParameters(requestParameters);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("testVnfId");
+ vnf.setVnfType("testVnfType");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId");
+ vfModule.setVfModuleName("testVfModuleName");
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
+ modelInfoVfModule.setModelName("vfModuleModelName");
+ modelInfoVfModule.setModelVersion("vfModuleModelVersion");
+ modelInfoVfModule.setModelUUID("vfModuleModelUuid");
+ modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+
+ CloudRegion cloudRegion = new CloudRegion();
+
+ GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest =
+ mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null,
+ vnf, serviceInstance, customer, cloudRegion, requestContext, null);
+
+ assertNull(vfModuleSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("vnfModelCustomizationUuid",
+ vfModuleSDNCrequest.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("vfModuleModelCustomizationUuid",
+ vfModuleSDNCrequest.getVfModuleInformation().getOnapModelInformation().getModelCustomizationUuid());
+ }
+
+ @Test
+ public void reqMapperNoModelInfoTest() throws Exception {
+
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
+ modelInfoServiceInstance.setModelName("serviceModelName");
+ modelInfoServiceInstance.setModelUuid("serviceModelUuid");
+ modelInfoServiceInstance.setModelVersion("serviceModelVersion");
+
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ // prepare Customer object
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ customer.setServiceSubscription(new ServiceSubscription());
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ //
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<String, Object>();
+ userParams.put("key1", "value1");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("testVnfId");
+ vnf.setVnfType("testVnfType");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
+ modelInfoGenericVnf.setModelName("vnfModelName");
+ modelInfoGenericVnf.setModelVersion("vnfModelVersion");
+ modelInfoGenericVnf.setModelUuid("vnfModelUuid");
+ modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
+ vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId");
+ vfModule.setVfModuleName("testVfModuleName");
+ vfModule.setModelInfoVfModule(null);
+
+ CloudRegion cloudRegion = new CloudRegion();
+
+ expectedException.expect(MapperException.class);
+ expectedException.expectMessage(ERRORMESSAGE);
+
+ mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf,
+ serviceInstance, customer, cloudRegion, requestContext, null);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
index 64b532fd07..cecf34ea10 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java
@@ -23,12 +23,10 @@ package org.onap.so.client.sdnc.mapper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -47,101 +45,107 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-
import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
@RunWith(MockitoJUnitRunner.class)
public class VnfTopologyOperationRequestMapperTest {
- @Spy
- private GeneralTopologyObjectMapper generalTopologyObjectMapper;
-
- @InjectMocks
- private VnfTopologyOperationRequestMapper mapper = new VnfTopologyOperationRequestMapper();
-
- @Test
- public void reqMapperTest() throws Exception {
- // prepare and set service instance
- ServiceInstance serviceInstance = new ServiceInstance();
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
- modelInfoServiceInstance.setModelName("modelName");
- modelInfoServiceInstance.setModelUuid("modelUuid");
- modelInfoServiceInstance.setModelVersion("modelVersion");
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
-
- //prepare VNF
- ModelInfoGenericVnf genericVnf = new ModelInfoGenericVnf();
- genericVnf.setModelInvariantUuid("vnfModelInvariantUUID");
- genericVnf.setModelVersion("vnfModelVersion");
- genericVnf.setModelName("vnfModelName");
- genericVnf.setModelUuid("vnfModelUUID");
- genericVnf.setModelCustomizationUuid("vnfModelCustomizationUUID");
-
- ModelInfoInstanceGroup modelL3Network = new ModelInfoInstanceGroup();
- modelL3Network.setType("L3-NETWORK");
-
- InstanceGroup instanceGroup1 = new InstanceGroup();
- instanceGroup1.setId("l3-network-ig-111");
- instanceGroup1.setModelInfoInstanceGroup(modelL3Network);
-
- InstanceGroup instanceGroup2 = new InstanceGroup();
- instanceGroup2.setId("l3-network-ig-222");
- instanceGroup2.setModelInfoInstanceGroup(modelL3Network);
-
- GenericVnf vnf = new GenericVnf();
- vnf.setModelInfoGenericVnf(genericVnf);
- vnf.setVnfId("vnfId");
- vnf.setVnfType("vnfType");
- vnf.getInstanceGroups().add(instanceGroup1);
- vnf.getInstanceGroups().add(instanceGroup2);
- License license = new License();
- List<String> entitlementPoolUuids = new ArrayList<>();
- entitlementPoolUuids.add("entitlementPoolUuid");
- List<String> licenseKeyGroupUuids = new ArrayList<>();
- licenseKeyGroupUuids.add("licenseKeyGroupUuid");
- license.setEntitlementPoolUuids(entitlementPoolUuids);
- license.setLicenseKeyGroupUuids(licenseKeyGroupUuids);
- vnf.setLicense(license);
-
- // prepare Customer object
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
-
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("productFamilyId");
- customer.setServiceSubscription(serviceSubscription);
-
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
-
-
- //prepare RequestContext
- RequestContext requestContext = new RequestContext();
- Map<String, Object> userParams = new HashMap<>();
- userParams.put("key1", "value1");
- requestContext.setUserParams(userParams);
- requestContext.setProductFamilyId("productFamilyId");
- requestContext.setMsoRequestId("MsoRequestId");
-
- CloudRegion cloudRegion = new CloudRegion();
-
- GenericResourceApiVnfOperationInformation vnfOpInformation = mapper.reqMapper(
- SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
- cloudRegion, requestContext,true);
- GenericResourceApiVnfOperationInformation vnfOpInformationNullReqContext = mapper.reqMapper(
- SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
- cloudRegion, null,true);
-
- assertNull(vnfOpInformation.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
- assertEquals("vnfModelCustomizationUUID", vnfOpInformation.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
- assertEquals(2, vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().size());
- assertEquals("l3-network-ig-111", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(0).getVnfNetworkInstanceGroupId());
- assertEquals("l3-network-ig-222", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(1).getVnfNetworkInstanceGroupId());
- assertEquals("entitlementPoolUuid", vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(1).getValue());
- assertEquals("licenseKeyGroupUuid", vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(2).getValue());
- assertEquals("MsoRequestId", vnfOpInformation.getRequestInformation().getRequestId());
- assertNotNull(vnfOpInformationNullReqContext.getRequestInformation().getRequestId());
- }
+ @Spy
+ private GeneralTopologyObjectMapper generalTopologyObjectMapper;
+
+ @InjectMocks
+ private VnfTopologyOperationRequestMapper mapper = new VnfTopologyOperationRequestMapper();
+
+ @Test
+ public void reqMapperTest() throws Exception {
+ // prepare and set service instance
+ ServiceInstance serviceInstance = new ServiceInstance();
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
+ modelInfoServiceInstance.setModelName("modelName");
+ modelInfoServiceInstance.setModelUuid("modelUuid");
+ modelInfoServiceInstance.setModelVersion("modelVersion");
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ // prepare VNF
+ ModelInfoGenericVnf genericVnf = new ModelInfoGenericVnf();
+ genericVnf.setModelInvariantUuid("vnfModelInvariantUUID");
+ genericVnf.setModelVersion("vnfModelVersion");
+ genericVnf.setModelName("vnfModelName");
+ genericVnf.setModelUuid("vnfModelUUID");
+ genericVnf.setModelCustomizationUuid("vnfModelCustomizationUUID");
+
+ ModelInfoInstanceGroup modelL3Network = new ModelInfoInstanceGroup();
+ modelL3Network.setType("L3-NETWORK");
+
+ InstanceGroup instanceGroup1 = new InstanceGroup();
+ instanceGroup1.setId("l3-network-ig-111");
+ instanceGroup1.setModelInfoInstanceGroup(modelL3Network);
+
+ InstanceGroup instanceGroup2 = new InstanceGroup();
+ instanceGroup2.setId("l3-network-ig-222");
+ instanceGroup2.setModelInfoInstanceGroup(modelL3Network);
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setModelInfoGenericVnf(genericVnf);
+ vnf.setVnfId("vnfId");
+ vnf.setVnfType("vnfType");
+ vnf.getInstanceGroups().add(instanceGroup1);
+ vnf.getInstanceGroups().add(instanceGroup2);
+ License license = new License();
+ List<String> entitlementPoolUuids = new ArrayList<>();
+ entitlementPoolUuids.add("entitlementPoolUuid");
+ List<String> licenseKeyGroupUuids = new ArrayList<>();
+ licenseKeyGroupUuids.add("licenseKeyGroupUuid");
+ license.setEntitlementPoolUuids(entitlementPoolUuids);
+ license.setLicenseKeyGroupUuids(licenseKeyGroupUuids);
+ vnf.setLicense(license);
+
+ // prepare Customer object
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("productFamilyId");
+ customer.setServiceSubscription(serviceSubscription);
+
+ // set Customer on service instance
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+
+
+ // prepare RequestContext
+ RequestContext requestContext = new RequestContext();
+ Map<String, Object> userParams = new HashMap<>();
+ userParams.put("key1", "value1");
+ requestContext.setUserParams(userParams);
+ requestContext.setProductFamilyId("productFamilyId");
+ requestContext.setMsoRequestId("MsoRequestId");
+
+ CloudRegion cloudRegion = new CloudRegion();
+
+ GenericResourceApiVnfOperationInformation vnfOpInformation =
+ mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
+ cloudRegion, requestContext, true);
+ GenericResourceApiVnfOperationInformation vnfOpInformationNullReqContext =
+ mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN,
+ GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer,
+ cloudRegion, null, true);
+
+ assertNull(vnfOpInformation.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals("vnfModelCustomizationUUID",
+ vnfOpInformation.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals(2, vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().size());
+ assertEquals("l3-network-ig-111", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(0)
+ .getVnfNetworkInstanceGroupId());
+ assertEquals("l3-network-ig-222", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(1)
+ .getVnfNetworkInstanceGroupId());
+ assertEquals("entitlementPoolUuid",
+ vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(1).getValue());
+ assertEquals("licenseKeyGroupUuid",
+ vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(2).getValue());
+ assertEquals("MsoRequestId", vnfOpInformation.getRequestInformation().getRequestId());
+ assertNotNull(vnfOpInformationNullReqContext.getRequestInformation().getRequestId());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java
index 722180f54b..56c52388f8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java
@@ -23,14 +23,12 @@ package org.onap.so.client.sniro;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.sniro.beans.SniroConductorRequest;
import org.onap.so.client.sniro.beans.SniroManagerRequest;
import org.springframework.beans.factory.annotation.Autowired;
-
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -42,108 +40,96 @@ public class SniroClientTestIT extends BaseIntegrationTest {
@Test(expected = Test.None.class)
public void testPostDemands_success() throws BadResponseException, JsonProcessingException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"corys cool\", \"requestStatus\": \"accepted\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"corys cool\", \"requestStatus\": \"accepted\"}";
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postDemands(new SniroManagerRequest());
+ client.postDemands(new SniroManagerRequest());
}
@Test(expected = BadResponseException.class)
public void testPostDemands_error_failed() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": \"failed\"}";
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postDemands(new SniroManagerRequest());
+ client.postDemands(new SniroManagerRequest());
- //TODO assertEquals("missing data", );
+ // TODO assertEquals("missing data", );
}
@Test(expected = BadResponseException.class)
public void testPostDemands_error_noMessage() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"\", \"requestStatus\": \"failed\"}";
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postDemands(new SniroManagerRequest());
+ client.postDemands(new SniroManagerRequest());
}
@Test(expected = BadResponseException.class)
public void testPostDemands_error_noStatus() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}";
+ String mockResponse =
+ "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"missing data\", \"requestStatus\": null}";
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postDemands(new SniroManagerRequest());
+ client.postDemands(new SniroManagerRequest());
}
@Test(expected = BadResponseException.class)
public void testPostDemands_error_empty() throws JsonProcessingException, BadResponseException {
- String mockResponse = "{ }";
+ String mockResponse = "{ }";
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postDemands(new SniroManagerRequest());
+ client.postDemands(new SniroManagerRequest());
}
@Test(expected = Test.None.class)
public void testPostRelease_success() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"status\": \"success\", \"message\": \"corys cool\"}";
- wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postRelease(new SniroConductorRequest());
+ client.postRelease(new SniroConductorRequest());
}
@Test(expected = BadResponseException.class)
public void testPostRelease_error_failed() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"status\": \"failure\", \"message\": \"corys cool\"}";
- wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postRelease(new SniroConductorRequest());
+ client.postRelease(new SniroConductorRequest());
}
@Test(expected = BadResponseException.class)
public void testPostRelease_error_noStatus() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"status\": \"\", \"message\": \"corys cool\"}";
- wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postRelease(new SniroConductorRequest());
+ client.postRelease(new SniroConductorRequest());
}
@@ -151,12 +137,10 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostRelease_error_noMessage() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"status\": \"failure\", \"message\": null}";
- wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postRelease(new SniroConductorRequest());
+ client.postRelease(new SniroConductorRequest());
}
@@ -164,12 +148,10 @@ public class SniroClientTestIT extends BaseIntegrationTest {
public void testPostRelease_error_empty() throws BadResponseException, JsonProcessingException {
String mockResponse = "{ }";
- wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders"))
- .willReturn(aResponse().withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBody(mockResponse)));
+ wireMockServer.stubFor(post(urlEqualTo("/v1/release-orders")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse)));
- client.postRelease(new SniroConductorRequest());
+ client.postRelease(new SniroConductorRequest());
}