aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/AllIntegrationTestSuites.java32
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java (renamed from bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseTest.java)67
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/IntegrationTestSuite.java32
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/UnitTestSuite.java33
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java139
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java41
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java20
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java85
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java36
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java95
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivityTest.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java32
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasksTest.java59
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java19
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java28
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasksTest.java51
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasksTest.java27
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java33
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java (renamed from bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksITTest.java)6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java2
-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.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java17
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java44
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOutTest.java24
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollectionTest.java20
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkTest.java15
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java25
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtilsTest.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java496
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java24
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignVnfTest.java26
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java82
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java71
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java55
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java75
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java50
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java85
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java32
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java161
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java126
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java16
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java146
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java137
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java94
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java906
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java14
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/sdno/tasks/SDNOHealthCheckTasksTest.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/NetworkAdapterClientIT.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java60
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfAdapterClientIT.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientIT.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java104
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java119
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java105
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java15
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java19
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java15
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java37
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java11
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java15
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java36
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java15
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVpnBindingResourcesTest.java25
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java105
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NetworkAdapterResourcesTest.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java45
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java189
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java54
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java78
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java82
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java11
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResourcesTest.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResourcesTest.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java (renamed from bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientTest.java)20
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sniro/SniroClientTestIT.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json58
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json59
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json106
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterDeleteVfModuleRequest.json3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/CreateNetworkCollection.json1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json125
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/VnfMacroReplace.json25
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/AssignResponse.json14
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/ErrorResponse.json6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/UnassignResponse.json14
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json15
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_ASYNC_Request.json15
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Client_Request.json28
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml23
101 files changed, 3779 insertions, 1591 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
new file mode 100644
index 0000000000..23fcddfe8a
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/AllIntegrationTestSuites.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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;
+
+import org.junit.runner.RunWith;
+
+import com.googlecode.junittoolbox.SuiteClasses;
+import com.googlecode.junittoolbox.WildcardPatternSuite;
+
+@RunWith(WildcardPatternSuite.class)
+@SuiteClasses({"**/SniroHomingV2IT.class"})
+public class AllIntegrationTestSuites{
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java
index e527b587b7..6500e3a850 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/BaseIntegrationTest.java
@@ -19,26 +19,87 @@
*/
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;
import org.onap.so.bpmn.common.data.TestDataSetup;
+import org.onap.so.client.appc.ApplicationControllerAction;
import org.onap.so.client.orchestration.SDNOHealthCheckResources;
+import org.onap.so.client.sdnc.SDNCClient;
+import org.onap.so.client.sniro.SniroClient;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
+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.client.WireMock;
+
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
@ContextConfiguration
-public abstract class BaseTest extends TestDataSetup {
-
+@AutoConfigureWireMock(port = 0)
+public abstract class BaseIntegrationTest extends TestDataSetup {
+
+ @Value("${wiremock.server.port}")
+ protected String wireMockPort;
+
+ @SpyBean
+ protected SDNCClient SPY_sdncClient;
+
@SpyBean
protected SDNOHealthCheckResources MOCK_sdnoHealthCheckResources;
- @MockBean
+ @SpyBean
protected SniroHomingV2 sniroHoming;
+
+ @SpyBean
+ protected SniroClient sniroClient;
+
+ @MockBean
+ protected ApplicationControllerAction appCClient;
+
+ @MockBean
+ protected CatalogDbClient catalogDbClient;
+
+ @Before
+ public void baseTestBefore() {
+ WireMock.reset();
+ }
+ 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;
+ }
}
+
+
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 a29df9cbcf..fb08e5e830 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
@@ -23,7 +23,7 @@ import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
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
new file mode 100644
index 0000000000..0eddeb1649
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/IntegrationTestSuite.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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;
+
+import org.junit.runner.RunWith;
+
+import com.googlecode.junittoolbox.SuiteClasses;
+import com.googlecode.junittoolbox.WildcardPatternSuite;
+
+@RunWith(WildcardPatternSuite.class)
+@SuiteClasses({"**/*IT.class"})
+public class IntegrationTestSuite {
+
+}
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 9244f7ee1f..87153144c8 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
@@ -21,7 +21,6 @@ package org.onap.so;
-import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;
import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -32,7 +31,6 @@ import org.springframework.context.annotation.Profile;
@SpringBootApplication
@Profile("test")
-@EnableProcessApplication("MSO CommonBPMN Test Application")
@ComponentScan(basePackages = {"org.onap.so"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = {
@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
public class TestApplication {
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
new file mode 100644
index 0000000000..82ad6582c5
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/UnitTestSuite.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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;
+
+
+import org.junit.runner.RunWith;
+
+import com.googlecode.junittoolbox.SuiteClasses;
+import com.googlecode.junittoolbox.WildcardPatternSuite;
+
+@RunWith(WildcardPatternSuite.class)
+@SuiteClasses({"**/*Test.class"})
+public class UnitTestSuite {
+
+}
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 2b25dfd9f1..7715de9672 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
@@ -7,9 +7,9 @@
* 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.
@@ -21,13 +21,19 @@ package org.onap.so.bpmn;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.onap.so.TestApplication;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.AssignNetworkBBUtils;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionExtractResourcesAAI;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper;
import org.onap.so.client.appc.ApplicationControllerAction;
+import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.AAICollectionResources;
import org.onap.so.client.orchestration.AAIConfigurationResources;
import org.onap.so.client.orchestration.AAIInstanceGroupResources;
@@ -37,6 +43,7 @@ import org.onap.so.client.orchestration.AAIVfModuleResources;
import org.onap.so.client.orchestration.AAIVnfResources;
import org.onap.so.client.orchestration.AAIVolumeGroupResources;
import org.onap.so.client.orchestration.AAIVpnBindingResources;
+import org.onap.so.client.orchestration.NamingServiceResources;
import org.onap.so.client.orchestration.NetworkAdapterResources;
import org.onap.so.client.orchestration.SDNCNetworkResources;
import org.onap.so.client.orchestration.SDNCServiceInstanceResources;
@@ -44,90 +51,102 @@ import org.onap.so.client.orchestration.SDNCVfModuleResources;
import org.onap.so.client.orchestration.SDNCVnfResources;
import org.onap.so.client.orchestration.VnfAdapterVfModuleResources;
import org.onap.so.client.orchestration.VnfAdapterVolumeGroupResources;
-import org.onap.so.client.sdnc.SDNCClient;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.client.RequestsDbClient;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.mock.mockito.MockBean;
-import org.springframework.boot.test.mock.mockito.SpyBean;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("test")
+import org.springframework.core.env.Environment;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
public abstract class BaseTaskTest extends TestDataSetup {
- @MockBean
+ @Mock
protected AAIVolumeGroupResources aaiVolumeGroupResources;
-
- @MockBean
+
+ @Mock
protected AAIServiceInstanceResources aaiServiceInstanceResources;
-
- @MockBean
+
+ @Mock
protected AAIVnfResources aaiVnfResources;
-
- @MockBean
+
+ @Mock
protected AAIVfModuleResources aaiVfModuleResources;
-
- @MockBean
+
+ @Mock
protected AAIVpnBindingResources aaiVpnBindingResources;
-
- @MockBean
+
+ @Mock
protected AAINetworkResources aaiNetworkResources;
-
- @MockBean
+
+ @Mock
protected AAICollectionResources aaiCollectionResources;
-
- @MockBean
+
+ @Mock
protected NetworkAdapterResources networkAdapterResources;
-
- @MockBean
+
+ @Mock
protected VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
-
- @MockBean
+
+ @Mock
protected VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
-
- @MockBean
+
+ @Mock
protected SDNCVnfResources sdncVnfResources;
-
- @MockBean
+
+ @Mock
protected SDNCNetworkResources sdncNetworkResources;
-
- @MockBean
+
+ @Mock
protected SDNCVfModuleResources sdncVfModuleResources;
-
- @MockBean
+
+ @Mock
protected SDNCServiceInstanceResources sdncServiceInstanceResources;
-
- @MockBean
+
+ @Mock
protected AssignNetworkBBUtils assignNetworkBBUtils;
-
- @MockBean
+
+ @Mock
protected NetworkAdapterObjectMapper networkAdapterObjectMapper;
-
- @MockBean
+
+ @Mock
protected AAIInstanceGroupResources aaiInstanceGroupResources;
- @MockBean
+ @Mock
+ protected NamingServiceResources namingServiceResources;
+
+ @Mock
+ protected ApplicationControllerAction appCClient;
+
+ @Mock
protected CatalogDbClient catalogDbClient;
-
- @MockBean
- @Qualifier("RequestsDbClient")
+
+ @Mock
protected RequestsDbClient requestsDbClient;
-
+
@Mock
protected BBInputSetupUtils bbSetupUtils;
-
+
@Mock
protected BBInputSetup bbInputSetup;
-
- @SpyBean
- protected SDNCClient SPY_sdncClient;
-
- @MockBean
- protected ApplicationControllerAction appCClient;
- @MockBean
+ @Mock
protected AAIConfigurationResources aaiConfigurationResources;
+
+ @Mock
+ protected AAIObjectMapper MOCK_aaiObjectMapper;
+
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
+
+ @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 946c5dfe80..cf28c114e8 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
@@ -19,9 +19,9 @@
*/
package org.onap.so.bpmn.common.aai.tasks;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -33,9 +33,11 @@ import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.common.data.TestDataSetup;
@@ -49,31 +51,12 @@ import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.AAIVnfResources;
import org.springframework.beans.factory.annotation.Autowired;
-@RunWith(MockitoJUnitRunner.class)
-public class AAIFlagTasksTest extends TestDataSetup {
+
+public class AAIFlagTasksTest extends BaseTaskTest {
@InjectMocks
private AAIFlagTasks aaiFlagTasks = new AAIFlagTasks();
- @Mock
- private AAIVnfResources aaiVnfResources;
-
- @Mock
- protected AAIObjectMapper MOCK_aaiObjectMapper;
-
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
-
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
-
- @Mock
- private ExtractPojosForBB extractPojosForBB;
-
- @Mock
- private ExceptionBuilder exceptionUtil;
-
private GenericVnf genericVnf;
@Before
@@ -107,7 +90,7 @@ public class AAIFlagTasksTest extends TestDataSetup {
public void checkVnfInMaintFlagExceptionTest() {
doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
- doThrow(Exception.class).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
+ doThrow(RuntimeException.class).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
try {
aaiFlagTasks.checkVnfInMaintFlag(execution);
} catch (Exception e) {
@@ -119,16 +102,16 @@ public class AAIFlagTasksTest extends TestDataSetup {
@Test
public void modifyVnfInMaintFlagTest() throws Exception {
- doNothing().when(aaiVnfResources).updateObjectVnf(isA(GenericVnf.class));
+ doNothing().when(aaiVnfResources).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
aaiFlagTasks.modifyVnfInMaintFlag(execution, true);
- verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
+ 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(Exception.class).when(aaiVnfResources).updateObjectVnf(isA(GenericVnf.class));
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(isA(GenericVnf.class));
try {
aaiFlagTasks.modifyVnfInMaintFlag(execution, true);
} catch (Exception e) {
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 380a94f951..df1f0adcea 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
@@ -23,12 +23,12 @@ 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.assertj.core.util.Arrays;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl;
import org.junit.Before;
@@ -306,6 +306,7 @@ public class TestDataSetup{
modelInfoServiceInstance.setModelVersion("testModelVersion" + serviceInstanceCounter);
modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter);
modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter);
+ modelInfoServiceInstance.setServiceRole("testServiceRole" + serviceInstanceCounter);
serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
serviceInstance.setProject(buildProject());
@@ -381,6 +382,7 @@ public class TestDataSetup{
collection.setInstanceGroup(instanceGroup);
+
return instanceGroup;
}
@@ -478,6 +480,8 @@ public class TestDataSetup{
modelInfoGenericVnf.setModelInvariantUuid("testModelInvariantUUID" + genericVnfCounter);
modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter);
modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter);
+ modelInfoGenericVnf.setModelInstanceName("testInstanceName" + genericVnfCounter);
+
genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
License license = new License();
@@ -652,6 +656,7 @@ public class TestDataSetup{
modelInfo.setModelName("testProxyModelName" + uniqueIdentifier);
modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier);
modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier);
+ modelInfo.setModelInstanceName("testProxyInstanceName" + uniqueIdentifier);
serviceProxy.setModelInfoServiceProxy(modelInfo);
@@ -663,10 +668,11 @@ public class TestDataSetup{
ar.setId("testAllottedResourceId" + uniqueIdentifier);
ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource();
- modelInfo.setModelInvariantUuid("testProxyModelInvariantUuid" + uniqueIdentifier);
- modelInfo.setModelName("testProxyModelName" + uniqueIdentifier);
- modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier);
- modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier);
+ modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier);
+ modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier);
+ modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
+ modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
+ modelInfo.setModelInstanceName("testAllottedModelInstanceName" + uniqueIdentifier);
ar.setModelInfoAllottedResource(modelInfo);
@@ -688,7 +694,7 @@ public class TestDataSetup{
serviceInstance.setConfigurations(configurations);
return config;
}
-
+
public Subnet buildSubnet() {
Subnet subnet = new Subnet();
subnet.setSubnetId("testSubnetId");
@@ -696,4 +702,4 @@ public class TestDataSetup{
subnet.setNeutronSubnetId("testNeutronSubnetId");
return subnet;
}
-} \ No newline at end of file
+}
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 0b802a3385..da7e727488 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
@@ -19,22 +19,25 @@
*/
package org.onap.so.bpmn.infrastructure.aai.tasks;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
-import java.util.ArrayList;
-import java.util.List;
+import static org.mockito.Mockito.when;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
@@ -44,12 +47,14 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-import org.springframework.beans.factory.annotation.Autowired;
public class AAICreateTasksTest extends BaseTaskTest{
- @Autowired
- private AAICreateTasks aaiCreateTasks;
+
+ @InjectMocks
+ private AAICreateTasks aaiCreateTasks = new AAICreateTasks();
+
private ServiceInstance serviceInstance;
private L3Network network;
@@ -60,11 +65,11 @@ public class AAICreateTasksTest extends BaseTaskTest{
private Customer customer;
private Configuration configuration;
- @Rule
- public final ExpectedException exception = ExpectedException.none();
+ @Rule
+ public final ExpectedException exception = ExpectedException.none();
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
customer = setCustomer();
serviceInstance = setServiceInstance();
network = setL3Network();
@@ -73,6 +78,17 @@ public class AAICreateTasksTest extends BaseTaskTest{
cloudRegion = setCloudRegion();
vfModule = setVfModule();
configuration = setConfiguration();
+
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any())).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID), any())).thenReturn(configuration);
+
+
+ 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));
}
@@ -88,7 +104,7 @@ public class AAICreateTasksTest extends BaseTaskTest{
expectedException.expect(BpmnError.class);
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "notfound");
- doThrow(Exception.class).when(aaiServiceInstanceResources).createServiceInstance(serviceInstance, customer);
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).createServiceInstance(serviceInstance, customer);
aaiCreateTasks.createServiceInstance(execution);
}
@@ -112,7 +128,7 @@ public class AAICreateTasksTest extends BaseTaskTest{
volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- doThrow(Exception.class).when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion);
aaiCreateTasks.createVolumeGroup(execution);
}
@@ -143,7 +159,7 @@ public class AAICreateTasksTest extends BaseTaskTest{
expectedException.expect(BpmnError.class);
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "notfound");
- doThrow(Exception.class).when(aaiServiceInstanceResources).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
aaiCreateTasks.createProject(execution);
}
@@ -227,7 +243,7 @@ public class AAICreateTasksTest extends BaseTaskTest{
doReturn(true).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
- doThrow(Exception.class).when(aaiServiceInstanceResources).connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
aaiCreateTasks.createOwningEntity(execution);
}
@@ -241,9 +257,9 @@ public class AAICreateTasksTest extends BaseTaskTest{
@Test
public void createVnfExceptionTest() throws Exception {
- expectedException.expect(BpmnError.class);
-
+ expectedException.expect(BpmnError.class);
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "notfound");
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID),eq("notfound"));
doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
aaiCreateTasks.createVnf(execution);
verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
@@ -267,7 +283,7 @@ public class AAICreateTasksTest extends BaseTaskTest{
@Test
public void createServiceSubscriptionTestExceptionHandling(){
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiServiceInstanceResources).createServiceSubscription(customer);
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).createServiceSubscription(customer);
aaiCreateTasks.createServiceSubscription(execution);
}
@@ -282,7 +298,7 @@ public class AAICreateTasksTest extends BaseTaskTest{
public void createVfModuleExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiVfModuleResources).createVfModule(vfModule, genericVnf);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).createVfModule(vfModule, genericVnf);
aaiCreateTasks.createVfModule(execution);
}
@@ -307,7 +323,7 @@ public class AAICreateTasksTest extends BaseTaskTest{
expectedException.expect(BpmnError.class);
lookupKeyMap.put(ResourceKey.NETWORK_ID, "notfound");
- doThrow(Exception.class).when(aaiNetworkResources).createNetworkConnectToServiceInstance(network,serviceInstance);
+ doThrow(RuntimeException.class).when(aaiNetworkResources).createNetworkConnectToServiceInstance(network,serviceInstance);
aaiCreateTasks.createNetwork(execution);
}
@@ -324,7 +340,7 @@ public class AAICreateTasksTest extends BaseTaskTest{
public void createCustomerExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiVpnBindingResources).createCustomer(customer);
+ doThrow(RuntimeException.class).when(aaiVpnBindingResources).createCustomer(customer);
aaiCreateTasks.createCustomer(execution);
}
@@ -369,6 +385,9 @@ public class AAICreateTasksTest extends BaseTaskTest{
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), eq("testServiceInstanceId"))).thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID),eq("testNetworkId"))).thenReturn(serviceInstance);
//verify connection call was not executednetwork
exception.expect(BpmnError.class);
aaiCreateTasks.connectNetworkToNetworkCollectionInstanceGroup(execution);
@@ -398,4 +417,32 @@ public class AAICreateTasksTest extends BaseTaskTest{
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());
+ }
}
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 efe5b5d971..67f5d197de 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
@@ -20,10 +20,13 @@
package org.onap.so.bpmn.infrastructure.aai.tasks;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
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;
@@ -31,7 +34,10 @@ import java.util.List;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -40,11 +46,13 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+
public class AAIDeleteTasksTest extends BaseTaskTest {
- @Autowired
- private AAIDeleteTasks aaiDeleteTasks;
+
+ @InjectMocks
+ private AAIDeleteTasks aaiDeleteTasks = new AAIDeleteTasks();
private L3Network network;
private ServiceInstance serviceInstance;
@@ -55,7 +63,7 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
private Configuration configuration;
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
serviceInstance = setServiceInstance();
genericVnf = setGenericVnf();
vfModule = setVfModule();
@@ -63,11 +71,23 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
volumeGroup = setVolumeGroup();
cloudRegion = setCloudRegion();
configuration = setConfiguration();
+
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any())).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID), any())).thenReturn(configuration);
+
+
+ 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);
}
@@ -75,7 +95,7 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
@Test
public void deleteVfModuleExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiVfModuleResources).deleteVfModule(vfModule, genericVnf);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).deleteVfModule(vfModule, genericVnf);
aaiDeleteTasks.deleteVfModule(execution);
}
@@ -92,7 +112,7 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
public void deleteServiceInstanceExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiServiceInstanceResources).deleteServiceInstance(serviceInstance);
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).deleteServiceInstance(serviceInstance);
aaiDeleteTasks.deleteServiceInstance(execution);
}
@@ -107,7 +127,7 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
@Test
public void deleteVnfTestException() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiVnfResources).deleteVnf(genericVnf);
+ doThrow(RuntimeException.class).when(aaiVnfResources).deleteVnf(genericVnf);
aaiDeleteTasks.deleteVnf(execution);
verify(aaiVnfResources, times(1)).deleteVnf(genericVnf);
@@ -147,7 +167,7 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
public void deleteVolumeGroupExceptionTest() {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiVolumeGroupResources).deleteVolumeGroup(volumeGroup, cloudRegion);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).deleteVolumeGroup(volumeGroup, cloudRegion);
aaiDeleteTasks.deleteVolumeGroup(execution);
}
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 1a302c29a7..f97b137fb3 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
@@ -21,8 +21,9 @@
package org.onap.so.bpmn.infrastructure.aai.tasks;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -38,9 +39,12 @@ import org.camunda.bpm.engine.delegate.BpmnError;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.mockito.Mockito;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -49,13 +53,15 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
+import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-import org.springframework.beans.factory.annotation.Autowired;
public class AAIUpdateTasksTest extends BaseTaskTest{
- @Autowired
- private AAIUpdateTasks aaiUpdateTasks;
+
+ @InjectMocks
+ private AAIUpdateTasks aaiUpdateTasks = new AAIUpdateTasks();
private L3Network network;
private ServiceInstance serviceInstance;
@@ -67,7 +73,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
private Subnet subnet;
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
serviceInstance = setServiceInstance();
genericVnf = setGenericVnf();
vfModule = setVfModule();
@@ -76,6 +82,16 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
network = setL3Network();
configuration = setConfiguration();
subnet = buildSubnet();
+
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any())).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID), any())).thenReturn(configuration);
+
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
}
@Test
@@ -91,7 +107,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
public void updateOrchestrationStatusAssignedServiceExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
}
@@ -109,7 +125,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
public void updateOrchestrationStatusActiveServiceExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
}
@@ -127,7 +143,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
public void updateOrchestrationStatusAssignedVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
}
@@ -145,7 +161,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
public void updateOrchestrationStatusActiveVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
}
@@ -160,7 +176,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void updateOrchestrationStatusAssignVfModuleExceptionTest() throws Exception {
- doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
expectedException.expect(BpmnError.class);
@@ -206,7 +222,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleExceptionTest() throws Exception {
execution.setVariable("aLaCarte", true);
- doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
expectedException.expect(BpmnError.class);
@@ -222,7 +238,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void updateOrchestrationStatusCreatedVfModuleExceptionTest() throws Exception {
- doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
expectedException.expect(BpmnError.class);
@@ -240,7 +256,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void updateOrchestrationStatusPendingActivatefModuleExceptionTest() throws Exception {
- doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
expectedException.expect(BpmnError.class);
@@ -258,7 +274,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void updateOrchestrationStatusDectivateVfModuleExceptionTest() throws Exception {
- doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
expectedException.expect(BpmnError.class);
@@ -277,8 +293,19 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
}
@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(Exception.class).when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
expectedException.expect(BpmnError.class);
@@ -297,7 +324,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void updateOrchestrationStatusActiveVolumeGroupExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
aaiUpdateTasks.updateOrchestrationStatusActiveVolumeGroup(execution);
}
@@ -313,7 +340,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void updateOrchestrationStatusCreatedVolumeGroupExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
aaiUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(execution);
}
@@ -330,7 +357,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void test_updateOrchestrationStatusAssignedVolumeGroup_exception() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution);
}
@Test
@@ -343,11 +370,21 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
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(Exception.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
+ doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
}
@@ -355,7 +392,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
public void updateNetworkExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiNetworkResources).updateNetwork(network);
+ doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
aaiUpdateTasks.updateNetwork(execution, OrchestrationStatus.ACTIVE);
}
@@ -370,7 +407,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void updateOstatusActiveNetworkColectionExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
+ doThrow(RuntimeException.class).when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
}
@@ -385,7 +422,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void updateOrchestrationStatusActivateVfModuleExceptionTest() throws Exception {
- doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
expectedException.expect(BpmnError.class);
@@ -397,7 +434,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
createNetworkResponse.setNetworkFqdn("testNetworkFqdn");
createNetworkResponse.setNetworkStackId("testNetworkStackId");
- HashMap<String, String> subnetMap = new HashMap<String, String>();
+ HashMap<String, String> subnetMap = new HashMap<>();
subnetMap.put("testSubnetId", "testNeutronSubnetId");
createNetworkResponse.setSubnetMap(subnetMap);
@@ -455,7 +492,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void updateNetworkCreatedkExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiNetworkResources).updateNetwork(network);
+ doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
aaiUpdateTasks.updateNetworkCreated(execution);
}
@@ -472,7 +509,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
public void updateObjectNetworkExceptionText() {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiNetworkResources).updateNetwork(network);
+ doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
aaiUpdateTasks.updateObjectNetwork(execution);
}
@@ -487,7 +524,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void test_updateServiceInstance_exception() {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
+ doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
aaiUpdateTasks.updateServiceInstance(execution);
}
@@ -503,7 +540,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void updateObjectVnfExceptionTest() {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiVnfResources).updateObjectVnf(genericVnf);
+ doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(genericVnf);
aaiUpdateTasks.updateObjectVnf(execution);
}
@@ -527,7 +564,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
@Test
public void updateModelVfModuleExceptionTest() {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
+ doThrow(RuntimeException.class).when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
aaiUpdateTasks.updateModelVfModule(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 d4956f9349..ee7a9ad952 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
@@ -31,14 +31,15 @@ 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;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.springframework.beans.factory.annotation.Autowired;
public class ExecuteActivityTest extends BaseTaskTest {
- @Autowired
- protected ExecuteActivity executeActivity;
+ @InjectMocks
+ protected ExecuteActivity executeActivity = new ExecuteActivity();
private DelegateExecution execution;
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 64760c03a0..3034f0bd67 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
@@ -20,28 +20,36 @@
package org.onap.so.bpmn.infrastructure.adapter.network.tasks;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+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 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;
+import org.mockito.InjectMocks;
+import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.onap.so.client.exception.BBObjectNotFoundException;
public class NetworkAdapterCreateTasksTest extends BaseTaskTest{
- @Autowired
- private NetworkAdapterCreateTasks networkAdapterCreateTasks;
+ @InjectMocks
+ private NetworkAdapterCreateTasks networkAdapterCreateTasks = new NetworkAdapterCreateTasks();
private ServiceInstance serviceInstance;
private RequestContext requestContext;
@@ -52,7 +60,7 @@ public class NetworkAdapterCreateTasksTest extends BaseTaskTest{
private Customer customer;
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
customer = setCustomer();
serviceInstance = setServiceInstance();
l3Network = setL3Network();
@@ -62,21 +70,23 @@ public class NetworkAdapterCreateTasksTest extends BaseTaskTest{
cloudRegion = setCloudRegion();
orchestrationContext = setOrchestrationContext();
orchestrationContext.setIsRollbackEnabled(true);
+
+
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any())).thenReturn(l3Network);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
+
}
@Test
public void createNetworkTest() throws Exception {
- CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
- createNetworkResponse.setNetworkStackId("networkStackId");
- createNetworkResponse.setNetworkCreated(true);
- Optional<CreateNetworkResponse> oCreateNetworkResponse = Optional.of(createNetworkResponse);
-
String cloudRegionPo = "cloudRegionPo";
+ CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
execution.setVariable("cloudRegionPo", cloudRegionPo);
- doReturn(oCreateNetworkResponse).when(networkAdapterResources).createNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo,customer);
+ 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(networkAdapterResources, times(1)).createNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo,customer);
+ verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
+ assertEquals(createNetworkRequest, execution.getVariable("networkAdapterRequest"));
}
@Test
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 88b654fd45..5b534e00e7 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
@@ -20,63 +20,72 @@
package org.onap.so.bpmn.infrastructure.adapter.network.tasks;
-import static org.junit.Assert.assertEquals;
+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 static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import java.io.UnsupportedEncodingException;
-import java.util.Optional;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
-import org.onap.so.adapters.nwrest.DeleteNetworkResponse;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
-import org.onap.so.client.adapter.network.NetworkAdapterClientException;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.onap.so.client.adapter.network.NetworkAdapterClientException;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+
-public class NetworkAdapterDeleteTasksTest extends BaseTaskTest{
- @Autowired
- private NetworkAdapterDeleteTasks 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 String cloudRegionPo;
+
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
serviceInstance = setServiceInstance();
l3Network = setL3Network();
requestContext = setRequestContext();
cloudRegion = setCloudRegion();
+
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any())).thenReturn(l3Network);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).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 {
-
- DeleteNetworkResponse deleteNetworkResponse = new DeleteNetworkResponse();
- deleteNetworkResponse.setNetworkDeleted(true);
- deleteNetworkResponse.setNetworkId(l3Network.getNetworkId());
- Optional<DeleteNetworkResponse> oDeleteNetworkResponse = Optional.of(deleteNetworkResponse);
- doReturn(oDeleteNetworkResponse).when(networkAdapterResources).deleteNetwork(requestContext, cloudRegion, serviceInstance, l3Network);
-
+ public void test_deleteNetwork() throws UnsupportedEncodingException, NetworkAdapterClientException {
+ DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
+ doReturn(deleteNetworkRequest).when(networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
+
networkAdapterDeleteTasks.deleteNetwork(execution);
-
- verify(networkAdapterResources, times(1)).deleteNetwork(requestContext, cloudRegion, serviceInstance, l3Network);
- assertEquals(deleteNetworkResponse, execution.getVariable("deleteNetworkResponse"));
+ verify(networkAdapterObjectMapper, times(1)).deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
}
-
+
@Test
- public void test_deleteNetwork_exception() {
+ 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);
}
}
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
new file mode 100644
index 0000000000..2ba8cb4b57
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
@@ -0,0 +1,19 @@
+package org.onap.so.bpmn.infrastructure.adapter.network.tasks;
+
+import java.io.IOException;
+
+import javax.xml.bind.JAXBException;
+
+import org.junit.Test;
+import org.onap.so.adapters.nwrest.CreateNetworkResponse;
+
+public class NetworkAdapterRestV1Test {
+
+ @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);
+ }
+}
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 6489c9b149..9f2f2fbdcc 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
@@ -22,29 +22,40 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+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 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;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+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{
- @Autowired
- private NetworkAdapterUpdateTasks networkAdapterUpdateTasks;
+ @InjectMocks
+ private NetworkAdapterUpdateTasks networkAdapterUpdateTasks = new NetworkAdapterUpdateTasks();
private ServiceInstance serviceInstance;
private L3Network network;
@@ -55,7 +66,7 @@ public class NetworkAdapterUpdateTasksTest extends BaseTaskTest{
private Customer customer;
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
customer = setCustomer();
serviceInstance = setServiceInstance();
network = setL3Network();
@@ -64,7 +75,10 @@ public class NetworkAdapterUpdateTasksTest extends BaseTaskTest{
orchestrationContext = setOrchestrationContext();
userInput = setUserInput();
userInput.put("userInputKey1", "userInputValue1");
-
+
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any())).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
+
}
@Test
@@ -93,9 +107,11 @@ public class NetworkAdapterUpdateTasksTest extends BaseTaskTest{
}
@Test
- public void updateNetworkExceptionTest() {
+ public void updateNetworkExceptionTest() throws UnsupportedEncodingException, NetworkAdapterClientException {
expectedException.expect(BpmnError.class);
-
+ doThrow(new NetworkAdapterClientException("ERROR")).when(networkAdapterResources).updateNetwork(any(RequestContext.class),any(CloudRegion.class),
+ any(OrchestrationContext.class),eq(serviceInstance),eq(network),any(Map.class),any(Customer.class));
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
networkAdapterUpdateTasks.updateNetwork(execution);
}
}
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 698ebb33f2..eaab75d4b9 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
@@ -20,29 +20,37 @@
package org.onap.so.bpmn.infrastructure.adapter.vnf.tasks;
+import static org.junit.Assert.assertEquals;
+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 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;
+import org.mockito.InjectMocks;
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
public class VnfAdapterCreateTasksTest extends BaseTaskTest{
- @Autowired
- private VnfAdapterCreateTasks vnfAdapterCreateTasks;
+ @InjectMocks
+ private VnfAdapterCreateTasks vnfAdapterCreateTasks = new VnfAdapterCreateTasks();
+
@Test
public void test_createVolumeGroupRequest() throws Exception {
@@ -68,7 +76,10 @@ public class VnfAdapterCreateTasksTest extends BaseTaskTest{
CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
request.setVolumeGroupId("volumeGroupStackId");
- doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVnfQueryResponse);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+ doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVnfQueryResponse);
vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
@@ -84,6 +95,9 @@ public class VnfAdapterCreateTasksTest extends BaseTaskTest{
GenericVnf genericVnf = setGenericVnf();
VolumeGroup volumeGroup = setVolumeGroup();
volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
+
+ VfModule vfModule = setVfModule();
+ vfModule.setSelflink("vfModuleSelfLink");
CloudRegion cloudRegion = setCloudRegion();
@@ -92,19 +106,24 @@ public class VnfAdapterCreateTasksTest extends BaseTaskTest{
CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
request.setVolumeGroupId("volumeGroupStackId");
-
+
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
doReturn(request).when(vnfAdapterVolumeGroupResources).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
- verify(vnfAdapterVolumeGroupResources, times(1)).createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, null);
+ 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 {
- // run with no data setup, and it will throw a BBObjectNotFoundException
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any());
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
expectedException.expect(BpmnError.class);
vnfAdapterCreateTasks.createVolumeGroupRequest(execution);
@@ -137,6 +156,9 @@ public class VnfAdapterCreateTasksTest extends BaseTaskTest{
String sdncVnfQueryResponse = "{someJson}";
execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), sdncVnfQueryResponse);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+
doReturn(createVfModuleRequest).when(vnfAdapterVfModuleResources).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
@@ -177,6 +199,9 @@ public class VnfAdapterCreateTasksTest extends BaseTaskTest{
String sdncVnfQueryResponse = "{someJson}";
execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), sdncVnfQueryResponse);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
doReturn(createVfModuleRequest).when(vnfAdapterVfModuleResources).createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance,
genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
@@ -191,6 +216,8 @@ public class VnfAdapterCreateTasksTest extends BaseTaskTest{
@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), any());
+ 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 3ff9ce605e..b8be26b12a 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
@@ -21,29 +21,35 @@
package org.onap.so.bpmn.infrastructure.adapter.vnf.tasks;
import static org.junit.Assert.assertEquals;
+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 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;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-import org.springframework.beans.factory.annotation.Autowired;
public class VnfAdapterDeleteTasksTest extends BaseTaskTest{
- @Autowired
- private VnfAdapterDeleteTasks vnfAdapterDeleteTasks;
+ @InjectMocks
+ private VnfAdapterDeleteTasks vnfAdapterDeleteTasks = new VnfAdapterDeleteTasks();
private VolumeGroup volumeGroup;
private VfModule vfModule;
@@ -69,6 +75,13 @@ public class VnfAdapterDeleteTasksTest extends BaseTaskTest{
orchestrationContext = setOrchestrationContext();
orchestrationContext.setIsRollbackEnabled(true);
+
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).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
@@ -80,7 +93,7 @@ public class VnfAdapterDeleteTasksTest extends BaseTaskTest{
vnfAdapterDeleteTasks.deleteVfModule(execution);
- verify(vnfAdapterVfModuleResources, times(1)).deleteVfModuleRequest(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
+ 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());
}
@@ -88,7 +101,7 @@ public class VnfAdapterDeleteTasksTest extends BaseTaskTest{
public void deleteVfModuleExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(vnfAdapterVfModuleResources).deleteVfModuleRequest(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
+ doThrow(RuntimeException.class).when(vnfAdapterVfModuleResources).deleteVfModuleRequest(requestContext, cloudRegion, serviceInstance, genericVnf, vfModule);
vnfAdapterDeleteTasks.deleteVfModule(execution);
}
@@ -102,7 +115,7 @@ public class VnfAdapterDeleteTasksTest extends BaseTaskTest{
vnfAdapterDeleteTasks.deleteVolumeGroup(execution);
- verify(vnfAdapterVolumeGroupResources, times(1)).deleteVolumeGroupRequest(requestContext, cloudRegion, serviceInstance, volumeGroup);
+ verify(vnfAdapterVolumeGroupResources, times(1)).deleteVolumeGroupRequest(ArgumentMatchers.eq(requestContext), ArgumentMatchers.eq(cloudRegion), ArgumentMatchers.eq(serviceInstance), ArgumentMatchers.eq(volumeGroup));
assertEquals(execution.getVariable("VNFREST_Request"), deleteVolumeGroupRequest.toXmlString());
}
@@ -110,7 +123,7 @@ public class VnfAdapterDeleteTasksTest extends BaseTaskTest{
public void deleteVolumeGroupExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(vnfAdapterVolumeGroupResources).deleteVolumeGroupRequest(requestContext, cloudRegion, serviceInstance, volumeGroup);
+ 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 2a8046b1be..4158f9cfae 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
@@ -22,21 +22,31 @@ package org.onap.so.bpmn.infrastructure.adapter.vnf.tasks;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+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;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.onap.so.FileUtil;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.client.exception.BBObjectNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
public class VnfAdapterImplTest extends BaseTaskTest {
- @Autowired
- private VnfAdapterImpl vnfAdapterImpl;
+
+ @InjectMocks
+ private VnfAdapterImpl vnfAdapterImpl = new VnfAdapterImpl();
private RequestContext requestContext;
private ServiceInstance serviceInstance;
@@ -51,20 +61,24 @@ public class VnfAdapterImplTest extends BaseTaskTest {
private static final String TEST_VOLUME_HEATSTACK_ID = "testHeatStackId1";
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
requestContext = setRequestContext();
serviceInstance = setServiceInstance();
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), any())).thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
}
@Test
public void preProcessVnfAdapterTest() {
vnfAdapterImpl.preProcessVnfAdapter(execution);
- assertEquals("true", execution.getVariable("isDebugLogEnabled"));
assertEquals(requestContext.getMsoRequestId(), execution.getVariable("mso-request-id"));
assertEquals(serviceInstance.getServiceInstanceId(), execution.getVariable("mso-service-instance-id"));
}
@@ -144,9 +158,10 @@ public class VnfAdapterImplTest extends BaseTaskTest {
}
@Test
- public void preProcessVnfAdapterExceptionTest() {
+ public void preProcessVnfAdapterExceptionTest() throws BBObjectNotFoundException {
expectedException.expect(BpmnError.class);
- lookupKeyMap.clear();
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any());
+
vnfAdapterImpl.preProcessVnfAdapter(execution);
}
@@ -198,10 +213,12 @@ public class VnfAdapterImplTest extends BaseTaskTest {
}
@Test
- public void postProcessVnfAdapterExceptionTest() {
+ public void postProcessVnfAdapterExceptionTest() throws BBObjectNotFoundException {
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any());
+
execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_CREATE_RESPONSE);
expectedException.expect(BpmnError.class);
- lookupKeyMap.clear();
+
vnfAdapterImpl.postProcessVnfAdapter(execution);
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksITTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java
index 9e1dac69e0..9cf1a1cdc9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksITTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java
@@ -31,17 +31,15 @@ import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mockito;
import org.onap.appc.client.lcm.model.Action;
-import org.onap.so.bpmn.BaseTaskTest;
-import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.BaseIntegrationTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
import org.springframework.beans.factory.annotation.Autowired;
-public class AppcRunTasksITTest extends BaseTaskTest {
+public class AppcRunTasksIT extends BaseIntegrationTest {
@Autowired
private AppcRunTasks appcRunTasks;
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 dcc95affce..114066aae3 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
@@ -22,7 +22,7 @@ package org.onap.so.bpmn.infrastructure.appc.tasks;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import org.junit.Test;
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
new file mode 100644
index 0000000000..57e463c0f8
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java
@@ -0,0 +1,24 @@
+package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
+
+import static org.junit.Assert.*;
+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.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"));
+ }
+
+}
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 dff953802e..e7f841fa47 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
@@ -23,11 +23,13 @@ import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
public class AssignNetworkBBUtilsTest extends BaseTaskTest {
- //Necessary because AssignNetworkBBUtils is already mocked using MockBean in the base class for use in other tests
+
+ @InjectMocks
private AssignNetworkBBUtils nonMockAssignNetworkBBUtils = new AssignNetworkBBUtils();
private CloudRegion cloudRegion;
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 6e5bd314d8..befeea411d 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
@@ -20,26 +20,35 @@
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;
+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;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-import org.springframework.beans.factory.annotation.Autowired;
public class AssignNetworkTest extends BaseTaskTest {
- @Autowired
- private AssignNetwork assignNetwork;
+ @InjectMocks
+ private AssignNetwork assignNetwork = new AssignNetwork();
private L3Network network;
@Before
- public void 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), any())).thenReturn(network);
}
@Test
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 8382b9be72..4ad6fba910 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
@@ -20,25 +20,39 @@
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.doNothing;
+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;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.common.name.generation.AAIObjectInstanceNameGenerator;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
import org.onap.so.client.aai.entities.AAIEdgeLabel;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.onap.so.client.exception.BBObjectNotFoundException;
public class AssignVnfTest extends BaseTaskTest {
- @Autowired
- private AssignVnf assignVnf;
+ @InjectMocks
+ private AssignVnf assignVnf = new AssignVnf();
+
+ @Mock
+ private AAIObjectInstanceNameGenerator aaiObjectInstanceNameGenerator = new AAIObjectInstanceNameGenerator();
private InstanceGroup instanceGroup1;
private InstanceGroup instanceGroup2;
@@ -47,13 +61,13 @@ public class AssignVnfTest extends BaseTaskTest {
private GenericVnf genericVnf;
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
modelVnfc.setType("VNFC");
modelVnfc.setFunction("function");
ModelInfoInstanceGroup modelNetworkInstanceGroup = new ModelInfoInstanceGroup();
- modelNetworkInstanceGroup.setType("networkInstanceGroup");
+ modelNetworkInstanceGroup.setType("L3-NETWORK");
modelNetworkInstanceGroup.setFunction("function");
instanceGroup1 = new InstanceGroup();
@@ -74,6 +88,13 @@ public class AssignVnfTest extends BaseTaskTest {
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), any())).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
@@ -84,7 +105,8 @@ public class AssignVnfTest extends BaseTaskTest {
instanceGroupList.add(instanceGroup2);
instanceGroupList.add(instanceGroup3);
instanceGroupList.add(instanceGroup4);
-
+
+
assignVnf.createInstanceGroups(execution);
verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup1);
verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup2);
@@ -97,12 +119,20 @@ public class AssignVnfTest extends BaseTaskTest {
@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");
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 85915bd4b4..ad848a4d49 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
@@ -20,11 +20,14 @@
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;
import static org.mockito.Mockito.doNothing;
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 static org.mockito.Mockito.when;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -38,18 +41,22 @@ import java.util.UUID;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.onap.appc.client.lcm.model.Action;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
-import org.springframework.beans.factory.annotation.Autowired;
public class ConfigurationScaleOutTest extends BaseTaskTest {
- @Autowired
- private ConfigurationScaleOut configurationScaleOut;
+ @InjectMocks
+ private ConfigurationScaleOut configurationScaleOut = new ConfigurationScaleOut();
private GenericVnf genericVnf;
private VfModule vfModule;
@@ -61,7 +68,7 @@ public class ConfigurationScaleOutTest extends BaseTaskTest {
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
genericVnf = setGenericVnf();
vfModule = setVfModule();
msoRequestId = UUID.randomUUID().toString();
@@ -72,6 +79,11 @@ public class ConfigurationScaleOutTest extends BaseTaskTest {
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), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+
}
@Test
@@ -169,7 +181,9 @@ public class ConfigurationScaleOutTest extends BaseTaskTest {
execution.setVariable("vfModuleId", "testVfModuleId");
execution.setVariable("payload", payload);
- doThrow(Exception.class).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
+
+ 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 207447ae35..7202bd5298 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
@@ -19,9 +19,13 @@
*/
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;
import static org.mockito.Mockito.doNothing;
+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;
@@ -29,17 +33,21 @@ import java.util.List;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.onap.so.client.exception.BBObjectNotFoundException;
public class CreateNetworkCollectionTest extends BaseTaskTest{
- @Autowired
- private CreateNetworkCollection createNetworkCollection;
+ @InjectMocks
+ private CreateNetworkCollection createNetworkCollection = new CreateNetworkCollection();
private L3Network network;
private ServiceInstance serviceInstance;
@@ -47,7 +55,7 @@ public class CreateNetworkCollectionTest extends BaseTaskTest{
private CloudRegion cloudRegion;
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
serviceInstance = setServiceInstance();
network = setL3Network();
cloudRegion = setCloudRegion();
@@ -60,6 +68,10 @@ public class CreateNetworkCollectionTest extends BaseTaskTest{
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), any())).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
}
@Test
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 f23df3312f..ddfd636a64 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
@@ -21,27 +21,33 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertThat;
+import static org.mockito.ArgumentMatchers.any;
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;
+import org.mockito.InjectMocks;
import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+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{
- @Autowired
- private CreateNetwork createNetwork;
+ @InjectMocks
+ private CreateNetwork createNetwork = new CreateNetwork();
private L3Network network;
private ServiceInstance serviceInstance;
@@ -53,7 +59,7 @@ public class CreateNetworkTest extends BaseTaskTest{
private Customer customer;
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
customer = setCustomer();
serviceInstance = setServiceInstance();
network = setL3Network();
@@ -64,7 +70,8 @@ public class CreateNetworkTest extends BaseTaskTest{
userInput = setUserInput();
customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
-
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any())).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
}
@Test
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 3ef7ef4dc5..7fdf2535bf 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
@@ -20,11 +20,14 @@
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;
import static org.mockito.Mockito.doNothing;
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 static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.Optional;
@@ -32,30 +35,38 @@ import java.util.UUID;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.onap.appc.client.lcm.model.Action;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
-import org.springframework.beans.factory.annotation.Autowired;
public class GenericVnfHealthCheckTest extends BaseTaskTest {
- @Autowired
- private GenericVnfHealthCheck genericVnfHealthCheck;
+ @InjectMocks
+ private GenericVnfHealthCheck genericVnfHealthCheck = new GenericVnfHealthCheck();
private GenericVnf genericVnf;
private RequestContext requestContext;
private String msoRequestId;
@Before
- public void 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), any())).thenReturn(genericVnf);
}
@Test
@@ -125,7 +136,8 @@ public class GenericVnfHealthCheckTest extends BaseTaskTest {
execution.setVariable("vnfHostIpAddress", "testOamIpAddress");
execution.setVariable("payload", payload);
- doThrow(Exception.class).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType);
+ 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);
@@ -133,7 +145,8 @@ public class GenericVnfHealthCheckTest extends BaseTaskTest {
}
@Test
- public void callAppcClientTimeOutExceptionTest() throws java.util.concurrent.TimeoutException {
+ @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();
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 4966a8b42d..bf9be282d4 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
@@ -30,6 +30,7 @@ import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.InjectMocks;
import org.mockito.Mockito;
import org.onap.aai.domain.yang.L3Network;
import org.onap.so.bpmn.BaseTaskTest;
@@ -38,8 +39,8 @@ import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.springframework.beans.factory.annotation.Autowired;
public class NetworkBBUtilsTest extends BaseTaskTest{
- @Autowired
- private NetworkBBUtils networkBBUtils;
+ @InjectMocks
+ private NetworkBBUtils networkBBUtils = new NetworkBBUtils();
private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/Network/";
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
new file mode 100644
index 0000000000..f0bb6a369c
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java
@@ -0,0 +1,496 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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;
+
+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.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+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;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
+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 org.onap.so.BaseIntegrationTest;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+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("iptollfree");
+ 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.setCandidateType(CandidateType.VNF_ID);
+ List<String> c = new ArrayList<String>();
+ c.add("testVnfId");
+ requiredCandidate.setCandidates(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");
+
+ 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");
+
+ 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();
+
+ 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();
+
+ 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();
+
+ 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("inventoryType", "service").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("inventoryType", "service").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("inventoryType", "service").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("inventoryType", "service").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("inventoryType", "service").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("inventoryType", "service").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("inventoryType", "service").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("inventoryType", "service").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("inventoryType", "cloud").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("inventoryType", "service").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("inventoryType", "service").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("inventoryType", "cloud").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\"}";
+ 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));
+ }
+
+}
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 32c285b0fe..ccfcabaf09 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
@@ -23,16 +23,22 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
+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;
+import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
@@ -44,14 +50,19 @@ public class UnassignNetworkBBTest extends BaseTaskTest {
@Mock
private NetworkBBUtils networkBBUtils;
- @Mock
- private ExtractPojosForBB extractPojosForBB;
- @Autowired
- private UnassignNetworkBB unassignNetworkBB;
+
+ @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);
@@ -60,9 +71,12 @@ public class UnassignNetworkBBTest extends BaseTaskTest {
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, "testNetworkId1");
doReturn(aaiResultWrapper).when(aaiNetworkResources).queryNetworkWrapperById(network);
- doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(l3network, "vf-module");
+
+ doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(any(Optional.class), eq("vf-module"));
+
unassignNetworkBB.checkRelationshipRelatedTo(execution, "vf-module");
assertThat(execution.getVariable("ErrorUnassignNetworkBB"), notNullValue());
}
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 98c1f185fe..688f95c3c0 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
@@ -20,21 +20,37 @@
package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.eq;
+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 static org.mockito.Mockito.when;
import org.camunda.bpm.engine.delegate.BpmnError;
+import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
-import org.springframework.beans.factory.annotation.Autowired;
public class UnassignVnfTest extends BaseTaskTest{
- @Autowired
- private UnassignVnf unassignVnf;
+ @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 {
@@ -52,7 +68,7 @@ public class UnassignVnfTest extends BaseTaskTest{
instanceGroup2.setId("test-002");
instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
genericVnf.getInstanceGroups().add(instanceGroup2);
-
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
unassignVnf.deleteInstanceGroups(execution);
verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup1));
verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup2));
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
new file mode 100644
index 0000000000..41739f37e6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.namingservice.tasks;
+
+import static org.junit.Assert.assertEquals;
+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 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;
+import org.mockito.InjectMocks;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+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), any())).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),eq("notfound"));
+ 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
new file mode 100644
index 0000000000..97dcc617ac
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.namingservice.tasks;
+
+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 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;
+import org.mockito.InjectMocks;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+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), any())).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),eq("notfound"));
+ 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 d3b421eedb..65e7d249c5 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
@@ -20,29 +20,42 @@
package org.onap.so.bpmn.infrastructure.sdnc.tasks;
-import static org.mockito.Matchers.isA;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
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 static org.mockito.Mockito.when;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-import org.springframework.beans.factory.annotation.Autowired;
-
+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{
- @Autowired
- private SDNCActivateTasks sdncActivateTasks;
+
+ @InjectMocks
+ private SDNCActivateTasks sdncActivateTasks = new SDNCActivateTasks();
private L3Network network;
private ServiceInstance serviceInstance;
@@ -53,7 +66,7 @@ public class SDNCActivateTaskTest extends BaseTaskTest{
private Customer customer;
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
serviceInstance = setServiceInstance();
network = setL3Network();
genericVnf = setGenericVnf();
@@ -63,54 +76,60 @@ public class SDNCActivateTaskTest extends BaseTaskTest{
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), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any())).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
}
@Test
public void activateVnfTest() throws Exception {
- doReturn("success").when(sdncVnfResources).activateVnf(genericVnf,serviceInstance, customer, cloudRegion,requestContext);
+ 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(Exception.class).when(sdncVnfResources).activateVnf(genericVnf,serviceInstance, customer,cloudRegion,requestContext);
+ doThrow(RuntimeException.class).when(sdncVnfResources).activateVnf(genericVnf,serviceInstance, customer,cloudRegion,requestContext);
sdncActivateTasks.activateVnf(execution);
}
@Test
public void activateNetworkTest() throws Exception {
- doReturn("response").when(sdncNetworkResources).activateNetwork(isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.class));
+ 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(Exception.class).when(sdncNetworkResources).activateNetwork(isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.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("success").when(sdncVfModuleResources).activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
-
+ 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(Exception.class).when(sdncVfModuleResources).activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ 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 cc96326563..d021df56e0 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
@@ -20,16 +20,26 @@
package org.onap.so.bpmn.infrastructure.sdnc.tasks;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+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 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;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -37,13 +47,16 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-import org.springframework.beans.factory.annotation.Autowired;
+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 SDNCAssignTasksTest extends BaseTaskTest{
- @Autowired
- private SDNCAssignTasks sdncAssignTasks;
+ @InjectMocks
+ private SDNCAssignTasks sdncAssignTasks = new SDNCAssignTasks();
private L3Network network;
private ServiceInstance serviceInstance;
@@ -55,7 +68,7 @@ public class SDNCAssignTasksTest extends BaseTaskTest{
private Customer customer;
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
customer = setCustomer();
serviceInstance = setServiceInstance();
network = setL3Network();
@@ -64,82 +77,78 @@ public class SDNCAssignTasksTest extends BaseTaskTest{
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), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any())).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup);
}
@Test
public void assignServiceInstanceTest() throws Exception {
- doReturn("response").when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext);
-
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext);
sdncAssignTasks.assignServiceInstance(execution);
-
verify(sdncServiceInstanceResources, times(1)).assignServiceInstance(serviceInstance, customer, requestContext);
- assertTrue(execution.getVariable("SDNCResponse").equals("response"));
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.SERVICE,sdncRequest.getTopology());
}
@Test
public void assignServiceInstanceExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
-
- doThrow(Exception.class).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext);
-
+ doThrow(RuntimeException.class).when(sdncServiceInstanceResources).assignServiceInstance(serviceInstance, customer, requestContext);
sdncAssignTasks.assignServiceInstance(execution);
}
@Test
public void assignVnfTest() throws Exception {
- doReturn("response").when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
-
+ 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);
- assertTrue(execution.getVariable("SDNCResponse").equals("response"));
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
}
@Test
public void assignVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
-
- doThrow(Exception.class).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
-
+ doThrow(RuntimeException.class).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
sdncAssignTasks.assignVnf(execution);
}
@Test
public void assignVfModuleTest() throws Exception {
- doReturn("response").when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
-
+ 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);
- assertTrue(execution.getVariable("SDNCAssignResponse_" + vfModule.getVfModuleId()).equals("response"));
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
}
@Test
public void assignVfModuleExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
-
- doThrow(Exception.class).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
-
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
sdncAssignTasks.assignVfModule(execution);
}
@Test
public void assignNetworkTest() throws Exception {
- doReturn("response").when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
-
+ 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(Exception.class).when(sdncNetworkResources).assignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
-
+ 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 fc2d182b52..f01596c86f 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
@@ -20,27 +20,37 @@
package org.onap.so.bpmn.infrastructure.sdnc.tasks;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+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 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;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-import org.springframework.beans.factory.annotation.Autowired;
+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{
- @Autowired
- private SDNCChangeAssignTasks sdncChangeAssignTasks;
+ @InjectMocks
+ private SDNCChangeAssignTasks sdncChangeAssignTasks = new SDNCChangeAssignTasks();
private ServiceInstance serviceInstance;
private RequestContext requestContext;
@@ -50,7 +60,7 @@ public class SDNCChangeAssignTasksTest extends BaseTaskTest{
private Customer customer;
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
customer = setCustomer();
serviceInstance = setServiceInstance();
genericVnf = setGenericVnf();
@@ -58,43 +68,41 @@ public class SDNCChangeAssignTasksTest extends BaseTaskTest{
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), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
}
@Test
public void changeModelVnfTest() throws Exception {
- String response = "sdncChangeModelServiceInstance";
-
- doReturn(response).when(sdncServiceInstanceResources).changeModelServiceInstance(serviceInstance, customer, requestContext);
-
- sdncChangeAssignTasks.changeModelServiceInstance(execution);
-
- verify(sdncServiceInstanceResources, times(1)).changeModelServiceInstance(serviceInstance, customer, requestContext);
-
- assertEquals(response, execution.getVariable("SDNCChangeAssignTasks.changeModelServiceInstance.response"));
+ 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(Exception.class).when(sdncVnfResources).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ doThrow(RuntimeException.class).when(sdncVnfResources).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
sdncChangeAssignTasks.changeModelVnf(execution);
}
@Test
public void changeAssignModelVfModuleTest() throws Exception {
- String response = "response";
- doReturn(response).when(sdncVfModuleResources).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
-
+ 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);
- assertTrue(execution.getVariable("SDNCChangeAssignVfModuleResponse").equals(response));
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
}
@Test
public void changeAssignModelVfModuleExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(sdncVfModuleResources).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ 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 ed281ce317..3d25addb9c 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
@@ -21,18 +21,25 @@
package org.onap.so.bpmn.infrastructure.sdnc.tasks;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+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 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;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -41,11 +48,13 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-import org.springframework.beans.factory.annotation.Autowired;
+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 SDNCDeactivateTaskTest extends BaseTaskTest {
- @Autowired
- private SDNCDeactivateTasks sdncDeactivateTasks;
+ @InjectMocks
+ private SDNCDeactivateTasks sdncDeactivateTasks = new SDNCDeactivateTasks();
private ServiceInstance serviceInstance;
private CloudRegion cloudRegion;
@@ -56,7 +65,7 @@ public class SDNCDeactivateTaskTest extends BaseTaskTest {
private Customer customer;
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
customer = setCustomer();
serviceInstance = setServiceInstance();
cloudRegion = setCloudRegion();
@@ -64,91 +73,77 @@ public class SDNCDeactivateTaskTest extends BaseTaskTest {
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), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any())).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
}
@Test
public void deactivateVfModuleTest() throws Exception {
- doReturn("success").when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
-
+ 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(Exception.class).when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
-
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext);
sdncDeactivateTasks.deactivateVfModule(execution);
}
@Test
public void deactivateVnfTest() throws Exception {
- doReturn("success").when(sdncVnfResources).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
-
+ 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(Exception.class).when(sdncVnfResources).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ 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("response").when(sdncServiceInstanceResources).deactivateServiceInstance(serviceInstance, customer, requestContext);
-
+ doReturn(new GenericResourceApiServiceOperationInformation()).when(sdncServiceInstanceResources).deactivateServiceInstance(serviceInstance, customer, requestContext);
sdncDeactivateTasks.deactivateServiceInstance(execution);
-
verify(sdncServiceInstanceResources, times(1)).deactivateServiceInstance(serviceInstance, customer, requestContext);
- assertEquals("response", execution.getVariable("deactivateServiceInstanceSDNCResponse"));
- assertTrue(execution.getVariable("sdncServiceInstanceRollback"));
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.SERVICE,sdncRequest.getTopology());
}
@Test
public void deactivateServiceInstanceExceptionTest() throws Exception {
- doThrow(Exception.class).when(sdncServiceInstanceResources).deactivateServiceInstance(serviceInstance, customer, requestContext);
+ doThrow(RuntimeException.class).when(sdncServiceInstanceResources).deactivateServiceInstance(serviceInstance, customer, requestContext);
expectedException.expect(BpmnError.class);
sdncDeactivateTasks.deactivateServiceInstance(execution);
}
@Test
public void test_deactivateNetwork() throws Exception {
- String expectedResponse = "return";
-
- doReturn(expectedResponse).when(sdncNetworkResources).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
-
+ doReturn(new GenericResourceApiNetworkOperationInformation()).when(sdncNetworkResources).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
sdncDeactivateTasks.deactivateNetwork(execution);
-
verify(sdncNetworkResources, times(1)).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
-
- assertEquals(expectedResponse, execution.getVariable("SDNCDeactivateTasks.deactivateNetwork.response"));
-
- assertTrue(execution.getVariable("SDNCDeactivateTasks.deactivateNetwork.rollback"));
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.NETWORK,sdncRequest.getTopology());
}
@Test
public void test_deactivateNetwork_exception() throws Exception {
expectedException.expect(BpmnError.class);
-
- try {
- lookupKeyMap.remove(ResourceKey.NETWORK_ID);
-
- sdncDeactivateTasks.deactivateNetwork(execution);
- } finally {
- verify(sdncNetworkResources, times(0)).deactivateNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
-
- assertNull(execution.getVariable("SDNCDeactivateTasks.deactivateNetwork.response"));
-
- assertFalse(execution.getVariable("SDNCDeactivateTasks.deactivateNetwork.rollback"));
- }
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any());
+ 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 b98ab71d1d..4c5c50ebbf 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
@@ -22,35 +22,53 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
-import static org.mockito.Matchers.any;
+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 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;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.client.exception.BBObjectNotFoundException;
public class SDNCQueryTasksTest extends BaseTaskTest{
- @Autowired
- private SDNCQueryTasks sdncQueryTasks;
+ @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() {
+ 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), any())).thenReturn(serviceInstance);
+
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
+
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+
}
@Test
@@ -105,8 +123,8 @@ public class SDNCQueryTasksTest extends BaseTaskTest{
@Test
public void queryVfModuleForVolumeGroupVfObjectExceptionTest() throws Exception {
- gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs().get(0).getVfModules().clear();
-
+ expectedException.expect(BpmnError.class);
+ doThrow(RuntimeException.class).when(extractPojosForBB).extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any());
sdncQueryTasks.queryVfModuleForVolumeGroup(execution);
verify(sdncVfModuleResources, times(0)).queryVfModule(any(VfModule.class));
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
new file mode 100644
index 0000000000..f1779cf119
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
@@ -0,0 +1,161 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.sdnc.tasks;
+
+import static org.junit.Assert.assertEquals;
+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.nio.file.Files;
+import java.nio.file.Paths;
+
+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;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
+import org.onap.so.client.exception.BadResponseException;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.exception.MapperException;
+import org.onap.so.client.sdnc.SDNCClient;
+import org.onap.so.client.sdnc.beans.SDNCRequest;
+import org.onap.so.client.sdnc.endpoint.SDNCTopology;
+
+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_Request.json")));
+ delegateExecution.setVariable("correlationName_MESSAGE", sdncResponse);
+ sndcRequestTasks.processCallback(delegateExecution);
+ assertEquals(true,delegateExecution.getVariable(IS_CALLBACK_COMPLETED));
+ }
+
+ 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 14243c5909..1301787dff 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
@@ -23,29 +23,40 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+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 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;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-import org.onap.so.db.catalog.beans.OrchestrationStatus;
-import org.springframework.beans.factory.annotation.Autowired;
+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{
- @Autowired
- private SDNCUnassignTasks sdncUnassignTasks;
+ @InjectMocks
+ private SDNCUnassignTasks sdncUnassignTasks = new SDNCUnassignTasks();
private ServiceInstance serviceInstance;
private RequestContext requestContext;
@@ -56,7 +67,7 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{
private Customer customer;
@Before
- public void before() {
+ public void before() throws BBObjectNotFoundException {
customer = setCustomer();
serviceInstance = setServiceInstance();
requestContext = setRequestContext();
@@ -64,139 +75,78 @@ public class SDNCUnassignTasksTest extends BaseTaskTest{
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), any())).thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.NETWORK_ID), any())).thenReturn(network);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
}
@Test
public void unassignServiceInstanceTest() throws Exception {
- doReturn("test").when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext);
-
+ 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 unassignServiceInstanceTest_inventoried() throws Exception {
- doReturn("test").when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext);
-
- serviceInstance.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- sdncUnassignTasks.unassignServiceInstance(execution);
-
- verify(sdncServiceInstanceResources, times(0)).unassignServiceInstance(serviceInstance, customer, requestContext);
- }
+
@Test
public void unassignServiceInstanceExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
-
- doThrow(Exception.class).when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext);
-
+ doThrow(RuntimeException.class).when(sdncServiceInstanceResources).unassignServiceInstance(serviceInstance, customer, requestContext);
sdncUnassignTasks.unassignServiceInstance(execution);
}
@Test
public void unassignVfModuleTest() throws Exception {
- doReturn("response").when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf, serviceInstance);
-
+ doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf, serviceInstance);
sdncUnassignTasks.unassignVfModule(execution);
-
verify(sdncVfModuleResources, times(1)).unassignVfModule(vfModule, genericVnf, serviceInstance);
- assertEquals("response", execution.getVariable("SDNCResponse"));
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VFMODULE,sdncRequest.getTopology());
}
- @Test
- public void unassignVfModuleTest_inventoried() throws Exception {
- vfModule.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- sdncUnassignTasks.unassignVfModule(execution);
- verify(sdncVfModuleResources, times(0)).unassignVfModule(vfModule, genericVnf, serviceInstance);
- assertNull(execution.getVariable("SDNCResponse"));
- }
- @Test
- public void unassignVfModuleTest_pendingCreate() throws Exception {
- vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_CREATE);
-
- sdncUnassignTasks.unassignVfModule(execution);
- verify(sdncVfModuleResources, times(0)).unassignVfModule(vfModule, genericVnf, serviceInstance);
- assertNull(execution.getVariable("SDNCResponse"));
- }
-
@Test
public void unassignVfModuleExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
-
- doThrow(Exception.class).when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf, serviceInstance);
-
+ doThrow(RuntimeException.class).when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf, serviceInstance);
sdncUnassignTasks.unassignVfModule(execution);
}
@Test
public void unassignVnfTest() throws Exception {
- doReturn("response").when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
-
+ doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
sdncUnassignTasks.unassignVnf(execution);
-
verify(sdncVnfResources, times(1)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- assertTrue(execution.getVariable("sdncUnassignVnfResponse").equals("response"));
- }
-
- @Test
- public void unassignVnfTest_inventoried() throws Exception {
- genericVnf.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- sdncUnassignTasks.unassignVnf(execution);
-
- verify(sdncVnfResources, times(0)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- assertNull(execution.getVariable("sdncUnassignVnfResponse"));
+ SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+ assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
}
- @Test
- public void unassignVnfTest_created() throws Exception {
- genericVnf.setOrchestrationStatus(OrchestrationStatus.CREATED);
-
- sdncUnassignTasks.unassignVnf(execution);
-
- verify(sdncVnfResources, times(0)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- assertNull(execution.getVariable("sdncUnassignVnfResponse"));
- }
@Test
public void unassignVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
- doThrow(Exception.class).when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
+ 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("response").when(sdncNetworkResources).unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
-
+ 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("response", execution.getVariable("SDNCUnAssignNetworkResponse"));
assertEquals(cloudRegionSdnc, cloudRegion.getLcpCloudRegionId());
- }
-
- @Test
- public void unassignNetworkTest_inventoried() throws Exception {
- network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
-
- sdncUnassignTasks.unassignNetwork(execution);
-
- verify(sdncNetworkResources, times(0)).unassignNetwork(network, serviceInstance, customer, requestContext, cloudRegion);
- assertNull(execution.getVariable("SDNCUnAssignNetworkResponse"));
+ 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/workflow/tasks/FlowCompletionTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/FlowCompletionTasksTest.java
index 03ed2cb4d4..3cf003d1ad 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
@@ -21,7 +21,7 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -36,8 +37,8 @@ import org.springframework.beans.factory.annotation.Autowired;
public class FlowCompletionTasksTest extends BaseTaskTest {
- @Autowired
- protected FlowCompletionTasks flowCompletionTasks;
+ @InjectMocks
+ protected FlowCompletionTasks flowCompletionTasks = new FlowCompletionTasks();
@Before
public void before() {
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 5ef020d6ed..60d456e2b5 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
@@ -21,15 +21,24 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
import static org.junit.Assert.assertEquals;
+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 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;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
@@ -43,9 +52,12 @@ import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective;
import org.onap.so.db.catalog.beans.ResourceType;
import org.springframework.beans.factory.annotation.Autowired;
+@Ignore
public class OrchestrationStatusValidatorTest extends BaseTaskTest {
- @Autowired
- protected OrchestrationStatusValidator orchestrationStatusValidator;
+ @InjectMocks
+ protected OrchestrationStatusValidator orchestrationStatusValidator = new OrchestrationStatusValidator();
+
+
@Test
public void test_validateOrchestrationStatus() throws Exception {
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
new file mode 100644
index 0000000000..14261e876d
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
@@ -0,0 +1,146 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.workflow.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.anyString;
+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;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.Spy;
+import org.onap.so.bpmn.BaseTaskTest;
+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 {
+
+ @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);
+ }
+}
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 8ed1f44b8a..f3b094f645 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
@@ -21,38 +21,47 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doThrow;
+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;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.Spy;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.springframework.beans.factory.annotation.Autowired;
public class WorkflowActionBBTasksTest extends BaseTaskTest {
- @Autowired
+ @Mock
protected WorkflowAction workflowAction;
- @Autowired
+ @Mock
+ protected WorkflowActionBBFailure workflowActionBBFailure;
+
+ @InjectMocks
+ @Spy
protected WorkflowActionBBTasks workflowActionBBTasks;
+ @Mock
+ InfraActiveRequests reqMock;
+
private DelegateExecution execution;
@Rule
@@ -86,32 +95,6 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
}
@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();
- when(requestsDbClient.getInfraActiveRequestbyRequestId(requestId)).thenReturn(mockedRequest);
- InfraActiveRequests actual = workflowActionBBTasks.getUpdatedRequest(execution, currentSequence);
- assertEquals(expectedStatusMessage, actual.getStatusMessage());
- assertEquals(expectedLong, actual.getProgress());
- }
-
- @Test
public void select2BBTest() throws Exception{
String gAction = "Delete-Network-Collection";
execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
@@ -131,30 +114,42 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
}
@Test
- public void msoCompleteProcessTest() throws Exception{
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ public void updateRequestStatusToCompleteTest() throws Exception{
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
execution.setVariable("requestAction", "createInstance");
- execution.setVariable("resourceId", "123");
- execution.setVariable("source","MSO");
execution.setVariable("resourceName", "Service");
execution.setVariable("aLaCarte", true);
- workflowActionBBTasks.setupCompleteMsoProcess(execution);
- String response = (String) execution.getVariable("CompleteMsoProcessRequest");
- assertEquals(response,"<aetgt:MsoCompletionRequest xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns=\"http://org.onap/so/request/types/v1\"><request-info xmlns=\"http://org.onap/so/infra/vnf-request/v1\"><request-id>00f704ca-c5e5-4f95-a72c-6889db7b0688</request-id><action>createInstance</action><source>MSO</source></request-info><status-message>ALaCarte-Service-createInstance request was executed correctly.</status-message><serviceInstanceId>123</serviceInstanceId><mso-bpel-name>WorkflowActionBB</mso-bpel-name></aetgt:MsoCompletionRequest>");
+ 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 setupFalloutHandlerTest(){
- execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- execution.setVariable("serviceInstanceId", "123");
- execution.setVariable("WorkflowActionErrorMessage", "Error in WorkFlowAction");
- execution.setVariable("requestAction", "createInstance");
- workflowActionBBTasks.setupFalloutHandler(execution);
- assertEquals(execution.getVariable("falloutRequest"),"<aetgt:FalloutHandlerRequest xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\"xmlns:ns=\"http://org.onap/so/request/types/v1\"xmlns:wfsch=\"http://org.onap/so/workflow/schema/v1\"><request-info xmlns=\"http://org.onap/so/infra/vnf-request/v1\"><request-id>00f704ca-c5e5-4f95-a72c-6889db7b0688</request-id><action>createInstance</action><source>VID</source></request-info><aetgt:WorkflowException xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\"><aetgt:ErrorMessage>Error in WorkFlowAction</aetgt:ErrorMessage><aetgt:ErrorCode>7000</aetgt:ErrorCode></aetgt:WorkflowException></aetgt:FalloutHandlerRequest>");
+ public void updateRequestStatusToFailedFlowStatusTest() {
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ execution.setVariable("isRollbackComplete", false);
+ execution.setVariable("isRollback", false);
+ ExecuteBuildingBlock ebb = new ExecuteBuildingBlock();
+ BuildingBlock buildingBlock = new BuildingBlock();
+ buildingBlock.setBpmnFlowName("CreateNetworkBB");
+ ebb.setBuildingBlock(buildingBlock);
+ execution.setVariable("buildingBlock", ebb);
+ WorkflowException wfe = new WorkflowException("failure", 1, "failure");
+ execution.setVariable("WorkflowException", wfe);
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBTasks.updateRequestStatusToFailed(execution);
+ assertEquals("CreateNetworkBB has failed.",execution.getVariable("flowStatus"));
}
@Test
public void rollbackExecutionPathTest(){
+ execution.setVariable("handlingCode", "Rollback");
execution.setVariable("isRollback", false);
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
@@ -175,6 +170,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
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");
@@ -186,6 +182,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
@Test
public void rollbackExecutionPathUnfinishedFlowTest(){
+ execution.setVariable("handlingCode", "Rollback");
execution.setVariable("isRollback", false);
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList();
ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock();
@@ -206,16 +203,19 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
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();
@@ -241,6 +241,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
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");
@@ -251,19 +252,59 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
}
@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 checkRetryStatusTest(){
+ String reqId = "reqId123";
+ execution.setVariable("mso-request-id", reqId);
+ doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
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 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"));
}
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
new file mode 100644
index 0000000000..0f106ad913
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksUpdateReqDbTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.workflow.tasks;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+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;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.InjectMocks;
+import org.mockito.Spy;
+import org.onap.so.bpmn.BaseTaskTest;
+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{
+
+ 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());
+ }
+}
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 c27b5dd655..7b348c8cb3 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
@@ -25,8 +25,9 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
@@ -36,7 +37,6 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@@ -49,17 +49,23 @@ import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.L3Network;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.VfModules;
import org.onap.aai.domain.yang.VolumeGroup;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
+import org.onap.so.client.aai.entities.Relationships;
import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResource;
import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
@@ -77,15 +83,19 @@ import org.onap.so.serviceinstancebeans.RequestDetails;
import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.serviceinstancebeans.SubscriberInfo;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
import com.fasterxml.jackson.databind.ObjectMapper;
public class WorkflowActionTest extends BaseTaskTest {
- @Autowired
- protected WorkflowAction workflowAction;
+
+ @Mock
+ protected Environment environment;
+ @InjectMocks
+ protected WorkflowAction workflowAction;
private DelegateExecution execution;
+
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -113,27 +123,15 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("aLaCarte", true);
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/networks/123");
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignNetwork1802BB","CreateNetworkBB","ActivateNetworkBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("AssignNetwork1802BB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("CreateNetworkBB");
- orchFlows.add(orch2);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("ActivateNetworkBB");
- orchFlows.add(orch3);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,true)).thenReturn(northBoundRequest);
-
-
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"AssignNetwork1802BB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"CreateNetworkBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"ActivateNetworkBB");
+ assertEqualsBulkFlowName(ebbs,"AssignNetwork1802BB","CreateNetworkBB","ActivateNetworkBB");
}
@Test
@@ -147,24 +145,15 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("aLaCarte", true);
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/networks/123");
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateNetworkBB","DeleteNetworkBB","UnassignNetwork1802BB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("DeactivateNetworkBB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("DeleteNetworkBB");
- orchFlows.add(orch2);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("UnassignNetwork1802BB");
- orchFlows.add(orch3);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,true)).thenReturn(northBoundRequest);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeactivateNetworkBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"UnassignNetwork1802BB");
+ assertEqualsBulkFlowName(ebbs,"DeactivateNetworkBB","DeleteNetworkBB","UnassignNetwork1802BB");
}
@Test
@@ -179,20 +168,15 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/serviceInstances/123");
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
- northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("AssignServiceInstanceBB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("ActivateServiceInstanceBB");
- orchFlows.add(orch2);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,true)).thenReturn(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");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"AssignServiceInstanceBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"ActivateServiceInstanceBB");
+ assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","ActivateServiceInstanceBB");
}
/**
@@ -210,24 +194,57 @@ public class WorkflowActionTest extends BaseTaskTest {
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 = new LinkedList<>();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("AssignServiceInstanceBB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("AssignNetworkBB");
- orchFlows.add(orch2);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("AssignVnfBB");
- orchFlows.add(orch3);
- OrchestrationFlow orch4 = new OrchestrationFlow();
- orch4.setFlowName("AssignVolumeGroupBB");
- orchFlows.add(orch4);
- OrchestrationFlow orch5 = new OrchestrationFlow();
- orch5.setFlowName("AssignVfModuleBB");
- orchFlows.add(orch5);
VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
@@ -250,18 +267,14 @@ public class WorkflowActionTest extends BaseTaskTest {
VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,false)).thenReturn(northBoundRequest);
+ 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");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"AssignServiceInstanceBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"AssignVnfBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"AssignVolumeGroupBB");
- assertEquals(ebbs.get(3).getBuildingBlock().getBpmnFlowName(),"AssignVfModuleBB");
- assertEquals(ebbs.get(4).getBuildingBlock().getBpmnFlowName(),"AssignVfModuleBB");
- assertEquals(ebbs.get(5).getBuildingBlock().getBpmnFlowName(),"AssignVfModuleBB");
+ assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB","AssignVfModuleBB","AssignVfModuleBB");
}
@Test
@@ -275,34 +288,12 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("aLaCarte", false);
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/serviceInstances/si0");
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
+ List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkBB","ActivateNetworkBB","CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","ActivateVfModuleBB"
+ ,"ActivateVnfBB","ActivateServiceInstanceBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("CreateNetworkBB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("ActivateNetworkBB");
- orchFlows.add(orch2);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("CreateVolumeGroupBB");
- orchFlows.add(orch3);
- OrchestrationFlow orch4 = new OrchestrationFlow();
- orch4.setFlowName("ActivateVolumeGroupBB");
- orchFlows.add(orch4);
- OrchestrationFlow orch5 = new OrchestrationFlow();
- orch5.setFlowName("CreateVfModuleBB");
- orchFlows.add(orch5);
- OrchestrationFlow orch6 = new OrchestrationFlow();
- orch6.setFlowName("ActivateVfModuleBB");
- orchFlows.add(orch6);
- OrchestrationFlow orch7 = new OrchestrationFlow();
- orch7.setFlowName("ActivateVnfBB");
- orchFlows.add(orch7);
- OrchestrationFlow orch8 = new OrchestrationFlow();
- orch8.setFlowName("ActivateServiceInstanceBB");
- orchFlows.add(orch8);
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId("si0");
@@ -325,24 +316,17 @@ public class WorkflowActionTest extends BaseTaskTest {
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("si0");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,false)).thenReturn(northBoundRequest);
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,false,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEquals("CreateVolumeGroupBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
+ assertEqualsBulkFlowName(ebbs,"CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","ActivateVfModuleBB","ActivateVnfBB","ActivateServiceInstanceBB");
assertEquals("volumeGroup0", ebbs.get(0).getWorkflowResourceIds().getVolumeGroupId());
- assertEquals("ActivateVolumeGroupBB", ebbs.get(1).getBuildingBlock().getBpmnFlowName());
assertEquals("volumeGroup0", ebbs.get(1).getWorkflowResourceIds().getVolumeGroupId());
- assertEquals("CreateVfModuleBB", ebbs.get(2).getBuildingBlock().getBpmnFlowName());
assertEquals("vfModule0", ebbs.get(2).getWorkflowResourceIds().getVfModuleId());
- assertEquals("CreateVfModuleBB", ebbs.get(3).getBuildingBlock().getBpmnFlowName());
assertEquals("vfModule1", ebbs.get(3).getWorkflowResourceIds().getVfModuleId());
- assertEquals("ActivateVfModuleBB", ebbs.get(4).getBuildingBlock().getBpmnFlowName());
assertEquals("vfModule0", ebbs.get(4).getWorkflowResourceIds().getVfModuleId());
- assertEquals("ActivateVfModuleBB", ebbs.get(5).getBuildingBlock().getBpmnFlowName());
assertEquals("vfModule1", ebbs.get(5).getWorkflowResourceIds().getVfModuleId());
- assertEquals("ActivateVnfBB", ebbs.get(6).getBuildingBlock().getBpmnFlowName());
assertEquals("vnf0", ebbs.get(6).getWorkflowResourceIds().getVnfId());
- assertEquals("ActivateServiceInstanceBB", ebbs.get(7).getBuildingBlock().getBpmnFlowName());
assertEquals("si0", ebbs.get(7).getWorkflowResourceIds().getServiceInstanceId());
}
@@ -358,15 +342,13 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("aLaCarte", false);
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/serviceInstances/123");
-
+
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
- northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch = new OrchestrationFlow();
- orch.setFlowName("DeactivateServiceInstanceBB");
- orchFlows.add(orch);
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,false)).thenReturn(northBoundRequest);
+ 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");
@@ -384,69 +366,20 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/serviceInstances/123");
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
northBoundRequest.setIsToplevelflow(true);
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB","CreateNetworkCollectionBB","AssignNetworkBB","AssignVnfBB","AssignVolumeGroupBB","AssignVfModuleBB"
+ ,"CreateNetworkBB","ActivateNetworkBB","CreateVolumeGroupBB","ActivateVolumeGroupBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB"
+ ,"ActivateVnfBB","ActivateNetworkCollectionBB","ActivateServiceInstanceBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("AssignServiceInstanceBB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("CreateNetworkCollectionBB");
- orchFlows.add(orch2);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("AssignNetworkBB");
- orchFlows.add(orch3);
- OrchestrationFlow orch4 = new OrchestrationFlow();
- orch4.setFlowName("AssignVnfBB");
- orchFlows.add(orch4);
- OrchestrationFlow orch5 = new OrchestrationFlow();
- orch5.setFlowName("AssignVolumeGroupBB");
- orchFlows.add(orch5);
- OrchestrationFlow orch6 = new OrchestrationFlow();
- orch6.setFlowName("AssignVfModuleBB");
- orchFlows.add(orch6);
- OrchestrationFlow orch7 = new OrchestrationFlow();
- orch7.setFlowName("CreateNetworkBB");
- orchFlows.add(orch7);
- OrchestrationFlow orch8 = new OrchestrationFlow();
- orch8.setFlowName("ActivateNetworkBB");
- orchFlows.add(orch8);
- OrchestrationFlow orch9 = new OrchestrationFlow();
- orch9.setFlowName("CreateVolumeGroupBB");
- orchFlows.add(orch9);
- OrchestrationFlow orch10 = new OrchestrationFlow();
- orch10.setFlowName("ActivateVolumeGroupBB");
- orchFlows.add(orch10);
- OrchestrationFlow orch11 = new OrchestrationFlow();
- orch11.setFlowName("CreateVfModuleBB");
- orchFlows.add(orch11);
- OrchestrationFlow orch12 = new OrchestrationFlow();
- orch12.setFlowName("ActivateVfModuleBB");
- orchFlows.add(orch12);
- OrchestrationFlow orch13 = new OrchestrationFlow();
- orch13.setFlowName("AssignFabricConfigurationBB");
- orchFlows.add(orch13);
- OrchestrationFlow orch14 = new OrchestrationFlow();
- orch14.setFlowName("ActivateFabricConfigurationBB");
- orchFlows.add(orch14);
- OrchestrationFlow orch15 = new OrchestrationFlow();
- orch15.setFlowName("ActivateVnfBB");
- orchFlows.add(orch15);
- OrchestrationFlow orch16 = new OrchestrationFlow();
- orch16.setFlowName("ActivateNetworkCollectionBB");
- orchFlows.add(orch16);
- OrchestrationFlow orch17 = new OrchestrationFlow();
- orch17.setFlowName("ActivateServiceInstanceBB");
- orchFlows.add(orch17);
Service service = new Service();
doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,false)).thenReturn(northBoundRequest);
+ 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(),"AssignServiceInstanceBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"ActivateServiceInstanceBB");
+ assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","ActivateServiceInstanceBB");
}
@Test
@@ -461,69 +394,23 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/serviceInstances/123");
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
northBoundRequest.setIsToplevelflow(true);
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
- northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("AssignServiceInstanceBB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("CreateNetworkCollectionBB");
- orchFlows.add(orch2);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("AssignNetworkBB");
- orchFlows.add(orch3);
- OrchestrationFlow orch4 = new OrchestrationFlow();
- orch4.setFlowName("AssignVnfBB");
- orchFlows.add(orch4);
- OrchestrationFlow orch5 = new OrchestrationFlow();
- orch5.setFlowName("AssignVolumeGroupBB");
- orchFlows.add(orch5);
- OrchestrationFlow orch6 = new OrchestrationFlow();
- orch6.setFlowName("AssignVfModuleBB");
- orchFlows.add(orch6);
- OrchestrationFlow orch7 = new OrchestrationFlow();
- orch7.setFlowName("CreateNetworkBB");
- orchFlows.add(orch7);
- OrchestrationFlow orch8 = new OrchestrationFlow();
- orch8.setFlowName("ActivateNetworkBB");
- orchFlows.add(orch8);
- OrchestrationFlow orch9 = new OrchestrationFlow();
- orch9.setFlowName("CreateVolumeGroupBB");
- orchFlows.add(orch9);
- OrchestrationFlow orch10 = new OrchestrationFlow();
- orch10.setFlowName("ActivateVolumeGroupBB");
- orchFlows.add(orch10);
- OrchestrationFlow orch11 = new OrchestrationFlow();
- orch11.setFlowName("CreateVfModuleBB");
- orchFlows.add(orch11);
- OrchestrationFlow orch12 = new OrchestrationFlow();
- orch12.setFlowName("ActivateVfModuleBB");
- orchFlows.add(orch12);
- OrchestrationFlow orch13 = new OrchestrationFlow();
- orch13.setFlowName("ActivateVnfBB");
- orchFlows.add(orch13);
- OrchestrationFlow orch14 = new OrchestrationFlow();
- orch14.setFlowName("ActivateNetworkCollectionBB");
- orchFlows.add(orch14);
- OrchestrationFlow orch15 = new OrchestrationFlow();
- orch15.setFlowName("ActivateServiceInstanceBB");
- orchFlows.add(orch15);
+ 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.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,false)).thenReturn(northBoundRequest);
+ 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(),"AssignServiceInstanceBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"AssignNetworkBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"CreateNetworkBB");
- assertEquals(ebbs.get(3).getBuildingBlock().getBpmnFlowName(),"ActivateNetworkBB");
- assertEquals(ebbs.get(4).getBuildingBlock().getBpmnFlowName(),"ActivateServiceInstanceBB");
+ assertEqualsBulkFlowName(ebbs,"AssignServiceInstanceBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","ActivateServiceInstanceBB");
}
@Test
@@ -538,55 +425,13 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/serviceInstances/123");
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
northBoundRequest.setIsToplevelflow(true);
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
- northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("AssignServiceInstanceBB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("CreateNetworkCollectionBB");
- orchFlows.add(orch2);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("AssignNetworkBB");
- orchFlows.add(orch3);
- OrchestrationFlow orch4 = new OrchestrationFlow();
- orch4.setFlowName("AssignVnfBB");
- orchFlows.add(orch4);
- OrchestrationFlow orch5 = new OrchestrationFlow();
- orch5.setFlowName("AssignVolumeGroupBB");
- orchFlows.add(orch5);
- OrchestrationFlow orch6 = new OrchestrationFlow();
- orch6.setFlowName("AssignVfModuleBB");
- orchFlows.add(orch6);
- OrchestrationFlow orch7 = new OrchestrationFlow();
- orch7.setFlowName("CreateNetworkBB");
- orchFlows.add(orch7);
- OrchestrationFlow orch8 = new OrchestrationFlow();
- orch8.setFlowName("ActivateNetworkBB");
- orchFlows.add(orch8);
- OrchestrationFlow orch9 = new OrchestrationFlow();
- orch9.setFlowName("CreateVolumeGroupBB");
- orchFlows.add(orch9);
- OrchestrationFlow orch10 = new OrchestrationFlow();
- orch10.setFlowName("ActivateVolumeGroupBB");
- orchFlows.add(orch10);
- OrchestrationFlow orch11 = new OrchestrationFlow();
- orch11.setFlowName("CreateVfModuleBB");
- orchFlows.add(orch11);
- OrchestrationFlow orch12 = new OrchestrationFlow();
- orch12.setFlowName("ActivateVfModuleBB");
- orchFlows.add(orch12);
- OrchestrationFlow orch13 = new OrchestrationFlow();
- orch13.setFlowName("ActivateVnfBB");
- orchFlows.add(orch13);
- OrchestrationFlow orch14 = new OrchestrationFlow();
- orch14.setFlowName("ActivateNetworkCollectionBB");
- orchFlows.add(orch14);
- OrchestrationFlow orch15 = new OrchestrationFlow();
- orch15.setFlowName("ActivateServiceInstanceBB");
- orchFlows.add(orch15);
+ 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<>();
@@ -619,40 +464,29 @@ public class WorkflowActionTest extends BaseTaskTest {
service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
doReturn(collectionResourceCustomization).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,false)).thenReturn(northBoundRequest);
+ 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(),"AssignServiceInstanceBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"CreateNetworkCollectionBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"AssignNetworkBB");
+ 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(ebbs.get(3).getBuildingBlock().getBpmnFlowName(),"CreateNetworkBB");
assertEquals("Network id not empty", !ebbs.get(3).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals(ebbs.get(4).getBuildingBlock().getBpmnFlowName(),"ActivateNetworkBB");
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(ebbs.get(5).getBuildingBlock().getBpmnFlowName(),"AssignNetworkBB");
assertEquals("Network id not empty", !ebbs.get(5).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals(ebbs.get(6).getBuildingBlock().getBpmnFlowName(),"CreateNetworkBB");
assertEquals("Network id not empty", !ebbs.get(6).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals(ebbs.get(7).getBuildingBlock().getBpmnFlowName(),"ActivateNetworkBB");
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(ebbs.get(8).getBuildingBlock().getBpmnFlowName(),"AssignNetworkBB");
assertEquals("Network id not empty", !ebbs.get(8).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals(ebbs.get(9).getBuildingBlock().getBpmnFlowName(),"CreateNetworkBB");
assertEquals("Network id not empty", !ebbs.get(9).getWorkflowResourceIds().getNetworkId().isEmpty(), true);
- assertEquals(ebbs.get(10).getBuildingBlock().getBpmnFlowName(),"ActivateNetworkBB");
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);
- assertEquals(ebbs.get(11).getBuildingBlock().getBpmnFlowName(),"ActivateNetworkCollectionBB");
- assertEquals(ebbs.get(12).getBuildingBlock().getBpmnFlowName(),"ActivateServiceInstanceBB");
}
@Test
@@ -667,54 +501,12 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/serviceInstances/123");
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
- northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("AssignServiceInstanceBB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("CreateNetworkCollectionBB");
- orchFlows.add(orch2);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("AssignNetworkBB");
- orchFlows.add(orch3);
- OrchestrationFlow orch4 = new OrchestrationFlow();
- orch4.setFlowName("AssignVnfBB");
- orchFlows.add(orch4);
- OrchestrationFlow orch5 = new OrchestrationFlow();
- orch5.setFlowName("AssignVolumeGroupBB");
- orchFlows.add(orch5);
- OrchestrationFlow orch6 = new OrchestrationFlow();
- orch6.setFlowName("AssignVfModuleBB");
- orchFlows.add(orch6);
- OrchestrationFlow orch7 = new OrchestrationFlow();
- orch7.setFlowName("CreateNetworkBB");
- orchFlows.add(orch7);
- OrchestrationFlow orch8 = new OrchestrationFlow();
- orch8.setFlowName("ActivateNetworkBB");
- orchFlows.add(orch8);
- OrchestrationFlow orch9 = new OrchestrationFlow();
- orch9.setFlowName("CreateVolumeGroupBB");
- orchFlows.add(orch9);
- OrchestrationFlow orch10 = new OrchestrationFlow();
- orch10.setFlowName("ActivateVolumeGroupBB");
- orchFlows.add(orch10);
- OrchestrationFlow orch11 = new OrchestrationFlow();
- orch11.setFlowName("CreateVfModuleBB");
- orchFlows.add(orch11);
- OrchestrationFlow orch12 = new OrchestrationFlow();
- orch12.setFlowName("ActivateVfModuleBB");
- orchFlows.add(orch12);
- OrchestrationFlow orch13 = new OrchestrationFlow();
- orch13.setFlowName("ActivateVnfBB");
- orchFlows.add(orch13);
- OrchestrationFlow orch14 = new OrchestrationFlow();
- orch14.setFlowName("ActivateNetworkCollectionBB");
- orchFlows.add(orch14);
- OrchestrationFlow orch15 = new OrchestrationFlow();
- orch15.setFlowName("ActivateServiceInstanceBB");
- orchFlows.add(orch15);
+ 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");
@@ -740,45 +532,31 @@ public class WorkflowActionTest extends BaseTaskTest {
VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,false)).thenReturn(northBoundRequest);
+ 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");
-
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"AssignServiceInstanceBB");
+ 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());
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"AssignVnfBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(1).getWorkflowResourceIds().getVnfId().length());
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"AssignVolumeGroupBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(2).getWorkflowResourceIds().getVolumeGroupId().length());
- assertEquals(ebbs.get(3).getBuildingBlock().getBpmnFlowName(),"AssignVfModuleBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(3).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(ebbs.get(4).getBuildingBlock().getBpmnFlowName(),"AssignVfModuleBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(4).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(ebbs.get(5).getBuildingBlock().getBpmnFlowName(),"AssignVfModuleBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(5).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(ebbs.get(6).getBuildingBlock().getBpmnFlowName(),"CreateVolumeGroupBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(6).getWorkflowResourceIds().getVolumeGroupId().length());
- assertEquals(ebbs.get(7).getBuildingBlock().getBpmnFlowName(),"ActivateVolumeGroupBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(7).getWorkflowResourceIds().getVolumeGroupId().length());
- assertEquals(ebbs.get(8).getBuildingBlock().getBpmnFlowName(),"CreateVfModuleBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(8).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(ebbs.get(9).getBuildingBlock().getBpmnFlowName(),"CreateVfModuleBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(9).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(ebbs.get(10).getBuildingBlock().getBpmnFlowName(),"CreateVfModuleBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(10).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(ebbs.get(11).getBuildingBlock().getBpmnFlowName(),"ActivateVfModuleBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(11).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(ebbs.get(12).getBuildingBlock().getBpmnFlowName(),"ActivateVfModuleBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(12).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(ebbs.get(13).getBuildingBlock().getBpmnFlowName(),"ActivateVfModuleBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(13).getWorkflowResourceIds().getVfModuleId().length());
- assertEquals(ebbs.get(14).getBuildingBlock().getBpmnFlowName(),"ActivateVnfBB");
- assertEquals(UUID.randomUUID().toString().length(),ebbs.get(14).getWorkflowResourceIds().getVnfId().length());
- assertEquals(ebbs.get(15).getBuildingBlock().getBpmnFlowName(),"ActivateServiceInstanceBB");
+ 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"));
}
@@ -794,52 +572,12 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("aLaCarte", false);
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/serviceInstances/123");
-
+
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","DeactivateVolumeGroupBB","DeleteVolumeGroupBB","DeactivateVnfBB","DeactivateNetworkBB"
+ ,"DeleteNetworkBB","DeleteNetworkCollectionBB","DeactivateServiceInstanceBB","UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignNetworkBB","UnassignServiceInstanceBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("DeactivateVfModuleBB");
- orchFlows.add(orch3);
- OrchestrationFlow orch4 = new OrchestrationFlow();
- orch4.setFlowName("DeleteVfModuleBB");
- orchFlows.add(orch4);
- OrchestrationFlow orch5 = new OrchestrationFlow();
- orch5.setFlowName("DeactivateVolumeGroupBB");
- orchFlows.add(orch5);
- OrchestrationFlow orch6 = new OrchestrationFlow();
- orch6.setFlowName("DeleteVolumeGroupBB");
- orchFlows.add(orch6);
- OrchestrationFlow orch7 = new OrchestrationFlow();
- orch7.setFlowName("DeactivateVnfBB");
- orchFlows.add(orch7);
- OrchestrationFlow orch8 = new OrchestrationFlow();
- orch8.setFlowName("DeactivateNetworkBB");
- orchFlows.add(orch8);
- OrchestrationFlow orch9 = new OrchestrationFlow();
- orch9.setFlowName("DeleteNetworkBB");
- orchFlows.add(orch9);
- OrchestrationFlow orch10 = new OrchestrationFlow();
- orch10.setFlowName("DeleteNetworkCollectionBB");
- orchFlows.add(orch10);
- OrchestrationFlow orch11 = new OrchestrationFlow();
- orch11.setFlowName("DeactivateServiceInstanceBB");
- orchFlows.add(orch11);
- OrchestrationFlow orch12 = new OrchestrationFlow();
- orch12.setFlowName("UnassignVfModuleBB");
- orchFlows.add(orch12);
- OrchestrationFlow orch13 = new OrchestrationFlow();
- orch13.setFlowName("UnassignVolumeGroupBB");
- orchFlows.add(orch13);
- OrchestrationFlow orch14 = new OrchestrationFlow();
- orch14.setFlowName("UnassignVnfBB");
- orchFlows.add(orch14);
- OrchestrationFlow orch15 = new OrchestrationFlow();
- orch15.setFlowName("UnassignNetworkBB");
- orchFlows.add(orch15);
- OrchestrationFlow orch16 = new OrchestrationFlow();
- orch16.setFlowName("UnassignServiceInstanceBB");
- orchFlows.add(orch16);
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId("aaisi123");
@@ -862,22 +600,11 @@ public class WorkflowActionTest extends BaseTaskTest {
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,false)).thenReturn(northBoundRequest);
+ 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(),"DeactivateVfModuleBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"DeactivateVfModuleBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"DeleteVfModuleBB");
- assertEquals(ebbs.get(3).getBuildingBlock().getBpmnFlowName(),"DeleteVfModuleBB");
- assertEquals(ebbs.get(4).getBuildingBlock().getBpmnFlowName(),"DeactivateVolumeGroupBB");
- assertEquals(ebbs.get(5).getBuildingBlock().getBpmnFlowName(),"DeleteVolumeGroupBB");
- assertEquals(ebbs.get(6).getBuildingBlock().getBpmnFlowName(),"DeactivateVnfBB");
- assertEquals(ebbs.get(7).getBuildingBlock().getBpmnFlowName(),"DeactivateServiceInstanceBB");
- assertEquals(ebbs.get(8).getBuildingBlock().getBpmnFlowName(),"UnassignVfModuleBB");
- assertEquals(ebbs.get(9).getBuildingBlock().getBpmnFlowName(),"UnassignVfModuleBB");
- assertEquals(ebbs.get(10).getBuildingBlock().getBpmnFlowName(),"UnassignVolumeGroupBB");
- assertEquals(ebbs.get(11).getBuildingBlock().getBpmnFlowName(),"UnassignVnfBB");
- assertEquals(ebbs.get(12).getBuildingBlock().getBpmnFlowName(),"UnassignServiceInstanceBB");
+ assertEqualsBulkFlowName(ebbs,"DeactivateVfModuleBB","DeactivateVfModuleBB","DeleteVfModuleBB","DeleteVfModuleBB","DeactivateVolumeGroupBB","DeleteVolumeGroupBB","DeactivateVnfBB"
+ ,"DeactivateServiceInstanceBB","UnassignVfModuleBB","UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignServiceInstanceBB");
}
@Test
@@ -892,24 +619,10 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/serviceInstances/123");
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
+ List<OrchestrationFlow> orchFlows = createFlowList("UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignNetworkBB","UnassignServiceInstanceBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("UnassignVfModuleBB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("UnassignVolumeGroupBB");
- orchFlows.add(orch2);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("UnassignVnfBB");
- orchFlows.add(orch3);
- OrchestrationFlow orch4 = new OrchestrationFlow();
- orch4.setFlowName("UnassignNetworkBB");
- orchFlows.add(orch4);
- OrchestrationFlow orch5 = new OrchestrationFlow();
- orch5.setFlowName("UnassignServiceInstanceBB");
- orchFlows.add(orch5);
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId("aaisi123");
@@ -932,14 +645,10 @@ public class WorkflowActionTest extends BaseTaskTest {
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,false)).thenReturn(northBoundRequest);
+ 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(),"UnassignVfModuleBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"UnassignVfModuleBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"UnassignVolumeGroupBB");
- assertEquals(ebbs.get(3).getBuildingBlock().getBpmnFlowName(),"UnassignVnfBB");
- assertEquals(ebbs.get(4).getBuildingBlock().getBpmnFlowName(),"UnassignServiceInstanceBB");
+ assertEqualsBulkFlowName(ebbs,"UnassignVfModuleBB","UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignServiceInstanceBB");
}
@Test
@@ -954,51 +663,11 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/serviceInstances/123");
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","DeactivateVolumeGroupBB","DeleteVolumeGroupBB","DeactivateVnfBB","DeactivateNetworkBB"
+ ,"DeleteNetworkBB","DeleteNetworkCollectionBB","DeactivateServiceInstanceBB","UnassignVfModuleBB","UnassignVolumeGroupBB","UnassignVnfBB","UnassignNetworkBB","UnassignServiceInstanceBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("DeactivateVfModuleBB");
- orchFlows.add(orch3);
- OrchestrationFlow orch4 = new OrchestrationFlow();
- orch4.setFlowName("DeleteVfModuleBB");
- orchFlows.add(orch4);
- OrchestrationFlow orch5 = new OrchestrationFlow();
- orch5.setFlowName("DeactivateVolumeGroupBB");
- orchFlows.add(orch5);
- OrchestrationFlow orch6 = new OrchestrationFlow();
- orch6.setFlowName("DeleteVolumeGroupBB");
- orchFlows.add(orch6);
- OrchestrationFlow orch7 = new OrchestrationFlow();
- orch7.setFlowName("DeactivateVnfBB");
- orchFlows.add(orch7);
- OrchestrationFlow orch8 = new OrchestrationFlow();
- orch8.setFlowName("DeactivateNetworkBB");
- orchFlows.add(orch8);
- OrchestrationFlow orch9 = new OrchestrationFlow();
- orch9.setFlowName("DeleteNetworkBB");
- orchFlows.add(orch9);
- OrchestrationFlow orch10 = new OrchestrationFlow();
- orch10.setFlowName("DeleteNetworkCollectionBB");
- orchFlows.add(orch10);
- OrchestrationFlow orch11 = new OrchestrationFlow();
- orch11.setFlowName("DeactivateServiceInstanceBB");
- orchFlows.add(orch11);
- OrchestrationFlow orch12 = new OrchestrationFlow();
- orch12.setFlowName("UnassignVfModuleBB");
- orchFlows.add(orch12);
- OrchestrationFlow orch13 = new OrchestrationFlow();
- orch13.setFlowName("UnassignVolumeGroupBB");
- orchFlows.add(orch13);
- OrchestrationFlow orch14 = new OrchestrationFlow();
- orch14.setFlowName("UnassignVnfBB");
- orchFlows.add(orch14);
- OrchestrationFlow orch15 = new OrchestrationFlow();
- orch15.setFlowName("UnassignNetworkBB");
- orchFlows.add(orch15);
- OrchestrationFlow orch16 = new OrchestrationFlow();
- orch16.setFlowName("UnassignServiceInstanceBB");
- orchFlows.add(orch16);
ServiceInstance serviceInstanceAAI = new ServiceInstance();
serviceInstanceAAI.setServiceInstanceId("aaisi123");
@@ -1016,20 +685,111 @@ public class WorkflowActionTest extends BaseTaskTest {
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,false)).thenReturn(northBoundRequest);
+ 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(),"DeactivateNetworkBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"UnassignNetworkBB");
- assertEquals(ebbs.get(3).getBuildingBlock().getBpmnFlowName(),"DeactivateNetworkBB");
- assertEquals(ebbs.get(4).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkBB");
- assertEquals(ebbs.get(5).getBuildingBlock().getBpmnFlowName(),"UnassignNetworkBB");
- assertEquals(ebbs.get(6).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkCollectionBB");
- assertEquals(ebbs.get(7).getBuildingBlock().getBpmnFlowName(),"DeactivateServiceInstanceBB");
- assertEquals(ebbs.get(8).getBuildingBlock().getBpmnFlowName(),"UnassignServiceInstanceBB");
+ 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);
+ 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);
+
+ 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();
+ vnf.setVnfId("1234");
+
+ 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);
+
+ 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);
+ 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");
+ }
+
+ @Test
+ 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);
+ 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);
+
+ 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();
+ vnf.setVnfId("1234");
+ 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);
+ serviceInstanceMSO.getVnfs().add(vnf);
+ VfModule vfModuleAAI = new VfModule();
+ vfModuleAAI.setVfModuleId("vfModule2");
+ RelationshipList relationshipList = new RelationshipList();
+ Relationship relationship = new Relationship();
+ relationshipList.getRelationship().add(relationship);
+ vfModuleAAI.setRelationshipList(relationshipList);
+ Relationships relationships = new Relationships("abc");
+ Configuration config = new Configuration();
+ 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);
+ 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{
@@ -1042,25 +802,11 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("aLaCarte", false);
execution.setVariable("apiVersion", "7");
execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123");
-
+
+
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
+ List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkCollectionBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","ActivateNetworkCollectionBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("CreateNetworkCollectionBB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("AssignNetworkBB");
- orchFlows.add(orch2);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("CreateNetworkBB");
- orchFlows.add(orch3);
- OrchestrationFlow orch4 = new OrchestrationFlow();
- orch4.setFlowName("ActivateNetworkBB");
- orchFlows.add(orch4);
- OrchestrationFlow orch5 = new OrchestrationFlow();
- orch5.setFlowName("ActivateNetworkCollectionBB");
- orchFlows.add(orch5);
Service service = new Service();
CollectionResourceCustomization collectionResourceCustomization = new CollectionResourceCustomization();
@@ -1069,18 +815,11 @@ public class WorkflowActionTest extends BaseTaskTest {
collectionResourceCustomization.setCollectionResource(collectionResource);
service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,false)).thenReturn(northBoundRequest);
+ 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");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"CreateNetworkCollectionBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"AssignNetworkBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"CreateNetworkBB");
- assertEquals(ebbs.get(3).getBuildingBlock().getBpmnFlowName(),"ActivateNetworkBB");
- assertEquals(ebbs.get(4).getBuildingBlock().getBpmnFlowName(),"AssignNetworkBB");
- assertEquals(ebbs.get(5).getBuildingBlock().getBpmnFlowName(),"CreateNetworkBB");
- assertEquals(ebbs.get(6).getBuildingBlock().getBpmnFlowName(),"ActivateNetworkBB");
- assertEquals(ebbs.get(7).getBuildingBlock().getBpmnFlowName(),"ActivateNetworkCollectionBB");
+ assertEqualsBulkFlowName(ebbs,"CreateNetworkCollectionBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","ActivateNetworkCollectionBB");
}
@Ignore
@@ -1097,23 +836,8 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123");
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkCollectionBB","DeleteNetworkCollectionBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("DeactivateNetworkBB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("DeleteNetworkBB");
- orchFlows.add(orch2);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("UnassignNetworkBB");
- orchFlows.add(orch3);
- OrchestrationFlow orch4 = new OrchestrationFlow();
- orch4.setFlowName("DeactivateNetworkCollectionBB");
- orchFlows.add(orch4);
- OrchestrationFlow orch5 = new OrchestrationFlow();
- orch5.setFlowName("DeleteNetworkCollectionBB");
- orchFlows.add(orch5);
Service service = new Service();
CollectionResourceCustomization collectionResourceCustomization = new CollectionResourceCustomization();
@@ -1122,18 +846,12 @@ public class WorkflowActionTest extends BaseTaskTest {
collectionResourceCustomization.setCollectionResource(collectionResource);
service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(gAction,resource,false)).thenReturn(northBoundRequest);
+ 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");
- assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeactivateNetworkBB");
- assertEquals(ebbs.get(1).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkBB");
- assertEquals(ebbs.get(2).getBuildingBlock().getBpmnFlowName(),"UnassignNetworkBB");
- assertEquals(ebbs.get(3).getBuildingBlock().getBpmnFlowName(),"DeactivateNetworkBB");
- assertEquals(ebbs.get(4).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkBB");
- assertEquals(ebbs.get(5).getBuildingBlock().getBpmnFlowName(),"UnassignNetworkBB");
- assertEquals(ebbs.get(6).getBuildingBlock().getBpmnFlowName(),"DeactivateNetworkCollectionBB");
- assertEquals(ebbs.get(7).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkCollectionBB");
+ assertEqualsBulkFlowName(ebbs,"DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkCollectionBB"
+ ,"DeleteNetworkCollectionBB");
}
/**
@@ -1197,12 +915,7 @@ public class WorkflowActionTest extends BaseTaskTest {
executeFlows.add(ebb6);
List<ExecuteBuildingBlock> sorted = workflowAction.sortExecutionPathByObjectForVlanTagging(executeFlows,"createInstance");
- assertEquals(sorted.get(0).getBuildingBlock().getBpmnFlowName(),"AssignNetworkBB");
- assertEquals(sorted.get(1).getBuildingBlock().getBpmnFlowName(),"CreateNetworkBB");
- assertEquals(sorted.get(2).getBuildingBlock().getBpmnFlowName(),"ActivateNetworkBB");
- assertEquals(sorted.get(3).getBuildingBlock().getBpmnFlowName(),"AssignNetworkBB");
- assertEquals(sorted.get(4).getBuildingBlock().getBpmnFlowName(),"CreateNetworkBB");
- assertEquals(sorted.get(5).getBuildingBlock().getBpmnFlowName(),"ActivateNetworkBB");
+ assertEqualsBulkFlowName(sorted,"AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB","AssignNetworkBB","CreateNetworkBB","ActivateNetworkBB");
}
@Test
@@ -1246,57 +959,18 @@ public class WorkflowActionTest extends BaseTaskTest {
executeFlows.add(ebb6);
List<ExecuteBuildingBlock> sorted = workflowAction.sortExecutionPathByObjectForVlanTagging(executeFlows,"deleteInstance");
- assertEquals(sorted.get(0).getBuildingBlock().getBpmnFlowName(),"DeactivateNetworkBB");
- assertEquals(sorted.get(1).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkBB");
- assertEquals(sorted.get(2).getBuildingBlock().getBpmnFlowName(),"UnassignNetworkBB");
- assertEquals(sorted.get(3).getBuildingBlock().getBpmnFlowName(),"DeactivateNetworkBB");
- assertEquals(sorted.get(4).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkBB");
- assertEquals(sorted.get(5).getBuildingBlock().getBpmnFlowName(),"UnassignNetworkBB");
+ assertEqualsBulkFlowName(sorted,"DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB","DeactivateNetworkBB","DeleteNetworkBB","UnassignNetworkBB");
}
@Test
public void queryNorthBoundRequestCatalogDbNestedTest() throws MalformedURLException {
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = new LinkedList<>();
- OrchestrationFlow orch1 = new OrchestrationFlow();
- orch1.setFlowName("AAICheckVnfInMaintBB");
- orchFlows.add(orch1);
- OrchestrationFlow orch2 = new OrchestrationFlow();
- orch2.setFlowName("AAISetVnfInMaintBB");
- orchFlows.add(orch2);
- OrchestrationFlow orch3 = new OrchestrationFlow();
- orch3.setFlowName("VNF-Macro-Replace");
- orchFlows.add(orch3);
- OrchestrationFlow orch4 = new OrchestrationFlow();
- orch4.setFlowName("SDNOVnfHealthCheckBB");
- orchFlows.add(orch4);
- OrchestrationFlow orch5 = new OrchestrationFlow();
- orch5.setFlowName("AAIUnsetVnfInMaintBB");
- orchFlows.add(orch5);
+ List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB","AAISetVnfInMaintBB","VNF-Macro-Replace","SDNOVnfHealthCheckBB","AAIUnsetVnfInMaintBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
+ List<OrchestrationFlow> macroFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","DeactivateVnfBB","CreateVfModuleBB","ActivateVfModuleBB","ActivateVnfBB");
- List<OrchestrationFlow> macroFlows = new LinkedList<>();
- OrchestrationFlow o1 = new OrchestrationFlow();
- o1.setFlowName("DeactivateVfModuleBB");
- macroFlows.add(o1);
- OrchestrationFlow o2 = new OrchestrationFlow();
- o2.setFlowName("DeleteVfModuleBB");
- macroFlows.add(o2);
- OrchestrationFlow o3 = new OrchestrationFlow();
- o3.setFlowName("DeactivateVnfBB");
- macroFlows.add(o3);
- OrchestrationFlow o4 = new OrchestrationFlow();
- o4.setFlowName("CreateVfModuleBB");
- macroFlows.add(o4);
- OrchestrationFlow o5 = new OrchestrationFlow();
- o5.setFlowName("ActivateVfModuleBB");
- macroFlows.add(o5);
- OrchestrationFlow o6 = new OrchestrationFlow();
- o6.setFlowName("ActivateVnfBB");
- macroFlows.add(o6);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScope("replaceInstance","Vnf",false)).thenReturn(northBoundRequest);
+ 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);
+ 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");
@@ -1308,6 +982,17 @@ public class WorkflowActionTest extends BaseTaskTest {
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(){
@@ -1473,6 +1158,7 @@ public class WorkflowActionTest extends BaseTaskTest {
}
}
+ @Ignore
@Test
public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException{
execution.setVariable("testProcessKey", "testProcessKeyValue");
@@ -1524,4 +1210,38 @@ public class WorkflowActionTest extends BaseTaskTest {
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());
+ }
+
+ 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 b4ec68050e..297d75a104 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
@@ -22,9 +22,9 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -43,10 +43,11 @@ import java.util.List;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
import org.onap.so.client.exception.ExceptionBuilder;
@@ -86,7 +87,7 @@ public class WorkflowActionUnitTest {
"flow y",
"ActivateFabricConfigurationBB",
"flow z");
- doReturn(Arrays.asList("yes", "yes")).when(workflowAction).traverseCatalogDbForConfiguration(any(String.class), any(String.class));
+ doReturn(Arrays.asList("yes", "yes")).when(workflowAction).traverseCatalogDbForConfiguration(ArgumentMatchers.isNull(), ArgumentMatchers.isNull());
List<OrchestrationFlow> result = workflowAction.filterOrchFlows(flows, WorkflowType.VFMODULE, mock(DelegateExecution.class));
@@ -101,7 +102,6 @@ public class WorkflowActionUnitTest {
"flow y",
"ActivateFabricConfigurationBB",
"flow z");
- doReturn(Arrays.asList()).when(workflowAction).traverseCatalogDbForConfiguration(any(String.class), any(String.class));
List<OrchestrationFlow> result = workflowAction.filterOrchFlows(flows, WorkflowType.VFMODULE, mock(DelegateExecution.class));
List<OrchestrationFlow> expected = createFlowList(
@@ -144,7 +144,7 @@ public class WorkflowActionUnitTest {
flow.setFlowName("flow x");
List<OrchestrationFlow> flows = Arrays.asList(flow);
- doReturn(Arrays.asList(flow)).when(workflowAction).queryNorthBoundRequestCatalogDb(any(), any(), any(), anyBoolean());
+ doReturn(Arrays.asList(flow)).when(workflowAction).queryNorthBoundRequestCatalogDb(any(), any(), any(), anyBoolean(), any(), any());
workflowAction.selectExecutionList(execution);
verify(workflowAction, times(1)).filterOrchFlows(eq(flows), any(), any());
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 10599bdab4..6eb22a6dcc 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
@@ -20,8 +20,8 @@
package org.onap.so.bpmn.sdno.tasks;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+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 static org.mockito.Mockito.times;
@@ -34,7 +34,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -45,7 +45,7 @@ import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.SDNOHealthCheckResources;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class SDNOHealthCheckTasksTest extends TestDataSetup {
@InjectMocks
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 352eb20630..a2880ce07f 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
@@ -25,11 +25,13 @@ import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
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.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
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;
import org.onap.so.adapters.nwrest.CreateNetworkError;
import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
@@ -44,21 +46,20 @@ import org.onap.so.adapters.nwrest.RollbackNetworkResponse;
import org.onap.so.adapters.nwrest.UpdateNetworkError;
import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
-import org.onap.so.BaseTest;
+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;
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-public class NetworkAdapterClientIT extends BaseTest{
+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 ObjectMapper();
+ private ObjectMapper mapper = new JettisonStyleMapperProvider().getMapper();
@BeforeClass
public static void setUp() {
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 1283d3ab1a..4bdbd1a846 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
@@ -22,6 +22,7 @@ package org.onap.so.client.adapter.network.mapper;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
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;
@@ -29,6 +30,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -98,24 +100,6 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
}
@Test
- public void testSetNetworkTechnology() {
- String networkTechnology = "Contrail";
- NetworkTechnology expectedNetworkTechnology = NetworkTechnology.CONTRAIL;
- NetworkTechnology actualNetworkTechnology = SPY_networkAdapterObjectMapper.setNetworkTechnology(networkTechnology);
- assertEquals("NetworkTechnology matches", expectedNetworkTechnology, actualNetworkTechnology);
-
- networkTechnology = "Neutron";
- expectedNetworkTechnology = NetworkTechnology.NEUTRON;
- actualNetworkTechnology = SPY_networkAdapterObjectMapper.setNetworkTechnology(networkTechnology);
- assertEquals("NetworkTechnology matches", expectedNetworkTechnology, actualNetworkTechnology);
-
- networkTechnology = "Vmware";
- expectedNetworkTechnology = NetworkTechnology.VMWARE;
- actualNetworkTechnology = SPY_networkAdapterObjectMapper.setNetworkTechnology(networkTechnology);
- assertEquals("NetworkTechnology matches", expectedNetworkTechnology, actualNetworkTechnology);
-
- }
- @Test
public void buildCreateNetworkRequestFromBbobjectTest() throws Exception {
String cloudRegionPo = "cloudRegionPo";
@@ -128,12 +112,19 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
expectedCreateNetworkRequest.setNetworkType(l3Network.getNetworkType());
expectedCreateNetworkRequest.setBackout(false);
expectedCreateNetworkRequest.setFailIfExists(true);
- expectedCreateNetworkRequest.setNetworkTechnology(NetworkTechnology.CONTRAIL);
+ 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();
@@ -144,11 +135,16 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
List<Subnet> subnetList = new ArrayList<Subnet>();
subnetList.add(openstackSubnet);
l3Network.getSubnets().add(openstackSubnet);
- l3Network.getModelInfoNetwork().setNetworkTechnology("Contrail");
+ 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("networkParams").ignoring("messageId"));
+ assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailRequest").ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("messageId"));
}
@Test
@@ -237,6 +233,12 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
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());
@@ -250,7 +252,7 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
expectedUpdateNetworkRequest.setSubnets(subnets);
expectedUpdateNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
expectedUpdateNetworkRequest.setContrailNetwork(contrailNetwork);
- expectedUpdateNetworkRequest.setNetworkParams(userInput);
+ expectedUpdateNetworkRequest.setNetworkParams(networkParams);
expectedUpdateNetworkRequest.setMsoRequest(msoRequest);
expectedUpdateNetworkRequest.setSkipAAI(true);
expectedUpdateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
@@ -295,6 +297,11 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
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));
@@ -331,6 +338,10 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
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));
@@ -352,6 +363,11 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
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 f7ad5f5ff4..3387920d40 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
@@ -31,6 +31,7 @@ import static org.junit.Assert.assertEquals;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.onap.so.BaseIntegrationTest;
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
import org.onap.so.adapters.vnfrest.CreateVfModuleResponse;
import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
@@ -42,11 +43,12 @@ import org.onap.so.adapters.vnfrest.UpdateVfModuleRequest;
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.BaseTest;
+import org.onap.so.client.policy.JettisonStyleMapperProvider;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class VnfAdapterClientIT extends BaseTest{
+public class VnfAdapterClientIT extends BaseIntegrationTest{
private static final String TESTING_ID = "___TESTING___";
private static final String AAI_VNF_ID = "test";
@@ -54,7 +56,7 @@ public class VnfAdapterClientIT extends BaseTest{
private static final String REST_ENDPOINT = "/services/rest/v1/vnfs";
private VnfAdapterClientImpl client = new VnfAdapterClientImpl();
- private ObjectMapper mapper = new ObjectMapper();
+ private ObjectMapper mapper = new JettisonStyleMapperProvider().getMapper();
@BeforeClass
public static void setUp() {
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 e3d849f925..40b6498034 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
@@ -32,7 +32,7 @@ import javax.ws.rs.core.UriBuilder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
@@ -42,11 +42,11 @@ import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse;
import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse;
import org.onap.so.client.adapter.rest.AdapterRestClient;
-import org.onap.so.BaseTest;
+import org.onap.so.BaseIntegrationTest;
-@RunWith(MockitoJUnitRunner.class)
-public class VnfVolumeAdapterClientIT extends BaseTest{
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class VnfVolumeAdapterClientIT extends BaseIntegrationTest{
private static final String TESTING_ID = "___TESTING___";
private static final String AAI_VOLUME_GROUP_ID = "test";
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 f176607dfa..339e9cbf17 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
@@ -23,7 +23,7 @@ package org.onap.so.client.adapter.vnf.mapper;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset;
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 dac26f728a..160feed426 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
@@ -24,7 +24,7 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import java.util.Arrays;
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
new file mode 100644
index 0000000000..7c58038f65
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.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;
+import org.onap.namingservice.model.Respelement;
+import org.onap.so.bpmn.common.data.TestDataSetup;
+import org.onap.so.client.exception.BadResponseException;
+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);
+ }
+
+}
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
new file mode 100644
index 0000000000..d6f8c70aa1
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.client.namingservice;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+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.stubFor;
+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;
+import org.junit.rules.ExpectedException;
+import org.onap.namingservice.model.Deleteelement;
+import org.onap.namingservice.model.Element;
+import org.onap.namingservice.model.NameGenDeleteRequest;
+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{
+ 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{
+ 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{
+ 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{
+ 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
new file mode 100644
index 0000000000..6cb4987bee
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java
@@ -0,0 +1,105 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.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;
+import org.onap.namingservice.model.NameGenDeleteRequest;
+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));
+ }
+}
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 149417d89b..0b33b1d187 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
@@ -20,20 +20,21 @@
package org.onap.so.client.oof;
-import com.fasterxml.jackson.core.JsonProcessingException;
+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.stubFor;
+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.oof.OofClient;
import org.onap.so.client.oof.beans.OofRequest;
import org.springframework.beans.factory.annotation.Autowired;
-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.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import com.fasterxml.jackson.core.JsonProcessingException;
-public class OofClientTestIT {
+public class OofClientTestIT extends BaseIntegrationTest {
@Autowired
private OofClient client;
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 fff4fc72fb..8bf3de5c4e 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
@@ -21,8 +21,8 @@
package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -32,7 +32,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
@@ -41,20 +42,12 @@ import org.onap.so.client.aai.AAIResourcesClient;
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.class)
-public class AAICollectionResourcesTest extends TestDataSetup{
+
+public class AAICollectionResourcesTest extends BaseTaskTest{
@InjectMocks
private AAICollectionResources aaiCollectionResources = new AAICollectionResources();
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
- @Mock
- protected AAIObjectMapper MOCK_aaiObjectMapper;
-
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
private Collection networkCollection;
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 3dc9a4da63..a38c8be686 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
@@ -20,9 +20,9 @@
package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
@@ -33,9 +33,10 @@ import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
@@ -54,7 +55,7 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.bpmn.common.data.TestDataSetup;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class AAIConfigurationResourcesTest extends TestDataSetup{
@@ -106,7 +107,7 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{
configuration.setConfigurationType("VNR");
configuration.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
aaiConfigurationResources.updateConfiguration(configuration);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.Configuration.class));
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull());
}
@Test
@@ -200,7 +201,7 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{
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), any(org.onap.aai.domain.yang.Configuration.class));
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
assertEquals(OrchestrationStatus.ACTIVE, configuration.getOrchestrationStatus());
}
} \ No newline at end of file
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 621e275fdf..10bbf39823 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
@@ -20,8 +20,8 @@
package org.onap.so.client.orchestration;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -33,7 +33,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -43,7 +43,7 @@ import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.AAIEdgeLabel;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class AAIInstanceGroupResourcesTest extends TestDataSetup{
@InjectMocks
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 bd61424a45..82ffdf9559 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
@@ -25,9 +25,9 @@ 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.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
@@ -44,7 +44,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.NetworkPolicy;
import org.onap.aai.domain.yang.RouteTableReference;
import org.onap.aai.domain.yang.VpnBinding;
@@ -66,7 +66,7 @@ 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.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class AAINetworkResourcesTest extends TestDataSetup{
private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
@@ -159,7 +159,7 @@ public class AAINetworkResourcesTest extends TestDataSetup{
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", "serviceModelVersionId");
+ AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, "ModelInvariantUUID");
doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
oVpnBinding = aaiNetworkResources.getVpnBinding(aaiUri);
@@ -176,7 +176,7 @@ public class AAINetworkResourcesTest extends TestDataSetup{
final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicy.json")));
AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
Optional<NetworkPolicy> oNetPolicy = Optional.empty();
- AAIResourceUri netPolicyUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "ModelInvariantUUID", "serviceModelVersionId");
+ AAIResourceUri netPolicyUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "ModelInvariantUUID");
doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri);
@@ -193,7 +193,7 @@ public class AAINetworkResourcesTest extends TestDataSetup{
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", "serviceModelVersionId");
+ AAIResourceUri rTRefUri = AAIUriFactory.createResourceUri(AAIObjectType.ROUTE_TABLE_REFERENCE, "ModelInvariantUUID");
doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
oRtref = aaiNetworkResources.getRouteTable(rTRefUri);
@@ -283,8 +283,8 @@ public class AAINetworkResourcesTest extends TestDataSetup{
@Test
public void connectNetworkToCloudRegionTest() throws Exception {
aaiNetworkResources.connectNetworkToCloudRegion(network, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
- cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())));
+ 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
@@ -340,4 +340,21 @@ public class AAINetworkResourcesTest extends TestDataSetup{
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));
+ }
+ }
}
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 46d4135b6d..a4b59f1f81 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
@@ -21,8 +21,8 @@
package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -32,11 +32,12 @@ import static org.mockito.Mockito.verify;
import java.util.Optional;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
@@ -49,7 +50,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class AAIServiceInstanceResourcesTest extends TestDataSetup{
@InjectMocks
@@ -168,12 +169,14 @@ 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));
}
@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));
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 477be816aa..0a8e7ce349 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
@@ -21,8 +21,8 @@
package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
@@ -33,9 +33,10 @@ import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
@@ -47,7 +48,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class AAIVfModuleResourcesTest extends TestDataSetup{
@InjectMocks
private AAIVfModuleResources aaiVfModuleResources = new AAIVfModuleResources();
@@ -79,7 +80,7 @@ public class AAIVfModuleResourcesTest extends TestDataSetup{
aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ACTIVE);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.VfModule.class));
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull());
assertEquals(OrchestrationStatus.ACTIVE, vfModule.getOrchestrationStatus());
}
@@ -111,7 +112,7 @@ public class AAIVfModuleResourcesTest extends TestDataSetup{
aaiVfModuleResources.changeAssignVfModule(vfModule, vnf);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.VfModule.class));
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
}
@Test
@@ -133,7 +134,7 @@ public class AAIVfModuleResourcesTest extends TestDataSetup{
aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.VfModule.class));
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull());
assertEquals("testHeatStackId", vfModule.getHeatStackId());
}
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 db719d3151..b87b5e4166 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
@@ -21,9 +21,9 @@
package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
@@ -34,26 +34,33 @@ import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.common.InjectionHelper;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
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.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class AAIVnfResourcesTest extends TestDataSetup {
private GenericVnf genericVnf;
private ServiceInstance serviceInstance;
+
+ private CloudRegion cloudRegion;
+
@Mock
protected AAIResourcesClient MOCK_aaiResourcesClient;
@@ -70,6 +77,7 @@ public class AAIVnfResourcesTest extends TestDataSetup {
public void before() {
serviceInstance = buildServiceInstance();
genericVnf = buildGenericVnf();
+ cloudRegion = buildCloudRegion();
doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
}
@@ -123,7 +131,7 @@ public class AAIVnfResourcesTest extends TestDataSetup {
aaiVnfResources.updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.Vnf.class));
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
assertEquals(OrchestrationStatus.ACTIVE, genericVnf.getOrchestrationStatus());
}
@@ -158,4 +166,20 @@ public class AAIVnfResourcesTest extends TestDataSetup {
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())));
+ }
}
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 f60f29fa34..6a44ed649e 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
@@ -21,8 +21,8 @@
package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
@@ -31,9 +31,10 @@ import static org.mockito.Mockito.verify;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
@@ -44,7 +45,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class AAIVolumeGroupResourcesTest extends TestDataSetup{
@InjectMocks
private AAIVolumeGroupResources aaiVolumeGroupResources = new AAIVolumeGroupResources();
@@ -78,7 +79,7 @@ public class AAIVolumeGroupResourcesTest extends TestDataSetup{
aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.VolumeGroup.class));
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
assertEquals(OrchestrationStatus.ACTIVE, volumeGroup.getOrchestrationStatus());
}
@@ -91,7 +92,7 @@ public class AAIVolumeGroupResourcesTest extends TestDataSetup{
aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.VolumeGroup.class));
+ verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), ArgumentMatchers.isNull());
assertEquals(OrchestrationStatus.ASSIGNED, volumeGroup.getOrchestrationStatus());
}
@@ -138,7 +139,7 @@ public class AAIVolumeGroupResourcesTest extends TestDataSetup{
aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
- verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.VolumeGroup.class));
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull());
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 7c31040f1d..c50b084df2 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
@@ -22,8 +22,8 @@ package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
@@ -34,30 +34,15 @@ import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
import org.onap.aai.domain.yang.VpnBindings;
-import org.onap.so.bpmn.common.data.TestDataSetup;
-import org.onap.so.bpmn.common.InjectionHelper;
+import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
-import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.mapper.AAIObjectMapper;
-@RunWith(MockitoJUnitRunner.class)
-public class AAIVpnBindingResourcesTest extends TestDataSetup{
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
- @Mock
- protected AAIObjectMapper MOCK_aaiObjectMapper;
-
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
+public class AAIVpnBindingResourcesTest extends BaseTaskTest{
@InjectMocks
private AAIVpnBindingResources aaiVpnBindingResources = new AAIVpnBindingResources();
@@ -67,7 +52,7 @@ public class AAIVpnBindingResourcesTest extends TestDataSetup{
@Before
public void before() {
customer = buildCustomer();
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
}
@Test
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
new file mode 100644
index 0000000000..629e98abb2
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java
@@ -0,0 +1,105 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.client.orchestration;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+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;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.data.TestDataSetup;
+import org.onap.namingservice.model.Deleteelement;
+import org.onap.namingservice.model.Element;
+import org.onap.namingservice.model.NameGenDeleteRequest;
+import org.onap.namingservice.model.NameGenDeleteResponse;
+import org.onap.namingservice.model.NameGenRequest;
+import org.onap.namingservice.model.NameGenResponse;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
+import org.onap.so.client.namingservice.NamingClient;
+import org.onap.so.client.namingservice.NamingRequestObjectBuilder;
+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));
+
+ }
+
+
+}
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 0669b84fd6..1ff9d2af2d 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
@@ -22,7 +22,7 @@ package org.onap.so.client.orchestration;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -38,7 +38,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
@@ -65,7 +65,7 @@ import org.onap.so.entity.MsoRequest;
import com.shazam.shazamcrest.matcher.Matchers;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class NetworkAdapterResourcesTest extends TestDataSetup{
@InjectMocks
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 679d809432..4d90a3fcc9 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
@@ -21,19 +21,23 @@
package org.onap.so.client.orchestration;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.any;
+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.net.URI;
+import java.net.URISyntaxException;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.Spy;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
@@ -48,7 +52,7 @@ import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper;
import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class SDNCConfigurationResourcesTest extends TestDataSetup{
@InjectMocks
@@ -68,49 +72,34 @@ public class SDNCConfigurationResourcesTest extends TestDataSetup{
@Before
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 {
-
- doReturn("success").when(MOCK_sdncClient).post(isA(GenericResourceApiGcTopologyOperationInformation.class), isA(SDNCTopology.class));
- String response = sdncConfigurationResources.activateVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf);
- verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiGcTopologyOperationInformation.class), any(SDNCTopology.class));
+ public void activateVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
+ GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.activateVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf,"uuid",new URI("http://localhost"));
assertNotNull(response);
}
@Test
- public void assignVnrConfigurationTest() throws BadResponseException, MapperException {
-
- doReturn("success").when(MOCK_sdncClient).post(isA(GenericResourceApiGcTopologyOperationInformation.class), isA(SDNCTopology.class));
- String response = sdncConfigurationResources.assignVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf);
- verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiGcTopologyOperationInformation.class), any(SDNCTopology.class));
+ public void assignVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
+ GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.assignVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf,"uuid",new URI("http://localhost"));
assertNotNull(response);
}
@Test
- public void unAssignVnrConfigurationTest() throws BadResponseException, MapperException {
- doReturn("success").when(MOCK_sdncClient).post(isA(GenericResourceApiGcTopologyOperationInformation.class), isA(SDNCTopology.class));
- String response = sdncConfigurationResources.unAssignVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration());
- verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiGcTopologyOperationInformation.class), any(SDNCTopology.class));
+ public void unAssignVnrConfigurationTest() throws BadResponseException, MapperException , URISyntaxException{
+ GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.unAssignVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration(),"uuid",new URI("http://localhost"));
assertNotNull(response);
}
@Test
- public void deactivateVnrConfigurationTest() throws BadResponseException, MapperException {
- doReturn("success").when(MOCK_sdncClient).post(isA(GenericResourceApiGcTopologyOperationInformation.class), isA(SDNCTopology.class));
- String response = sdncConfigurationResources.deactivateVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration());
- verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiGcTopologyOperationInformation.class), any(SDNCTopology.class));
+ public void deactivateVnrConfigurationTest() throws BadResponseException, MapperException , URISyntaxException{
+ GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.deactivateVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration(),"uuid",new URI("http://localhost"));
assertNotNull(response);
}
}
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 3cec3a656a..f275f3c484 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
@@ -20,10 +20,6 @@
package org.onap.so.client.orchestration;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -33,44 +29,40 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.SDNCClient;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-import org.onap.so.client.sdnc.endpoint.SDNCTopology;
import org.onap.so.client.sdnc.mapper.NetworkTopologyOperationRequestMapper;
-import org.onap.so.db.catalog.beans.OrchestrationStatus;
-import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation;
-import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class SDNCNetworkResourcesTest extends TestDataSetup {
-@RunWith(MockitoJUnitRunner.class)
-public class SDNCNetworkResourcesTest extends TestDataSetup{
-
@InjectMocks
private SDNCNetworkResources sdncNetworkResources;
-
+
@Mock
protected SDNCClient MOCK_sdncClient;
-
+
@Mock
- protected NetworkTopologyOperationRequestMapper MOCK_networkTopologyOperationRequestMapper;
-
+ 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();
@@ -80,125 +72,98 @@ public class SDNCNetworkResourcesTest extends TestDataSetup{
serviceInstance = buildServiceInstance();
requestContext = buildRequestContext();
-
+
cloudRegion = new CloudRegion();
}
@Test
public void assignNetworkTest() throws Exception {
- network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK));
-
+ 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_sdncClient, times(1)).post(any(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK));
-
- assertEquals(OrchestrationStatus.ASSIGNED, network.getOrchestrationStatus());
+ 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 {
- network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK));
-
+ 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_sdncClient, times(1)).post(any(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK));
-
- assertEquals(OrchestrationStatus.ASSIGNED, network.getOrchestrationStatus());
+ 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 {
- network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK));
-
+ 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_sdncClient, times(1)).post(any(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK));
-
- assertEquals(OrchestrationStatus.ASSIGNED, network.getOrchestrationStatus());
+ 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 {
- network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
-
- doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK));
-
+ 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_sdncClient, times(1)).post(any(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK));
-
- assertEquals(OrchestrationStatus.ASSIGNED, network.getOrchestrationStatus());
+ 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 {
- serviceInstance.getNetworks().add(network);
-
- Customer customer = new Customer();
- customer.setGlobalCustomerId("gcustId");
- customer.setServiceSubscription(new ServiceSubscription());
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
-
- GenericResourceApiNetworkOperationInformation expectedGenericResourceApiNetworkOperationInformation = new GenericResourceApiNetworkOperationInformation();
-
- String expectedResponse = "response";
-
- doReturn(expectedResponse).when(MOCK_sdncClient).post(expectedGenericResourceApiNetworkOperationInformation, SDNCTopology.NETWORK);
-
- doReturn(expectedGenericResourceApiNetworkOperationInformation).when(MOCK_networkTopologyOperationRequestMapper).reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, customer, requestContext, cloudRegion);
-
- String actualResponse = 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);
-
- verify(MOCK_sdncClient).post(expectedGenericResourceApiNetworkOperationInformation, SDNCTopology.NETWORK);
-
- assertEquals(expectedResponse, actualResponse);
+ 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 {
- String expectedSdncResponse = "SDNCChangeAssignNetworkResponse";
-
- serviceInstance.getNetworks().add(network);
-
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- customer.setServiceSubscription(new ServiceSubscription());
- // set Customer on service instance
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
-
- GenericResourceApiNetworkOperationInformation sdncReq = new GenericResourceApiNetworkOperationInformation();
-
- doReturn(sdncReq).when(MOCK_networkTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(L3Network.class), isA(ServiceInstance.class), isA(Customer.class), isA(RequestContext.class), isA(CloudRegion.class));
-
- doReturn(expectedSdncResponse).when(MOCK_sdncClient).post(isA(GenericResourceApiNetworkOperationInformation.class), isA(SDNCTopology.class));
-
- String actualSdncResponse = 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);
- verify(MOCK_sdncClient, times(1)).post(sdncReq, SDNCTopology.NETWORK);
- assertEquals(actualSdncResponse, expectedSdncResponse);
+ 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 {
- network.setOrchestrationStatus(OrchestrationStatus.CREATED);
-
- doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK));
-
- sdncNetworkResources.unassignNetwork(network, serviceInstance, customer,
- requestContext, cloudRegion);
-
- verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiNetworkOperationInformation.class), eq(SDNCTopology.NETWORK));
-
- assertEquals(OrchestrationStatus.CREATED, network.getOrchestrationStatus());
- }
+ 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
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 43426fcfde..509dc1de0d 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
@@ -20,8 +20,8 @@
package org.onap.so.client.orchestration;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+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 static org.mockito.Mockito.times;
@@ -32,118 +32,98 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.MapperException;
-import org.onap.so.client.sdnc.SDNCClient;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-import org.onap.so.client.sdnc.endpoint.SDNCTopology;
import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper;
-import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
-import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
-
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class SDNCServiceInstanceResourcesTest extends TestDataSetup{
+
@InjectMocks
private SDNCServiceInstanceResources sdncServiceInstanceResources;
-
-
@Mock
protected ServiceTopologyOperationMapper MOCK_serviceTopologyOperationMapper;
-
private RequestContext requestContext;
private ServiceInstance serviceInstance;
private Customer customer;
- @Mock
- protected SDNCClient MOCK_sdncClient;
-
@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));
- doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
+ 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);
- 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));
- doThrow(Exception.class).when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
+ 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));
- doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
+ 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);
- 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));
- doThrow(Exception.class).when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
+ 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));
- doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
sdncServiceInstanceResources.unassignServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
+ 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);
- 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));
- doThrow(Exception.class).when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
+ 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.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
+ 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_sdncClient, times(1)).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
+ 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);
- doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
- doThrow(Exception.class).when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
+ 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));
- doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, customer, requestContext);
- verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.SERVICE));
+ 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 39894265ad..7d05758129 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
@@ -20,8 +20,6 @@
package org.onap.so.client.orchestration;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -31,8 +29,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Spy;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
@@ -43,16 +41,18 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.MapperException;
-import org.onap.so.client.sdnc.SDNCClient;
-import org.onap.so.client.sdnc.endpoint.SDNCTopology;
-import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper;
+import org.onap.so.client.sdnc.beans.SDNCSvcAction;
+import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
+import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper;;
-import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation;;
-
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class SDNCVfModuleResourcesTest extends TestDataSetup{
+
@InjectMocks
- private SDNCVfModuleResources sdncVfModuleResources = new SDNCVfModuleResources();
+ private SDNCVfModuleResources sdncVfModuleResources;
+
+ @Mock
+ protected VfModuleTopologyOperationRequestMapper vfModuleTopologyMapper;
private VfModule vfModule;
private GenericVnf vnf;
@@ -61,12 +61,7 @@ public class SDNCVfModuleResourcesTest extends TestDataSetup{
private Customer customer;
private CloudRegion cloudRegion;
private RequestContext requestContext;
-
- @Mock
- protected SDNCClient MOCK_sdncClient;
-
- @Spy
- protected VfModuleTopologyOperationRequestMapper vfModuleTopologyMapper;
+ private GenericResourceApiVfModuleOperationInformation sdncReq;
@Before
public void before() {
@@ -77,50 +72,51 @@ public class SDNCVfModuleResourcesTest extends TestDataSetup{
customer = buildCustomer();
cloudRegion = buildCloudRegion();
requestContext = buildRequestContext();
+ sdncReq = new GenericResourceApiVfModuleOperationInformation();
}
@Test
- public void assignVfModuleTest() throws MapperException, BadResponseException {
- doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVfModuleOperationInformation.class), isA(SDNCTopology.class));
-
+ 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(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVfModuleOperationInformation.class), eq(SDNCTopology.VFMODULE));
+ 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, BadResponseException {
- doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVfModuleOperationInformation.class), eq(SDNCTopology.VFMODULE));
-
+ 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(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVfModuleOperationInformation.class), eq(SDNCTopology.VFMODULE));
+ 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, BadResponseException {
- doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVfModuleOperationInformation.class), isA(SDNCTopology.class));
-
+ 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(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVfModuleOperationInformation.class), eq(SDNCTopology.VFMODULE));
+ 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, BadResponseException {
- doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVfModuleOperationInformation.class), isA(SDNCTopology.class));
-
+ 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(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVfModuleOperationInformation.class), eq(SDNCTopology.VFMODULE));
+ 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("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVfModuleOperationInformation.class), isA(SDNCTopology.class));
-
+ 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(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVfModuleOperationInformation.class), eq(SDNCTopology.VFMODULE));
+ 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 06c18ae1f0..9bbf790ecb 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
@@ -20,11 +20,10 @@
package org.onap.so.client.orchestration;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
@@ -35,7 +34,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
import org.onap.so.bpmn.common.data.TestDataSetup;
@@ -49,10 +48,9 @@ import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.SDNCClient;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-import org.onap.so.client.sdnc.endpoint.SDNCTopology;
import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class SDNCVnfResourcesTest extends TestDataSetup{
@InjectMocks
private SDNCVnfResources sdncVnfResources;
@@ -73,113 +71,83 @@ public class SDNCVnfResourcesTest extends TestDataSetup{
@Before
public void before() {
serviceInstance = buildServiceInstance();
-
genericVnf = buildGenericVnf();
-
customer = buildCustomer();
-
cloudRegion = buildCloudRegion();
-
requestContext = buildRequestContext();
-
sdncReq = new GenericResourceApiVnfOperationInformation();
}
@Test
- public void assignVnfTest() throws MapperException, BadResponseException {
+ 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());
- doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
-
sdncVnfResources.assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
-
- verify(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
+ 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() throws MapperException, BadResponseException {
+ 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());
- doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
-
sdncVnfResources.activateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
-
- verify(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
+ 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() throws MapperException, BadResponseException {
- 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());
- doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
-
+ 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_sdncClient, times(1)).post(isA(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
+ 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() throws MapperException, BadResponseException {
+ 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());
- doReturn("SDNCChangeModelVnfResponse").when(MOCK_sdncClient).post(isA(GenericResourceApiVnfOperationInformation.class), isA(SDNCTopology.class));
-
- String actualResponse = sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
-
+ 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);
- verify(MOCK_sdncClient, times(1)).post(sdncReq, SDNCTopology.VNF);
- assertEquals("SDNCChangeModelVnfResponse", actualResponse);
}
@Test
- public void deactivateVnfSuccessTest() throws Exception {
+ 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());
- doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
+ 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(expected = Exception.class)
- public void deactivateVnfExceptionTest() throws Exception {
- 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());
- doThrow(Exception.class).when(MOCK_sdncClient).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
+ @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);
- verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
}
@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());
- doReturn("test").when(MOCK_sdncClient).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext);
- verify(MOCK_sdncClient, times(1)).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
+ 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(expected = Exception.class)
+ @Test
public void unassignVnfExceptionTest() 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());
- doThrow(Exception.class).when(MOCK_sdncClient).post(any(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
+ 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);
- //verify(client, times(1)).post(any(GenericResourceApiServiceOperationInformation.class), eq(SDNCTopology.VNF));
}
-
}
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 38113b8078..46d87c7ca3 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
@@ -21,8 +21,9 @@
package org.onap.so.client.orchestration;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.ArgumentMatchers.any;
import java.util.UUID;
@@ -31,15 +32,15 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.client.sdno.SDNOValidator;
-@RunWith(MockitoJUnitRunner.class)
-public class SDNOHealthCheckResourcesTest extends TestDataSetup{
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class SDNOHealthCheckResourcesTest extends TestDataSetup{
@InjectMocks
private SDNOHealthCheckResources sdnoHealthCheckResources = new SDNOHealthCheckResources();
@@ -61,7 +62,7 @@ public class SDNOHealthCheckResourcesTest extends TestDataSetup{
@Test
public void healthCheckTest() throws Exception {
- doReturn(true).when(MOCK_sdnoValidator).healthDiagnostic(isA(String.class), isA(UUID.class), isA(String.class));
+ 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 f7c12104cc..2de4f11801 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
@@ -22,7 +22,7 @@ package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -32,7 +32,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
import org.onap.so.bpmn.common.data.TestDataSetup;
@@ -47,7 +47,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.so.client.adapter.vnf.mapper.VnfAdapterVfModuleObjectMapper;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class VnfAdapterVfModuleResourcesTest extends TestDataSetup{
@InjectMocks
private VnfAdapterVfModuleResources vnfAdapterVfModuleResources = new VnfAdapterVfModuleResources();
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 d582253df1..b1812a3da9 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
@@ -30,7 +30,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
@@ -49,7 +49,7 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
import com.shazam.shazamcrest.matcher.Matchers;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.Silent.class)
public class VnfAdapterVolumeGroupResourcesTest extends TestDataSetup {
@InjectMocks
private VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
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 e30fe660c3..2636aec4a7 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
@@ -60,12 +60,13 @@ public class SdnCommonTasksTest{
@Test
public void validateSDNResponseTest() throws BadResponseException {
+ 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");
output.put("response-message", "success");
responseMap.put("output", output);
- assertEquals("success", sdnCommonTasks.validateSDNResponse(responseMap));
+ assertEquals(jsonResponse, sdnCommonTasks.validateSDNResponse(responseMap));
}
@Test
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
index e24ca339a3..9117b8ea64 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
@@ -23,36 +23,30 @@ package org.onap.so.client.sdnc;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
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.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
-import org.junit.Rule;
import org.junit.Test;
-import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.BaseIntegrationTest;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
import org.skyscreamer.jsonassert.JSONAssert;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-public class SDNCClientTest extends BaseTaskTest {
+public class SDNCClientIT extends BaseIntegrationTest {
private final static String JSON_FILE_LOCATION = "src/test/resources/__files/";
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8446));
-
@Test
public void getTest() throws BadResponseException, MapperException, IOException {
String responseJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientGetResponse.json")));
String queryLink = "/topologyQuery";
- wireMockRule.stubFor(get(urlEqualTo(queryLink))
+ stubFor(get(urlEqualTo(queryLink))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json").withBody(responseJson)));
String response = SPY_sdncClient.get(queryLink);
@@ -65,7 +59,7 @@ public class SDNCClientTest extends BaseTaskTest {
String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
- wireMockRule.stubFor(post(urlMatching(queryLink))
+ stubFor(post(urlMatching(queryLink))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json").withBody(responseJson)));
@@ -78,11 +72,11 @@ public class SDNCClientTest extends BaseTaskTest {
String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/";
- wireMockRule.stubFor(post(urlMatching(queryLink))
+ stubFor(post(urlMatching(queryLink))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json").withBody(responseJson)));
String response = SPY_sdncClient.post("", SDNCTopology.NETWORK);
- JSONAssert.assertEquals("", response, false);
+ 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 7c5e9ccf26..f01eeaeae8 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
@@ -20,6 +20,8 @@
package org.onap.so.client.sdnc.mapper;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.List;
@@ -44,7 +46,7 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup{
private GCTopologyOperationRequestMapper genObjMapper = new GCTopologyOperationRequestMapper();
@Test
- public void deactivateOrUnassignVnrReqMapperTest() {
+ public void deactivateOrUnassignVnrReqMapperTest() throws URISyntaxException {
RequestContext requestContext = new RequestContext();
requestContext.setMsoRequestId("MsoRequestId");
ServiceInstance serviceInstance = new ServiceInstance();
@@ -52,10 +54,15 @@ public class GCTopologyOperationRequestMapperTest extends TestDataSetup{
Configuration Configuration = new Configuration();
Configuration.setConfigurationId("ConfigurationId");
GenericResourceApiGcTopologyOperationInformation genericInfo = genObjMapper.deactivateOrUnassignVnrReqMapper
- (SDNCSvcAction.UNASSIGN, serviceInstance, requestContext, Configuration);
+ (SDNCSvcAction.UNASSIGN, serviceInstance, requestContext, Configuration,"uuid",new URI("http://localhost"));
Assert.assertNotNull(genericInfo);
- Assert.assertNotNull(genericInfo.getSdncRequestHeader().getSvcRequestId());
+ Assert.assertNotNull(genericInfo.getRequestInformation());
+ Assert.assertNotNull(genericInfo.getSdncRequestHeader());
+ Assert.assertNotNull(genericInfo.getClass());
+ Assert.assertNotNull(genericInfo.getServiceInformation());
+ Assert.assertEquals("uuid",genericInfo.getSdncRequestHeader().getSvcRequestId());
+ Assert.assertEquals("http://localhost",genericInfo.getSdncRequestHeader().getSvcNotificationUrl());
}
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 54ca116d55..63c3680e8c 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
@@ -67,7 +67,7 @@ public class VnfTopologyOperationRequestMapperTest {
genericVnf.setModelCustomizationUuid("vnfModelCustomizationUUID");
ModelInfoInstanceGroup modelL3Network = new ModelInfoInstanceGroup();
- modelL3Network.setType("networkInstanceGroup");
+ modelL3Network.setType("L3-NETWORK");
InstanceGroup instanceGroup1 = new InstanceGroup();
instanceGroup1.setId("l3-network-ig-111");
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 e5eb6bce54..3387e9ddef 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
@@ -22,18 +22,20 @@ 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.stubFor;
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;
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-public class SniroClientTestIT{
+public class SniroClientTestIT extends BaseIntegrationTest {
@Autowired
private SniroClient client;
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json
index ba7ab9e3b8..b65203b24d 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json
@@ -1,6 +1,56 @@
{
- "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800},
- "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"},
- "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyInstanceName2","serviceResourceId":"testProxyId2"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}},
- "licenseInfo" : []
+ "requestInfo" : {
+ "transactionId" : "testRequestId",
+ "requestId" : "testRequestId",
+ "callbackUrl" : "http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId",
+ "sourceId" : "mso",
+ "requestType" : "create",
+ "timeout" : 1800
+ },
+ "serviceInfo" : {
+ "modelInfo" : {
+ "modelName" : "testModelName1",
+ "modelVersionId" : "testModelUUID1",
+ "modelVersion" : "testModelVersion1",
+ "modelInvariantId" : "testModelInvariantUUID1"
+ },
+ "serviceRole" : "testServiceRole1",
+ "serviceInstanceId" : "testServiceInstanceId1",
+ "serviceName" : "testServiceType1"
+ },
+ "placementInfo" : {
+ "subscriberInfo" : {
+ "globalSubscriberId" : "testCustomerId",
+ "subscriberName" : "testCustomerName"
+ },
+ "placementDemands" : [ {
+ "serviceResourceId" : "testProxyId1",
+ "resourceModuleName" : "testProxyInstanceName1",
+ "resourceModelInfo" : {
+ "modelName" : "testProxyModelName1",
+ "modelVersionId" : "testProxyModelUuid1",
+ "modelVersion" : "testProxyModelVersion1",
+ "modelInvariantId" : "testProxyModelInvariantUuid1"
+ }
+ }, {
+ "serviceResourceId" : "testProxyId2",
+ "resourceModuleName" : "testProxyInstanceName2",
+ "resourceModelInfo" : {
+ "modelName" : "testProxyModelName2",
+ "modelVersionId" : "testProxyModelUuid2",
+ "modelVersion" : "testProxyModelVersion2",
+ "modelInvariantId" : "testProxyModelInvariantUuid2"
+ },
+ "requiredCandidates" : [ {
+ "candidateType" : {
+ "name" : "vnfId"
+ },
+ "candidates" : [ "testVnfId" ]
+ } ]
+ } ],
+ "requestParameters" : {"subscriptionServiceType":"iptollfree","aLaCarte":false}
+ },
+ "licenseInfo" : {
+ "licenseDemands" : [ ]
+ }
} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json
new file mode 100644
index 0000000000..ac460c328a
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json
@@ -0,0 +1,59 @@
+{
+ "requestInfo" : {
+ "transactionId" : "testRequestId",
+ "requestId" : "testRequestId",
+ "callbackUrl" : "http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId",
+ "sourceId" : "mso",
+ "requestType" : "create",
+ "timeout" : 1800
+ },
+ "serviceInfo" : {
+ "modelInfo" : {
+ "modelName" : "testModelName1",
+ "modelVersionId" : "testModelUUID1",
+ "modelVersion" : "testModelVersion1",
+ "modelInvariantId" : "testModelInvariantUUID1"
+ },
+ "serviceRole" : "testServiceRole1",
+ "serviceInstanceId" : "testServiceInstanceId1",
+ "serviceName" : "testServiceType1"
+ },
+ "placementInfo" : {
+ "subscriberInfo" : {
+ "globalSubscriberId" : "testCustomerId",
+ "subscriberName" : "testCustomerName"
+ },
+ "placementDemands" : [ {
+ "serviceResourceId" : "testAllottedResourceId1",
+ "resourceModuleName" : "testAllottedModelInstanceName1",
+ "resourceModelInfo" : {
+ "modelName" : "testAllottedModelName1",
+ "modelVersionId" : "testAllottedModelUuid1",
+ "modelVersion" : "testAllottedModelVersion1",
+ "modelInvariantId" : "testAllottedModelInvariantUuid1"
+ }
+ }, {
+ "serviceResourceId" : "testAllottedResourceId2",
+ "resourceModuleName" : "testAllottedModelInstanceName2",
+ "resourceModelInfo" : {
+ "modelName" : "testAllottedModelName2",
+ "modelVersionId" : "testAllottedModelUuid2",
+ "modelVersion" : "testAllottedModelVersion2",
+ "modelInvariantId" : "testAllottedModelInvariantUuid2"
+ }
+ }, {
+ "serviceResourceId" : "testAllottedResourceId3",
+ "resourceModuleName" : "testAllottedModelInstanceName3",
+ "resourceModelInfo" : {
+ "modelName" : "testAllottedModelName3",
+ "modelVersionId" : "testAllottedModelUuid3",
+ "modelVersion" : "testAllottedModelVersion3",
+ "modelInvariantId" : "testAllottedModelInvariantUuid3"
+ }
+ } ],
+ "requestParameters" : {"subscriptionServiceType":"iptollfree","aLaCarte":false}
+ },
+ "licenseInfo" : {
+ "licenseDemands" : [ ]
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json
index c5d0ffe38d..6db2153691 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json
@@ -1,6 +1,104 @@
{
- "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800},
- "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"},
- "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyInstanceName2","serviceResourceId":"testProxyId2"},{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyInstanceName2","serviceResourceId":"testProxyId2"},{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyInstanceName2","serviceResourceId":"testProxyId2"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}},
- "licenseInfo" : []
+ "requestInfo" : {
+ "transactionId" : "testRequestId",
+ "requestId" : "testRequestId",
+ "callbackUrl" : "http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId",
+ "sourceId" : "mso",
+ "requestType" : "create",
+ "timeout" : 1800
+ },
+ "serviceInfo" : {
+ "modelInfo" : {
+ "modelName" : "testModelName1",
+ "modelVersionId" : "testModelUUID1",
+ "modelVersion" : "testModelVersion1",
+ "modelInvariantId" : "testModelInvariantUUID1"
+ },
+ "serviceRole" : "testServiceRole1",
+ "serviceInstanceId" : "testServiceInstanceId1",
+ "serviceName" : "testServiceType1"
+ },
+ "placementInfo" : {
+ "subscriberInfo" : {
+ "globalSubscriberId" : "testCustomerId",
+ "subscriberName" : "testCustomerName"
+ },
+ "placementDemands" : [ {
+ "serviceResourceId" : "testProxyId1",
+ "resourceModuleName" : "testProxyInstanceName1",
+ "resourceModelInfo" : {
+ "modelName" : "testProxyModelName1",
+ "modelVersionId" : "testProxyModelUuid1",
+ "modelVersion" : "testProxyModelVersion1",
+ "modelInvariantId" : "testProxyModelInvariantUuid1"
+ }
+ }, {
+ "serviceResourceId" : "testProxyId2",
+ "resourceModuleName" : "testProxyInstanceName2",
+ "resourceModelInfo" : {
+ "modelName" : "testProxyModelName2",
+ "modelVersionId" : "testProxyModelUuid2",
+ "modelVersion" : "testProxyModelVersion2",
+ "modelInvariantId" : "testProxyModelInvariantUuid2"
+ },
+ "requiredCandidates" : [ {
+ "candidateType" : {
+ "name" : "vnfId"
+ },
+ "candidates" : [ "testVnfId" ]
+ } ]
+ }, {
+ "serviceResourceId" : "testProxyId1",
+ "resourceModuleName" : "testProxyInstanceName1",
+ "resourceModelInfo" : {
+ "modelName" : "testProxyModelName1",
+ "modelVersionId" : "testProxyModelUuid1",
+ "modelVersion" : "testProxyModelVersion1",
+ "modelInvariantId" : "testProxyModelInvariantUuid1"
+ }
+ }, {
+ "serviceResourceId" : "testProxyId2",
+ "resourceModuleName" : "testProxyInstanceName2",
+ "resourceModelInfo" : {
+ "modelName" : "testProxyModelName2",
+ "modelVersionId" : "testProxyModelUuid2",
+ "modelVersion" : "testProxyModelVersion2",
+ "modelInvariantId" : "testProxyModelInvariantUuid2"
+ },
+ "requiredCandidates" : [ {
+ "candidateType" : {
+ "name" : "vnfId"
+ },
+ "candidates" : [ "testVnfId" ]
+ } ]
+ }, {
+ "serviceResourceId" : "testProxyId1",
+ "resourceModuleName" : "testProxyInstanceName1",
+ "resourceModelInfo" : {
+ "modelName" : "testProxyModelName1",
+ "modelVersionId" : "testProxyModelUuid1",
+ "modelVersion" : "testProxyModelVersion1",
+ "modelInvariantId" : "testProxyModelInvariantUuid1"
+ }
+ }, {
+ "serviceResourceId" : "testProxyId2",
+ "resourceModuleName" : "testProxyInstanceName2",
+ "resourceModelInfo" : {
+ "modelName" : "testProxyModelName2",
+ "modelVersionId" : "testProxyModelUuid2",
+ "modelVersion" : "testProxyModelVersion2",
+ "modelInvariantId" : "testProxyModelInvariantUuid2"
+ },
+ "requiredCandidates" : [ {
+ "candidateType" : {
+ "name" : "vnfId"
+ },
+ "candidates" : [ "testVnfId" ]
+ } ]
+ } ],
+ "requestParameters" : {"subscriptionServiceType":"iptollfree","aLaCarte":false}
+ },
+ "licenseInfo" : {
+ "licenseDemands" : [ ]
+ }
} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterDeleteVfModuleRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterDeleteVfModuleRequest.json
index 21e5bde3ec..1d2e7d090f 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterDeleteVfModuleRequest.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterDeleteVfModuleRequest.json
@@ -2,7 +2,8 @@
"cloudSiteId" : "cloudRegionId",
"tenantId" : "tenantId",
"vnfId" : "vnfId",
- "vfModuleId" : "vfModuleId",
+ "vfModuleId" : "vfModuleId",
+ "vfModuleStackId" : "vfModuleName",
"skipAAI" : true,
"msoRequest" : {
"requestId" : "requestId",
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/CreateNetworkCollection.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/CreateNetworkCollection.json
index 7b369ab97e..579075f502 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/CreateNetworkCollection.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/CreateNetworkCollection.json
@@ -8,6 +8,7 @@
"modelVersion": "10"
},
"cloudConfiguration": {
+ "cloudOwner" : "my-custom-cloud-owner",
"lcpCloudRegionId": "mdt1",
"tenantId": "88a6ca3ee0394ade9403f075db23167e"
},
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json
index 771283c603..26838024da 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json
@@ -7,6 +7,9 @@
"modelName": "MOW AVPN vMX BV vPE 1 Service",
"modelVersion": "10.0"
},
+ "cloudConfiguration": {
+ "cloudOwner" : "my-custom-cloud-owner"
+ },
"owningEntity": {
"owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
"owningEntityName": "PACKET CORE"
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json
index 51caddd48a..ddb118ea49 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json
@@ -7,6 +7,9 @@
"modelName": "MOW AVPN vMX BV vPE 1 Service",
"modelVersion": "10.0"
},
+ "cloudConfiguration": {
+ "cloudOwner" : "my-custom-cloud-owner"
+ },
"owningEntity": {
"owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
"owningEntityName": "PACKET CORE"
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json
new file mode 100644
index 0000000000..51caddd48a
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json
@@ -0,0 +1,125 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelName": "MOW AVPN vMX BV vPE 1 Service",
+ "modelVersion": "10.0"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "{some project name}"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "{some subscriber id}"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": true,
+ "requestorId": "xxxxxx"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "VMX",
+ "aLaCarte": false,
+ "userParams": [
+ {
+ "service": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MOW AVPN vMX BV vPE 1 Service",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a"
+ },
+ "instanceParams": [],
+ "resources": {
+ "vnfs": [
+ {
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "2016-73_MOW-AVPN-vPE-BV-L",
+ "modelVersionId": "7f40c192-f63c-463e-ba94-286933b895f8",
+ "modelCustomizationName": "2016-73_MOW-AVPN-vPE-BV-L 0",
+ "modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "platform": {
+ "platformName": "test"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "someValue"
+ },
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "instanceParams": [],
+ "vfModules": [
+ {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0",
+ "modelVersionId": "4c75f813-fa91-45a4-89d0-790ff5f1ae79",
+ "modelCustomizationId": "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"
+ },
+ "instanceParams": [
+ {
+ "vmx_int_net_len": "24"
+ }
+ ]
+ },
+ {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1",
+ "modelVersionId": "56e2b103-637c-4d1a-adc8-3a7f4a6c3240",
+ "modelCustomizationId": "72d9d1cd-f46d-447a-abdb-451d6fb05fa8"
+ },
+ "instanceParams": [
+ {
+ "availability_zone_0": "mtpocdv-kvm-az01",
+ "vre_a_volume_size_0": "100"
+ }
+ ]
+ },
+ {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1",
+ "modelVersionId": "56e2b103-637c-4d1a-adc8-3a7f4a6c3240",
+ "modelCustomizationId": "72d9d1cd-f46d-447a-abdb-451d6fb05fa8"
+ },
+ "instanceParams": [
+ {
+ "availability_zone_0": "mtpocdv-kvm-az01",
+ "vre_a_volume_size_0": "50"
+ }
+ ]
+ },
+ {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_vPFE_BV..module-2",
+ "modelVersionId": "f555558f-d538-4876-8ffa-b102650fad64",
+ "modelCustomizationId": "da4d4327-fb7d-4311-ac7a-be7ba60cf969"
+ },
+ "instanceParams": [
+ {
+ "availability_zone_0": "mtpocdv-kvm-az01",
+ "vmx_vpfe_int_ip_0": "192.168.0.16"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/VnfMacroReplace.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/VnfMacroReplace.json
new file mode 100644
index 0000000000..5c34903e30
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/VnfMacroReplace.json
@@ -0,0 +1,25 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelInvariantId": "2b80014c-851a-4051-a2f0-2994fcf26164",
+ "modelVersionId": "038111e7-dfb6-4875-ba06-d1fc1306b471",
+ "modelName": "Resource",
+ "modelVersion": "4.0",
+ "modelCustomizationName": "Resource 0",
+ "modelCustomizationId": "5769aaa9-84f0-4b9d-bf8a-d891e5c461e1"
+ },
+ "cloudConfiguration": {
+ "cloudOwner": "cloud-owner",
+ "lcpCloudRegionId": "abc3",
+ "tenantId": "ab33582f8d3948078dc8c18d6834bf75"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "test"
+ },
+ "requestParameters": {
+ "testApi": "GR_API"
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/AssignResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/AssignResponse.json
new file mode 100644
index 0000000000..b065c21339
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/AssignResponse.json
@@ -0,0 +1,14 @@
+{
+ "elements": [
+ {
+ "external-key": "$vnf-id",
+ "resource-name": "instance-group-name",
+ "resource-value": "$vnf-name"
+ },
+ {
+ "external-key": "$vnf-id",
+ "resource-name": "vm-name",
+ "resource-value": "$vm-name"
+ }
+ ]
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/ErrorResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/ErrorResponse.json
new file mode 100644
index 0000000000..8bac7cd1f9
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/ErrorResponse.json
@@ -0,0 +1,6 @@
+{
+ "error": {
+ "errorId": "NELGEN-0003",
+ "message": "External Key is required and must be unique"
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/UnassignResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/UnassignResponse.json
new file mode 100644
index 0000000000..b065c21339
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/UnassignResponse.json
@@ -0,0 +1,14 @@
+{
+ "elements": [
+ {
+ "external-key": "$vnf-id",
+ "resource-name": "instance-group-name",
+ "resource-value": "$vnf-name"
+ },
+ {
+ "external-key": "$vnf-id",
+ "resource-name": "vm-name",
+ "resource-value": "$vm-name"
+ }
+ ]
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json
new file mode 100644
index 0000000000..deb4de0219
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json
@@ -0,0 +1,15 @@
+{
+ "output": {
+ "svc-request-id": "5d24d40e-4c77-4c06-94a3-6d168c47a57c",
+ "network-response-information": {
+ "instance-id": "4063e0aa-af13-4872-8473-b40c94f9316b",
+ "object-path": "restconf/config/GENERIC-RESOURCE-API:services/service/2c9c7996-75a7-4f92-becc-9e13e8bd288a/service-data/networks/network/4063e0aa-af13-4872-8473-b40c94f9316b/network-data/network-topology/"
+ },
+ "response-code": "200",
+ "service-response-information": {
+ "instance-id": "2c9c7996-75a7-4f92-becc-9e13e8bd288a"
+ },
+ "response-message": "",
+ "ack-final-indicator": "N"
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_ASYNC_Request.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_ASYNC_Request.json
new file mode 100644
index 0000000000..c1ea682068
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_ASYNC_Request.json
@@ -0,0 +1,15 @@
+{
+ "input": {
+ "svc-request-id": "5d24d40e-4c77-4c06-94a3-6d168c47a57c",
+ "network-response-information": {
+ "instance-id": "4063e0aa-af13-4872-8473-b40c94f9316b",
+ "object-path": "restconf/config/GENERIC-RESOURCE-API:services/service/2c9c7996-75a7-4f92-becc-9e13e8bd288a/service-data/networks/network/4063e0aa-af13-4872-8473-b40c94f9316b/network-data/network-topology/"
+ },
+ "response-code": "200",
+ "service-response-information": {
+ "instance-id": "2c9c7996-75a7-4f92-becc-9e13e8bd288a"
+ },
+ "response-message": "",
+ "ack-final-indicator": "Y"
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Client_Request.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Client_Request.json
new file mode 100644
index 0000000000..f60767b85e
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Client_Request.json
@@ -0,0 +1,28 @@
+: {
+ "input": {
+ "request-information": {
+ "request-action": "CreateServiceInstance",
+ "source": "MSO",
+ "request-id": "5a09ab96-032b-41cd-ad81-4fb9ec5fade7"
+ },
+ "sdnc-request-header": {
+ "svc-request-id": "5a09ab96-032b-41cd-ad81-4fb9ec5fade7",
+ "svc-action": "assign"
+ },
+ "service-information": {
+ "onap-model-information": {
+ "model-name": "Vf zrdm5bpxmc02092017-Service",
+ "model-version": "1.0",
+ "model-uuid": "bad955c3-29b2-4a27-932e-28e942cc6480",
+ "model-invariant-uuid": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b"
+ },
+ "subscription-service-type": "Robot_Test_Service_Type",
+ "service-id": "48121c5e-dde0-42a6-a78a-89556ff355d0",
+ "global-customer-id": "Robot_Test_Subscriber_ID",
+ "service-instance-id": "48121c5e-dde0-42a6-a78a-89556ff355d0"
+ },
+ "service-request-input": {
+ "service-instance-name": "Robot_SI_For_VolumeGroup"
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
index d9ad1363e4..fed2aa69c7 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
+++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
@@ -1,5 +1,5 @@
aai:
- auth: 26AFB797A6A57960D5D718491925C50F77CDC22AC394B3DBA09950D8FD1C0764
+ auth: 5A1272FE739BECA4D4374A86B25C021DFE6745E3BB7BE6836BF64A6059B8220E586C21FD7567AF41DB42571EB7
endpoint: http://localhost:${wiremock.server.port}
pnfEntryNotificationTimeout: P14D
appc:
@@ -41,6 +41,9 @@ pnf:
consumerId: consumerId
topicListenerDelayInSeconds: 5
mso:
+ naming:
+ endpoint: http://localhost:${wiremock.server.port}/web/service/v1/genNetworkElementName
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
adapters:
requestDb:
auth: Basic YnBlbDptc28tZGItMTUwNyE=
@@ -48,7 +51,7 @@ mso:
completemsoprocess:
endpoint: http://localhost:${wiremock.server.port}/CompleteMsoProcess
db:
- auth: 757A94191D685FD2092AC1490730A4FC
+ auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C
endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter
spring:
endpoint: http://localhost:${wiremock.server.port}
@@ -60,7 +63,7 @@ mso:
db:
endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter
po:
- auth: 757A94191D685FD2092AC1490730A4FC
+ auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C
password: 3141634BF7E070AA289CF2892C986C0B
sdnc:
endpoint: http://localhost:${wiremock.server.port}/SDNCAdapter
@@ -90,6 +93,7 @@ mso:
bpmn:
optimisticlockingexception:
retrycount: '3'
+ cloudRegionIdsToSkipAddingVnfEdgesTo: test25Region1,test25Region2,test25Region99
callbackRetryAttempts: '5'
catalog:
db:
@@ -160,7 +164,7 @@ policy:
environment: TEST
sdnc:
auth: Basic YWRtaW46YWRtaW4=
- host: http://localhost:8446
+ host: http://localhost:${wiremock.server.port}
path: /restconf/operations/GENERIC-RESOURCE-API
sniro:
conductor:
@@ -180,16 +184,19 @@ sniro:
oof:
timeout: PT30M
host: http://localhost:${wiremock.server.port}
- uri.v1: /api/oof/v1/placement
- uri.v2: /api/oof/v2/placement
+ uri: /api/oof/v1/placement
headers.auth: Basic dGVzdDp0ZXN0cHdk
+org:
+ onap:
+ so:
+ cloud-owner: att-aic
spring:
datasource:
- url: jdbc:mariadb://localhost:3307/camundabpmn
+ jdbc-url: jdbc:mariadb://localhost:3307/camundabpmn
username: root
password: password
driver-class-name: org.mariadb.jdbc.Driver
- initialize: true
+ initialization-mode: always
jpa:
generate-ddl: false
show-sql: false