aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/mso-infrastructure-bpmn/src/test/java
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-04-08 14:14:34 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-04-08 14:24:59 -0400
commitf47919f1fe367b612fa9c96d34c59f01a541e882 (patch)
tree5b6aa2fc36747d868897e68ccbec0c6db0aee81c /bpmn/mso-infrastructure-bpmn/src/test/java
parent54452b80a1cf4d22ef750bc1377f8c1b05431d57 (diff)
Replaced all tabs with spaces in java and pom.xml
Added in maven plugins to enforce coding style rules Added in eclipse java formatting xml Change-Id: I3727bbf4ce8dc66abfd8ad21b6cfd0890c5d3ff0 Issue-ID: SO-1765 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn/src/test/java')
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/RequestHeaderTest.java62
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterCallbackRequestTest.java52
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterRequestTest.java48
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/BaseIntegrationTest.java27
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/InfraEmbeddedMariaDbConfig.java24
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/IntegrationTestSuite.java4
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/BPMNUtil.java604
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CompleteMsoProcessIT.java282
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupNameIT.java158
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupTenantIT.java104
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java432
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java178
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DecomposeServiceIT.java76
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java453
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java343
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenerateVfModuleNameIT.java71
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java110
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java20
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java45
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java522
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockLoggerDelegate.java16
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java640
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java625
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java334
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/RainyDayHandlerIT.java68
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ReceiveWorkflowMessageTest.java183
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterCallbackRule.java81
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java145
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SPIPropertiesTest.java65
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java1008
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java257
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java197
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java600
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowAsyncResourceTest.java98
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowContextHolderTest.java63
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java4245
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTestTransformer.java13
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/adapter/sdnc/ObjectFactoryTest.java1
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerServiceTest.java1
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java61
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/FlakyTests.java2
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java47
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java1
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/AbstractTestBase.java56
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/CreateVcpeResCustServiceIT.java596
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DeleteVcpeResCustServiceIT.java394
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGIT.java465
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java589
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCIT.java473
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java591
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceBRGIT.java238
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceTXCIT.java228
52 files changed, 7799 insertions, 8197 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/RequestHeaderTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/RequestHeaderTest.java
index e56b45f19d..b185f80aaf 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/RequestHeaderTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/RequestHeaderTest.java
@@ -1,46 +1,40 @@
/*
-* ============LICENSE_START=======================================================
- * ONAP : SO
- * ================================================================================
- * Copyright (C) 2018 TechMahindra
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright (C) 2018 TechMahindra
+ * ================================================================================ Licensed under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy
+ * of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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.
+ * 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=========================================================
-*/
+ */
import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
import org.onap.so.bpmn.common.adapter.sdnc.RequestHeader;
-public class RequestHeaderTest{
- RequestHeader rh = new RequestHeader();
+public class RequestHeaderTest {
+ RequestHeader rh = new RequestHeader();
- @Test
- public void testRequestHeader() {
- rh.setRequestId("requestId");
- rh.setSvcInstanceId("svcInstanceId");
- rh.setSvcAction("svcAction");
- rh.setSvcOperation("svcOperation");
- rh.setCallbackUrl("callbackUrl");
- rh.setMsoAction("msoAction");
- assertEquals(rh.getRequestId(), "requestId");
- assertEquals(rh.getSvcInstanceId(), "svcInstanceId");
- assertEquals(rh.getSvcAction(), "svcAction");
- assertEquals(rh.getSvcOperation(), "svcOperation");
- assertEquals(rh.getCallbackUrl(), "callbackUrl");
- assertEquals(rh.getMsoAction(), "msoAction");
- assert(rh.toString()!=null);
- }
+ @Test
+ public void testRequestHeader() {
+ rh.setRequestId("requestId");
+ rh.setSvcInstanceId("svcInstanceId");
+ rh.setSvcAction("svcAction");
+ rh.setSvcOperation("svcOperation");
+ rh.setCallbackUrl("callbackUrl");
+ rh.setMsoAction("msoAction");
+ assertEquals(rh.getRequestId(), "requestId");
+ assertEquals(rh.getSvcInstanceId(), "svcInstanceId");
+ assertEquals(rh.getSvcAction(), "svcAction");
+ assertEquals(rh.getSvcOperation(), "svcOperation");
+ assertEquals(rh.getCallbackUrl(), "callbackUrl");
+ assertEquals(rh.getMsoAction(), "msoAction");
+ assert (rh.toString() != null);
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterCallbackRequestTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterCallbackRequestTest.java
index 884c2ac9c6..7ce82810be 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterCallbackRequestTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterCallbackRequestTest.java
@@ -1,44 +1,38 @@
/*
-* ============LICENSE_START=======================================================
- * ONAP : SO
- * ================================================================================
- * Copyright (C) 2018 TechMahindra
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright (C) 2018 TechMahindra
+ * ================================================================================ Licensed under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy
+ * of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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.
+ * 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=========================================================
-*/
+ */
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import org.junit.Test;
import org.onap.so.bpmn.common.adapter.sdnc.CallbackHeader;
import org.onap.so.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest;
-public class SDNCAdapterCallbackRequestTest{
-
- SDNCAdapterCallbackRequest sdnccall = new SDNCAdapterCallbackRequest();
- CallbackHeader cbh = new CallbackHeader();
- String o = "test";
+public class SDNCAdapterCallbackRequestTest {
+
+ SDNCAdapterCallbackRequest sdnccall = new SDNCAdapterCallbackRequest();
+ CallbackHeader cbh = new CallbackHeader();
+ String o = "test";
- @Test
- public void testSDNCAdapterCallbackRequest() {
- sdnccall.setCallbackHeader(cbh);
- sdnccall.setRequestData(o);
- assertEquals(sdnccall.getCallbackHeader(), cbh);
- assertEquals(sdnccall.getRequestData(), o);
- assertNotNull(sdnccall.toString());
- }
+ @Test
+ public void testSDNCAdapterCallbackRequest() {
+ sdnccall.setCallbackHeader(cbh);
+ sdnccall.setRequestData(o);
+ assertEquals(sdnccall.getCallbackHeader(), cbh);
+ assertEquals(sdnccall.getRequestData(), o);
+ assertNotNull(sdnccall.toString());
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterRequestTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterRequestTest.java
index 79bffe40d0..8a976711c6 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterRequestTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/SDNCAdapterRequestTest.java
@@ -1,41 +1,35 @@
/*
-* ============LICENSE_START=======================================================
- * ONAP : SO
- * ================================================================================
- * Copyright (C) 2018 TechMahindra
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright (C) 2018 TechMahindra
+ * ================================================================================ Licensed under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy
+ * of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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.
+ * 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=========================================================
-*/
+ */
import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
import org.onap.so.bpmn.common.adapter.sdnc.RequestHeader;
import org.onap.so.bpmn.common.adapter.sdnc.SDNCAdapterRequest;
public class SDNCAdapterRequestTest {
-
- SDNCAdapterRequest adapter = new SDNCAdapterRequest();
- RequestHeader rh = new RequestHeader();
- Object o = new Object();
- @Test
- public void testSDNCAdapterRequest() {
- adapter.setRequestHeader(rh);
- adapter.setRequestData(o);
- assertEquals(adapter.getRequestHeader(), rh);
- assertEquals(adapter.getRequestData(), o);
- }
+ SDNCAdapterRequest adapter = new SDNCAdapterRequest();
+ RequestHeader rh = new RequestHeader();
+ Object o = new Object();
+
+ @Test
+ public void testSDNCAdapterRequest() {
+ adapter.setRequestHeader(rh);
+ adapter.setRequestData(o);
+ assertEquals(adapter.getRequestHeader(), rh);
+ assertEquals(adapter.getRequestData(), o);
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/BaseIntegrationTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/BaseIntegrationTest.java
index fc21ff905d..2176dd885b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/BaseIntegrationTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/BaseIntegrationTest.java
@@ -31,7 +31,6 @@ import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
-
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
@@ -40,19 +39,19 @@ import com.github.tomakehurst.wiremock.client.WireMock;
@ActiveProfiles("test")
@ContextConfiguration
@AutoConfigureWireMock(port = 0)
-public abstract class BaseIntegrationTest extends WorkflowTest {
- @Autowired
- BPMNUtil bpmnUtil;
+public abstract class BaseIntegrationTest extends WorkflowTest {
+ @Autowired
+ BPMNUtil bpmnUtil;
+
+ @Value("${wiremock.server.port}")
+ protected String wiremockPort;
+
+ @Autowired
+ protected WireMockServer wireMockServer;
- @Value("${wiremock.server.port}")
- protected String wiremockPort;
-
- @Autowired
- protected WireMockServer wireMockServer;
-
- @After
- public void baseAfterTest() {
- wireMockServer.resetAll();
- }
+ @After
+ public void baseAfterTest() {
+ wireMockServer.resetAll();
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/InfraEmbeddedMariaDbConfig.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/InfraEmbeddedMariaDbConfig.java
index c28a86c49a..0a532663b8 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/InfraEmbeddedMariaDbConfig.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/InfraEmbeddedMariaDbConfig.java
@@ -19,6 +19,7 @@
*/
package org.onap.so.bpmn;
+
import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
@@ -35,38 +36,27 @@ import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
-
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration
@EnableTransactionManagement
-@EnableJpaRepositories(
- entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager",
- basePackages = { "org.onap.so.db.request.data.repository"}
-)
+@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory",
+ transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"})
@Profile({"test"})
public class InfraEmbeddedMariaDbConfig {
@Primary
@Bean(name = "requestEntityManagerFactory")
- public LocalContainerEntityManagerFactoryBean
- entityManagerFactory(
- EntityManagerFactoryBuilder builder,
- DataSource dataSource
- ) {
- return builder
- .dataSource(dataSource)
- .packages("org.onap.so.db.request.beans")
- .persistenceUnit("requestDB")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
+ DataSource dataSource) {
+ return builder.dataSource(dataSource).packages("org.onap.so.db.request.beans").persistenceUnit("requestDB")
.build();
}
@Bean(name = "requestTransactionManager")
public PlatformTransactionManager transactionManager(
- @Qualifier("requestEntityManagerFactory") EntityManagerFactory
- entityManagerFactory
- ) {
+ @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
}
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/IntegrationTestSuite.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/IntegrationTestSuite.java
index f65cadae3c..bc002c7022 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/IntegrationTestSuite.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/IntegrationTestSuite.java
@@ -27,6 +27,6 @@ import org.junit.runner.RunWith;
@RunWith(WildcardPatternSuite.class)
@SuiteClasses({"**/*IT.class"})
public class IntegrationTestSuite {
- // the class remains empty,
- // used only as a holder for the above annotations
+ // the class remains empty,
+ // used only as a holder for the above annotations
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/BPMNUtil.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/BPMNUtil.java
index 5f0722aa3d..f417a550d1 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/BPMNUtil.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/BPMNUtil.java
@@ -25,14 +25,11 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import javax.ws.rs.core.Response;
-
import org.camunda.bpm.engine.HistoryService;
import org.camunda.bpm.engine.ProcessEngineServices;
import org.camunda.bpm.engine.RuntimeService;
@@ -52,306 +49,303 @@ import org.springframework.stereotype.Component;
@Component
public class BPMNUtil {
- private static WorkflowAsyncResource workflowResource;
-
- @Autowired
- public void setWorkflowResource(WorkflowAsyncResource workflowResource) {
- BPMNUtil.workflowResource = workflowResource;
- }
-
- public static String getVariable(ProcessEngineServices processEngineServices, String processDefinitionID, String name) {
- String pID = getProcessInstanceId(processEngineServices,
- processDefinitionID);
- return getVariable( processEngineServices, processDefinitionID, name, pID);
- }
-
- public static String getVariable(ProcessEngineServices processEngineServices, String processDefinitionID, String name, String processInstanceId) {
- assertProcessInstanceFinished(processEngineServices, processInstanceId);
- HistoricVariableInstance responseData = processEngineServices.getHistoryService()
- .createHistoricVariableInstanceQuery().processInstanceId(processInstanceId)
- .variableName(name)
- .singleResult();
-
- if (responseData != null) {
- return (responseData.getValue() != null ? responseData.getValue().toString(): null);
- }
- return null;
- }
-
- /*
- @SuppressWarnings("unchecked")
- public static <T extends Object> T getRawVariable(HistoryService historyService, String processDefinitionID, String name) {
- //String pID = getProcessInstanceId(processEngineServices,
- // processDefinitionID);
- assertProcessInstanceFinished(historyService, pID);
- Object responseData = historyService
- .createHistoricVariableInstanceQuery().processInstanceId(pID)
- .variableName(name)
- .singleResult()
- .getValue();
- return (T) responseData;
- }
- */
-
- @SuppressWarnings("unchecked")
- public static <T> T getRawVariable(ProcessEngineServices processEngineServices, String processDefinitionID, String name) {
- String pID = getProcessInstanceId(processEngineServices,
- processDefinitionID);
- return getRawVariable( processEngineServices, processDefinitionID, name, pID);
- }
-
- @SuppressWarnings("unchecked")
- public static <T> T getRawVariable(ProcessEngineServices processEngineServices, String processDefinitionID, String name, String processInstanceId) {
- assertProcessInstanceFinished(processEngineServices, processInstanceId);
- Object responseData = processEngineServices.getHistoryService()
- .createHistoricVariableInstanceQuery().processInstanceId(processInstanceId)
- .variableName(name)
- .singleResult()
- .getValue();
- return (T) responseData;
- }
-
-
- public static void assertAnyProcessInstanceFinished(ProcessEngineServices processEngineServices, String processDefinitionID) {
- String pID = getProcessInstanceId(processEngineServices,
- processDefinitionID);
- assertNotNull(pID);
- assertTrue(processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pID).finished().count() > 0);
- }
-
- public static void assertNoProcessInstance(ProcessEngineServices processEngineServices, String processDefinitionID) {
- assertNull(getProcessInstanceId(processEngineServices, processDefinitionID));
- }
-
- public static void assertProcessInstanceFinished(HistoryService historyService, String pid) {
- assertEquals(1, historyService.createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count());
- }
-
- public static void assertProcessInstanceFinished(ProcessEngineServices processEngineServices, String pid) {
- assertEquals(1, processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count());
- }
-
- public static void assertProcessInstanceNotFinished(ProcessEngineServices processEngineServices, String processDefinitionID) {
- String pID = getProcessInstanceId(processEngineServices,
- processDefinitionID);
- assertEquals(0, processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pID).finished().count());
- }
-
- private static String getProcessInstanceId(
- ProcessEngineServices processEngineServices, String processDefinitionID) {
- List<HistoricProcessInstance> historyList = processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().list();
- String pID = null;
- for (HistoricProcessInstance hInstance: historyList) {
- if (hInstance.getProcessDefinitionKey().equals(processDefinitionID)) {
- pID = hInstance.getId();
- break;
- }
- }
- return pID;
- }
-
- public static void cleanHistory(ProcessEngineServices processEngineServices) {
- List<HistoricProcessInstance> historyList = processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().list();
- List<String> pidList = new ArrayList<>();
- for (HistoricProcessInstance hInstance : historyList) {
- pidList.add(hInstance.getId());
- }
- if (pidList.size() > 0) {
- processEngineServices.getHistoryService().deleteHistoricProcessInstances(pidList);
- }
- }
-
- private static String getProcessInstanceId(
- HistoryService historyService, String processDefinitionID) {
- List<HistoricProcessInstance> historyList = historyService.createHistoricProcessInstanceQuery().list();
- String pID = null;
- for (HistoricProcessInstance hInstance: historyList) {
- if (hInstance.getProcessDefinitionKey().equals(processDefinitionID)) {
- pID = hInstance.getId();
- break;
- }
- }
- return pID;
- }
-
- public static boolean isProcessInstanceFinished(ProcessEngineServices processEngineServices, String pid) {
- return processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count() == 1 ? true: false;
- }
-
-
- private static void buildVariable(String key, String value, Map<String,Object> variableValueType) {
- Map<String, Object> host = new HashMap<>();
- host.put("value", value);
- host.put("type", "String");
- variableValueType.put(key, host);
- }
-
- public static WorkflowResponse executeWorkFlow(ProcessEngineServices processEngineServices, String processKey, Map<String,String> variables) {
- VariableMapImpl variableMap = new VariableMapImpl();
-
- Map<String, Object> variableValueType = new HashMap<>();
- for (String key : variables.keySet()) {
- buildVariable(key, variables.get(key), variableValueType);
- }
- buildVariable("mso-service-request-timeout","600", variableValueType);
- variableMap.put("variables", variableValueType);
-
- workflowResource.setProcessEngineServices4junit(processEngineServices);
- Response response = workflowResource.startProcessInstanceByKey(
- processKey, variableMap);
- WorkflowResponse workflowResponse = (WorkflowResponse) response.getEntity();
- return workflowResponse;
- }
-
- public static WorkflowResponse executeWorkFlow(RuntimeService runtimeService, String processKey, Map<String,String> variables, WorkflowResource workflowResource) {
-
- VariableMapImpl variableMap = new VariableMapImpl();
-
- Map<String, Object> variableValueType = new HashMap<String, Object>();
- for (String key : variables.keySet()) {
- buildVariable(key, variables.get(key), variableValueType);
- }
- buildVariable("mso-service-request-timeout","600", variableValueType);
- variableMap.put("variables", variableValueType);
-
-
- Response response = workflowResource.startProcessInstanceByKey(
- processKey, variableMap);
- WorkflowResponse workflowResponse = (WorkflowResponse) response.getEntity();
- return workflowResponse;
- }
-
- //Check the runtime service to see whether the process is completed
- public static void waitForWorkflowToFinish(ProcessEngineServices processEngineServices, String pid) throws InterruptedException {
- // Don't wait forever
- long waitTime = 120000;
- long endTime = System.currentTimeMillis() + waitTime;
-
- while (true) {
- if (processEngineServices.getRuntimeService().createProcessInstanceQuery().processInstanceId(pid).singleResult() == null) {
- break;
- }
-
- if (System.currentTimeMillis() >= endTime) {
- fail("Process " + pid + " did not finish in " + waitTime + "ms");
- }
-
- Thread.sleep(200);
- }
- }
-
-
- //Check the runtime service to see whether the process is completed
- public static void waitForWorkflowToFinish(RuntimeService runtimeService, String pid) throws InterruptedException {
- // Don't wait forever
- long waitTime = 120000;
- long endTime = System.currentTimeMillis() + waitTime;
-
- while (true) {
- if (runtimeService.createProcessInstanceQuery().processInstanceId(pid).singleResult() == null) {
- break;
- }
-
- if (System.currentTimeMillis() >= endTime) {
- fail("Process " + pid + " did not finish in " + waitTime + "ms");
- }
-
- Thread.sleep(200);
- }
- }
-
-
- /**
- * Executes the Asynchronous workflow in synchronous fashion and returns the WorkflowResponse object
- * @param processEngineServices
- * @param processKey
- * @param variables
- * @return
- * @throws InterruptedException
- */
- public static WorkflowResponse executeAsyncWorkflow(ProcessEngineServices processEngineServices, String processKey, Map<String,String> variables) throws InterruptedException {
- ProcessThread pthread = new ProcessThread(processKey, processEngineServices, variables);
- pthread.start();
- BPMNUtil.assertProcessInstanceNotFinished(processEngineServices, processKey);
- String pid = getProcessInstanceId(processEngineServices, processKey);
- //Caution: If there is a problem with workflow, this may wait for ever
- while (true) {
- pid = getProcessInstanceId(processEngineServices, processKey);
- if (!isProcessInstanceFinished(processEngineServices,pid)) {
- Thread.sleep(200);
- } else{
- break;
- }
- }
- //need to retrieve for second time ?
- pid = getProcessInstanceId(processEngineServices, processKey);
- waitForWorkflowToFinish(processEngineServices, pid);
- return pthread.workflowResponse;
- }
-
- /**
- * Execute workflow using async resource
- * @param processEngineServices
- * @param processKey
- * @param asyncResponse
- * @param variables
- * @throws InterruptedException
- */
- private static void executeAsyncFlow(ProcessEngineServices processEngineServices, String processKey, Map<String,String> variables) throws InterruptedException {
- VariableMapImpl variableMap = new VariableMapImpl();
-
- Map<String, Object> variableValueType = new HashMap<>();
- for (String key : variables.keySet()) {
- buildVariable(key, variables.get(key), variableValueType);
- }
- buildVariable("mso-service-request-timeout","600", variableValueType);
- variableMap.put("variables", variableValueType);
-
- workflowResource.setProcessEngineServices4junit(processEngineServices);
- workflowResource.startProcessInstanceByKey(processKey, variableMap);
- }
-
- /**
- * Helper class which executes workflow in a thread
- *
- */
- static class ProcessThread extends Thread {
-
- public WorkflowResponse workflowResponse = null;
- public String processKey;
- public boolean started;
- public ProcessEngineServices processEngineServices;
- public Map<String,String> variables;
-
- public ProcessThread(String processKey, ProcessEngineServices processEngineServices, Map<String,String> variables) {
- this.processKey = processKey;
- this.processEngineServices = processEngineServices;
- this.variables = variables;
- }
-
- public void run() {
- started = true;
- /*doAnswer(new Answer<Void>() {
- public Void answer(InvocationOnMock invocation) {
- Response response = (Response) invocation.getArguments()[0];
- try {
- workflowResponse = (WorkflowResponse) response.getEntity();
- } catch (ClassCastException e) {
- String workflowResponseString = (String)response.getEntity();
- workflowResponse = new WorkflowResponse();
- workflowResponse.setResponse(workflowResponseString);
- workflowResponse.setMessageCode(200);
- }
- return null;
- }
- }).when(asyncResponse).setResponse(any(Response.class));
- */
- try {
- executeAsyncFlow(processEngineServices, processKey, variables);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
+ private static WorkflowAsyncResource workflowResource;
+
+ @Autowired
+ public void setWorkflowResource(WorkflowAsyncResource workflowResource) {
+ BPMNUtil.workflowResource = workflowResource;
+ }
+
+ public static String getVariable(ProcessEngineServices processEngineServices, String processDefinitionID,
+ String name) {
+ String pID = getProcessInstanceId(processEngineServices, processDefinitionID);
+ return getVariable(processEngineServices, processDefinitionID, name, pID);
+ }
+
+ public static String getVariable(ProcessEngineServices processEngineServices, String processDefinitionID,
+ String name, String processInstanceId) {
+ assertProcessInstanceFinished(processEngineServices, processInstanceId);
+ HistoricVariableInstance responseData =
+ processEngineServices.getHistoryService().createHistoricVariableInstanceQuery()
+ .processInstanceId(processInstanceId).variableName(name).singleResult();
+
+ if (responseData != null) {
+ return (responseData.getValue() != null ? responseData.getValue().toString() : null);
+ }
+ return null;
+ }
+
+ /*
+ * @SuppressWarnings("unchecked") public static <T extends Object> T getRawVariable(HistoryService historyService,
+ * String processDefinitionID, String name) { //String pID = getProcessInstanceId(processEngineServices, //
+ * processDefinitionID); assertProcessInstanceFinished(historyService, pID); Object responseData = historyService
+ * .createHistoricVariableInstanceQuery().processInstanceId(pID) .variableName(name) .singleResult() .getValue();
+ * return (T) responseData; }
+ */
+
+ @SuppressWarnings("unchecked")
+ public static <T> T getRawVariable(ProcessEngineServices processEngineServices, String processDefinitionID,
+ String name) {
+ String pID = getProcessInstanceId(processEngineServices, processDefinitionID);
+ return getRawVariable(processEngineServices, processDefinitionID, name, pID);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T> T getRawVariable(ProcessEngineServices processEngineServices, String processDefinitionID,
+ String name, String processInstanceId) {
+ assertProcessInstanceFinished(processEngineServices, processInstanceId);
+ Object responseData = processEngineServices.getHistoryService().createHistoricVariableInstanceQuery()
+ .processInstanceId(processInstanceId).variableName(name).singleResult().getValue();
+ return (T) responseData;
+ }
+
+
+ public static void assertAnyProcessInstanceFinished(ProcessEngineServices processEngineServices,
+ String processDefinitionID) {
+ String pID = getProcessInstanceId(processEngineServices, processDefinitionID);
+ assertNotNull(pID);
+ assertTrue(processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pID)
+ .finished().count() > 0);
+ }
+
+ public static void assertNoProcessInstance(ProcessEngineServices processEngineServices,
+ String processDefinitionID) {
+ assertNull(getProcessInstanceId(processEngineServices, processDefinitionID));
+ }
+
+ public static void assertProcessInstanceFinished(HistoryService historyService, String pid) {
+ assertEquals(1, historyService.createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count());
+ }
+
+ public static void assertProcessInstanceFinished(ProcessEngineServices processEngineServices, String pid) {
+ assertEquals(1, processEngineServices.getHistoryService().createHistoricProcessInstanceQuery()
+ .processInstanceId(pid).finished().count());
+ }
+
+ public static void assertProcessInstanceNotFinished(ProcessEngineServices processEngineServices,
+ String processDefinitionID) {
+ String pID = getProcessInstanceId(processEngineServices, processDefinitionID);
+ assertEquals(0, processEngineServices.getHistoryService().createHistoricProcessInstanceQuery()
+ .processInstanceId(pID).finished().count());
+ }
+
+ private static String getProcessInstanceId(ProcessEngineServices processEngineServices,
+ String processDefinitionID) {
+ List<HistoricProcessInstance> historyList =
+ processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().list();
+ String pID = null;
+ for (HistoricProcessInstance hInstance : historyList) {
+ if (hInstance.getProcessDefinitionKey().equals(processDefinitionID)) {
+ pID = hInstance.getId();
+ break;
+ }
+ }
+ return pID;
+ }
+
+ public static void cleanHistory(ProcessEngineServices processEngineServices) {
+ List<HistoricProcessInstance> historyList =
+ processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().list();
+ List<String> pidList = new ArrayList<>();
+ for (HistoricProcessInstance hInstance : historyList) {
+ pidList.add(hInstance.getId());
+ }
+ if (pidList.size() > 0) {
+ processEngineServices.getHistoryService().deleteHistoricProcessInstances(pidList);
+ }
+ }
+
+ private static String getProcessInstanceId(HistoryService historyService, String processDefinitionID) {
+ List<HistoricProcessInstance> historyList = historyService.createHistoricProcessInstanceQuery().list();
+ String pID = null;
+ for (HistoricProcessInstance hInstance : historyList) {
+ if (hInstance.getProcessDefinitionKey().equals(processDefinitionID)) {
+ pID = hInstance.getId();
+ break;
+ }
+ }
+ return pID;
+ }
+
+ public static boolean isProcessInstanceFinished(ProcessEngineServices processEngineServices, String pid) {
+ return processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid)
+ .finished().count() == 1 ? true : false;
+ }
+
+
+ private static void buildVariable(String key, String value, Map<String, Object> variableValueType) {
+ Map<String, Object> host = new HashMap<>();
+ host.put("value", value);
+ host.put("type", "String");
+ variableValueType.put(key, host);
+ }
+
+ public static WorkflowResponse executeWorkFlow(ProcessEngineServices processEngineServices, String processKey,
+ Map<String, String> variables) {
+ VariableMapImpl variableMap = new VariableMapImpl();
+
+ Map<String, Object> variableValueType = new HashMap<>();
+ for (String key : variables.keySet()) {
+ buildVariable(key, variables.get(key), variableValueType);
+ }
+ buildVariable("mso-service-request-timeout", "600", variableValueType);
+ variableMap.put("variables", variableValueType);
+
+ workflowResource.setProcessEngineServices4junit(processEngineServices);
+ Response response = workflowResource.startProcessInstanceByKey(processKey, variableMap);
+ WorkflowResponse workflowResponse = (WorkflowResponse) response.getEntity();
+ return workflowResponse;
+ }
+
+ public static WorkflowResponse executeWorkFlow(RuntimeService runtimeService, String processKey,
+ Map<String, String> variables, WorkflowResource workflowResource) {
+
+ VariableMapImpl variableMap = new VariableMapImpl();
+
+ Map<String, Object> variableValueType = new HashMap<String, Object>();
+ for (String key : variables.keySet()) {
+ buildVariable(key, variables.get(key), variableValueType);
+ }
+ buildVariable("mso-service-request-timeout", "600", variableValueType);
+ variableMap.put("variables", variableValueType);
+
+
+ Response response = workflowResource.startProcessInstanceByKey(processKey, variableMap);
+ WorkflowResponse workflowResponse = (WorkflowResponse) response.getEntity();
+ return workflowResponse;
+ }
+
+ // Check the runtime service to see whether the process is completed
+ public static void waitForWorkflowToFinish(ProcessEngineServices processEngineServices, String pid)
+ throws InterruptedException {
+ // Don't wait forever
+ long waitTime = 120000;
+ long endTime = System.currentTimeMillis() + waitTime;
+
+ while (true) {
+ if (processEngineServices.getRuntimeService().createProcessInstanceQuery().processInstanceId(pid)
+ .singleResult() == null) {
+ break;
+ }
+
+ if (System.currentTimeMillis() >= endTime) {
+ fail("Process " + pid + " did not finish in " + waitTime + "ms");
+ }
+
+ Thread.sleep(200);
+ }
+ }
+
+
+ // Check the runtime service to see whether the process is completed
+ public static void waitForWorkflowToFinish(RuntimeService runtimeService, String pid) throws InterruptedException {
+ // Don't wait forever
+ long waitTime = 120000;
+ long endTime = System.currentTimeMillis() + waitTime;
+
+ while (true) {
+ if (runtimeService.createProcessInstanceQuery().processInstanceId(pid).singleResult() == null) {
+ break;
+ }
+
+ if (System.currentTimeMillis() >= endTime) {
+ fail("Process " + pid + " did not finish in " + waitTime + "ms");
+ }
+
+ Thread.sleep(200);
+ }
+ }
+
+
+ /**
+ * Executes the Asynchronous workflow in synchronous fashion and returns the WorkflowResponse object
+ *
+ * @param processEngineServices
+ * @param processKey
+ * @param variables
+ * @return
+ * @throws InterruptedException
+ */
+ public static WorkflowResponse executeAsyncWorkflow(ProcessEngineServices processEngineServices, String processKey,
+ Map<String, String> variables) throws InterruptedException {
+ ProcessThread pthread = new ProcessThread(processKey, processEngineServices, variables);
+ pthread.start();
+ BPMNUtil.assertProcessInstanceNotFinished(processEngineServices, processKey);
+ String pid = getProcessInstanceId(processEngineServices, processKey);
+ // Caution: If there is a problem with workflow, this may wait for ever
+ while (true) {
+ pid = getProcessInstanceId(processEngineServices, processKey);
+ if (!isProcessInstanceFinished(processEngineServices, pid)) {
+ Thread.sleep(200);
+ } else {
+ break;
+ }
+ }
+ // need to retrieve for second time ?
+ pid = getProcessInstanceId(processEngineServices, processKey);
+ waitForWorkflowToFinish(processEngineServices, pid);
+ return pthread.workflowResponse;
+ }
+
+ /**
+ * Execute workflow using async resource
+ *
+ * @param processEngineServices
+ * @param processKey
+ * @param asyncResponse
+ * @param variables
+ * @throws InterruptedException
+ */
+ private static void executeAsyncFlow(ProcessEngineServices processEngineServices, String processKey,
+ Map<String, String> variables) throws InterruptedException {
+ VariableMapImpl variableMap = new VariableMapImpl();
+
+ Map<String, Object> variableValueType = new HashMap<>();
+ for (String key : variables.keySet()) {
+ buildVariable(key, variables.get(key), variableValueType);
+ }
+ buildVariable("mso-service-request-timeout", "600", variableValueType);
+ variableMap.put("variables", variableValueType);
+
+ workflowResource.setProcessEngineServices4junit(processEngineServices);
+ workflowResource.startProcessInstanceByKey(processKey, variableMap);
+ }
+
+ /**
+ * Helper class which executes workflow in a thread
+ *
+ */
+ static class ProcessThread extends Thread {
+
+ public WorkflowResponse workflowResponse = null;
+ public String processKey;
+ public boolean started;
+ public ProcessEngineServices processEngineServices;
+ public Map<String, String> variables;
+
+ public ProcessThread(String processKey, ProcessEngineServices processEngineServices,
+ Map<String, String> variables) {
+ this.processKey = processKey;
+ this.processEngineServices = processEngineServices;
+ this.variables = variables;
+ }
+
+ public void run() {
+ started = true;
+ /*
+ * doAnswer(new Answer<Void>() { public Void answer(InvocationOnMock invocation) { Response response =
+ * (Response) invocation.getArguments()[0]; try { workflowResponse = (WorkflowResponse)
+ * response.getEntity(); } catch (ClassCastException e) { String workflowResponseString =
+ * (String)response.getEntity(); workflowResponse = new WorkflowResponse();
+ * workflowResponse.setResponse(workflowResponseString); workflowResponse.setMessageCode(200); } return
+ * null; } }).when(asyncResponse).setResponse(any(Response.class));
+ */
+ try {
+ executeAsyncFlow(processEngineServices, processKey, variables);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CompleteMsoProcessIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CompleteMsoProcessIT.java
index f528205d17..2be72184af 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CompleteMsoProcessIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CompleteMsoProcessIT.java
@@ -16,17 +16,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
import static org.onap.so.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
import static org.onap.so.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Assert;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -36,148 +34,140 @@ import org.onap.so.BaseIntegrationTest;
*/
public class CompleteMsoProcessIT extends BaseIntegrationTest {
-
- private void executeFlow(String inputRequestFile) throws InterruptedException {
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
- Map<String, Object> variables = new HashMap<>();
- variables.put("CompleteMsoProcessRequest",inputRequestFile);
- variables.put("mso-request-id", UUID.randomUUID().toString());
- String processId = invokeSubProcess( "CompleteMsoProcess", variables);
- waitForWorkflowToFinish(processEngine,processId);
- logEnd();
- }
-
- @Test
- public void msoCompletionRequestWithNotificationUrl_200() throws Exception {
- logStart();
-
- //Execute Flow
- executeFlow(gMsoCompletionRequestWithNotificationurl());
-
- //Verify Error
- String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode");
- Assert.assertEquals("200", CMSO_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
- logEnd();
- }
-
- @Test
- public void msoCompletionRequestWithNoNotificationurl() throws Exception {
- logStart();
-
- //Execute Flow
- executeFlow(gMsoCompletionRequestWithNoNotificationurl());
-
- //Verify Error
- String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode");
- Assert.assertEquals("200", CMSO_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
- logEnd();
- }
-
- @Test
- public void msoCompletionRequestWithNotificationurlNoRequestId() throws Exception {
- logStart();
-
- //Execute Flow
- executeFlow(gMsoCompletionRequestWithNotificationurlNoRequestId());
-
- //Verify Error
- String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode");
- Assert.assertEquals("200", CMSO_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
- logEnd();
- }
-
- @Test
- public void msoCompletionRequestWithNoNotificationurlNoRequestId() throws Exception {
- logStart();
-
- //Execute Flow
- executeFlow(gMsoCompletionRequestWithNoNotificationurlNoRequestId());
-
- //Verify Error
- String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode");
- Assert.assertEquals("200", CMSO_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
- logEnd();
- }
-
- public String gMsoCompletionRequestWithNotificationurl() {
- String xml = ""
- + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://ecomp.openecomp.org.com/mso/workflow/schema/v1\">"
- + " <ns:request-information>"
- + " <ns:request-id>STUW105_5002</ns:request-id>"
- + " <ns:request-action>RequestAction</ns:request-action>"
- + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
- + " <ns:source>SOURCE</ns:source>"
- + " <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>"
- + " <ns:order-number>10205000</ns:order-number>"
- + " <ns:order-version>1</ns:order-version>"
- + " </ns:request-information>"
- + " <sdncadapterworkflow:mso-bpel-name>BPELNAME</sdncadapterworkflow:mso-bpel-name>"
- + "</sdncadapterworkflow:MsoCompletionRequest>";
-
- return xml;
- }
-
-
-
- public String gMsoCompletionRequestWithNoNotificationurl() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
- + " <ns:request-information>"
- + " <ns:request-id>STUW105_5002</ns:request-id>"
- + " <ns:request-action>RequestAction</ns:request-action>"
- + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
- + " <ns:source>SOURCE</ns:source>"
- + " <ns:notification-url></ns:notification-url>"
- + " <ns:order-number>10205000</ns:order-number>"
- + " <ns:order-version>1</ns:order-version>"
- + " </ns:request-information>"
- + " <sdncadapterworkflow:mso-bpel-name>BPELNAME</sdncadapterworkflow:mso-bpel-name>"
- + "</sdncadapterworkflow:MsoCompletionRequest>";
-
- return xml;
- }
-
- public String gMsoCompletionRequestWithNoNotificationurlNoRequestId() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
- + " <ns:request-information>"
- + " <ns:request-id></ns:request-id>"
- + " <ns:request-action>RequestAction</ns:request-action>"
- + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
- + " <ns:source>SOURCE</ns:source>"
- + " <ns:notification-url></ns:notification-url>"
- + " <ns:order-number>10205000</ns:order-number>"
- + " <ns:order-version>1</ns:order-version>"
- + " </ns:request-information>"
- + " <sdncadapterworkflow:mso-bpel-name>BPELNAME</sdncadapterworkflow:mso-bpel-name>"
- + "</sdncadapterworkflow:MsoCompletionRequest>";
-
- return xml;
- }
-
- public String gMsoCompletionRequestWithNotificationurlNoRequestId() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
- + " <ns:request-information>"
- + " <ns:request-id></ns:request-id>"
- + " <ns:request-action>RequestAction</ns:request-action>"
- + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
- + " <ns:source>SOURCE</ns:source>"
- + " <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>"
- + " <ns:order-number>10205000</ns:order-number>"
- + " <ns:order-version>1</ns:order-version>"
- + " </ns:request-information>"
- + " <sdncadapterworkflow:mso-bpel-name>BPELNAME</sdncadapterworkflow:mso-bpel-name>"
- + "</sdncadapterworkflow:MsoCompletionRequest>";
-
- return xml;
- }
+
+ private void executeFlow(String inputRequestFile) throws InterruptedException {
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("CompleteMsoProcessRequest", inputRequestFile);
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ String processId = invokeSubProcess("CompleteMsoProcess", variables);
+ waitForWorkflowToFinish(processEngine, processId);
+ logEnd();
+ }
+
+ @Test
+ public void msoCompletionRequestWithNotificationUrl_200() throws Exception {
+ logStart();
+
+ // Execute Flow
+ executeFlow(gMsoCompletionRequestWithNotificationurl());
+
+ // Verify Error
+ String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode");
+ Assert.assertEquals("200", CMSO_ResponseCode);
+ Assert.assertTrue(
+ (boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
+ logEnd();
+ }
+
+ @Test
+ public void msoCompletionRequestWithNoNotificationurl() throws Exception {
+ logStart();
+
+ // Execute Flow
+ executeFlow(gMsoCompletionRequestWithNoNotificationurl());
+
+ // Verify Error
+ String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode");
+ Assert.assertEquals("200", CMSO_ResponseCode);
+ Assert.assertTrue(
+ (boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
+ logEnd();
+ }
+
+ @Test
+ public void msoCompletionRequestWithNotificationurlNoRequestId() throws Exception {
+ logStart();
+
+ // Execute Flow
+ executeFlow(gMsoCompletionRequestWithNotificationurlNoRequestId());
+
+ // Verify Error
+ String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode");
+ Assert.assertEquals("200", CMSO_ResponseCode);
+ Assert.assertTrue(
+ (boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
+ logEnd();
+ }
+
+ @Test
+ public void msoCompletionRequestWithNoNotificationurlNoRequestId() throws Exception {
+ logStart();
+
+ // Execute Flow
+ executeFlow(gMsoCompletionRequestWithNoNotificationurlNoRequestId());
+
+ // Verify Error
+ String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode");
+ Assert.assertEquals("200", CMSO_ResponseCode);
+ Assert.assertTrue(
+ (boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
+ logEnd();
+ }
+
+ public String gMsoCompletionRequestWithNotificationurl() {
+ String xml = ""
+ + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://ecomp.openecomp.org.com/mso/workflow/schema/v1\">"
+ + " <ns:request-information>" + " <ns:request-id>STUW105_5002</ns:request-id>"
+ + " <ns:request-action>RequestAction</ns:request-action>"
+ + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>" + " <ns:source>SOURCE</ns:source>"
+ + " <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>"
+ + " <ns:order-number>10205000</ns:order-number>" + " <ns:order-version>1</ns:order-version>"
+ + " </ns:request-information>"
+ + " <sdncadapterworkflow:mso-bpel-name>BPELNAME</sdncadapterworkflow:mso-bpel-name>"
+ + "</sdncadapterworkflow:MsoCompletionRequest>";
+
+ return xml;
+ }
+
+
+
+ public String gMsoCompletionRequestWithNoNotificationurl() {
+ // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
+ String xml = ""
+ + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
+ + " <ns:request-information>" + " <ns:request-id>STUW105_5002</ns:request-id>"
+ + " <ns:request-action>RequestAction</ns:request-action>"
+ + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>" + " <ns:source>SOURCE</ns:source>"
+ + " <ns:notification-url></ns:notification-url>"
+ + " <ns:order-number>10205000</ns:order-number>" + " <ns:order-version>1</ns:order-version>"
+ + " </ns:request-information>"
+ + " <sdncadapterworkflow:mso-bpel-name>BPELNAME</sdncadapterworkflow:mso-bpel-name>"
+ + "</sdncadapterworkflow:MsoCompletionRequest>";
+
+ return xml;
+ }
+
+ public String gMsoCompletionRequestWithNoNotificationurlNoRequestId() {
+ // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
+ String xml = ""
+ + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
+ + " <ns:request-information>" + " <ns:request-id></ns:request-id>"
+ + " <ns:request-action>RequestAction</ns:request-action>"
+ + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>" + " <ns:source>SOURCE</ns:source>"
+ + " <ns:notification-url></ns:notification-url>"
+ + " <ns:order-number>10205000</ns:order-number>" + " <ns:order-version>1</ns:order-version>"
+ + " </ns:request-information>"
+ + " <sdncadapterworkflow:mso-bpel-name>BPELNAME</sdncadapterworkflow:mso-bpel-name>"
+ + "</sdncadapterworkflow:MsoCompletionRequest>";
+
+ return xml;
+ }
+
+ public String gMsoCompletionRequestWithNotificationurlNoRequestId() {
+ // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
+ String xml = ""
+ + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
+ + " <ns:request-information>" + " <ns:request-id></ns:request-id>"
+ + " <ns:request-action>RequestAction</ns:request-action>"
+ + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>" + " <ns:source>SOURCE</ns:source>"
+ + " <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>"
+ + " <ns:order-number>10205000</ns:order-number>" + " <ns:order-version>1</ns:order-version>"
+ + " </ns:request-information>"
+ + " <sdncadapterworkflow:mso-bpel-name>BPELNAME</sdncadapterworkflow:mso-bpel-name>"
+ + "</sdncadapterworkflow:MsoCompletionRequest>";
+
+ return xml;
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupNameIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupNameIT.java
index cc3ca941e4..ad0428c68e 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupNameIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupNameIT.java
@@ -16,17 +16,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
import static org.junit.Assert.assertEquals;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.test.Deployment;
import org.junit.Ignore;
@@ -38,79 +36,83 @@ import org.onap.so.BaseIntegrationTest;
*/
public class ConfirmVolumeGroupNameIT extends BaseIntegrationTest {
- /**
- * Sunny day scenario.
- *
- * @throws Exception
- */
- @Test
- public void sunnyDay() throws Exception {
- logStart();
- MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
- variables.put("ConfirmVolumeGroupName_volumeGroupName", "VOLUME_GROUP_ID_1_NAME");
- variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);
- String responseCode = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode",processId);
-
- assertEquals("200", responseCode);
-
- logEnd();
- }
-
- /**
- * Rainy day scenario - nonexisting volume group id.
- *
- * @throws Exception
- */
- @Test
- public void rainyDayNoVolumeGroupId() throws Exception {
- logStart();
-
- // does not exist would return a 404 from AAI
- MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST", "aai-volume-group-id-info.xml", 404);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
- variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST");
- variables.put("ConfirmVolumeGroupName_volumeGroupName", "cee6d136-e378-4678-a024-2cd15f0ee0cg");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);
- String responseCode = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode",processId);
-
- assertEquals("404", responseCode);
-
- logEnd();
- }
-
- /**
- * Rainy day scenario - volume group name does not match the name in AAI
- *
- *
- * @throws Exception
- */
- @Test
- public void rainyDayNameDoesNotMatch() throws Exception {
- logStart();
-
- MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml", 200);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
- variables.put("ConfirmVolumeGroupName_volumeGroupName", "BAD_VOLUME_GROUP_NAME");
- variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);
- String volumeGroupNameMatches = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName", "CVGN_volumeGroupNameMatches",processId);
-
- assertEquals("false", volumeGroupNameMatches);
-
- logEnd();
- }
+ /**
+ * Sunny day scenario.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void sunnyDay() throws Exception {
+ logStart();
+ MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
+ variables.put("ConfirmVolumeGroupName_volumeGroupName", "VOLUME_GROUP_ID_1_NAME");
+ variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);
+ String responseCode = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName",
+ "CVGN_queryVolumeGroupResponseCode", processId);
+
+ assertEquals("200", responseCode);
+
+ logEnd();
+ }
+
+ /**
+ * Rainy day scenario - nonexisting volume group id.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void rainyDayNoVolumeGroupId() throws Exception {
+ logStart();
+
+ // does not exist would return a 404 from AAI
+ MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST",
+ "aai-volume-group-id-info.xml", 404);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
+ variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST");
+ variables.put("ConfirmVolumeGroupName_volumeGroupName", "cee6d136-e378-4678-a024-2cd15f0ee0cg");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);
+ String responseCode = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName",
+ "CVGN_queryVolumeGroupResponseCode", processId);
+
+ assertEquals("404", responseCode);
+
+ logEnd();
+ }
+
+ /**
+ * Rainy day scenario - volume group name does not match the name in AAI
+ *
+ *
+ * @throws Exception
+ */
+ @Test
+ public void rainyDayNameDoesNotMatch() throws Exception {
+ logStart();
+
+ MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml", 200);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
+ variables.put("ConfirmVolumeGroupName_volumeGroupName", "BAD_VOLUME_GROUP_NAME");
+ variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);
+ String volumeGroupNameMatches =
+ BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName", "CVGN_volumeGroupNameMatches", processId);
+
+ assertEquals("false", volumeGroupNameMatches);
+
+ logEnd();
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupTenantIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupTenantIT.java
index fd1f7c1a2b..f190b6243b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupTenantIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ConfirmVolumeGroupTenantIT.java
@@ -19,17 +19,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
import static org.junit.Assert.assertEquals;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -40,49 +38,59 @@ import org.onap.so.BaseIntegrationTest;
public class ConfirmVolumeGroupTenantIT extends BaseIntegrationTest {
- @Test
- public void testRemoveLayer3Service_success() throws Exception{
- MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariables(variables);
-
- String processId = invokeSubProcess("ConfirmVolumeGroupTenant", variables);
-
- String actualNameMatch = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "groupNamesMatch",processId);
- String actualIdMatch = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "tenantIdsMatch",processId);
- String actualResponse = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "volumeHeatStackId",processId);
-
- assertEquals("Response", "true", actualNameMatch);
- assertEquals("Response", "true", actualIdMatch);
- assertEquals("Response", "MoG_CinderVolumes_2/19387dc6-060f-446e-b41f-dcfd29c73845", actualResponse);
- }
-
- @Test
- public void testRemoveLayer3Service_idsNotMatch() throws Exception{
- MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariables(variables);
-
- String processId = invokeSubProcess("ConfirmVolumeGroupTenant", variables);
-
-
- String actualNameMatch = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "groupNamesMatch",processId);
- String actualIdMatch = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "tenantIdsMatch",processId);
- String actualResponse = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "WorkflowException",processId);
-
- assertEquals("Response", "true", actualNameMatch);
- assertEquals("Response", "false", actualIdMatch);
- assertEquals("Response", "WorkflowException[processKey=ConfirmVolumeGroupTenant,errorCode=1,errorMessage=Volume Group a8399879-31b3-4973-be26-0a0cbe776b58 does not belong to your tenant,workStep=*]", actualResponse);
-
- }
-
- private void setVariables(Map<String, Object> variables) {
- variables.put("isDebugLogEnabled", "true");
- variables.put("volumeGroupId","a8399879-31b3-4973-be26-0a0cbe776b58");
- variables.put("tenantId", "7dd5365547234ee8937416c65507d266");
- variables.put("aicCloudRegion", "MDTWNJ21");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- }
+ @Test
+ public void testRemoveLayer3Service_success() throws Exception {
+ MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58",
+ "CRTGVNF_queryAAIResponseVolume.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariables(variables);
+
+ String processId = invokeSubProcess("ConfirmVolumeGroupTenant", variables);
+
+ String actualNameMatch =
+ BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "groupNamesMatch", processId);
+ String actualIdMatch =
+ BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "tenantIdsMatch", processId);
+ String actualResponse =
+ BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "volumeHeatStackId", processId);
+
+ assertEquals("Response", "true", actualNameMatch);
+ assertEquals("Response", "true", actualIdMatch);
+ assertEquals("Response", "MoG_CinderVolumes_2/19387dc6-060f-446e-b41f-dcfd29c73845", actualResponse);
+ }
+
+ @Test
+ public void testRemoveLayer3Service_idsNotMatch() throws Exception {
+ MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58",
+ "CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariables(variables);
+
+ String processId = invokeSubProcess("ConfirmVolumeGroupTenant", variables);
+
+
+ String actualNameMatch =
+ BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "groupNamesMatch", processId);
+ String actualIdMatch =
+ BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "tenantIdsMatch", processId);
+ String actualResponse =
+ BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "WorkflowException", processId);
+
+ assertEquals("Response", "true", actualNameMatch);
+ assertEquals("Response", "false", actualIdMatch);
+ assertEquals("Response",
+ "WorkflowException[processKey=ConfirmVolumeGroupTenant,errorCode=1,errorMessage=Volume Group a8399879-31b3-4973-be26-0a0cbe776b58 does not belong to your tenant,workStep=*]",
+ actualResponse);
+
+ }
+
+ private void setVariables(Map<String, Object> variables) {
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("volumeGroupId", "a8399879-31b3-4973-be26-0a0cbe776b58");
+ variables.put("tenantId", "7dd5365547234ee8937416c65507d266");
+ variables.put("aicCloudRegion", "MDTWNJ21");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java
index f6cd74a55b..47d3799e7d 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
@@ -26,18 +26,15 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Assert;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.bpmn.core.WorkflowException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import com.github.tomakehurst.wiremock.WireMockServer;
/**
@@ -45,223 +42,228 @@ import com.github.tomakehurst.wiremock.WireMockServer;
*/
public class CreateAAIVfModuleIT extends BaseIntegrationTest {
-
- Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class);
-
- @Test
- public void TestCreateGenericVnfSuccess_200() {
- new MockAAIGenericVnfSearch(wireMockServer);
- MockAAICreateGenericVnf(wireMockServer);
- MockAAIVfModulePUT(wireMockServer, true);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfName", "STMTN5MMSC22");
- variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC22-MMSC::module-0-0");
- variables.put("vfModuleModelName", "MMSC::module-0");
-
- String processId = invokeSubProcess("CreateAAIVfModule", variables);
- String response = BPMNUtil.getVariable(processEngine, "CreateAAIVfModule", "CAAIVfMod_createVfModuleResponseCode",processId);
- String responseCode = BPMNUtil.getVariable(processEngine, "CreateAAIVfModule", "CAAIVfMod_createVfModuleResponseCode",processId);
- Assert.assertEquals("201", responseCode);
- logger.debug(response);
- }
+ Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class);
+
+ @Test
+ public void TestCreateGenericVnfSuccess_200() {
+
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("isVidRequest", "false");
+ variables.put("vnfName", "STMTN5MMSC22");
+ variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
+ variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
+ variables.put("personaModelVersion", "1.0");
+ variables.put("vfModuleName", "STMTN5MMSC22-MMSC::module-0-0");
+ variables.put("vfModuleModelName", "MMSC::module-0");
+
+ String processId = invokeSubProcess("CreateAAIVfModule", variables);
+ String response = BPMNUtil.getVariable(processEngine, "CreateAAIVfModule",
+ "CAAIVfMod_createVfModuleResponseCode", processId);
+ String responseCode = BPMNUtil.getVariable(processEngine, "CreateAAIVfModule",
+ "CAAIVfMod_createVfModuleResponseCode", processId);
+ Assert.assertEquals("201", responseCode);
+ logger.debug(response);
+ }
+
+ @Test
+ public void TestCreateVfModuleSuccess_200() {
+ // create Add-on VF Module for existing Generic VNF
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("isVidRequest", "false");
+ variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
+ variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
+ variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
+ variables.put("personaModelVersion", "1.0");
+ variables.put("vfModuleName", "STMTN5MMSC21-MMSC::module-1-0");
+ variables.put("vfModuleModelName", "STMTN5MMSC21-MMSC::model-1-0");
+ String processId = invokeSubProcess("CreateAAIVfModule", variables);
+ String response = BPMNUtil.getVariable(processEngine, "CreateAAIVfModule",
+ "CAAIVfMod_createVfModuleResponseCode", processId);
+ String responseCode = BPMNUtil.getVariable(processEngine, "CreateAAIVfModule",
+ "CAAIVfMod_createVfModuleResponseCode", processId);
+ Assert.assertEquals("201", responseCode);
+ logger.debug(response);
+ }
+
+ @Test
+ public void TestQueryGenericVnfFailure_5000() {
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("isVidRequest", "false");
+ variables.put("vnfName", "STMTN5MMSC23");
+ variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
+ variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
+ variables.put("personaModelVersion", "1.0");
+ variables.put("vfModuleName", "STMTN5MMSC23-MMSC::module-0-0");
+ variables.put("vfModuleModelName", "MMSC::module-0");
+ String processId = invokeSubProcess("CreateAAIVfModule", variables);
+ WorkflowException exception =
+ BPMNUtil.getRawVariable(processEngine, "CreateAAIVfModule", "WorkflowException", processId);
+ Assert.assertEquals(500, exception.getErrorCode());
+ Assert.assertEquals(true, exception.getErrorMessage().contains("Error occurred attempting to query AAI"));
+ logger.debug(exception.getErrorMessage());
+ }
+
+ @Test
+ public void TestCreateDupGenericVnfFailure_1002() {
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("isVidRequest", "false");
+ variables.put("vnfName", "STMTN5MMSC21");
+ variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
+ variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
+ variables.put("personaModelVersion", "1.0");
+ variables.put("vfModuleName", "STMTN5MMSC21-MMSC::module-0-0");
+ variables.put("vfModuleModelName", "MMSC::module-0");
+ String processId = invokeSubProcess("CreateAAIVfModule", variables);
+ WorkflowException exception =
+ BPMNUtil.getRawVariable(processEngine, "CreateAAIVfModule", "WorkflowException", processId);
+ Assert.assertEquals(1002, exception.getErrorCode());
+ Assert.assertEquals(true,
+ exception.getErrorMessage().contains("Invalid request for new Generic VNF which already exists"));
+ logger.debug(exception.getErrorMessage());
+ }
+
+ @Test
+ public void TestCreateDupVfModuleFailure_1002() {
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("isVidRequest", "false");
+ variables.put("vnfId", "2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4");
+ variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
+ variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
+ variables.put("personaModelVersion", "1.0");
+ variables.put("vfModuleName", "STMTN5MMSC20-MMSC::module-1-0");
+ variables.put("vfModuleModelName", "STMTN5MMSC20-MMSC::model-1-0");
+ String processId = invokeSubProcess("CreateAAIVfModule", variables);
+ WorkflowException exception =
+ BPMNUtil.getRawVariable(processEngine, "CreateAAIVfModule", "WorkflowException", processId);
+ Assert.assertEquals(1002, exception.getErrorCode());
+ Assert.assertEquals(true, exception.getErrorMessage().contains("already exists for Generic VNF"));
+ logger.debug(exception.getErrorMessage());
+ }
+
+ @Test
+ public void TestCreateGenericVnfFailure_5000() {
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("isVidRequest", "false");
+ variables.put("vnfName", "STMTN5MMSC22");
+ variables.put("serviceId", "99999999-9999-9999-9999-999999999999");
+ variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
+ variables.put("personaModelVersion", "1.0");
+ variables.put("vfModuleName", "STMTN5MMSC22-PCRF::module-1-0");
+ variables.put("vfModuleModelName", "PCRF::module-0");
+ String processId = invokeSubProcess("CreateAAIVfModule", variables);
+ WorkflowException exception =
+ BPMNUtil.getRawVariable(processEngine, "CreateAAIVfModule", "WorkflowException", processId);
+ Assert.assertEquals(5000, exception.getErrorCode());
+ Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
+ logger.debug(exception.getErrorMessage());
+ }
- @Test
- public void TestCreateVfModuleSuccess_200() {
- // create Add-on VF Module for existing Generic VNF
- new MockAAIGenericVnfSearch(wireMockServer);
- MockAAICreateGenericVnf(wireMockServer);
- MockAAIVfModulePUT(wireMockServer, true);
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
- variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC21-MMSC::module-1-0");
- variables.put("vfModuleModelName", "STMTN5MMSC21-MMSC::model-1-0");
- String processId = invokeSubProcess("CreateAAIVfModule", variables);
- String response = BPMNUtil.getVariable(processEngine, "CreateAAIVfModule", "CAAIVfMod_createVfModuleResponseCode",processId);
- String responseCode = BPMNUtil.getVariable(processEngine, "CreateAAIVfModule", "CAAIVfMod_createVfModuleResponseCode",processId);
- Assert.assertEquals("201", responseCode);
- logger.debug(response);
- }
+ @Test
+ public void TestCreateGenericVnfFailure_1002() {
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
- @Test
- public void TestQueryGenericVnfFailure_5000() {
- new MockAAIGenericVnfSearch(wireMockServer);
- MockAAICreateGenericVnf(wireMockServer);
- MockAAIVfModulePUT(wireMockServer, true);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfName", "STMTN5MMSC23");
- variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC23-MMSC::module-0-0");
- variables.put("vfModuleModelName", "MMSC::module-0");
- String processId = invokeSubProcess("CreateAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "CreateAAIVfModule", "WorkflowException",processId);
- Assert.assertEquals(500, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("Error occurred attempting to query AAI"));
- logger.debug(exception.getErrorMessage());
- }
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("isVidRequest", "false");
+ variables.put("vnfId", "768073c7-f41f-4822-9323-b75962763d74");
+ variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
+ variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
+ variables.put("personaModelVersion", "1.0");
+ variables.put("vfModuleName", "STMTN5MMSC22-PCRF::module-1-0");
+ variables.put("vfModuleModelName", "PCRF::module-0");
+ String processId = invokeSubProcess("CreateAAIVfModule", variables);
+ WorkflowException exception =
+ BPMNUtil.getRawVariable(processEngine, "CreateAAIVfModule", "WorkflowException", processId);
+ Assert.assertEquals(1002, exception.getErrorCode());
+ Assert.assertEquals(true, exception.getErrorMessage().contains("Generic VNF Not Found"));
+ logger.debug(exception.getErrorMessage());
+ }
- @Test
- public void TestCreateDupGenericVnfFailure_1002() {
- new MockAAIGenericVnfSearch(wireMockServer);
- MockAAICreateGenericVnf(wireMockServer);
- MockAAIVfModulePUT(wireMockServer, true);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfName", "STMTN5MMSC21");
- variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC21-MMSC::module-0-0");
- variables.put("vfModuleModelName", "MMSC::module-0");
- String processId = invokeSubProcess("CreateAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "CreateAAIVfModule", "WorkflowException",processId);
- Assert.assertEquals(1002, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("Invalid request for new Generic VNF which already exists"));
- logger.debug(exception.getErrorMessage());
- }
+ @Test
+ public void TestCreateVfModuleFailure_5000() {
+ new MockAAIGenericVnfSearch(wireMockServer);
+ MockAAICreateGenericVnf(wireMockServer);
+ MockAAIVfModulePUT(wireMockServer, true);
- @Test
- public void TestCreateDupVfModuleFailure_1002() {
- new MockAAIGenericVnfSearch(wireMockServer);
- MockAAICreateGenericVnf(wireMockServer);
- MockAAIVfModulePUT(wireMockServer, true);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfId", "2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4");
- variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC20-MMSC::module-1-0");
- variables.put("vfModuleModelName", "STMTN5MMSC20-MMSC::model-1-0");
- String processId = invokeSubProcess("CreateAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "CreateAAIVfModule", "WorkflowException",processId);
- Assert.assertEquals(1002, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("already exists for Generic VNF"));
- logger.debug(exception.getErrorMessage());
- }
-
- @Test
- public void TestCreateGenericVnfFailure_5000() {
- new MockAAIGenericVnfSearch(wireMockServer);
- MockAAICreateGenericVnf(wireMockServer);
- MockAAIVfModulePUT(wireMockServer, true);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfName", "STMTN5MMSC22");
- variables.put("serviceId", "99999999-9999-9999-9999-999999999999");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC22-PCRF::module-1-0");
- variables.put("vfModuleModelName", "PCRF::module-0");
- String processId = invokeSubProcess("CreateAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "CreateAAIVfModule", "WorkflowException",processId);
- Assert.assertEquals(5000, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
- logger.debug(exception.getErrorMessage());
- }
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("isVidRequest", "false");
+ variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
+ variables.put("serviceId", "99999999-9999-9999-9999-999999999999");
+ variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
+ variables.put("personaModelVersion", "1.0");
+ variables.put("vfModuleName", "STMTN5MMSC21-PCRF::module-1-0");
+ variables.put("vfModuleModelName", "STMTN5MMSC21-PCRF::model-1-0");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ String processId = invokeSubProcess("CreateAAIVfModule", variables);
+ WorkflowException exception =
+ BPMNUtil.getRawVariable(processEngine, "CreateAAIVfModule", "WorkflowException", processId);
+ Assert.assertEquals(5000, exception.getErrorCode());
+ Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
+ logger.debug(exception.getErrorMessage());
+ }
- @Test
- public void TestCreateGenericVnfFailure_1002() {
- new MockAAIGenericVnfSearch(wireMockServer);
- MockAAICreateGenericVnf(wireMockServer);
- MockAAIVfModulePUT(wireMockServer, true);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfId", "768073c7-f41f-4822-9323-b75962763d74");
- variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC22-PCRF::module-1-0");
- variables.put("vfModuleModelName", "PCRF::module-0");
- String processId = invokeSubProcess("CreateAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "CreateAAIVfModule", "WorkflowException",processId);
- Assert.assertEquals(1002, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("Generic VNF Not Found"));
- logger.debug(exception.getErrorMessage());
- }
+ public static void MockAAICreateGenericVnf(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
+ .withRequestBody(containing("<service-id>00000000-0000-0000-0000-000000000000</service-id>"))
+ .willReturn(aResponse().withStatus(201)));
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
+ .withRequestBody(containing("<service-id>99999999-9999-9999-9999-999999999999</service-id>"))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
+ .withBodyFile("aaiFault.xml")));
+ }
- @Test
- public void TestCreateVfModuleFailure_5000() {
- new MockAAIGenericVnfSearch(wireMockServer);
- MockAAICreateGenericVnf(wireMockServer);
- MockAAIVfModulePUT(wireMockServer, true);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
- variables.put("serviceId", "99999999-9999-9999-9999-999999999999");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC21-PCRF::module-1-0");
- variables.put("vfModuleModelName", "STMTN5MMSC21-PCRF::model-1-0");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- String processId = invokeSubProcess("CreateAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "CreateAAIVfModule", "WorkflowException",processId);
- Assert.assertEquals(5000, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
- logger.debug(exception.getErrorMessage());
- }
+ // start of mocks used locally and by other VF Module unit tests
+ public static void MockAAIVfModulePUT(WireMockServer wireMockServer, boolean isCreate) {
+ wireMockServer
+ .stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*"))
+ .withRequestBody(containing("MMSC")).willReturn(aResponse().withStatus(isCreate ? 201 : 200)));
+ wireMockServer
+ .stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*"))
+ .withRequestBody(containing("PCRF")).willReturn(aResponse().withStatus(500)
+ .withHeader("Content-Type", "text/xml").withBodyFile("aaiFault.xml")));
+ wireMockServer.stubFor(
+ put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721"))
+ .willReturn(aResponse().withStatus(200)));
+ }
- public static void MockAAICreateGenericVnf(WireMockServer wireMockServer){
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
- .withRequestBody(containing("<service-id>00000000-0000-0000-0000-000000000000</service-id>"))
- .willReturn(aResponse()
- .withStatus(201)));
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
- .withRequestBody(containing("<service-id>99999999-9999-9999-9999-999999999999</service-id>"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
- }
-
- // start of mocks used locally and by other VF Module unit tests
- public static void MockAAIVfModulePUT(WireMockServer wireMockServer, boolean isCreate){
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*"))
- .withRequestBody(containing("MMSC"))
- .willReturn(aResponse()
- .withStatus(isCreate ? 201 : 200)));
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*"))
- .withRequestBody(containing("PCRF"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721"))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java
index 39a7e0c74b..b78c5b8aad 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java
@@ -26,12 +26,10 @@ import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPri
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetVfModuleId;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutVfModuleId;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse;
-
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Assert;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -45,91 +43,95 @@ import org.slf4j.LoggerFactory;
public class CreateAAIVfModuleVolumeGroupIT extends BaseIntegrationTest {
- Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleVolumeGroupIT.class);
-
- /**
- * Test the happy path through the flow.
- */
- @Test
- public void happyPath() throws IOException {
-
- logStart();
-
- String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
- MockGetGenericVnfByIdWithPriority(wireMockServer, "skask", "lukewarm", 200, "VfModularity/VfModule-lukewarm.xml", 2);
- MockPutVfModuleIdNoResponse(wireMockServer, "skask", "PCRF", "lukewarm");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
- invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
- logger.debug("Subflow response code: {}", responseCode);
- logger.debug("Subflow response: {}", response);
- Assert.assertEquals(200, responseCode.intValue());
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI returns a 404.
- */
- @Test
- public void badGet() throws IOException {
-
- logStart();
-
- String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
- MockGetVfModuleId(wireMockServer, "skask", ".*", "VfModularity/VfModule-supercool.xml", 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
- invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode");
- logger.debug("Subflow response code: {}", responseCode);
- logger.debug("Subflow response: {}", response);
- Assert.assertEquals(404, responseCode.intValue());
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
- */
- @Test
- public void badPatch() throws IOException {
-
- logStart();
-
- String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
- MockGetVfModuleId(wireMockServer, "skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200);
- MockPutVfModuleId(wireMockServer, "skask", "lukewarm", 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
- invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
- logger.debug("Subflow response code: {}", responseCode);
- logger.debug("Subflow response: {}", response);
- Assert.assertEquals(404, responseCode.intValue());
-
- logEnd();
- }
+ Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleVolumeGroupIT.class);
+
+ /**
+ * Test the happy path through the flow.
+ */
+ @Test
+ public void happyPath() throws IOException {
+
+ logStart();
+
+ String updateAAIVfModuleRequest =
+ FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
+ MockGetGenericVnfByIdWithPriority(wireMockServer, "skask", "lukewarm", 200,
+ "VfModularity/VfModule-lukewarm.xml", 2);
+ MockPutVfModuleIdNoResponse(wireMockServer, "skask", "PCRF", "lukewarm");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", "999-99-9999");
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
+ invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
+ Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
+ logger.debug("Subflow response code: {}", responseCode);
+ logger.debug("Subflow response: {}", response);
+ Assert.assertEquals(200, responseCode.intValue());
+
+ logEnd();
+ }
+
+ /**
+ * Test the case where the GET to AAI returns a 404.
+ */
+ @Test
+ public void badGet() throws IOException {
+
+ logStart();
+
+ String updateAAIVfModuleRequest =
+ FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
+ MockGetVfModuleId(wireMockServer, "skask", ".*", "VfModularity/VfModule-supercool.xml", 404);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", "999-99-9999");
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
+ invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse");
+ Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode");
+ logger.debug("Subflow response code: {}", responseCode);
+ logger.debug("Subflow response: {}", response);
+ Assert.assertEquals(404, responseCode.intValue());
+
+ logEnd();
+ }
+
+ /**
+ * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
+ */
+ @Test
+ public void badPatch() throws IOException {
+
+ logStart();
+
+ String updateAAIVfModuleRequest =
+ FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
+ MockGetVfModuleId(wireMockServer, "skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200);
+ MockPutVfModuleId(wireMockServer, "skask", "lukewarm", 404);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", "999-99-9999");
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
+ invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
+ Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
+ logger.debug("Subflow response code: {}", responseCode);
+ logger.debug("Subflow response: {}", response);
+ Assert.assertEquals(404, responseCode.intValue());
+
+ logEnd();
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DecomposeServiceIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DecomposeServiceIT.java
index 3d15a4b29b..0bfcbd370d 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DecomposeServiceIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DecomposeServiceIT.java
@@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
@@ -25,7 +25,6 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.test.Deployment;
import org.junit.Assert;
import org.junit.Ignore;
@@ -40,56 +39,55 @@ import org.onap.so.BaseIntegrationTest;
public class DecomposeServiceIT extends BaseIntegrationTest {
- public DecomposeServiceIT() throws IOException {
+ public DecomposeServiceIT() throws IOException {
+
+ }
- }
+ @Test
+ public void testDecomposeService_success() throws Exception {
+ MockGetServiceResourcesCatalogData(wireMockServer, "cmw-123-456-789", "1.0",
+ "/getCatalogServiceResourcesDataWithConfig.json");
- @Test
- public void testDecomposeService_success() throws Exception{
- MockGetServiceResourcesCatalogData(wireMockServer, "cmw-123-456-789", "1.0", "/getCatalogServiceResourcesDataWithConfig.json");
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
+ invokeSubProcess("DecomposeService", businessKey, variables);
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
- invokeSubProcess("DecomposeService", businessKey, variables);
+ waitForProcessEnd(businessKey, 10000);
- waitForProcessEnd(businessKey, 10000);
+ Assert.assertTrue(isProcessEnded(businessKey));
- Assert.assertTrue(isProcessEnded(businessKey));
+ }
- }
-
- //@Test
- @Test
- public void testDecomposeService_success_partial() throws Exception{
- MockGetServiceResourcesCatalogData(wireMockServer, "cmw-123-456-789", "1.0", "/getCatalogServiceResourcesDataNoNetwork.json");
+ // @Test
+ @Test
+ public void testDecomposeService_success_partial() throws Exception {
+ MockGetServiceResourcesCatalogData(wireMockServer, "cmw-123-456-789", "1.0",
+ "/getCatalogServiceResourcesDataNoNetwork.json");
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
- invokeSubProcess("DecomposeService", businessKey, variables);
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
+ invokeSubProcess("DecomposeService", businessKey, variables);
- waitForProcessEnd(businessKey, 10000);
+ waitForProcessEnd(businessKey, 10000);
- Assert.assertTrue(isProcessEnded(businessKey));
+ Assert.assertTrue(isProcessEnded(businessKey));
- }
+ }
- private void setVariablesSuccess(Map<String, Object> variables, String requestId, String siId) {
- variables.put("isDebugLogEnabled", "true");
- variables.put("mso-request-id", requestId);
- variables.put("msoRequestId", requestId);
- variables.put("serviceInstanceId",siId);
+ private void setVariablesSuccess(Map<String, Object> variables, String requestId, String siId) {
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("mso-request-id", requestId);
+ variables.put("msoRequestId", requestId);
+ variables.put("serviceInstanceId", siId);
- String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," +
- "\"modelInvariantUuid\": \"cmw-123-456-789\"," +
- "\"modelVersionId\": \"ab6478e5-ea33-3346-ac12-ab121484a3fe\"," +
- "\"modelName\": \"ServicevSAMP12\"," +
- "\"modelVersion\": \"1.0\"," +
- "}";
- variables.put("serviceModelInfo", serviceModelInfo);
+ String serviceModelInfo = "{ " + "\"modelType\": \"service\"," + "\"modelInvariantUuid\": \"cmw-123-456-789\","
+ + "\"modelVersionId\": \"ab6478e5-ea33-3346-ac12-ab121484a3fe\"," + "\"modelName\": \"ServicevSAMP12\","
+ + "\"modelVersion\": \"1.0\"," + "}";
+ variables.put("serviceModelInfo", serviceModelInfo);
- }
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java
index 99e4b8cbde..cac237aec4 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java
@@ -16,14 +16,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Assert;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -36,245 +35,227 @@ import org.slf4j.LoggerFactory;
*/
public class DeleteAAIVfModuleIT extends BaseIntegrationTest {
- private static final String EOL = "\n";
-
- Logger logger = LoggerFactory.getLogger(DeleteAAIVfModuleIT.class);
-
- @Test
- public void TestDeleteGenericVnfSuccess_200() {
- // delete the Base Module and Generic Vnf
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73
- new MockAAIGenericVnfSearch(wireMockServer);
- new MockAAIDeleteGenericVnf(wireMockServer);
- new MockAAIDeleteVfModule(wireMockServer);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("DeleteAAIVfModuleRequest","<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\"> <request-info> <action>DELETE_VF_MODULE</action> <source>PORTAL</source> </request-info> <vnf-inputs> <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id> <vnf-name>STMTN5MMSC21</vnf-name> <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id> <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name> </vnf-inputs> <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/> </vnf-request>");
- String processId = invokeSubProcess("DeleteAAIVfModule", variables);
- String response = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule", "DAAIVfMod_deleteGenericVnfResponseCode",processId);
- String responseCode = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule", "DAAIVfMod_deleteGenericVnfResponseCode",processId);
- Assert.assertEquals("200", responseCode);
- logger.debug(response);
- }
+ private static final String EOL = "\n";
+
+ Logger logger = LoggerFactory.getLogger(DeleteAAIVfModuleIT.class);
+
+ @Test
+ public void TestDeleteGenericVnfSuccess_200() {
+ // delete the Base Module and Generic Vnf
+ // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("DeleteAAIVfModuleRequest",
+ "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\"> <request-info> <action>DELETE_VF_MODULE</action> <source>PORTAL</source> </request-info> <vnf-inputs> <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id> <vnf-name>STMTN5MMSC21</vnf-name> <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id> <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name> </vnf-inputs> <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/> </vnf-request>");
+ String processId = invokeSubProcess("DeleteAAIVfModule", variables);
+ String response = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule",
+ "DAAIVfMod_deleteGenericVnfResponseCode", processId);
+ String responseCode = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule",
+ "DAAIVfMod_deleteGenericVnfResponseCode", processId);
+ Assert.assertEquals("200", responseCode);
+ logger.debug(response);
+ }
+
+ @Test
+ public void TestDeleteVfModuleSuccess_200() {
+ // delete Add-on Vf Module for existing Generic Vnf
+ // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a75
+ String request = "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL
+ + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
+ + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL
+ + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL + " </vnf-inputs>" + EOL
+ + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>"
+ + EOL;
+
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("DeleteAAIVfModuleRequest", request);
+ String processId = invokeSubProcess("DeleteAAIVfModule", variables);
+ String response = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule",
+ "DAAIVfMod_deleteVfModuleResponseCode", processId);
+ String responseCode = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule",
+ "DAAIVfMod_deleteVfModuleResponseCode", processId);
+ Assert.assertEquals("200", responseCode);
+ logger.debug(response);
+ }
+
+ @Test
+ public void TestQueryGenericVnfFailure_5000() {
+ // query Generic Vnf failure (non-404) with A&AI
+ // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c723, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a71
+ String request = "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL
+ + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
+ + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c723</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC23</vnf-name>" + EOL
+ + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a71</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL + " </vnf-inputs>" + EOL
+ + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>"
+ + EOL;
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("DeleteAAIVfModuleRequest", request);
+ String processId = invokeSubProcess("DeleteAAIVfModule", variables);
+ WorkflowException exception =
+ BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException", processId);
+ Assert.assertEquals(5000, exception.getErrorCode());
+ Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
+ logger.debug(exception.getErrorMessage());
+ }
+
+ @Test
+ public void TestQueryGenericVnfFailure_1002() {
+ // attempt to delete Vf Module for Generic Vnf that does not exist (A&AI returns 404)
+ // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c722, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a72
+ String request = "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL
+ + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
+ + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c722</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC22</vnf-name>" + EOL
+ + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a72</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC22-MMSC::module-1-0</vf-module-name>" + EOL + " </vnf-inputs>" + EOL
+ + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>"
+ + EOL;
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("DeleteAAIVfModuleRequest", request);
+ String processId = invokeSubProcess("DeleteAAIVfModule", variables);
+ WorkflowException exception =
+ BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException", processId);
+ Assert.assertEquals(1002, exception.getErrorCode());
+ Assert.assertEquals(true, exception.getErrorMessage().contains("Generic VNF Not Found"));
+ logger.debug(exception.getErrorMessage());
+ }
+
+ @Test
+ public void TestDeleteGenericVnfFailure_5000() {
+ // A&AI failure (non-200) when attempting to delete a Generic Vnf
+ // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c718, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a78
+ String request = "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL
+ + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
+ + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC18</vnf-name>" + EOL
+ + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL + " </vnf-inputs>" + EOL
+ + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>"
+ + EOL;
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("DeleteAAIVfModuleRequest", request);
+ String processId = invokeSubProcess("DeleteAAIVfModule", variables);
+ WorkflowException exception =
+ BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException", processId);
+ Assert.assertEquals(5000, exception.getErrorCode());
+ Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
+ logger.debug(exception.getErrorMessage());
+ }
- @Test
- public void TestDeleteVfModuleSuccess_200() {
- // delete Add-on Vf Module for existing Generic Vnf
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a75
- String request =
- "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
+ @Test
+ public void TestDeleteVfModuleFailure_5000() {
+ // A&AI failure (non-200) when attempting to delete a Vf Module
+ // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c719, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a77
+ String request = "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL
+ + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
+ + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC19</vnf-name>" + EOL
+ + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL + " </vnf-inputs>" + EOL
+ + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>"
+ + EOL;
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
- new MockAAIGenericVnfSearch(wireMockServer);
- new MockAAIDeleteGenericVnf(wireMockServer);
- new MockAAIDeleteVfModule(wireMockServer);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("DeleteAAIVfModuleRequest",request);
- String processId = invokeSubProcess("DeleteAAIVfModule", variables);
- String response = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule", "DAAIVfMod_deleteVfModuleResponseCode",processId);
- String responseCode = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule", "DAAIVfMod_deleteVfModuleResponseCode",processId);
- Assert.assertEquals("200", responseCode);
- logger.debug(response);
- }
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("DeleteAAIVfModuleRequest", request);
+ String processId = invokeSubProcess("DeleteAAIVfModule", variables);
+ WorkflowException exception =
+ BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException", processId);
+ Assert.assertEquals(5000, exception.getErrorCode());
+ Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
+ logger.debug(exception.getErrorMessage());
+ }
- @Test
- public void TestQueryGenericVnfFailure_5000() {
- // query Generic Vnf failure (non-404) with A&AI
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c723, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a71
- String request =
- "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c723</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC23</vnf-name>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a71</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
- new MockAAIGenericVnfSearch(wireMockServer);
- new MockAAIDeleteGenericVnf(wireMockServer);
- new MockAAIDeleteVfModule(wireMockServer);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("DeleteAAIVfModuleRequest",request);
- String processId = invokeSubProcess("DeleteAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException",processId);
- Assert.assertEquals(5000, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
- logger.debug(exception.getErrorMessage());
- }
+ @Test
+ public void TestDeleteVfModuleFailure_1002_1() {
+ // failure attempting to delete Base Module when not the last Vf Module
+ // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a74
+ String request = "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL
+ + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
+ + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL
+ + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL + " </vnf-inputs>" + EOL
+ + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>"
+ + EOL;
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
- @Test
- public void TestQueryGenericVnfFailure_1002() {
- // attempt to delete Vf Module for Generic Vnf that does not exist (A&AI returns 404)
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c722, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a72
- String request =
- "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c722</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC22</vnf-name>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a72</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC22-MMSC::module-1-0</vf-module-name>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
- new MockAAIGenericVnfSearch(wireMockServer);
- new MockAAIDeleteGenericVnf(wireMockServer);
- new MockAAIDeleteVfModule(wireMockServer);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("DeleteAAIVfModuleRequest",request);
- String processId = invokeSubProcess("DeleteAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException",processId);
- Assert.assertEquals(1002, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("Generic VNF Not Found"));
- logger.debug(exception.getErrorMessage());
- }
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("DeleteAAIVfModuleRequest", request);
+ String processId = invokeSubProcess("DeleteAAIVfModule", variables);
+ WorkflowException exception =
+ BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException", processId);
+ Assert.assertEquals(1002, exception.getErrorCode());
+ Assert.assertEquals(true, exception.getErrorMessage().contains("is Base Module, not Last Module"));
+ logger.debug(exception.getErrorMessage());
+ }
- @Test
- public void TestDeleteGenericVnfFailure_5000() {
- // A&AI failure (non-200) when attempting to delete a Generic Vnf
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c718, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a78
- String request =
- "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC18</vnf-name>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
- new MockAAIGenericVnfSearch(wireMockServer);
- new MockAAIDeleteGenericVnf(wireMockServer);
- new MockAAIDeleteVfModule(wireMockServer);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("DeleteAAIVfModuleRequest",request);
- String processId = invokeSubProcess("DeleteAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException",processId);
- Assert.assertEquals(5000, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
- logger.debug(exception.getErrorMessage());
- }
-
- @Test
- public void TestDeleteVfModuleFailure_5000() {
- // A&AI failure (non-200) when attempting to delete a Vf Module
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c719, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a77
- String request =
- "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC19</vnf-name>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
- new MockAAIGenericVnfSearch(wireMockServer);
- new MockAAIDeleteGenericVnf(wireMockServer);
- new MockAAIDeleteVfModule(wireMockServer);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("DeleteAAIVfModuleRequest",request);
- String processId = invokeSubProcess("DeleteAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException",processId);
- Assert.assertEquals(5000, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
- logger.debug(exception.getErrorMessage());
- }
-
- @Test
- public void TestDeleteVfModuleFailure_1002_1() {
- // failure attempting to delete Base Module when not the last Vf Module
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a74
- String request =
- "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
- new MockAAIGenericVnfSearch(wireMockServer);
- new MockAAIDeleteGenericVnf(wireMockServer);
- new MockAAIDeleteVfModule(wireMockServer);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("DeleteAAIVfModuleRequest",request);
- String processId = invokeSubProcess("DeleteAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException",processId);
- Assert.assertEquals(1002, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("is Base Module, not Last Module"));
- logger.debug(exception.getErrorMessage());
- }
+ @Test
+ public void TestDeleteVfModuleFailure_1002_2() {
+ // failure attempting to delete a Vf Module that does not exist (A&AI returns 404)
+ // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a76
+ new MockAAIGenericVnfSearch(wireMockServer);
+ new MockAAIDeleteGenericVnf(wireMockServer);
+ new MockAAIDeleteVfModule(wireMockServer);
- @Test
- public void TestDeleteVfModuleFailure_1002_2() {
- // failure attempting to delete a Vf Module that does not exist (A&AI returns 404)
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a76
- new MockAAIGenericVnfSearch(wireMockServer);
- new MockAAIDeleteGenericVnf(wireMockServer);
- new MockAAIDeleteVfModule(wireMockServer);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("DeleteAAIVfModuleRequest","<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\"> <request-info> <action>DELETE_VF_MODULE</action> <source>PORTAL</source> </request-info> <vnf-inputs> <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id> <vnf-name>STMTN5MMSC20</vnf-name> <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id> <vf-module-name>STMTN5MMSC20-MMSC::module-2-0</vf-module-name> </vnf-inputs> <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/> </vnf-request>");
- String processId = invokeSubProcess("DeleteAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException",processId);
- Assert.assertEquals(1002, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("does not exist for Generic Vnf Id"));
- logger.debug(exception.getErrorMessage());
- }
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("DeleteAAIVfModuleRequest",
+ "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\"> <request-info> <action>DELETE_VF_MODULE</action> <source>PORTAL</source> </request-info> <vnf-inputs> <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id> <vnf-name>STMTN5MMSC20</vnf-name> <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id> <vf-module-name>STMTN5MMSC20-MMSC::module-2-0</vf-module-name> </vnf-inputs> <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/> </vnf-request>");
+ String processId = invokeSubProcess("DeleteAAIVfModule", variables);
+ WorkflowException exception =
+ BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException", processId);
+ Assert.assertEquals(1002, exception.getErrorCode());
+ Assert.assertEquals(true, exception.getErrorMessage().contains("does not exist for Generic Vnf Id"));
+ logger.debug(exception.getErrorMessage());
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java
index 88f8e5deb7..59f46b2a93 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
@@ -26,11 +26,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.onap.so.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Assert;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -42,185 +40,164 @@ import org.slf4j.LoggerFactory;
*/
public class FalloutHandlerIT extends BaseIntegrationTest {
-
- Logger logger = LoggerFactory.getLogger(FalloutHandlerIT.class);
-
-
- private void setupMocks() {
- wireMockServer.stubFor(post(urlEqualTo("/dbadapters/AttRequestsDbAdapter"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody("<DbTag>Notified</DbTag>")));
- wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody("<DbTag>Notified</DbTag>")));
- }
-
- private String executeFlow(String inputRequestFile) throws InterruptedException {
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("FalloutHandlerRequest",inputRequestFile); variables.put("mso-request-id", UUID.randomUUID().toString());
- String processId = invokeSubProcess( "FalloutHandler", variables);
- waitForWorkflowToFinish(processEngine,processId);
- logEnd();
- return processId;
- }
-
- @Test
- public void msoFalloutHandlerWithNotificationurl_200() throws Exception{
- //Setup Mocks
- setupMocks();
- //Execute Flow
- String processId = executeFlow(gMsoFalloutHandlerWithNotificationurl());
- //Verify Error
- String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode",processId);
- Assert.assertEquals("200", FH_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator",processId));
- }
-
- public String gMsoFalloutHandlerWithNotificationurl() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
- + " <ns7:request-information>"
- + " <ns7:request-id>1020_STUW105_5002</ns7:request-id>"
- + " <ns7:request-action>requestAction</ns7:request-action>"
- + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
- + " <ns7:source>source</ns7:source>"
- + " <ns7:notification-url>http://localhost:28090/CCD/StatusNotification</ns7:notification-url>"
- + " <ns7:order-number>10205000</ns7:order-number>"
- + " <ns7:order-version>1</ns7:order-version>"
- + " </ns7:request-information>"
- + " <sdncadapterworkflow:WorkflowException>"
- + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
- + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
- + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
- + " </sdncadapterworkflow:WorkflowException>"
- + "</sdncadapterworkflow:FalloutHandlerRequest>";
-
- return xml;
-
- }
-
-
-
-
- @Test
- public void msoFalloutHandlerWithNoNotificationurl() throws Exception{
-
- //Setup Mocks
- setupMocks();
- //Execute Flow
- executeFlow(gMsoFalloutHandlerWithNoNotificationurl());
- //Verify Error
- String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
- Assert.assertEquals("200", FH_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
- }
-
- public String gMsoFalloutHandlerWithNoNotificationurl() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
- + " <ns7:request-information>"
- + " <ns7:request-id>1020_STUW105_5002</ns7:request-id>"
- + " <ns7:request-action>requestAction</ns7:request-action>"
- + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
- + " <ns7:source>source</ns7:source>"
- + " <ns7:notification-url></ns7:notification-url>"
- + " <ns7:order-number>10205000</ns7:order-number>"
- + " <ns7:order-version>1</ns7:order-version>"
- + " </ns7:request-information>"
- + " <sdncadapterworkflow:WorkflowException>"
- + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
- + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
- + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
- + " </sdncadapterworkflow:WorkflowException>"
- + "</sdncadapterworkflow:FalloutHandlerRequest>";
-
- return xml;
- }
-
- @Test
-
- public void msoFalloutHandlerWithNotificationurlNoRequestId() throws Exception{
- String method = getClass().getSimpleName() + "." + new Object() {
- }.getClass().getEnclosingMethod().getName();
- logger.debug("STARTED TEST: {}", method);
- //Setup Mocks
- setupMocks();
- //Execute Flow
- executeFlow(gMsoFalloutHandlerWithNotificationurlNoRequestId());
- //Verify Error
- String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
- Assert.assertEquals("200", FH_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
- }
-
- public String gMsoFalloutHandlerWithNotificationurlNoRequestId() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
- + " <ns7:request-information>"
- + " <ns7:request-id></ns7:request-id>"
- + " <ns7:request-action>requestAction</ns7:request-action>"
- + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
- + " <ns7:source>source</ns7:source>"
- + " <ns7:notification-url>www.test.com</ns7:notification-url>"
- + " <ns7:order-number>10205000</ns7:order-number>"
- + " <ns7:order-version>1</ns7:order-version>"
- + " </ns7:request-information>"
- + " <sdncadapterworkflow:WorkflowException>"
- + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
- + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
- + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
- + " </sdncadapterworkflow:WorkflowException>"
- + "</sdncadapterworkflow:FalloutHandlerRequest>";
-
- return xml;
- }
-
- @Test
-
- public void msoFalloutHandlerWithNoNotificationurlNoRequestId() throws Exception{
- String method = getClass().getSimpleName() + "." + new Object() {
- }.getClass().getEnclosingMethod().getName();
- logger.debug("STARTED TEST: {}", method);
- //Setup Mocks
- setupMocks();
- //Execute Flow
- executeFlow(gMsoFalloutHandlerWithNoNotificationurlNoRequestId());
- //Verify Error
- String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
- Assert.assertEquals("200", FH_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
- }
-
- public String gMsoFalloutHandlerWithNoNotificationurlNoRequestId() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
- + " <ns7:request-information>"
- + " <ns7:request-id></ns7:request-id>"
- + " <ns7:request-action>requestAction</ns7:request-action>"
- + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
- + " <ns7:source>source</ns7:source>"
- + " <ns7:notification-url></ns7:notification-url>"
- + " <ns7:order-number>10205000</ns7:order-number>"
- + " <ns7:order-version>1</ns7:order-version>"
- + " </ns7:request-information>"
- + " <sdncadapterworkflow:WorkflowException>"
- + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
- + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
- + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
- + " </sdncadapterworkflow:WorkflowException>"
- + "</sdncadapterworkflow:FalloutHandlerRequest>";
-
- return xml;
- }
-
+
+ Logger logger = LoggerFactory.getLogger(FalloutHandlerIT.class);
+
+
+ private void setupMocks() {
+ wireMockServer.stubFor(post(urlEqualTo("/dbadapters/AttRequestsDbAdapter")).willReturn(aResponse()
+ .withStatus(200).withHeader("Content-Type", "text/xml").withBody("<DbTag>Notified</DbTag>")));
+ wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter")).willReturn(aResponse().withStatus(200)
+ .withHeader("Content-Type", "text/xml").withBody("<DbTag>Notified</DbTag>")));
+ }
+
+ private String executeFlow(String inputRequestFile) throws InterruptedException {
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("FalloutHandlerRequest", inputRequestFile);
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ String processId = invokeSubProcess("FalloutHandler", variables);
+ waitForWorkflowToFinish(processEngine, processId);
+ logEnd();
+ return processId;
+ }
+
+ @Test
+ public void msoFalloutHandlerWithNotificationurl_200() throws Exception {
+ // Setup Mocks
+ setupMocks();
+ // Execute Flow
+ String processId = executeFlow(gMsoFalloutHandlerWithNotificationurl());
+ // Verify Error
+ String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode", processId);
+ Assert.assertEquals("200", FH_ResponseCode);
+ Assert.assertTrue(
+ (boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator", processId));
+ }
+
+ public String gMsoFalloutHandlerWithNotificationurl() {
+ // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
+ String xml = ""
+ + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
+ + " <ns7:request-information>" + " <ns7:request-id>1020_STUW105_5002</ns7:request-id>"
+ + " <ns7:request-action>requestAction</ns7:request-action>"
+ + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
+ + " <ns7:source>source</ns7:source>"
+ + " <ns7:notification-url>http://localhost:28090/CCD/StatusNotification</ns7:notification-url>"
+ + " <ns7:order-number>10205000</ns7:order-number>"
+ + " <ns7:order-version>1</ns7:order-version>" + " </ns7:request-information>"
+ + " <sdncadapterworkflow:WorkflowException>"
+ + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
+ + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
+ + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
+ + " </sdncadapterworkflow:WorkflowException>" + "</sdncadapterworkflow:FalloutHandlerRequest>";
+
+ return xml;
+
+ }
+
+
+
+ @Test
+ public void msoFalloutHandlerWithNoNotificationurl() throws Exception {
+
+ // Setup Mocks
+ setupMocks();
+ // Execute Flow
+ executeFlow(gMsoFalloutHandlerWithNoNotificationurl());
+ // Verify Error
+ String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
+ Assert.assertEquals("200", FH_ResponseCode);
+ Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
+ }
+
+ public String gMsoFalloutHandlerWithNoNotificationurl() {
+ // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
+ String xml = ""
+ + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
+ + " <ns7:request-information>" + " <ns7:request-id>1020_STUW105_5002</ns7:request-id>"
+ + " <ns7:request-action>requestAction</ns7:request-action>"
+ + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
+ + " <ns7:source>source</ns7:source>" + " <ns7:notification-url></ns7:notification-url>"
+ + " <ns7:order-number>10205000</ns7:order-number>"
+ + " <ns7:order-version>1</ns7:order-version>" + " </ns7:request-information>"
+ + " <sdncadapterworkflow:WorkflowException>"
+ + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
+ + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
+ + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
+ + " </sdncadapterworkflow:WorkflowException>" + "</sdncadapterworkflow:FalloutHandlerRequest>";
+
+ return xml;
+ }
+
+ @Test
+
+ public void msoFalloutHandlerWithNotificationurlNoRequestId() throws Exception {
+ String method = getClass().getSimpleName() + "." + new Object() {}.getClass().getEnclosingMethod().getName();
+ logger.debug("STARTED TEST: {}", method);
+ // Setup Mocks
+ setupMocks();
+ // Execute Flow
+ executeFlow(gMsoFalloutHandlerWithNotificationurlNoRequestId());
+ // Verify Error
+ String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
+ Assert.assertEquals("200", FH_ResponseCode);
+ Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
+ }
+
+ public String gMsoFalloutHandlerWithNotificationurlNoRequestId() {
+ // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
+ String xml = ""
+ + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
+ + " <ns7:request-information>" + " <ns7:request-id></ns7:request-id>"
+ + " <ns7:request-action>requestAction</ns7:request-action>"
+ + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
+ + " <ns7:source>source</ns7:source>"
+ + " <ns7:notification-url>www.test.com</ns7:notification-url>"
+ + " <ns7:order-number>10205000</ns7:order-number>"
+ + " <ns7:order-version>1</ns7:order-version>" + " </ns7:request-information>"
+ + " <sdncadapterworkflow:WorkflowException>"
+ + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
+ + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
+ + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
+ + " </sdncadapterworkflow:WorkflowException>" + "</sdncadapterworkflow:FalloutHandlerRequest>";
+
+ return xml;
+ }
+
+ @Test
+
+ public void msoFalloutHandlerWithNoNotificationurlNoRequestId() throws Exception {
+ String method = getClass().getSimpleName() + "." + new Object() {}.getClass().getEnclosingMethod().getName();
+ logger.debug("STARTED TEST: {}", method);
+ // Setup Mocks
+ setupMocks();
+ // Execute Flow
+ executeFlow(gMsoFalloutHandlerWithNoNotificationurlNoRequestId());
+ // Verify Error
+ String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
+ Assert.assertEquals("200", FH_ResponseCode);
+ Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
+ }
+
+ public String gMsoFalloutHandlerWithNoNotificationurlNoRequestId() {
+ // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
+ String xml = ""
+ + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
+ + " <ns7:request-information>" + " <ns7:request-id></ns7:request-id>"
+ + " <ns7:request-action>requestAction</ns7:request-action>"
+ + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
+ + " <ns7:source>source</ns7:source>" + " <ns7:notification-url></ns7:notification-url>"
+ + " <ns7:order-number>10205000</ns7:order-number>"
+ + " <ns7:order-version>1</ns7:order-version>" + " </ns7:request-information>"
+ + " <sdncadapterworkflow:WorkflowException>"
+ + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
+ + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
+ + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
+ + " </sdncadapterworkflow:WorkflowException>" + "</sdncadapterworkflow:FalloutHandlerRequest>";
+
+ return xml;
+ }
+
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenerateVfModuleNameIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenerateVfModuleNameIT.java
index 7299e0602e..ff0b318df9 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenerateVfModuleNameIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenerateVfModuleNameIT.java
@@ -22,10 +22,8 @@ package org.onap.so.bpmn.common;
import static org.junit.Assert.assertNotNull;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfById;
-
import java.util.HashMap;
import java.util.Map;
-
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.test.Deployment;
import org.junit.Ignore;
@@ -37,42 +35,37 @@ import org.onap.so.BaseIntegrationTest;
*/
public class GenerateVfModuleNameIT extends BaseIntegrationTest {
- private static final String EOL = "\n";
-
- @Test
- public void TestGenerateVfModuleNameSuvvess() {
- //
- String request =
- "<vnf-request xmlns=\"http://ecomp.att.com/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>CREATE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-name>STMTN5MMSC22</vnf-name>" + EOL +
- " <vf-module-name>STMTN5MMSC22-MMSC::module-0-0</vf-module-name>" + EOL +
- " <vf-module-model-name>MMSC::module-0</vf-module-model-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <service-id>00000000-0000-0000-0000-000000000000</service-id>" + EOL +
- " <aic-node-clli>MDTWNJ21</aic-node-clli>" + EOL +
- " <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://ecomp.att.com/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
+ private static final String EOL = "\n";
+
+ @Test
+ public void TestGenerateVfModuleNameSuvvess() {
+ //
+ String request =
+ "<vnf-request xmlns=\"http://ecomp.att.com/mso/infra/vnf-request/v1\">" + EOL + " <request-info>" + EOL
+ + " <action>CREATE_VF_MODULE</action>" + EOL + " <source>PORTAL</source>" + EOL
+ + " </request-info>" + EOL + " <vnf-inputs>" + EOL + " <vnf-name>STMTN5MMSC22</vnf-name>"
+ + EOL + " <vf-module-name>STMTN5MMSC22-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <vf-module-model-name>MMSC::module-0</vf-module-model-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <service-id>00000000-0000-0000-0000-000000000000</service-id>" + EOL
+ + " <aic-node-clli>MDTWNJ21</aic-node-clli>" + EOL
+ + " <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id>" + EOL + " </vnf-inputs>" + EOL
+ + " <vnf-params xmlns:tns=\"http://ecomp.att.com/mso/infra/vnf-request/v1\"/>" + EOL
+ + "</vnf-request>" + EOL;
+
+ MockGetGenericVnfById(wireMockServer, ".*", "GenericFlows/getGenericVnfByNameResponse.xml");
+ RuntimeService runtimeService = processEngine.getRuntimeService();
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("vnfName", "STMTN5MMSC20");
+ variables.put("vfModuleLabel", "ModuleLabel1");
+ variables.put("personaModelId", "extrovert");
+ variables.put("vnfId", "12345678-f41f-4822-9323-b75962763d74");
+
+ runtimeService.startProcessInstanceByKey("GenerateVfModuleName", variables);
+ String response = BPMNUtil.getVariable(processEngine, "GenerateVfModuleName", "vfModuleName");
- MockGetGenericVnfById(wireMockServer, ".*", "GenericFlows/getGenericVnfByNameResponse.xml");
- RuntimeService runtimeService = processEngine.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("isDebugLogEnabled","true");
- variables.put("vnfName", "STMTN5MMSC20");
- variables.put("vfModuleLabel", "ModuleLabel1");
- variables.put("personaModelId", "extrovert");
- variables.put("vnfId", "12345678-f41f-4822-9323-b75962763d74");
-
- runtimeService.startProcessInstanceByKey("GenerateVfModuleName", variables);
- String response = BPMNUtil.getVariable(processEngine, "GenerateVfModuleName", "vfModuleName");
-
- assertNotNull(response);
- }
+ assertNotNull(response);
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java
index 53d29c51bf..97a09d84aa 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java
@@ -23,12 +23,10 @@
package org.onap.so.bpmn.common;
import static org.onap.so.bpmn.mock.StubResponseDatabase.MockPostRequestDB;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.task.Task;
import org.camunda.bpm.engine.task.TaskQuery;
@@ -42,58 +40,58 @@ import org.slf4j.LoggerFactory;
* Unit test for RainyDayHandler.bpmn.
*/
public class ManualHandlingIT extends BaseIntegrationTest {
- Logger logger = LoggerFactory.getLogger(ManualHandlingIT.class);
-
- @Test
- public void TestManualHandlingSuccess() {
- MockPostRequestDB(wireMockServer);
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("msoRequestId", "testRequestId");
- variables.put("serviceType", "X");
- variables.put("vnfType", "Y");
- variables.put("currentActivity", "BB1");
- variables.put("workStep", "1");
- variables.put("failedActivity", "AAI");
- variables.put("vnfName", "vSAMP12");
- variables.put("errorCode", "123");
- variables.put("errorText", "update failed");
- variables.put("validResponses", "Rollback");
- variables.put("vnfName", "vSAMP1");
-
-
- String businessKey = UUID.randomUUID().toString();
- invokeSubProcess("ManualHandling", businessKey, variables);
-
- try {
- Thread.sleep(5);
- } catch (Exception e) {
-
- }
-
- TaskService taskService = processEngine.getTaskService();
-
- TaskQuery q = taskService.createTaskQuery();
-
- List<Task> tasks = q.orderByTaskCreateTime().asc().list();
-
- for (Task task : tasks) {
- logger.debug("TASK ID: {}", task.getId());
- logger.debug("TASK NAME: {}", task.getName());
-
- try {
- logger.debug("Completing the task");
- Map<String,Object> completeVariables = new HashMap<>();
- completeVariables.put("responseValue", "skip");
- taskService.complete(task.getId(), completeVariables);
- } catch(Exception e) {
- logger.debug("GOT EXCEPTION: {}", e.getMessage());
- }
- }
-
- waitForProcessEnd(businessKey, 100000);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- }
+ Logger logger = LoggerFactory.getLogger(ManualHandlingIT.class);
+
+ @Test
+ public void TestManualHandlingSuccess() {
+ MockPostRequestDB(wireMockServer);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("msoRequestId", "testRequestId");
+ variables.put("serviceType", "X");
+ variables.put("vnfType", "Y");
+ variables.put("currentActivity", "BB1");
+ variables.put("workStep", "1");
+ variables.put("failedActivity", "AAI");
+ variables.put("vnfName", "vSAMP12");
+ variables.put("errorCode", "123");
+ variables.put("errorText", "update failed");
+ variables.put("validResponses", "Rollback");
+ variables.put("vnfName", "vSAMP1");
+
+
+ String businessKey = UUID.randomUUID().toString();
+ invokeSubProcess("ManualHandling", businessKey, variables);
+
+ try {
+ Thread.sleep(5);
+ } catch (Exception e) {
+
+ }
+
+ TaskService taskService = processEngine.getTaskService();
+
+ TaskQuery q = taskService.createTaskQuery();
+
+ List<Task> tasks = q.orderByTaskCreateTime().asc().list();
+
+ for (Task task : tasks) {
+ logger.debug("TASK ID: {}", task.getId());
+ logger.debug("TASK NAME: {}", task.getName());
+
+ try {
+ logger.debug("Completing the task");
+ Map<String, Object> completeVariables = new HashMap<>();
+ completeVariables.put("responseValue", "skip");
+ taskService.complete(task.getId(), completeVariables);
+ } catch (Exception e) {
+ logger.debug("GOT EXCEPTION: {}", e.getMessage());
+ }
+ }
+
+ waitForProcessEnd(businessKey, 100000);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java
index 052fd5dc94..45ef0add2b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java
@@ -23,18 +23,16 @@ package org.onap.so.bpmn.common;
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.urlMatching;
-
import com.github.tomakehurst.wiremock.WireMockServer;
public class MockAAIDeleteGenericVnf {
- public MockAAIDeleteGenericVnf(WireMockServer wireMockServer){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/[?]resource-version=0000021"))
- .willReturn(aResponse()
- .withStatus(200)));
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/[?]resource-version=0000018"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
- }
+ public MockAAIDeleteGenericVnf(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/[?]resource-version=0000021"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/[?]resource-version=0000018"))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
+ .withBodyFile("aaiFault.xml")));
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java
index 1cbe0b9244..f405fc943b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java
@@ -24,31 +24,30 @@ 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.get;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import com.github.tomakehurst.wiremock.WireMockServer;
public class MockAAIDeleteVfModule {
-
- public MockAAIDeleteVfModule(WireMockServer wireMockServer)
- {
- wireMockServer.stubFor(delete(urlMatching(
- "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73/[?]resource-version=0000073"))
- .willReturn(aResponse().withStatus(200)));
- wireMockServer.stubFor(delete(urlMatching(
- "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a75/[?]resource-version=0000075"))
- .willReturn(aResponse().withStatus(200)));
- wireMockServer.stubFor(delete(urlMatching(
- "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a78/[?]resource-version=0000078"))
- .willReturn(aResponse().withStatus(200)));
- wireMockServer.stubFor(delete(urlMatching(
- "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a77/[?]resource-version=0000077"))
- .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*"))
- .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml")));
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
- .willReturn(aResponse().withStatus(200)));
- }
+ public MockAAIDeleteVfModule(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73/[?]resource-version=0000073"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a75/[?]resource-version=0000075"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a78/[?]resource-version=0000078"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a77/[?]resource-version=0000077"))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
+ .withBodyFile("aaiFault.xml")));
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml")));
+
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
+ .willReturn(aResponse().withStatus(200)));
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java
index 1d6337ffc4..a33268efbe 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java
@@ -23,319 +23,219 @@ package org.onap.so.bpmn.common;
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.urlMatching;
-
import com.github.tomakehurst.wiremock.WireMockServer;
public class MockAAIGenericVnfSearch {
-
- private static final String EOL = "\n";
- public MockAAIGenericVnfSearch(WireMockServer wireMockServer){
- String body;
-
- // The following stubs are for CreateAAIVfModule and UpdateAAIVfModule
-
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC23&depth=1"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
-
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC22&depth=1"))
- .willReturn(aResponse()
- .withStatus(404)
- .withHeader("Content-Type", "text/xml")
- .withBody("Generic VNF Not Found")));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/768073c7-f41f-4822-9323-b75962763d74[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(404)
- .withHeader("Content-Type", "text/xml")
- .withBody("Generic VNF Not Found")));
-
- body =
- "<generic-vnf xmlns=\"http://com.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>1508691</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>1508692</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC21&depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>1508691</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>1508692</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>false</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>1508692</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC20&depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- // The following stubs are for DeleteAAIVfModule
-
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c723[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
-
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c722[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(404)
- .withHeader("Content-Type", "text/xml")
- .withBody("Generic VNF Not Found")));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000021</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000073</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000020</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000074</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>false</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000075</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC19</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000019</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC19-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000076</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>false</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000077</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC18</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000018</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000078</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000021</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000073</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- }
+ private static final String EOL = "\n";
+
+ public MockAAIGenericVnfSearch(WireMockServer wireMockServer) {
+ String body;
+
+ // The following stubs are for CreateAAIVfModule and UpdateAAIVfModule
+
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC23&depth=1"))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
+ .withBodyFile("aaiFault.xml")));
+
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC22&depth=1"))
+ .willReturn(aResponse().withStatus(404).withHeader("Content-Type", "text/xml")
+ .withBody("Generic VNF Not Found")));
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/768073c7-f41f-4822-9323-b75962763d74[?]depth=1"))
+ .willReturn(aResponse().withStatus(404).withHeader("Content-Type", "text/xml")
+ .withBody("Generic VNF Not Found")));
+
+ body = "<generic-vnf xmlns=\"http://com.aai.inventory/v7\">" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>1508691</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>1508692</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC21&depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ body = "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL
+ + " <vnf-id>2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>1508691</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>1508692</resource-version>" + EOL + " </vf-module>" + EOL
+ + " <vf-module>" + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>"
+ + EOL + " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>false</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>1508692</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC20&depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ // The following stubs are for DeleteAAIVfModule
+
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c723[?]depth=1"))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
+ .withBodyFile("aaiFault.xml")));
+
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c722[?]depth=1"))
+ .willReturn(aResponse().withStatus(404).withHeader("Content-Type", "text/xml")
+ .withBody("Generic VNF Not Found")));
+
+ body = "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>0000021</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000073</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ body = "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>0000020</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000074</resource-version>" + EOL + " </vf-module>" + EOL
+ + " <vf-module>" + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>"
+ + EOL + " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>false</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000075</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ body = "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC19</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>0000019</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC19-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000076</resource-version>" + EOL + " </vf-module>" + EOL
+ + " <vf-module>" + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>"
+ + EOL + " <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>false</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000077</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ body = "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC18</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>0000018</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000078</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ body = "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>0000021</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000073</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockLoggerDelegate.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockLoggerDelegate.java
index 6a9ff2a4a8..0154f2eae7 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockLoggerDelegate.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/MockLoggerDelegate.java
@@ -24,12 +24,12 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
public class MockLoggerDelegate implements JavaDelegate {
- @Override
- public void execute(DelegateExecution execution) throws Exception {
- System.out.println("\n\n ..." + MockLoggerDelegate.class.getName() + " invoked by " + "processDefinitionId="
- + execution.getProcessDefinitionId() + ", activtyId=" + execution.getCurrentActivityId()
- + ", activtyName='" + execution.getCurrentActivityName() + "'" + ", processInstanceId="
- + execution.getProcessInstanceId() + ", businessKey=" + execution.getProcessBusinessKey()
- + ", executionId=" + execution.getId() + " \n\n");
- }
+ @Override
+ public void execute(DelegateExecution execution) throws Exception {
+ System.out.println("\n\n ..." + MockLoggerDelegate.class.getName() + " invoked by " + "processDefinitionId="
+ + execution.getProcessDefinitionId() + ", activtyId=" + execution.getCurrentActivityId()
+ + ", activtyName='" + execution.getCurrentActivityName() + "'" + ", processInstanceId="
+ + execution.getProcessInstanceId() + ", businessKey=" + execution.getProcessBusinessKey()
+ + ", executionId=" + execution.getId() + " \n\n");
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java
index 4d7a127a85..c128f58103 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java
@@ -25,14 +25,12 @@ import static org.junit.Assert.assertNull;
import static org.onap.so.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid;
import static org.onap.so.bpmn.mock.StubResponseOof.mockOof;
import static org.onap.so.bpmn.mock.StubResponseOof.mockOof_500;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Ignore;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -65,12 +63,12 @@ public class OofHomingIT extends BaseIntegrationTest {
String oofCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf.json");
String oofCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf2Net.json");
- String oofCallbackNoSolution = FileUtil.
- readResourceFile("__files/BuildingBlocks/oofCallbackNoSolutionFound.json");
- String oofCallbackPolicyException = FileUtil.
- readResourceFile("__files/BuildingBlocks/oofCallbackPolicyException.json");
- String oofCallbackServiceException = FileUtil.
- readResourceFile("__files/BuildingBlocks/oofCallbackServiceException.json");
+ String oofCallbackNoSolution =
+ FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackNoSolutionFound.json");
+ String oofCallbackPolicyException =
+ FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackPolicyException.json");
+ String oofCallbackServiceException =
+ FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackServiceException.json");
callbacks.put("oof", JSON, "oofResponse", oofCallback);
callbacks.put("oof2", JSON, "oofResponse", oofCallback2);
@@ -121,133 +119,73 @@ public class OofHomingIT extends BaseIntegrationTest {
VnfResource vnf = new VnfResource();
vnf.setResourceId("testResourceIdVNF");
vnf.setNfFunction("testVnfFunctionName");
- vnf.getHomingSolution().setOofDirectives(
- "{ \n" +
- " \"directives\":[ \n" +
- " { \n" +
- " \"vnfc_directives\":[ \n" +
- " { \n" +
- " \"vnfc_id\":\"<ID of VNFC>\",\n" +
- " \"directives\":[ \n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
- " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
- " \"attribute_value\":\"<value such as direct/normal>\"\n" +
- " },\n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
- " \"attribute_value\":\"<value such as physnet>\"\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " { \n" +
- " \"vnf_directives\":{ \n" +
- " \"directives\":[ \n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute>\",\n" +
- " \"attribute_value\":\"<value>\"\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute>\",\n" +
- " \"attribute_value\":\"<value >\"\n" +
- " },\n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute>\",\n" +
- " \"attribute_value\":\"<value >\"\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " \"sdnc_directives\":{ \n" +
- " \"directives\":[ \n" +
- " { \n" +
- " \"vnfc_directives\":[ \n" +
- " { \n" +
- " \"vnfc_id\":\"<ID of VNFC>\",\n" +
- " \"directives\":[ \n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
- " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
- " \"attribute_value\":\"<value such as direct/normal>\"\n" +
- " },\n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
- " \"attribute_value\":\"<value such as physnet>\"\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " { \n" +
- " \"vnf_directives\":{ \n" +
- " \"directives\":[ \n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute>\",\n" +
- " \"attribute_value\":\"<value>\"\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute>\",\n" +
- " \"attribute_value\":\"<value >\"\n" +
- " },\n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute>\",\n" +
- " \"attribute_value\":\"<value >\"\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- " }");
+ vnf.getHomingSolution().setOofDirectives("{ \n" + " \"directives\":[ \n" + " { \n"
+ + " \"vnfc_directives\":[ \n" + " { \n"
+ + " \"vnfc_id\":\"<ID of VNFC>\",\n" + " \"directives\":[ \n"
+ + " { \n"
+ + " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n"
+ + " \"attribute_value\":\"<value such as cloud specific flavor>\"\n"
+ + " }\n" + " ]\n" + " },\n"
+ + " { \n"
+ + " \"directive_name\":\"<Name of directive,example vnic-info>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n"
+ + " \"attribute_value\":\"<value such as direct/normal>\"\n"
+ + " },\n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n"
+ + " \"attribute_value\":\"<value such as physnet>\"\n"
+ + " }\n" + " ]\n" + " }\n"
+ + " ]\n" + " }\n" + " ]\n" + " },\n" + " { \n"
+ + " \"vnf_directives\":{ \n" + " \"directives\":[ \n"
+ + " { \n" + " \"directive_name\":\"<Name of directive>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute>\",\n"
+ + " \"attribute_value\":\"<value>\"\n" + " }\n"
+ + " ]\n" + " },\n" + " { \n"
+ + " \"directive_name\":\"<Name of directive>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute>\",\n"
+ + " \"attribute_value\":\"<value >\"\n" + " },\n"
+ + " { \n"
+ + " \"attribute_name\":\"<name of attribute>\",\n"
+ + " \"attribute_value\":\"<value >\"\n" + " }\n"
+ + " ]\n" + " }\n" + " ]\n" + " }\n"
+ + " }\n" + " ]\n" + " },\n" + " \"sdnc_directives\":{ \n" + " \"directives\":[ \n"
+ + " { \n" + " \"vnfc_directives\":[ \n" + " { \n"
+ + " \"vnfc_id\":\"<ID of VNFC>\",\n" + " \"directives\":[ \n"
+ + " { \n"
+ + " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n"
+ + " \"attribute_value\":\"<value such as cloud specific flavor>\"\n"
+ + " }\n" + " ]\n" + " },\n"
+ + " { \n"
+ + " \"directive_name\":\"<Name of directive,example vnic-info>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n"
+ + " \"attribute_value\":\"<value such as direct/normal>\"\n"
+ + " },\n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n"
+ + " \"attribute_value\":\"<value such as physnet>\"\n"
+ + " }\n" + " ]\n" + " }\n"
+ + " ]\n" + " }\n" + " ]\n" + " },\n" + " { \n"
+ + " \"vnf_directives\":{ \n" + " \"directives\":[ \n"
+ + " { \n" + " \"directive_name\":\"<Name of directive>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute>\",\n"
+ + " \"attribute_value\":\"<value>\"\n" + " }\n"
+ + " ]\n" + " },\n" + " { \n"
+ + " \"directive_name\":\"<Name of directive>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute>\",\n"
+ + " \"attribute_value\":\"<value >\"\n" + " },\n"
+ + " { \n"
+ + " \"attribute_name\":\"<name of attribute>\",\n"
+ + " \"attribute_value\":\"<value >\"\n" + " }\n"
+ + " ]\n" + " }\n" + " ]\n" + " }\n"
+ + " }\n" + " ]\n" + " }");
ModelInfo vnfModel = new ModelInfo();
vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF");
vnfModel.setModelInvariantUuid("testModelInvariantIdVNF");
@@ -264,11 +202,12 @@ public class OofHomingIT extends BaseIntegrationTest {
serviceDecomposition.setServiceInstance(si);
// Subscriber
- subscriber = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
+ subscriber =
+ "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
}
- @Test
+ @Test
public void testHoming_success_2AR1Vnf() throws Exception {
mockOof(wireMockServer);
@@ -283,11 +222,11 @@ public class OofHomingIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
- ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
- "serviceDecomposition");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ ServiceDecomposition serviceDecompositionExp =
+ (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
@@ -305,22 +244,23 @@ public class OofHomingIT extends BaseIntegrationTest {
expectedOofRequest = expectedOofRequest.replaceAll("\\s+", "");
assertNull(workflowException);
- assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
- resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx",
- "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
+ assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", resourceARHoming.getVnf().getResourceId(),
+ "aic", "dfwtx", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
"\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
resourceARHomingString);
- assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
- resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2",
- null, null), resourceARHoming2String);
- assertEquals(homingSolutionCloud("cloud","aic", "testCloudRegionId3",
- true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
- "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
+ assertEquals(
+ homingSolutionService("service", "testSIID2", "testVnfHostname2",
+ resourceARHoming2.getVnf().getResourceId(), "aic", "testCloudRegionId2", null, null),
+ resourceARHoming2String);
+ assertEquals(
+ homingSolutionCloud("cloud", "aic", "testCloudRegionId3", true,
+ "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
resourceVNFHomingString);
assertEquals(verifyOofRequest(), expectedOofRequest);
}
- @Test
+ @Test
public void testHoming_success_2AR1Vnf2Net() throws Exception {
mockOof(wireMockServer);
@@ -335,11 +275,11 @@ public class OofHomingIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
- ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
- "serviceDecomposition");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ ServiceDecomposition serviceDecompositionExp =
+ (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
@@ -367,28 +307,27 @@ public class OofHomingIT extends BaseIntegrationTest {
assertNull(workflowException);
- assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
- resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx",
- "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
+ assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", resourceARHoming.getVnf().getResourceId(),
+ "aic", "dfwtx", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
"\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
resourceARHomingString);
- assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
- resourceARHoming2.getVnf().getResourceId(),
- "aic", "testCloudRegionId2",
- null, null), resourceARHoming2String);
- assertEquals(homingSolutionCloud("cloud","aic",
- "testCloudRegionId3",
- true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
- "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
+ assertEquals(
+ homingSolutionService("service", "testSIID2", "testVnfHostname2",
+ resourceARHoming2.getVnf().getResourceId(), "aic", "testCloudRegionId2", null, null),
+ resourceARHoming2String);
+ assertEquals(
+ homingSolutionCloud("cloud", "aic", "testCloudRegionId3", true,
+ "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
resourceVNFHomingString);
- assertEquals(homingSolutionService("service", "testServiceInstanceIdNet",
- "testVnfHostNameNet", resourceNetHoming.getVnf().getResourceId(),"aic",
- "testCloudRegionIdNet",
- null, null), resourceNetHomingString);
- assertEquals(homingSolutionCloud("cloud", "aic",
- "testCloudRegionIdNet2",
- false, "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"",
- "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""),
+ assertEquals(
+ homingSolutionService("service", "testServiceInstanceIdNet", "testVnfHostNameNet",
+ resourceNetHoming.getVnf().getResourceId(), "aic", "testCloudRegionIdNet", null, null),
+ resourceNetHomingString);
+ assertEquals(
+ homingSolutionCloud("cloud", "aic", "testCloudRegionIdNet2", false,
+ "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"",
+ "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""),
resourceNetHoming2String);
assertEquals(verifyOofRequest(), expectedOofRequest);
@@ -402,8 +341,7 @@ public class OofHomingIT extends BaseIntegrationTest {
"/BuildingBlocks/oofCatalogResp.json");
String busKey = UUID.randomUUID().toString();
Map<String, Object> vars = new HashMap<>();
- setVariablesForServiceDecomposition(vars, "testRequestId123",
- "ff5256d2-5a33-55df-13ab-12abad84e7ff");
+ setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
invokeSubProcess("DecomposeService", busKey, vars);
ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition");
@@ -438,12 +376,12 @@ public class OofHomingIT extends BaseIntegrationTest {
injectWorkflowMessages(callbacks, "oof3");
waitForProcessEnd(businessKey, 10000);
- //Get Variables
+ // Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
- ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
- "serviceDecomposition");
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ ServiceDecomposition serviceDecompositionExp =
+ (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
System.out.println("serviceDecompositionExp is: " + serviceDecompositionExp);
Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000");
@@ -457,26 +395,26 @@ public class OofHomingIT extends BaseIntegrationTest {
assertNull(workflowException);
- //Verify request
+ // Verify request
String oofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
System.out.println("oofRequest is: " + oofRequest);
- assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf").
- replaceAll("\n", "").replaceAll("\r", "").
- replaceAll("\t", ""), oofRequest.replaceAll("\n", "").
- replaceAll("\r", "").replaceAll("\t", ""));
-
- //System.out.println("resourceVnfHoming.getVnf().getResourceId() is: " + resourceVnfHoming.getVnf().getResourceId());
-
- assertEquals(homingSolutionService("service", "service-instance-01234",
- "MDTNJ01", "test-resource-id-000","CloudOwner",
- "mtmnj1a",
- "\"f1d563e8-e714-4393-8f99-cc480144a05e\"," +
- " \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
- "\"s1d563e8-e714-4393-8f99-cc480144a05e\"," +
- " \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString);
+ assertEquals(
+ FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf").replaceAll("\n", "")
+ .replaceAll("\r", "").replaceAll("\t", ""),
+ oofRequest.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""));
+
+ // System.out.println("resourceVnfHoming.getVnf().getResourceId() is: " +
+ // resourceVnfHoming.getVnf().getResourceId());
+
+ assertEquals(
+ homingSolutionService("service", "service-instance-01234", "MDTNJ01", "test-resource-id-000",
+ "CloudOwner", "mtmnj1a",
+ "\"f1d563e8-e714-4393-8f99-cc480144a05e\"," + " \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"s1d563e8-e714-4393-8f99-cc480144a05e\"," + " \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
+ resourceVnfHomingString);
}
- @Test
+ @Test
public void testHoming_success_existingLicense() throws Exception {
mockOof(wireMockServer);
@@ -491,9 +429,11 @@ public class OofHomingIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ ServiceDecomposition serviceDecompositionExp =
+ (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
String oofRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
@@ -511,24 +451,25 @@ public class OofHomingIT extends BaseIntegrationTest {
oofRequest = oofRequest.replaceAll("\\s+", "");
assertNull(workflowException);
- assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
- "aic", "dfwtx", "KDTNJ01",
- "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
- "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
+ assertEquals(
+ homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01",
+ "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
resourceARHomingString);
- assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
- resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2",
- null, null), resourceARHoming2String);
- assertEquals(homingSolutionCloud("cloud", "aic",
- "testCloudRegionId3",
- false, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
- "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
+ assertEquals(
+ homingSolutionService("service", "testSIID2", "testVnfHostname2",
+ resourceARHoming2.getVnf().getResourceId(), "aic", "testCloudRegionId2", null, null),
+ resourceARHoming2String);
+ assertEquals(
+ homingSolutionCloud("cloud", "aic", "testCloudRegionId3", false,
+ "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
resourceVNFHomingString);
assertEquals(verifyOofRequestExistingLicense(), oofRequest);
}
- @Test
+ @Test
public void testHoming_error_inputVariable() throws Exception {
String businessKey = UUID.randomUUID().toString();
@@ -539,15 +480,15 @@ public class OofHomingIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required " +
- "input variable is missing or null,workStep=*]", workflowException.toString());
+ assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required "
+ + "input variable is missing or null,workStep=*]", workflowException.toString());
}
- @Test
+ @Test
public void testHoming_error_badResponse() throws Exception {
mockOof_500(wireMockServer);
@@ -559,14 +500,16 @@ public class OofHomingIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- assertEquals("WorkflowException[processKey=Homing,errorCode=401,errorMessage=Internal Error - BasicAuth value null,workStep=*]", workflowException.toString());
+ assertEquals(
+ "WorkflowException[processKey=Homing,errorCode=401,errorMessage=Internal Error - BasicAuth value null,workStep=*]",
+ workflowException.toString());
}
- @Test
+ @Test
public void testHoming_error_oofNoSolution() throws Exception {
mockOof(wireMockServer);
@@ -580,15 +523,16 @@ public class OofHomingIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
- Boolean errorMatch = workflowException.toString().contains("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " +
- "Response contains error: Unable to find any candidate for demand *** Response:");
- assert(errorMatch);
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ Boolean errorMatch = workflowException.toString()
+ .contains("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback "
+ + "Response contains error: Unable to find any candidate for demand *** Response:");
+ assert (errorMatch);
}
- @Test
+ @Test
public void testHoming_error_oofPolicyException() throws Exception {
mockOof(wireMockServer);
@@ -602,16 +546,16 @@ public class OofHomingIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " +
- "Response contains a Request Error Policy Exception: Message content size exceeds the allowable " +
- "limit]", workflowException.toString());
+ assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback "
+ + "Response contains a Request Error Policy Exception: Message content size exceeds the allowable "
+ + "limit]", workflowException.toString());
}
- @Test
+ @Test
public void testHoming_error_oofServiceException() throws Exception {
mockOof(wireMockServer);
@@ -623,14 +567,15 @@ public class OofHomingIT extends BaseIntegrationTest {
injectWorkflowMessages(callbacks, "oofServiceEx");
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " +
- "Response contains a Request Error Service Exception: OOF PlacementError: " +
- "requests.exceptions.HTTPError: 404 Client Error: Not Found for " +
- "url: http://192.168.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]",
+ assertEquals(
+ "WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback "
+ + "Response contains a Request Error Service Exception: OOF PlacementError: "
+ + "requests.exceptions.HTTPError: 404 Client Error: Not Found for "
+ + "url: http://192.168.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]",
workflowException.toString());
}
@@ -649,7 +594,7 @@ public class OofHomingIT extends BaseIntegrationTest {
variables.put("cloudRegionId", "TNZED");
variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR");
variables.put("vgMuxInfraModelId", "testArModelUuid");
- // variables.put("mso-request-id", "testRequestId");
+ // variables.put("mso-request-id", "testRequestId");
variables.put("msoRequestId", "testRequestId");
variables.put("serviceInstanceId", "testServiceInstanceId123");
variables.put("serviceInstanceName", "testServiceName");
@@ -716,7 +661,7 @@ public class OofHomingIT extends BaseIntegrationTest {
variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR");
variables.put("vgMuxInfraModelId", "testArModelUuid");
variables.put("isDebugLogEnabled", "true");
- // variables.put("mso-request-id", "testRequestId");
+ // variables.put("mso-request-id", "testRequestId");
variables.put("msoRequestId", "testRequestId");
variables.put("serviceInstanceId", "testServiceInstanceId123");
variables.put("serviceInstanceName", "testServiceName");
@@ -727,11 +672,15 @@ public class OofHomingIT extends BaseIntegrationTest {
private void setVariablesExistingLicense(Map<String, Object> variables) {
HomingSolution currentHomingSolution = new HomingSolution();
serviceDecomposition.getVnfResources().get(0).setCurrentHomingSolution(currentHomingSolution);
- serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId1");
- serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId2");
+ serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
+ .addEntitlementPool("testEntitlementPoolId1");
+ serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
+ .addEntitlementPool("testEntitlementPoolId2");
- serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId1");
- serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId2");
+ serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
+ .addLicenseKeyGroup("testLicenseKeyGroupId1");
+ serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
+ .addLicenseKeyGroup("testLicenseKeyGroupId2");
variables.put("isDebugLogEnabled", "true");
variables.put("msoRequestId", "testRequestId");
@@ -742,56 +691,52 @@ public class OofHomingIT extends BaseIntegrationTest {
}
private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname,
- String vnfResourceId, String cloudOwner,
- String cloudRegionId, String enList,
- String licenseList){
+ String vnfResourceId, String cloudOwner, String cloudRegionId, String enList, String licenseList) {
String solution = "";
- if(enList == null){
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" +
- serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" +
- cloudRegionId + "\", " + "\"vnf\" : { \"resourceId\" : \"" + vnfResourceId +
- "\", \"resourceType\" : \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" :" +
- " { }, \"rehome\" : false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { }," +
- " \"rehome\" : false } }";
- }else{
- //language=JSON
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" +
- serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" +
- cloudRegionId + "\", \"vnf\" : { \"resourceId\" : \"" + vnfResourceId + "\", \"resourceType\" :" +
- " \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" : { }, \"rehome\" :" +
- " false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { \"entitlementPoolList\" :" +
- " [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }";
+ if (enList == null) {
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \""
+ + serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \""
+ + cloudRegionId + "\", " + "\"vnf\" : { \"resourceId\" : \"" + vnfResourceId
+ + "\", \"resourceType\" : \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" :"
+ + " { }, \"rehome\" : false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { },"
+ + " \"rehome\" : false } }";
+ } else {
+ // language=JSON
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \""
+ + serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \""
+ + cloudRegionId + "\", \"vnf\" : { \"resourceId\" : \"" + vnfResourceId + "\", \"resourceType\" :"
+ + " \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" : { }, \"rehome\" :"
+ + " false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { \"entitlementPoolList\" :"
+ + " [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList
+ + " ] }, \"rehome\" : false } }";
}
return solution;
}
- private String homingSolutionCloud(String type, String cloudOwner,
- String cloudRegionId, Boolean flavors, String enList,
- String licenseList){
+ private String homingSolutionCloud(String type, String cloudOwner, String cloudRegionId, Boolean flavors,
+ String enList, String licenseList) {
String solution = "";
- if(enList == null){
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
- cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
- "\", \"license\" : { }, \"rehome\" : false } }";
- } else if (flavors && enList == null){
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
- cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
- "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, " +
- "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], " +
- "\"license\" : { }, \"rehome\" : false } }";
+ if (enList == null) {
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
+ + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"license\" : { }, \"rehome\" : false } }";
+ } else if (flavors && enList == null) {
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
+ + "\", \"cloudRegionId\" : \"" + cloudRegionId
+ + "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, "
+ + "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], "
+ + "\"license\" : { }, \"rehome\" : false } }";
} else if (flavors) {
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
- cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
- "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, " +
- "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], " +
- "\"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " +
- licenseList + " ] }, \"rehome\" : false } }";
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
+ + "\", \"cloudRegionId\" : \"" + cloudRegionId
+ + "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, "
+ + "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], "
+ + "\"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ "
+ + licenseList + " ] }, \"rehome\" : false } }";
} else {
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
- cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
- "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " +
- licenseList + " ] }, \"rehome\" : false } }";
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
+ + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"license\" : { \"entitlementPoolList\" : [ "
+ + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }";
}
return solution;
}
@@ -814,68 +759,67 @@ public class OofHomingIT extends BaseIntegrationTest {
variables.put("cloudRegionId", "TNZED");
- String serviceModelInfo = "{\"modelInvariantId\":\"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\",\"modelUuid\":" +
- "\"2f7f309d-c842-4644-a2e4-34167be5eeb4\",\"modelName\":\"vCPE Service\",\"modelVersion\":\"2.0\",}";
+ String serviceModelInfo = "{\"modelInvariantId\":\"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\",\"modelUuid\":"
+ + "\"2f7f309d-c842-4644-a2e4-34167be5eeb4\",\"modelName\":\"vCPE Service\",\"modelVersion\":\"2.0\",}";
variables.put("serviceModelInfo", serviceModelInfo);
}
private String verifyOofRequest() {
- String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," +
- "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/oofResponse/testRequestId\"," +
- "\"sourceId\":\"so\",\"requestType\":\"create\",\"numSolutions\":1,\"optimizers\":[\"placement\"]," +
- "\"timeout\":600},\"placementInfo\":{\"requestParameters\":{\"customerLatitude\":" +
- "\"32.89748\",\"customerLongitude\":\"-97.040443\",\"customerName\":\"xyz\"},\"subscriberInfo\":" +
- "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," +
- "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"testARFunctionName\"" +
- ",\"serviceResourceId\":\"testResourceIdAR\",\"tenantId\":" +
- "\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"no-resourceModelInvariantId\"," +
- "\"modelVersionId\":\"no-resourceModelVersionId\",\"modelName\":\"\",\"modelType\":" +
- "\"\",\"modelVersion\":\"\",\"modelCustomizationName\":\"\"}}," +
- "{\"resourceModuleName\":\"testAR2FunctionName\",\"serviceResourceId\":\"testResourceIdAR2\"," +
- "\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"no-resourceModelInvariantId\"," +
- "\"modelVersionId\":\"no-resourceModelVersionId\",\"modelName\":\"\"," +
- "\"modelType\":\"\",\"modelVersion\":\"\"," +
- "\"modelCustomizationName\":\"\"}},{\"resourceModuleName\":\"testVnfFunctionName\",\"serviceResourceId\":\"" +
- "testResourceIdVNF\",\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\"" +
- ":\"testModelInvariantIdVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelName\":\"" +
- "testModelNameVNF\",\"modelType\":\"testModelTypeVNF\",\"modelVersion\":\"testModelVersionVNF\"" +
- ",\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":" +
- "{\"serviceInstanceId\":\"testServiceInstanceId123\"," +
- "\"serviceName\":\"testServiceName\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":" +
- "\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\"," +
- "\"modelVersion\":\"testModelVersion\",\"modelCustomizationName\":\"" +
- "\"}}}";
+ String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\","
+ + "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/oofResponse/testRequestId\","
+ + "\"sourceId\":\"so\",\"requestType\":\"create\",\"numSolutions\":1,\"optimizers\":[\"placement\"],"
+ + "\"timeout\":600},\"placementInfo\":{\"requestParameters\":{\"customerLatitude\":"
+ + "\"32.89748\",\"customerLongitude\":\"-97.040443\",\"customerName\":\"xyz\"},\"subscriberInfo\":"
+ + "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\","
+ + "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"testARFunctionName\""
+ + ",\"serviceResourceId\":\"testResourceIdAR\",\"tenantId\":"
+ + "\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"no-resourceModelInvariantId\","
+ + "\"modelVersionId\":\"no-resourceModelVersionId\",\"modelName\":\"\",\"modelType\":"
+ + "\"\",\"modelVersion\":\"\",\"modelCustomizationName\":\"\"}},"
+ + "{\"resourceModuleName\":\"testAR2FunctionName\",\"serviceResourceId\":\"testResourceIdAR2\","
+ + "\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"no-resourceModelInvariantId\","
+ + "\"modelVersionId\":\"no-resourceModelVersionId\",\"modelName\":\"\","
+ + "\"modelType\":\"\",\"modelVersion\":\"\","
+ + "\"modelCustomizationName\":\"\"}},{\"resourceModuleName\":\"testVnfFunctionName\",\"serviceResourceId\":\""
+ + "testResourceIdVNF\",\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\""
+ + ":\"testModelInvariantIdVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelName\":\""
+ + "testModelNameVNF\",\"modelType\":\"testModelTypeVNF\",\"modelVersion\":\"testModelVersionVNF\""
+ + ",\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":"
+ + "{\"serviceInstanceId\":\"testServiceInstanceId123\","
+ + "\"serviceName\":\"testServiceName\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":"
+ + "\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\","
+ + "\"modelVersion\":\"testModelVersion\",\"modelCustomizationName\":\"" + "\"}}}";
return request;
}
- private String verifyOofRequestExistingLicense(){
- String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," +
- "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\"," +
- "\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"]," +
- "\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\"," +
- "\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":" +
- "\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":" +
- "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," +
- "\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":" +
- "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\"," +
- "\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\"," +
- "\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\"," +
- "\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":" +
- "\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":" +
- "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":" +
- "\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\"," +
- "\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\"," +
- "\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\"," +
- "\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":" +
- "[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\"," +
- "\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":" +
- "\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\"," +
- "\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\"," +
- "\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}," +
- "\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\"," +
- "\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\"," +
- "\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":" +
- "\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";
+ private String verifyOofRequestExistingLicense() {
+ String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\","
+ + "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\","
+ + "\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"],"
+ + "\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\","
+ + "\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":"
+ + "\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":"
+ + "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\","
+ + "\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":"
+ + "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\","
+ + "\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\","
+ + "\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\","
+ + "\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":"
+ + "\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":"
+ + "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":"
+ + "\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\","
+ + "\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\","
+ + "\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\","
+ + "\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":"
+ + "[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\","
+ + "\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":"
+ + "\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\","
+ + "\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\","
+ + "\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"},"
+ + "\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\","
+ + "\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\","
+ + "\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":"
+ + "\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";
return request;
}
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java
index 390f5294aa..39a8995607 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java
@@ -38,14 +38,12 @@ import org.onap.so.bpmn.core.domain.VnfResource;
import org.onap.so.bpmn.mock.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.onap.so.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid;
@@ -59,7 +57,7 @@ import static org.onap.so.bpmn.mock.StubResponseOof.mockOof_500;
@Ignore
public class OofHomingTestIT extends BaseIntegrationTest {
- Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class);
+ Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class);
ServiceDecomposition serviceDecomposition = new ServiceDecomposition();
String subscriber = "";
@@ -72,12 +70,11 @@ public class OofHomingTestIT extends BaseIntegrationTest {
String oofCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf");
String oofCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf2Net");
- String oofCallbackNoSolution = FileUtil.
- readResourceFile("__files/BuildingBlocks/oofCallbackNoSolutionFound");
- String oofCallbackPolicyException = FileUtil.
- readResourceFile("__files/BuildingBlocks/oofCallbackPolicyException");
- String oofCallbackServiceException = FileUtil.
- readResourceFile("__files/BuildingBlocks/oofCallbackServiceException");
+ String oofCallbackNoSolution = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackNoSolutionFound");
+ String oofCallbackPolicyException =
+ FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackPolicyException");
+ String oofCallbackServiceException =
+ FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackServiceException");
callbacks.put("oof", JSON, "oofResponse", oofCallback);
callbacks.put("oof2", JSON, "oofResponse", oofCallback2);
@@ -128,133 +125,73 @@ public class OofHomingTestIT extends BaseIntegrationTest {
VnfResource vnf = new VnfResource();
vnf.setResourceId("testResourceIdVNF");
vnf.setResourceInstanceName("testVnfInstanceName");
- vnf.getHomingSolution().setOofDirectives(
- "{ \n" +
- " \"directives\":[ \n" +
- " { \n" +
- " \"vnfc_directives\":[ \n" +
- " { \n" +
- " \"vnfc_id\":\"<ID of VNFC>\",\n" +
- " \"directives\":[ \n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
- " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
- " \"attribute_value\":\"<value such as direct/normal>\"\n" +
- " },\n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
- " \"attribute_value\":\"<value such as physnet>\"\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " { \n" +
- " \"vnf_directives\":{ \n" +
- " \"directives\":[ \n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute>\",\n" +
- " \"attribute_value\":\"<value>\"\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute>\",\n" +
- " \"attribute_value\":\"<value >\"\n" +
- " },\n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute>\",\n" +
- " \"attribute_value\":\"<value >\"\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " \"sdnc_directives\":{ \n" +
- " \"directives\":[ \n" +
- " { \n" +
- " \"vnfc_directives\":[ \n" +
- " { \n" +
- " \"vnfc_id\":\"<ID of VNFC>\",\n" +
- " \"directives\":[ \n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n" +
- " \"attribute_value\":\"<value such as cloud specific flavor>\"\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive,example vnic-info>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n" +
- " \"attribute_value\":\"<value such as direct/normal>\"\n" +
- " },\n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n" +
- " \"attribute_value\":\"<value such as physnet>\"\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " { \n" +
- " \"vnf_directives\":{ \n" +
- " \"directives\":[ \n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute>\",\n" +
- " \"attribute_value\":\"<value>\"\n" +
- " }\n" +
- " ]\n" +
- " },\n" +
- " { \n" +
- " \"directive_name\":\"<Name of directive>\",\n" +
- " \"attributes\":[ \n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute>\",\n" +
- " \"attribute_value\":\"<value >\"\n" +
- " },\n" +
- " { \n" +
- " \"attribute_name\":\"<name of attribute>\",\n" +
- " \"attribute_value\":\"<value >\"\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- " }");
+ vnf.getHomingSolution().setOofDirectives("{ \n" + " \"directives\":[ \n" + " { \n"
+ + " \"vnfc_directives\":[ \n" + " { \n"
+ + " \"vnfc_id\":\"<ID of VNFC>\",\n" + " \"directives\":[ \n"
+ + " { \n"
+ + " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n"
+ + " \"attribute_value\":\"<value such as cloud specific flavor>\"\n"
+ + " }\n" + " ]\n" + " },\n"
+ + " { \n"
+ + " \"directive_name\":\"<Name of directive,example vnic-info>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n"
+ + " \"attribute_value\":\"<value such as direct/normal>\"\n"
+ + " },\n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n"
+ + " \"attribute_value\":\"<value such as physnet>\"\n"
+ + " }\n" + " ]\n" + " }\n"
+ + " ]\n" + " }\n" + " ]\n" + " },\n" + " { \n"
+ + " \"vnf_directives\":{ \n" + " \"directives\":[ \n"
+ + " { \n" + " \"directive_name\":\"<Name of directive>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute>\",\n"
+ + " \"attribute_value\":\"<value>\"\n" + " }\n"
+ + " ]\n" + " },\n" + " { \n"
+ + " \"directive_name\":\"<Name of directive>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute>\",\n"
+ + " \"attribute_value\":\"<value >\"\n" + " },\n"
+ + " { \n"
+ + " \"attribute_name\":\"<name of attribute>\",\n"
+ + " \"attribute_value\":\"<value >\"\n" + " }\n"
+ + " ]\n" + " }\n" + " ]\n" + " }\n"
+ + " }\n" + " ]\n" + " },\n" + " \"sdnc_directives\":{ \n" + " \"directives\":[ \n"
+ + " { \n" + " \"vnfc_directives\":[ \n" + " { \n"
+ + " \"vnfc_id\":\"<ID of VNFC>\",\n" + " \"directives\":[ \n"
+ + " { \n"
+ + " \"directive_name\":\"<Name of directive,example flavor_directive>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute, such as flavor label>\",\n"
+ + " \"attribute_value\":\"<value such as cloud specific flavor>\"\n"
+ + " }\n" + " ]\n" + " },\n"
+ + " { \n"
+ + " \"directive_name\":\"<Name of directive,example vnic-info>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute, such as vnic-type>\",\n"
+ + " \"attribute_value\":\"<value such as direct/normal>\"\n"
+ + " },\n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute, such as provider netweork>\",\n"
+ + " \"attribute_value\":\"<value such as physnet>\"\n"
+ + " }\n" + " ]\n" + " }\n"
+ + " ]\n" + " }\n" + " ]\n" + " },\n" + " { \n"
+ + " \"vnf_directives\":{ \n" + " \"directives\":[ \n"
+ + " { \n" + " \"directive_name\":\"<Name of directive>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute>\",\n"
+ + " \"attribute_value\":\"<value>\"\n" + " }\n"
+ + " ]\n" + " },\n" + " { \n"
+ + " \"directive_name\":\"<Name of directive>\",\n"
+ + " \"attributes\":[ \n" + " { \n"
+ + " \"attribute_name\":\"<name of attribute>\",\n"
+ + " \"attribute_value\":\"<value >\"\n" + " },\n"
+ + " { \n"
+ + " \"attribute_name\":\"<name of attribute>\",\n"
+ + " \"attribute_value\":\"<value >\"\n" + " }\n"
+ + " ]\n" + " }\n" + " ]\n" + " }\n"
+ + " }\n" + " ]\n" + " }");
ModelInfo vnfModel = new ModelInfo();
vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF");
vnfModel.setModelInvariantUuid("testModelInvariantIdVNF");
@@ -271,7 +208,8 @@ public class OofHomingTestIT extends BaseIntegrationTest {
serviceDecomposition.setServiceInstance(si);
// Subscriber
- subscriber = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
+ subscriber =
+ "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
}
@@ -285,17 +223,17 @@ public class OofHomingTestIT extends BaseIntegrationTest {
Map<String, Object> variables = new HashMap<>();
setVariables(variables);
- invokeSubProcess("Homing", businessKey, variables);
+ invokeSubProcess("Homing", businessKey, variables);
injectWorkflowMessages(callbacks, "oof2");
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
- ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
- "serviceDecomposition");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ ServiceDecomposition serviceDecompositionExp =
+ (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
@@ -313,17 +251,18 @@ public class OofHomingTestIT extends BaseIntegrationTest {
expectedOofRequest = expectedOofRequest.replaceAll("\\s+", "");
assertNull(workflowException);
- assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
- resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx",
- "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
+ assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", resourceARHoming.getVnf().getResourceId(),
+ "aic", "dfwtx", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
"\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
resourceARHomingString);
- assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
- resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2",
- null, null), resourceARHoming2String);
- assertEquals(homingSolutionCloud("cloud","aic", "testCloudRegionId3",
- true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
- "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
+ assertEquals(
+ homingSolutionService("service", "testSIID2", "testVnfHostname2",
+ resourceARHoming2.getVnf().getResourceId(), "aic", "testCloudRegionId2", null, null),
+ resourceARHoming2String);
+ assertEquals(
+ homingSolutionCloud("cloud", "aic", "testCloudRegionId3", true,
+ "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
resourceVNFHomingString);
assertEquals(verifyOofRequest(), expectedOofRequest);
}
@@ -338,17 +277,17 @@ public class OofHomingTestIT extends BaseIntegrationTest {
Map<String, Object> variables = new HashMap<>();
setVariables2(variables);
- invokeSubProcess("Homing", businessKey, variables);
+ invokeSubProcess("Homing", businessKey, variables);
injectWorkflowMessages(callbacks, "oof3");
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
- ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
- "serviceDecomposition");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ ServiceDecomposition serviceDecompositionExp =
+ (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
@@ -376,28 +315,27 @@ public class OofHomingTestIT extends BaseIntegrationTest {
assertNull(workflowException);
- assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
- resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx",
- "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
+ assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", resourceARHoming.getVnf().getResourceId(),
+ "aic", "dfwtx", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
"\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
resourceARHomingString);
- assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
- resourceARHoming2.getVnf().getResourceId(),
- "aic", "testCloudRegionId2",
- null, null), resourceARHoming2String);
- assertEquals(homingSolutionCloud("cloud","aic",
- "testCloudRegionId3",
- true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
- "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
+ assertEquals(
+ homingSolutionService("service", "testSIID2", "testVnfHostname2",
+ resourceARHoming2.getVnf().getResourceId(), "aic", "testCloudRegionId2", null, null),
+ resourceARHoming2String);
+ assertEquals(
+ homingSolutionCloud("cloud", "aic", "testCloudRegionId3", true,
+ "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
resourceVNFHomingString);
- assertEquals(homingSolutionService("service", "testServiceInstanceIdNet",
- "testVnfHostNameNet", resourceNetHoming.getVnf().getResourceId(),"aic",
- "testCloudRegionIdNet",
- null, null), resourceNetHomingString);
- assertEquals(homingSolutionCloud("cloud", "aic",
- "testCloudRegionIdNet2",
- false, "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"",
- "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""),
+ assertEquals(
+ homingSolutionService("service", "testServiceInstanceIdNet", "testVnfHostNameNet",
+ resourceNetHoming.getVnf().getResourceId(), "aic", "testCloudRegionIdNet", null, null),
+ resourceNetHomingString);
+ assertEquals(
+ homingSolutionCloud("cloud", "aic", "testCloudRegionIdNet2", false,
+ "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"",
+ "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""),
resourceNetHoming2String);
assertEquals(verifyOofRequest(), expectedOofRequest);
@@ -413,12 +351,10 @@ public class OofHomingTestIT extends BaseIntegrationTest {
"/BuildingBlocks/oofCatalogResp.json");
String busKey = UUID.randomUUID().toString();
Map<String, Object> vars = new HashMap<>();
- setVariablesForServiceDecomposition(vars, "testRequestId123",
- "ff5256d2-5a33-55df-13ab-12abad84e7ff");
+ setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
invokeSubProcess("DecomposeService", busKey, vars);
- ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey,
- "serviceDecomposition");
+ ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition");
logger.debug("In testHoming_success_vnfResourceList, ServiceDecomposition = {}", sd);
List<VnfResource> vnfResourceList = sd.getVnfResources();
vnfResourceList.get(0).setResourceId("test-resource-id-000");
@@ -450,12 +386,12 @@ public class OofHomingTestIT extends BaseIntegrationTest {
injectWorkflowMessages(callbacks, "oof3");
waitForProcessEnd(businessKey, 10000);
- //Get Variables
+ // Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
- ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey,
- "serviceDecomposition");
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ ServiceDecomposition serviceDecompositionExp =
+ (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
logger.debug("serviceDecompositionExp is: {}", serviceDecompositionExp);
Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000");
@@ -469,21 +405,20 @@ public class OofHomingTestIT extends BaseIntegrationTest {
assertNull(workflowException);
- //Verify request
+ // Verify request
String oofRequest = (String) getVariableFromHistory(businessKey, "oofRequest");
logger.debug("oofRequest is: {}", oofRequest);
- assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf").
- replaceAll("\n", "").replaceAll("\r", "").
- replaceAll("\t", ""), oofRequest.replaceAll("\n", "").
- replaceAll("\r", "").replaceAll("\t", ""));
-
- assertEquals(homingSolutionService("service", "service-instance-01234",
- "MDTNJ01", "test-resource-id-000","CloudOwner",
- "mtmnj1a",
- "\"f1d563e8-e714-4393-8f99-cc480144a05e\"," +
- " \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
- "\"s1d563e8-e714-4393-8f99-cc480144a05e\"," +
- " \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString);
+ assertEquals(
+ FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf").replaceAll("\n", "")
+ .replaceAll("\r", "").replaceAll("\t", ""),
+ oofRequest.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""));
+
+ assertEquals(
+ homingSolutionService("service", "service-instance-01234", "MDTNJ01", "test-resource-id-000",
+ "CloudOwner", "mtmnj1a",
+ "\"f1d563e8-e714-4393-8f99-cc480144a05e\"," + " \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"s1d563e8-e714-4393-8f99-cc480144a05e\"," + " \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
+ resourceVnfHomingString);
}
@Test
@@ -501,9 +436,11 @@ public class OofHomingTestIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ ServiceDecomposition serviceDecompositionExp =
+ (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
String oofRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
@@ -521,18 +458,19 @@ public class OofHomingTestIT extends BaseIntegrationTest {
oofRequest = oofRequest.replaceAll("\\s+", "");
assertNull(workflowException);
- assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01",
- "aic", "dfwtx", "KDTNJ01",
- "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
- "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
+ assertEquals(
+ homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01",
+ "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
resourceARHomingString);
- assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2",
- resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2",
- null, null), resourceARHoming2String);
- assertEquals(homingSolutionCloud("cloud", "aic",
- "testCloudRegionId3",
- false, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
- "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
+ assertEquals(
+ homingSolutionService("service", "testSIID2", "testVnfHostname2",
+ resourceARHoming2.getVnf().getResourceId(), "aic", "testCloudRegionId2", null, null),
+ resourceARHoming2String);
+ assertEquals(
+ homingSolutionCloud("cloud", "aic", "testCloudRegionId3", false,
+ "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
resourceVNFHomingString);
assertEquals(verifyOofRequestExistingLicense(), oofRequest);
@@ -549,12 +487,12 @@ public class OofHomingTestIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required " +
- "input variable is missing or null]", workflowException.toString());
+ assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required "
+ + "input variable is missing or null]", workflowException.toString());
}
@Test
@@ -570,12 +508,12 @@ public class OofHomingTestIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- assertEquals("WorkflowException[processKey=Homing,errorCode=500,errorMessage=Received a " +
- "Bad Sync Response from Sniro/OOF.]", workflowException.toString());
+ assertEquals("WorkflowException[processKey=Homing,errorCode=500,errorMessage=Received a "
+ + "Bad Sync Response from Sniro/OOF.]", workflowException.toString());
}
@Test
@@ -593,12 +531,12 @@ public class OofHomingTestIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=No solution found " +
- "for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8]", workflowException.toString());
+ assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=No solution found "
+ + "for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8]", workflowException.toString());
}
@Test
@@ -616,13 +554,13 @@ public class OofHomingTestIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " +
- "Response contains a Request Error Policy Exception: Message content size exceeds the allowable " +
- "limit]", workflowException.toString());
+ assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback "
+ + "Response contains a Request Error Policy Exception: Message content size exceeds the allowable "
+ + "limit]", workflowException.toString());
}
@Test
@@ -640,14 +578,15 @@ public class OofHomingTestIT extends BaseIntegrationTest {
waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey,
- "WorkflowException");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " +
- "Response contains a Request Error Service Exception: OOF PlacementError: " +
- "requests.exceptions.HTTPError: 404 Client Error: Not Found for " +
- "url: http://192.168.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]",
+ assertEquals(
+ "WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback "
+ + "Response contains a Request Error Service Exception: OOF PlacementError: "
+ + "requests.exceptions.HTTPError: 404 Client Error: Not Found for "
+ + "url: http://192.168.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]",
workflowException.toString());
}
@@ -665,7 +604,7 @@ public class OofHomingTestIT extends BaseIntegrationTest {
variables.put("cloudOwner", "amazon");
variables.put("cloudRegionId", "TNZED");
variables.put("isDebugLogEnabled", "true");
- // variables.put("mso-request-id", "testRequestId");
+ // variables.put("mso-request-id", "testRequestId");
variables.put("msoRequestId", "testRequestId");
variables.put("serviceInstanceId", "testServiceInstanceId");
variables.put("serviceDecomposition", serviceDecomposition);
@@ -726,7 +665,7 @@ public class OofHomingTestIT extends BaseIntegrationTest {
variables.put("cloudOwner", "amazon");
variables.put("cloudRegionId", "TNZED");
variables.put("isDebugLogEnabled", "true");
- // variables.put("mso-request-id", "testRequestId");
+ // variables.put("mso-request-id", "testRequestId");
variables.put("msoRequestId", "testRequestId");
variables.put("serviceInstanceId", "testServiceInstanceId");
variables.put("serviceDecomposition", null);
@@ -736,11 +675,15 @@ public class OofHomingTestIT extends BaseIntegrationTest {
private void setVariablesExistingLicense(Map<String, Object> variables) {
HomingSolution currentHomingSolution = new HomingSolution();
serviceDecomposition.getVnfResources().get(0).setCurrentHomingSolution(currentHomingSolution);
- serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId1");
- serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId2");
+ serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
+ .addEntitlementPool("testEntitlementPoolId1");
+ serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
+ .addEntitlementPool("testEntitlementPoolId2");
- serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId1");
- serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId2");
+ serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
+ .addLicenseKeyGroup("testLicenseKeyGroupId1");
+ serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
+ .addLicenseKeyGroup("testLicenseKeyGroupId2");
variables.put("isDebugLogEnabled", "true");
variables.put("msoRequestId", "testRequestId");
@@ -751,56 +694,52 @@ public class OofHomingTestIT extends BaseIntegrationTest {
}
private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname,
- String vnfResourceId, String cloudOwner,
- String cloudRegionId, String enList,
- String licenseList){
+ String vnfResourceId, String cloudOwner, String cloudRegionId, String enList, String licenseList) {
String solution = "";
- if(enList == null){
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" +
- serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" +
- cloudRegionId + "\", " + "\"vnf\" : { \"resourceId\" : \"" + vnfResourceId +
- "\", \"resourceType\" : \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" :" +
- " { }, \"rehome\" : false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { }," +
- " \"rehome\" : false } }";
- }else{
- //language=JSON
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" +
- serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" +
- cloudRegionId + "\", \"vnf\" : { \"resourceId\" : \"" + vnfResourceId + "\", \"resourceType\" :" +
- " \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" : { }, \"rehome\" :" +
- " false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { \"entitlementPoolList\" :" +
- " [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }";
+ if (enList == null) {
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \""
+ + serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \""
+ + cloudRegionId + "\", " + "\"vnf\" : { \"resourceId\" : \"" + vnfResourceId
+ + "\", \"resourceType\" : \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" :"
+ + " { }, \"rehome\" : false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { },"
+ + " \"rehome\" : false } }";
+ } else {
+ // language=JSON
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \""
+ + serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \""
+ + cloudRegionId + "\", \"vnf\" : { \"resourceId\" : \"" + vnfResourceId + "\", \"resourceType\" :"
+ + " \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" : { }, \"rehome\" :"
+ + " false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { \"entitlementPoolList\" :"
+ + " [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList
+ + " ] }, \"rehome\" : false } }";
}
return solution;
}
- private String homingSolutionCloud(String type, String cloudOwner,
- String cloudRegionId, Boolean flavors, String enList,
- String licenseList){
+ private String homingSolutionCloud(String type, String cloudOwner, String cloudRegionId, Boolean flavors,
+ String enList, String licenseList) {
String solution = "";
- if(enList == null){
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
- cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
- "\", \"license\" : { }, \"rehome\" : false } }";
- } else if (flavors && enList == null){
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
- cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
- "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, " +
- "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], " +
- "\"license\" : { }, \"rehome\" : false } }";
+ if (enList == null) {
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
+ + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"license\" : { }, \"rehome\" : false } }";
+ } else if (flavors && enList == null) {
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
+ + "\", \"cloudRegionId\" : \"" + cloudRegionId
+ + "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, "
+ + "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], "
+ + "\"license\" : { }, \"rehome\" : false } }";
} else if (flavors) {
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
- cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
- "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, " +
- "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], " +
- "\"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " +
- licenseList + " ] }, \"rehome\" : false } }";
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
+ + "\", \"cloudRegionId\" : \"" + cloudRegionId
+ + "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, "
+ + "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], "
+ + "\"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ "
+ + licenseList + " ] }, \"rehome\" : false } }";
} else {
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" +
- cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId +
- "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " +
- licenseList + " ] }, \"rehome\" : false } }";
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
+ + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"license\" : { \"entitlementPoolList\" : [ "
+ + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }";
}
return solution;
}
@@ -823,68 +762,68 @@ public class OofHomingTestIT extends BaseIntegrationTest {
variables.put("cloudRegionId", "TNZED");
- String serviceModelInfo = "{\"modelInvariantId\":\"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\",\"modelUuid\":" +
- "\"2f7f309d-c842-4644-a2e4-34167be5eeb4\",\"modelName\":\"vCPE Service\",\"modelVersion\":\"2.0\",}";
+ String serviceModelInfo = "{\"modelInvariantId\":\"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\",\"modelUuid\":"
+ + "\"2f7f309d-c842-4644-a2e4-34167be5eeb4\",\"modelName\":\"vCPE Service\",\"modelVersion\":\"2.0\",}";
variables.put("serviceModelInfo", serviceModelInfo);
}
private String verifyOofRequest() {
- String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," +
- "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/oofResponse/testRequestId\"," +
- "\"sourceId\":\"so\",\"requestType\":\"create\",\"numSolutions\":1,\"optimizers\":[\"placement\"]," +
- "\"timeout\":600},\"placementInfo\":{\"requestParameters\":{\"customerLatitude\":" +
- "\"32.89748\",\"customerLongitude\":\"-97.040443\",\"customerName\":\"xyz\"},\"subscriberInfo\":" +
- "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," +
- "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"ALLOTTED_RESOURCE\"" +
- ",\"serviceResourceId\":\"testResourceIdAR\",\"tenantId\":" +
- "\"null\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR\"," +
- "\"modelVersionId\":\"testARModelUuid\",\"modelName\":\"testModelNameAR\",\"modelType\":" +
- "\"testModelTypeAR\",\"modelVersion\":\"testModelVersionAR\",\"modelCustomizationName\":\"\"}}," +
- "{\"resourceModuleName\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\"," +
- "\"tenantId\":\"null\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR2\"," +
- "\"modelVersionId\":\"testAr2ModelUuid\",\"modelName\":\"testModelNameAR2\"," +
- "\"modelType\":\"testModelTypeAR2\",\"modelVersion\":\"testModelVersionAR2\"," +
- "\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":" +
- "{\"serviceInstanceId\":\"testServiceInstanceId123\"," +
- "\"serviceName\":\"null\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":" +
- "\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\"," +
- "\"modelVersion\":\"testModelVersion\",\"modelCustomizationName\":\"" +
- "\"}},\"licenseInfo\":{\"licenseDemands\":[{\"resourceModuleName\":\"VNF\",\"serviceResourceId\":" +
- "\"testResourceIdVNF\",\"resourceInstanceType\":\"VNF\",\"resourceModelInfo\":{\"modelInvariantId\":" +
- "\"testModelInvariantIdVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelName\":" +
- "\"testModelNameVNF\",\"modelType\":\"testModelTypeVNF\",\"modelVersion\":\"testModelVersionVNF\"," +
- "\"modelCustomizationName\":\"\"}}]}}";
+ String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\","
+ + "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/oofResponse/testRequestId\","
+ + "\"sourceId\":\"so\",\"requestType\":\"create\",\"numSolutions\":1,\"optimizers\":[\"placement\"],"
+ + "\"timeout\":600},\"placementInfo\":{\"requestParameters\":{\"customerLatitude\":"
+ + "\"32.89748\",\"customerLongitude\":\"-97.040443\",\"customerName\":\"xyz\"},\"subscriberInfo\":"
+ + "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\","
+ + "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"ALLOTTED_RESOURCE\""
+ + ",\"serviceResourceId\":\"testResourceIdAR\",\"tenantId\":"
+ + "\"null\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR\","
+ + "\"modelVersionId\":\"testARModelUuid\",\"modelName\":\"testModelNameAR\",\"modelType\":"
+ + "\"testModelTypeAR\",\"modelVersion\":\"testModelVersionAR\",\"modelCustomizationName\":\"\"}},"
+ + "{\"resourceModuleName\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\","
+ + "\"tenantId\":\"null\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR2\","
+ + "\"modelVersionId\":\"testAr2ModelUuid\",\"modelName\":\"testModelNameAR2\","
+ + "\"modelType\":\"testModelTypeAR2\",\"modelVersion\":\"testModelVersionAR2\","
+ + "\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":"
+ + "{\"serviceInstanceId\":\"testServiceInstanceId123\","
+ + "\"serviceName\":\"null\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":"
+ + "\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\","
+ + "\"modelVersion\":\"testModelVersion\",\"modelCustomizationName\":\""
+ + "\"}},\"licenseInfo\":{\"licenseDemands\":[{\"resourceModuleName\":\"VNF\",\"serviceResourceId\":"
+ + "\"testResourceIdVNF\",\"resourceInstanceType\":\"VNF\",\"resourceModelInfo\":{\"modelInvariantId\":"
+ + "\"testModelInvariantIdVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelName\":"
+ + "\"testModelNameVNF\",\"modelType\":\"testModelTypeVNF\",\"modelVersion\":\"testModelVersionVNF\","
+ + "\"modelCustomizationName\":\"\"}}]}}";
return request;
}
- private String verifyOofRequestExistingLicense(){
- String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," +
- "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\"," +
- "\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"]," +
- "\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\"," +
- "\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":" +
- "\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":" +
- "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," +
- "\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":" +
- "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\"," +
- "\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\"," +
- "\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\"," +
- "\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":" +
- "\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":" +
- "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":" +
- "\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\"," +
- "\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\"," +
- "\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\"," +
- "\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":" +
- "[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\"," +
- "\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":" +
- "\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\"," +
- "\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\"," +
- "\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}," +
- "\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\"," +
- "\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\"," +
- "\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":" +
- "\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";
+ private String verifyOofRequestExistingLicense() {
+ String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\","
+ + "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\","
+ + "\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"],"
+ + "\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\","
+ + "\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":"
+ + "\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":"
+ + "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\","
+ + "\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":"
+ + "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\","
+ + "\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\","
+ + "\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\","
+ + "\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":"
+ + "\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":"
+ + "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":"
+ + "\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\","
+ + "\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\","
+ + "\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\","
+ + "\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":"
+ + "[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\","
+ + "\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":"
+ + "\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\","
+ + "\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\","
+ + "\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"},"
+ + "\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\","
+ + "\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\","
+ + "\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":"
+ + "\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";
return request;
}
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java
index c994173cd7..ace5fdd15b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
@@ -27,12 +27,10 @@ import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDep
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchVfModuleId;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
-
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.test.Deployment;
import org.junit.Assert;
import org.junit.Test;
@@ -47,164 +45,176 @@ import org.slf4j.LoggerFactory;
*/
public class PrepareUpdateAAIVfModuleIT extends BaseIntegrationTest {
-
- Logger logger = LoggerFactory.getLogger(PrepareUpdateAAIVfModuleIT.class);
-
- /**
- * Test the happy path through the flow.
- */
- @Test
-
- public void happyPath() throws IOException {
-
- logStart();
-
- String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml");
-
- MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
- MockPutGenericVnf(wireMockServer, "/skask/vf-modules/vf-module/supercool", "PCRF", 200);
- MockPatchVfModuleId(wireMockServer, "skask", "supercool");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
- invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponseCode");
- logger.debug("Subflow response code: {}", responseCode);
- logger.debug("Subflow response: {}", response);
- Assert.assertEquals(200, responseCode.intValue());
- String heatStackId = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_heatStackId");
- logger.debug("Ouput heat-stack-id:{}", heatStackId);
- Assert.assertEquals("slowburn", heatStackId);
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI returns a 404.
- */
- @Test
-
- public void badGet() throws IOException {
-
- logStart();
-
- String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfById_404(wireMockServer, "skask[?]depth=1");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
- invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_getVnfResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_getVnfResponseCode");
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- logger.debug("Subflow response code: {}", responseCode);
- logger.debug("Subflow response: {}", response);
- Assert.assertEquals(404, responseCode.intValue());
- Assert.assertNotNull(workflowException);
- logger.debug("Subflow WorkflowException error message: {}", workflowException.getErrorMessage());
-
- logEnd();
- }
-
- /**
- * Test the case where the validation of the VF Module fails.
- */
- @Test
-
- public void failValidation1() throws IOException {
-
- logStart();
-
- String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml").replaceFirst("supercool", "lukewarm");
-
- MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
- invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
-
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- Assert.assertNotNull(workflowException);
- logger.debug("Subflow WorkflowException error message: {}", workflowException.getErrorMessage());
- Assert.assertTrue(workflowException.getErrorMessage().startsWith("VF Module validation error: Orchestration"));
-
- logEnd();
- }
-
- /**
- * Test the case where the validation of the VF Module fails.
- */
- @Test
-
- public void failValidation2() throws IOException {
-
- logStart();
-
- String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml").replaceFirst("supercool", "notsocool");
-
- MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
- invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
-
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- Assert.assertNotNull(workflowException);
- logger.debug("Subflow WorkflowException error message: {}", workflowException.getErrorMessage());
- Assert.assertTrue(workflowException.getErrorMessage().startsWith("VF Module validation error: VF Module"));
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI is successful, but the subsequent PUT returns 404.
- */
- @Test
-
- public void badPatch() throws IOException {
-
- logStart();
-
- String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml");
-
- MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
- MockAAIVfModuleBadPatch(wireMockServer, "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
- invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponseCode");
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- logger.debug("Subflow response code: {}", responseCode);
- logger.debug("Subflow response: {}", response);
- Assert.assertEquals(404, responseCode.intValue());
- Assert.assertNotNull(workflowException);
- logger.debug("Subflow WorkflowException error message: {}", workflowException.getErrorMessage());
-
- logEnd();
- }
+
+ Logger logger = LoggerFactory.getLogger(PrepareUpdateAAIVfModuleIT.class);
+
+ /**
+ * Test the happy path through the flow.
+ */
+ @Test
+
+ public void happyPath() throws IOException {
+
+ logStart();
+
+ String prepareUpdateAAIVfModuleRequest =
+ FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml");
+
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
+ MockPutGenericVnf(wireMockServer, "/skask/vf-modules/vf-module/supercool", "PCRF", 200);
+ MockPatchVfModuleId(wireMockServer, "skask", "supercool");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
+ invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponse");
+ Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponseCode");
+ logger.debug("Subflow response code: {}", responseCode);
+ logger.debug("Subflow response: {}", response);
+ Assert.assertEquals(200, responseCode.intValue());
+ String heatStackId = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_heatStackId");
+ logger.debug("Ouput heat-stack-id:{}", heatStackId);
+ Assert.assertEquals("slowburn", heatStackId);
+
+ logEnd();
+ }
+
+ /**
+ * Test the case where the GET to AAI returns a 404.
+ */
+ @Test
+
+ public void badGet() throws IOException {
+
+ logStart();
+
+ String prepareUpdateAAIVfModuleRequest =
+ FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml");
+ MockGetGenericVnfById_404(wireMockServer, "skask[?]depth=1");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
+ invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_getVnfResponse");
+ Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_getVnfResponseCode");
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ logger.debug("Subflow response code: {}", responseCode);
+ logger.debug("Subflow response: {}", response);
+ Assert.assertEquals(404, responseCode.intValue());
+ Assert.assertNotNull(workflowException);
+ logger.debug("Subflow WorkflowException error message: {}", workflowException.getErrorMessage());
+
+ logEnd();
+ }
+
+ /**
+ * Test the case where the validation of the VF Module fails.
+ */
+ @Test
+
+ public void failValidation1() throws IOException {
+
+ logStart();
+
+ String prepareUpdateAAIVfModuleRequest =
+ FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml")
+ .replaceFirst("supercool", "lukewarm");
+
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
+ invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
+
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ Assert.assertNotNull(workflowException);
+ logger.debug("Subflow WorkflowException error message: {}", workflowException.getErrorMessage());
+ Assert.assertTrue(workflowException.getErrorMessage().startsWith("VF Module validation error: Orchestration"));
+
+ logEnd();
+ }
+
+ /**
+ * Test the case where the validation of the VF Module fails.
+ */
+ @Test
+
+ public void failValidation2() throws IOException {
+
+ logStart();
+
+ String prepareUpdateAAIVfModuleRequest =
+ FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml")
+ .replaceFirst("supercool", "notsocool");
+
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
+ invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
+
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ Assert.assertNotNull(workflowException);
+ logger.debug("Subflow WorkflowException error message: {}", workflowException.getErrorMessage());
+ Assert.assertTrue(workflowException.getErrorMessage().startsWith("VF Module validation error: VF Module"));
+
+ logEnd();
+ }
+
+ /**
+ * Test the case where the GET to AAI is successful, but the subsequent PUT returns 404.
+ */
+ @Test
+
+ public void badPatch() throws IOException {
+
+ logStart();
+
+ String prepareUpdateAAIVfModuleRequest =
+ FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml");
+
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
+ MockAAIVfModuleBadPatch(wireMockServer,
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
+ invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponse");
+ Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponseCode");
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ logger.debug("Subflow response code: {}", responseCode);
+ logger.debug("Subflow response: {}", response);
+ Assert.assertEquals(404, responseCode.intValue());
+ Assert.assertNotNull(workflowException);
+ logger.debug("Subflow WorkflowException error message: {}", workflowException.getErrorMessage());
+
+ logEnd();
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/RainyDayHandlerIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/RainyDayHandlerIT.java
index 2f6d2ae85b..d669674297 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/RainyDayHandlerIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/RainyDayHandlerIT.java
@@ -16,16 +16,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
import static org.onap.so.bpmn.mock.StubResponsePolicy.MockPolicyAbort;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Assert;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
@@ -35,35 +33,35 @@ import org.onap.so.BaseIntegrationTest;
*/
public class RainyDayHandlerIT extends BaseIntegrationTest {
-
- @Test
-
- public void TestRainyDayHandlingSuccess() {
-
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("msoRequestId", "testRequestId");
- variables.put("serviceType", "X");
- variables.put("vnfType", "Y");
- variables.put("currentActivity", "BB1");
- variables.put("workStep", "1");
- variables.put("failedActivity", "");
- variables.put("errorCode", "123");
- variables.put("errorText", "update failed");
- variables.put("vnfName", "vSAMP1");
-
- MockPolicyAbort(wireMockServer);
-
-
- String businessKey = UUID.randomUUID().toString();
- invokeSubProcess("RainyDayHandler", businessKey, variables);
-
- waitForProcessEnd(businessKey, 10000);
-
- Assert.assertTrue(isProcessEnded(businessKey));
-
- }
-
-
-
-} \ No newline at end of file
+
+ @Test
+
+ public void TestRainyDayHandlingSuccess() {
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("msoRequestId", "testRequestId");
+ variables.put("serviceType", "X");
+ variables.put("vnfType", "Y");
+ variables.put("currentActivity", "BB1");
+ variables.put("workStep", "1");
+ variables.put("failedActivity", "");
+ variables.put("errorCode", "123");
+ variables.put("errorText", "update failed");
+ variables.put("vnfName", "vSAMP1");
+
+ MockPolicyAbort(wireMockServer);
+
+
+ String businessKey = UUID.randomUUID().toString();
+ invokeSubProcess("RainyDayHandler", businessKey, variables);
+
+ waitForProcessEnd(businessKey, 10000);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+
+ }
+
+
+
+}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ReceiveWorkflowMessageTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ReceiveWorkflowMessageTest.java
index 7f3e884601..d8e3264091 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ReceiveWorkflowMessageTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ReceiveWorkflowMessageTest.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
+
package org.onap.so.bpmn.common;
import static org.junit.Assert.assertEquals;
@@ -25,12 +25,10 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.test.Deployment;
import org.junit.Ignore;
import org.junit.Test;
@@ -44,102 +42,85 @@ import org.onap.so.bpmn.core.WorkflowException;
@Ignore
public class ReceiveWorkflowMessageTest extends WorkflowTest {
- private static final String EOL = "\n";
-
- private final CallbackSet callbacks = new CallbackSet();
-
- public ReceiveWorkflowMessageTest() throws IOException {
- callbacks.put("sdnc-event-success", JSON, "SDNCAEvent",
- "{" + EOL +
- " \"SDNCEvent\": {" + EOL +
- " \"eventType\": \"evenType\"," + EOL +
- " \"eventCorrelatorType\": \"HOST-NAME\"," + EOL +
- " \"eventCorrelator\": \"((CORRELATOR))\"," + EOL +
- " \"params\": {" + EOL +
- " \"success-indicator\":\"Y\"" + EOL +
- " }" +EOL +
- " }" + EOL +
- "}" + EOL);
-
- callbacks.put("sdnc-event-fail", JSON, "SDNCAEvent",
- "{" + EOL +
- " \"SDNCEvent\": {" + EOL +
- " \"eventType\": \"evenType\"," + EOL +
- " \"eventCorrelatorType\": \"HOST-NAME\"," + EOL +
- " \"eventCorrelator\": \"((CORRELATOR))\"," + EOL +
- " \"params\": {" + EOL +
- " \"success-indicator\":\"N\"," + EOL +
- " \"error-message\":\"SOMETHING BAD HAPPENED\"" + EOL +
- " }" +EOL +
- " }" + EOL +
- "}" + EOL);
- }
-
- /**
- * Test the happy path.
- */
- @Test
- @Deployment(resources = {
- "subprocess/ReceiveWorkflowMessage.bpmn"
- })
- public void happyPath() throws Exception {
-
- logStart();
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312");
- variables.put("isDebugLogEnabled", "true");
- variables.put("RCVWFMSG_timeout", "PT1M");
- variables.put("RCVWFMSG_messageType", "SDNCAEvent");
- variables.put("RCVWFMSG_correlator", "USOSTCDALTX0101UJZZ31");
-
- invokeSubProcess("ReceiveWorkflowMessage", businessKey, variables);
- injectWorkflowMessages(callbacks, "sdnc-event-success");
- waitForProcessEnd(businessKey, 10000);
-
- String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse");
- System.out.println("Response:\n" + response);
- assertTrue(response.contains("\"SDNCEvent\""));
- assertTrue((boolean)getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator"));
-
- logEnd();
- }
-
- /**
- * Test the timeout scenario.
- */
- @Test
- @Deployment(resources = {
- "subprocess/ReceiveWorkflowMessage.bpmn"
- })
- public void timeout() throws Exception {
-
- logStart();
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312");
- variables.put("isDebugLogEnabled", "true");
- variables.put("RCVWFMSG_timeout", "PT5S");
- variables.put("RCVWFMSG_messageType", "SDNCAEvent");
- variables.put("RCVWFMSG_correlator", "USOSTCDALTX0101UJZZ31");
-
- invokeSubProcess("ReceiveWorkflowMessage", businessKey, variables);
-
- // No injection
-
- waitForProcessEnd(businessKey, 10000);
-
- // There is no response from SDNC, so the flow doesn't set WorkflowResponse.
- String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse");
- assertNull(response);
- WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- assertNotNull(wfe);
- System.out.println(wfe.toString());
- assertEquals("Receive Workflow Message Timeout Error", wfe.getErrorMessage());
- assertFalse((boolean)getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator"));
-
- logEnd();
- }
+ private static final String EOL = "\n";
+
+ private final CallbackSet callbacks = new CallbackSet();
+
+ public ReceiveWorkflowMessageTest() throws IOException {
+ callbacks.put("sdnc-event-success", JSON, "SDNCAEvent",
+ "{" + EOL + " \"SDNCEvent\": {" + EOL + " \"eventType\": \"evenType\"," + EOL
+ + " \"eventCorrelatorType\": \"HOST-NAME\"," + EOL
+ + " \"eventCorrelator\": \"((CORRELATOR))\"," + EOL + " \"params\": {" + EOL
+ + " \"success-indicator\":\"Y\"" + EOL + " }" + EOL + " }" + EOL + "}" + EOL);
+
+ callbacks.put("sdnc-event-fail", JSON, "SDNCAEvent", "{" + EOL + " \"SDNCEvent\": {" + EOL
+ + " \"eventType\": \"evenType\"," + EOL + " \"eventCorrelatorType\": \"HOST-NAME\"," + EOL
+ + " \"eventCorrelator\": \"((CORRELATOR))\"," + EOL + " \"params\": {" + EOL
+ + " \"success-indicator\":\"N\"," + EOL + " \"error-message\":\"SOMETHING BAD HAPPENED\""
+ + EOL + " }" + EOL + " }" + EOL + "}" + EOL);
+ }
+
+ /**
+ * Test the happy path.
+ */
+ @Test
+ @Deployment(resources = {"subprocess/ReceiveWorkflowMessage.bpmn"})
+ public void happyPath() throws Exception {
+
+ logStart();
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312");
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("RCVWFMSG_timeout", "PT1M");
+ variables.put("RCVWFMSG_messageType", "SDNCAEvent");
+ variables.put("RCVWFMSG_correlator", "USOSTCDALTX0101UJZZ31");
+
+ invokeSubProcess("ReceiveWorkflowMessage", businessKey, variables);
+ injectWorkflowMessages(callbacks, "sdnc-event-success");
+ waitForProcessEnd(businessKey, 10000);
+
+ String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse");
+ System.out.println("Response:\n" + response);
+ assertTrue(response.contains("\"SDNCEvent\""));
+ assertTrue((boolean) getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator"));
+
+ logEnd();
+ }
+
+ /**
+ * Test the timeout scenario.
+ */
+ @Test
+ @Deployment(resources = {"subprocess/ReceiveWorkflowMessage.bpmn"})
+ public void timeout() throws Exception {
+
+ logStart();
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312");
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("RCVWFMSG_timeout", "PT5S");
+ variables.put("RCVWFMSG_messageType", "SDNCAEvent");
+ variables.put("RCVWFMSG_correlator", "USOSTCDALTX0101UJZZ31");
+
+ invokeSubProcess("ReceiveWorkflowMessage", businessKey, variables);
+
+ // No injection
+
+ waitForProcessEnd(businessKey, 10000);
+
+ // There is no response from SDNC, so the flow doesn't set WorkflowResponse.
+ String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse");
+ assertNull(response);
+ WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ assertNotNull(wfe);
+ System.out.println(wfe.toString());
+ assertEquals("Receive Workflow Message Timeout Error", wfe.getErrorMessage());
+ assertFalse((boolean) getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator"));
+
+ logEnd();
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterCallbackRule.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterCallbackRule.java
index dc5c36f5a7..36adccd758 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterCallbackRule.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterCallbackRule.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.common;
import javax.xml.ws.Endpoint;
-
import org.camunda.bpm.engine.ProcessEngineServices;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
@@ -29,56 +28,54 @@ import org.junit.runners.model.Statement;
import org.onap.so.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl;
/**
- * A JUnit rule that starts the SDNC Adapter Callback Service before
- * every test, and tears it down after every test. Example:
+ * A JUnit rule that starts the SDNC Adapter Callback Service before every test, and tears it down after every test.
+ * Example:
+ *
* <pre>
- * @Rule
- * public final SDNCAdapterCallbackRule sdncAdapterCallbackRule =
- * new SDNCAdapterCallbackRule(processEngineRule);
+ * &#64;Rule
+ * public final SDNCAdapterCallbackRule sdncAdapterCallbackRule = new SDNCAdapterCallbackRule(processEngineRule);
* </pre>
*/
public class SDNCAdapterCallbackRule implements TestRule {
- public static final String DEFAULT_ENDPOINT_URL =
- "http://localhost:28080/mso/SDNCAdapterCallbackService";
+ public static final String DEFAULT_ENDPOINT_URL = "http://localhost:28080/mso/SDNCAdapterCallbackService";
- private final ProcessEngineServices processEngineServices;
- private final String endpointUrl;
+ private final ProcessEngineServices processEngineServices;
+ private final String endpointUrl;
- public SDNCAdapterCallbackRule(ProcessEngineServices processEngineServices) {
- this(processEngineServices, DEFAULT_ENDPOINT_URL);
- }
+ public SDNCAdapterCallbackRule(ProcessEngineServices processEngineServices) {
+ this(processEngineServices, DEFAULT_ENDPOINT_URL);
+ }
- public SDNCAdapterCallbackRule(ProcessEngineServices processEngineServices,
- String endpointUrl) {
- this.processEngineServices = processEngineServices;
- this.endpointUrl = endpointUrl;
- }
+ public SDNCAdapterCallbackRule(ProcessEngineServices processEngineServices, String endpointUrl) {
+ this.processEngineServices = processEngineServices;
+ this.endpointUrl = endpointUrl;
+ }
- @Override
- public Statement apply(final Statement baseStmt, Description description) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- Endpoint endpoint = null;
+ @Override
+ public Statement apply(final Statement baseStmt, Description description) {
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ Endpoint endpoint = null;
- try {
- SDNCAdapterCallbackServiceImpl sdncCallbackService = new SDNCAdapterCallbackServiceImpl();
- sdncCallbackService.setProcessEngineServices4junit(processEngineServices);
+ try {
+ SDNCAdapterCallbackServiceImpl sdncCallbackService = new SDNCAdapterCallbackServiceImpl();
+ sdncCallbackService.setProcessEngineServices4junit(processEngineServices);
- System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true");
- System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");
+ System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true");
+ System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");
- System.out.println("Publishing Endpoint - " + endpointUrl);
- endpoint = Endpoint.publish(endpointUrl, sdncCallbackService);
+ System.out.println("Publishing Endpoint - " + endpointUrl);
+ endpoint = Endpoint.publish(endpointUrl, sdncCallbackService);
- baseStmt.evaluate();
- } finally {
- if (endpoint != null) {
- System.out.println("Stopping Endpoint - " + endpointUrl);
- endpoint.stop();
- }
- }
- }
- };
- }
-} \ No newline at end of file
+ baseStmt.evaluate();
+ } finally {
+ if (endpoint != null) {
+ System.out.println("Stopping Endpoint - " + endpointUrl);
+ endpoint.stop();
+ }
+ }
+ }
+ };
+ }
+}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java
index bf3fefdf9c..415e8096a3 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java
@@ -25,12 +25,10 @@ package org.onap.so.bpmn.common;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -42,81 +40,78 @@ import org.slf4j.LoggerFactory;
/**
* Unit tests for SDNCAdapterRestV2.bpmn.
*
- * This version of SDNCAdapterRest allows for interim notifications to be sent for
- * any non-final response received from SDNC.
+ * This version of SDNCAdapterRest allows for interim notifications to be sent for any non-final response received from
+ * SDNC.
*/
public class SDNCAdapterRestV2IT extends BaseIntegrationTest {
- private final CallbackSet callbacks = new CallbackSet();
-
- Logger logger = LoggerFactory.getLogger(SDNCAdapterRestV2IT.class);
-
-
- /**
- * Constructor. Insert callbacks.
- *
- * @throws IOException
- */
- public SDNCAdapterRestV2IT() throws IOException {
- String sdncCallbackFinal = FileUtil.readResourceFile("__files/SDNCAdapterRestCallbackFinal.json");
- String sdncCallbackNonFinal = FileUtil.readResourceFile("__files/SDNCAdapterRestCallbackNonFinal.json");
- callbacks.put("nonfinal", sdncCallbackNonFinal);
- callbacks.put("final", sdncCallbackFinal);
- }
-
- /**
- * Test the success path through the subflow.
- */
- @Test
- @Ignore
- public void success() throws IOException {
- logStart();
- mocks();
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("mso-request-id", "a4383a52-b9de-4bc4-bedf-02f3f9466535");
- variables.put("mso-service-instance-id", "fd8bcdbb-b799-43ce-a7ff-ed8f2965a3b5");
- variables.put("isDebugLogEnabled", "true");
- variables.put("SDNCREST_Request",
- FileUtil.readResourceFile("__files/SDNCAdapterRestV2Request.json"));
- variables.put("SDNCREST_InterimNotification1",
- FileUtil.readResourceFile("__files/SDNCInterimNotification1.json"));
-
- invokeSubProcess("SDNCAdapterRestV2", businessKey, variables);
-
- injectSDNCRestCallbacks(callbacks, "nonfinal");
-
- // First non-final response will have done a notification
- Object interimNotification = getVariableFromHistory(businessKey, "SDNCREST_interimNotification");
- Assert.assertNotNull(interimNotification);
-
- injectSDNCRestCallbacks(callbacks, "nonfinal");
-
- // Second non-final response will not have done a notification
- interimNotification = getVariableFromHistory(businessKey, "SDNCREST_interimNotification");
- Assert.assertNull(interimNotification);
-
- injectSDNCRestCallbacks(callbacks, "final");
-
- interimNotification = this.getVariableFromHistory(businessKey, "SDNCREST_interimNotification");
- Assert.assertNull(interimNotification);
-
- waitForProcessEnd(businessKey, 10000);
-
- Assert.assertTrue(isProcessEnded(businessKey));
-
- logEnd();
- }
-
- /**
- * Defines WireMock stubs needed by these tests.
- */
- private void mocks() {
- wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc"))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/json")));
- }
+ private final CallbackSet callbacks = new CallbackSet();
+
+ Logger logger = LoggerFactory.getLogger(SDNCAdapterRestV2IT.class);
+
+
+ /**
+ * Constructor. Insert callbacks.
+ *
+ * @throws IOException
+ */
+ public SDNCAdapterRestV2IT() throws IOException {
+ String sdncCallbackFinal = FileUtil.readResourceFile("__files/SDNCAdapterRestCallbackFinal.json");
+ String sdncCallbackNonFinal = FileUtil.readResourceFile("__files/SDNCAdapterRestCallbackNonFinal.json");
+ callbacks.put("nonfinal", sdncCallbackNonFinal);
+ callbacks.put("final", sdncCallbackFinal);
+ }
+
+ /**
+ * Test the success path through the subflow.
+ */
+ @Test
+ @Ignore
+ public void success() throws IOException {
+ logStart();
+ mocks();
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("mso-request-id", "a4383a52-b9de-4bc4-bedf-02f3f9466535");
+ variables.put("mso-service-instance-id", "fd8bcdbb-b799-43ce-a7ff-ed8f2965a3b5");
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("SDNCREST_Request", FileUtil.readResourceFile("__files/SDNCAdapterRestV2Request.json"));
+ variables.put("SDNCREST_InterimNotification1",
+ FileUtil.readResourceFile("__files/SDNCInterimNotification1.json"));
+
+ invokeSubProcess("SDNCAdapterRestV2", businessKey, variables);
+
+ injectSDNCRestCallbacks(callbacks, "nonfinal");
+
+ // First non-final response will have done a notification
+ Object interimNotification = getVariableFromHistory(businessKey, "SDNCREST_interimNotification");
+ Assert.assertNotNull(interimNotification);
+
+ injectSDNCRestCallbacks(callbacks, "nonfinal");
+
+ // Second non-final response will not have done a notification
+ interimNotification = getVariableFromHistory(businessKey, "SDNCREST_interimNotification");
+ Assert.assertNull(interimNotification);
+
+ injectSDNCRestCallbacks(callbacks, "final");
+
+ interimNotification = this.getVariableFromHistory(businessKey, "SDNCREST_interimNotification");
+ Assert.assertNull(interimNotification);
+
+ waitForProcessEnd(businessKey, 10000);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+
+ logEnd();
+ }
+
+ /**
+ * Defines WireMock stubs needed by these tests.
+ */
+ private void mocks() {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc"))
+ .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/json")));
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SPIPropertiesTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SPIPropertiesTest.java
index 9239889f28..96ea1cad9b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SPIPropertiesTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SPIPropertiesTest.java
@@ -22,10 +22,8 @@ package org.onap.so.bpmn.common;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
-
import java.io.FileNotFoundException;
import java.io.IOException;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.so.client.RestPropertiesLoader;
@@ -36,34 +34,37 @@ import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer;
public class SPIPropertiesTest {
- @BeforeClass
- public static void beforeClass() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void notEqual() {
- DmaapProperties one = DmaapPropertiesLoader.getInstance().getNewImpl();
- DmaapProperties two = DmaapPropertiesLoader.getInstance().getNewImpl();
- assertNotEquals(one, two);
- }
- @Test
- public void equal() {
- DmaapProperties one = DmaapPropertiesLoader.getInstance().getImpl();
- DmaapProperties two = DmaapPropertiesLoader.getInstance().getImpl();
- assertEquals(one, two);
- }
- @Test
- public void restNotEqual() {
- AAIProperties one = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
- AAIProperties two = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
- assertNotEquals(one, two);
- }
- @Test
- public void restEqual() {
- AAIProperties one = RestPropertiesLoader.getInstance().getImpl(AAIProperties.class);
- AAIProperties two = RestPropertiesLoader.getInstance().getImpl(AAIProperties.class);
- assertEquals(one, two);
- }
-
+ @BeforeClass
+ public static void beforeClass() {
+ System.setProperty("mso.config.path", "src/test/resources");
+ }
+
+ @Test
+ public void notEqual() {
+ DmaapProperties one = DmaapPropertiesLoader.getInstance().getNewImpl();
+ DmaapProperties two = DmaapPropertiesLoader.getInstance().getNewImpl();
+ assertNotEquals(one, two);
+ }
+
+ @Test
+ public void equal() {
+ DmaapProperties one = DmaapPropertiesLoader.getInstance().getImpl();
+ DmaapProperties two = DmaapPropertiesLoader.getInstance().getImpl();
+ assertEquals(one, two);
+ }
+
+ @Test
+ public void restNotEqual() {
+ AAIProperties one = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
+ AAIProperties two = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
+ assertNotEquals(one, two);
+ }
+
+ @Test
+ public void restEqual() {
+ AAIProperties one = RestPropertiesLoader.getInstance().getImpl(AAIProperties.class);
+ AAIProperties two = RestPropertiesLoader.getInstance().getImpl(AAIProperties.class);
+ assertEquals(one, two);
+ }
+
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java
index c7ba702212..6b253d2b4d 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java
@@ -25,14 +25,12 @@ package org.onap.so.bpmn.common;
import static org.onap.so.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid;
import static org.onap.so.bpmn.mock.StubResponseSNIRO.*;
import static org.junit.Assert.*;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.test.Deployment;
import org.junit.Ignore;
import org.junit.Test;
@@ -49,504 +47,588 @@ import org.slf4j.LoggerFactory;
*/
@Ignore
public class SniroHomingV1IT extends BaseIntegrationTest {
-
- Logger logger = LoggerFactory.getLogger(SniroHomingV1IT.class);
-
-
- ServiceDecomposition serviceDecomposition = new ServiceDecomposition();
- String subscriber = "";
- String subscriber2 = "";
-
- private final CallbackSet callbacks = new CallbackSet();
-
- public SniroHomingV1IT() throws IOException {
- String sniroCallback = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf");
- String sniroCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf2Net");
- String sniroCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackInfraVnf");
- String sniroCallbackNoSolution = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackNoSolutionFound");
- String sniroCallbackPolicyException = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackPolicyException");
- String sniroCallbackServiceException = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackServiceException");
- callbacks.put("sniro", JSON, "SNIROResponse", sniroCallback);
- callbacks.put("sniro2", JSON, "SNIROResponse", sniroCallback2);
- callbacks.put("sniro3", JSON, "SNIROResponse", sniroCallback3);
- callbacks.put("sniroNoSol", JSON, "SNIROResponse", sniroCallbackNoSolution);
- callbacks.put("sniroPolicyEx", JSON, "SNIROResponse", sniroCallbackPolicyException);
- callbacks.put("sniroServiceEx", JSON, "SNIROResponse", sniroCallbackServiceException);
-
- // Service Model
- ModelInfo sModel = new ModelInfo();
- sModel.setModelCustomizationUuid("testModelCustomizationUuid");
- sModel.setModelInstanceName("testModelInstanceName");
- sModel.setModelInvariantUuid("testModelInvariantId");
- sModel.setModelName("testModelName");
- sModel.setModelUuid("testModelUuid");
- sModel.setModelVersion("testModelVersion");
- // Service Instance
- ServiceInstance si = new ServiceInstance();
- si.setInstanceId("testServiceInstanceId123");
- // Allotted Resources
- List<AllottedResource> arList = new ArrayList<AllottedResource>();
- AllottedResource ar = new AllottedResource();
- ar.setResourceId("testResourceIdAR");
- ar.setResourceInstanceName("testARInstanceName");
- ModelInfo arModel = new ModelInfo();
- arModel.setModelCustomizationUuid("testModelCustomizationUuidAR");
- arModel.setModelInvariantUuid("testModelInvariantIdAR");
- arModel.setModelName("testModelNameAR");
- arModel.setModelVersion("testModelVersionAR");
- arModel.setModelUuid("testARModelUuid");
- arModel.setModelType("testModelTypeAR");
- ar.setModelInfo(arModel);
- AllottedResource ar2 = new AllottedResource();
- ar2.setResourceId("testResourceIdAR2");
- ar2.setResourceInstanceName("testAR2InstanceName");
- ModelInfo arModel2 = new ModelInfo();
- arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2");
- arModel2.setModelInvariantUuid("testModelInvariantIdAR2");
- arModel2.setModelName("testModelNameAR2");
- arModel2.setModelVersion("testModelVersionAR2");
- arModel2.setModelUuid("testAr2ModelUuid");
- arModel2.setModelType("testModelTypeAR2");
- ar2.setModelInfo(arModel2);
- arList.add(ar);
- arList.add(ar2);
- // Vnfs
- List<VnfResource> vnfList = new ArrayList<VnfResource>();
- VnfResource vnf = new VnfResource();
- vnf.setResourceId("testResourceIdVNF");
- vnf.setResourceInstanceName("testVnfInstanceName");
- ModelInfo vnfModel = new ModelInfo();
- vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF");
- vnfModel.setModelInvariantUuid("testModelInvariantIdVNF");
- vnfModel.setModelName("testModelNameVNF");
- vnfModel.setModelVersion("testModelVersionVNF");
- vnfModel.setModelUuid("testVnfModelUuid");
- vnfModel.setModelType("testModelTypeVNF");
- vnf.setModelInfo(vnfModel);
- vnfList.add(vnf);
- logger.debug("SERVICE DECOMP: {}", serviceDecomposition.getServiceResourcesJsonString());
- serviceDecomposition.setModelInfo(sModel);
- serviceDecomposition.setAllottedResources(arList);
- serviceDecomposition.setVnfResources(vnfList);
- serviceDecomposition.setServiceInstance(si);
-
- // Subscriber
- subscriber = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
- subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
- }
-
- @Test
- // 1802 merge
-
- public void testHoming_success_2AR1Vnf() throws Exception {
-
- mockSNIRO(wireMockServer);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariables(variables);
-
- invokeSubProcess("Homing", businessKey, variables);
-
- injectWorkflowMessages(callbacks, "sniro");
-
- waitForProcessEnd(businessKey, 10000);
-
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
- String expectedSniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
-
- Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
- HomingSolution resourceARHoming = resourceAR.getHomingSolution();
- Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
- HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
- Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
- HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
- String resourceARHomingString = resourceARHoming.toString();
- resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
- String resourceARHoming2String = resourceARHoming2.toString();
- resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
- String resourceVNFHomingString = resourceVNFHoming.toString();
- resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
- expectedSniroRequest = expectedSniroRequest.replaceAll("\\s+", "");
-
- assertNull(workflowException);
- assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString);
- assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String);
- assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString);
- assertEquals(verifySniroRequest(), expectedSniroRequest);
-
- }
-
- @Test
- // 1802 merge
-
- public void testHoming_success_2AR1Vnf2Net() throws Exception {
-
- mockSNIRO(wireMockServer);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariables2(variables);
-
- invokeSubProcess("Homing", businessKey, variables);
-
- injectWorkflowMessages(callbacks, "sniro2");
-
- waitForProcessEnd(businessKey, 10000);
-
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
- String expectedSniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
-
- Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
- HomingSolution resourceARHoming = resourceAR.getHomingSolution();
- Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
- HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
- Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
- HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
- Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet");
- HomingSolution resourceNetHoming = resourceNet.getHomingSolution();
- Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2");
- HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution();
-
- String resourceARHomingString = resourceARHoming.toString();
- resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
- String resourceARHoming2String = resourceARHoming2.toString();
- resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
- String resourceVNFHomingString = resourceVNFHoming.toString();
- resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
- String resourceNetHomingString = resourceNetHoming.toString();
- resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " ");
- String resourceNetHoming2String = resourceNetHoming2.toString();
- resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " ");
- expectedSniroRequest = expectedSniroRequest.replaceAll("\\s+", "");
-
- assertNull(workflowException);
- assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString);
- assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String);
- assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString);
- assertEquals(homingSolutionService("service", "testServiceInstanceIdNet", "testVnfHostNameNet", "aic", "testCloudRegionIdNet", "testAicClliNet", "3.0", null, null), resourceNetHomingString);
- assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionIdNet2", "testAicClliNet2", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"", "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""), resourceNetHoming2String);
- assertEquals(verifySniroRequest(), expectedSniroRequest);
- }
-
- @Test
- // 1802 merge
-
- public void testHoming_success_vnfResourceList() throws Exception {
-
- // Create a Service Decomposition
- MockGetServiceResourcesCatalogDataByModelUuid(wireMockServer, "2f7f309d-c842-4644-a2e4-34167be5eeb4", "/BuildingBlocks/catalogResp.json");
- String busKey = UUID.randomUUID().toString();
- Map<String, Object> vars = new HashMap<>();
- setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
- invokeSubProcess("DecomposeService", busKey, vars);
-
- ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition");
- List<VnfResource> vnfResourceList = sd.getVnfResources();
- vnfResourceList.get(0).setResourceId("test-resource-id-000");
-
- // Invoke Homing
-
- mockSNIRO(wireMockServer);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("homingService", "sniro");
- variables.put("isDebugLogEnabled", "true");
- variables.put("msoRequestId", "testRequestId");
- variables.put("serviceInstanceId", "testServiceInstanceId");
- variables.put("serviceDecomposition", sd);
- variables.put("subscriberInfo", subscriber2);
-
- invokeSubProcess("Homing", businessKey, variables);
- injectWorkflowMessages(callbacks, "sniro3");
- waitForProcessEnd(businessKey, 10000);
-
- //Get Variables
-
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
-
- Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000");
- HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution();
-
- String resourceVnfHomingString = resourceVnfHoming.toString();
- resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " ");
-
- assertNull(workflowException);
-
- //Verify request
- String sniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
- assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/sniroRequest_infravnf").replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""), sniroRequest.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""));
-
- assertEquals(homingSolutionService("service", "service-instance-01234", "MDTNJ01", "CloudOwner", "mtmnj1a", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString);
- }
-
- @Test
-
- public void testHoming_success_existingLicense() throws Exception {
-
- mockSNIRO(wireMockServer);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
- setVariablesExistingLicense(variables);
-
- invokeSubProcess("Homing", businessKey, variables);
- injectWorkflowMessages(callbacks, "sniro");
+ Logger logger = LoggerFactory.getLogger(SniroHomingV1IT.class);
+
+
+ ServiceDecomposition serviceDecomposition = new ServiceDecomposition();
+ String subscriber = "";
+ String subscriber2 = "";
+
+ private final CallbackSet callbacks = new CallbackSet();
+
+ public SniroHomingV1IT() throws IOException {
+ String sniroCallback = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf");
+ String sniroCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf2Net");
+ String sniroCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackInfraVnf");
+ String sniroCallbackNoSolution =
+ FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackNoSolutionFound");
+ String sniroCallbackPolicyException =
+ FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackPolicyException");
+ String sniroCallbackServiceException =
+ FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackServiceException");
+ callbacks.put("sniro", JSON, "SNIROResponse", sniroCallback);
+ callbacks.put("sniro2", JSON, "SNIROResponse", sniroCallback2);
+ callbacks.put("sniro3", JSON, "SNIROResponse", sniroCallback3);
+ callbacks.put("sniroNoSol", JSON, "SNIROResponse", sniroCallbackNoSolution);
+ callbacks.put("sniroPolicyEx", JSON, "SNIROResponse", sniroCallbackPolicyException);
+ callbacks.put("sniroServiceEx", JSON, "SNIROResponse", sniroCallbackServiceException);
+
+ // Service Model
+ ModelInfo sModel = new ModelInfo();
+ sModel.setModelCustomizationUuid("testModelCustomizationUuid");
+ sModel.setModelInstanceName("testModelInstanceName");
+ sModel.setModelInvariantUuid("testModelInvariantId");
+ sModel.setModelName("testModelName");
+ sModel.setModelUuid("testModelUuid");
+ sModel.setModelVersion("testModelVersion");
+ // Service Instance
+ ServiceInstance si = new ServiceInstance();
+ si.setInstanceId("testServiceInstanceId123");
+ // Allotted Resources
+ List<AllottedResource> arList = new ArrayList<AllottedResource>();
+ AllottedResource ar = new AllottedResource();
+ ar.setResourceId("testResourceIdAR");
+ ar.setResourceInstanceName("testARInstanceName");
+ ModelInfo arModel = new ModelInfo();
+ arModel.setModelCustomizationUuid("testModelCustomizationUuidAR");
+ arModel.setModelInvariantUuid("testModelInvariantIdAR");
+ arModel.setModelName("testModelNameAR");
+ arModel.setModelVersion("testModelVersionAR");
+ arModel.setModelUuid("testARModelUuid");
+ arModel.setModelType("testModelTypeAR");
+ ar.setModelInfo(arModel);
+ AllottedResource ar2 = new AllottedResource();
+ ar2.setResourceId("testResourceIdAR2");
+ ar2.setResourceInstanceName("testAR2InstanceName");
+ ModelInfo arModel2 = new ModelInfo();
+ arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2");
+ arModel2.setModelInvariantUuid("testModelInvariantIdAR2");
+ arModel2.setModelName("testModelNameAR2");
+ arModel2.setModelVersion("testModelVersionAR2");
+ arModel2.setModelUuid("testAr2ModelUuid");
+ arModel2.setModelType("testModelTypeAR2");
+ ar2.setModelInfo(arModel2);
+ arList.add(ar);
+ arList.add(ar2);
+ // Vnfs
+ List<VnfResource> vnfList = new ArrayList<VnfResource>();
+ VnfResource vnf = new VnfResource();
+ vnf.setResourceId("testResourceIdVNF");
+ vnf.setResourceInstanceName("testVnfInstanceName");
+ ModelInfo vnfModel = new ModelInfo();
+ vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF");
+ vnfModel.setModelInvariantUuid("testModelInvariantIdVNF");
+ vnfModel.setModelName("testModelNameVNF");
+ vnfModel.setModelVersion("testModelVersionVNF");
+ vnfModel.setModelUuid("testVnfModelUuid");
+ vnfModel.setModelType("testModelTypeVNF");
+ vnf.setModelInfo(vnfModel);
+ vnfList.add(vnf);
+ logger.debug("SERVICE DECOMP: {}", serviceDecomposition.getServiceResourcesJsonString());
+ serviceDecomposition.setModelInfo(sModel);
+ serviceDecomposition.setAllottedResources(arList);
+ serviceDecomposition.setVnfResources(vnfList);
+ serviceDecomposition.setServiceInstance(si);
+
+ // Subscriber
+ subscriber =
+ "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
+ subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
+ }
+
+ @Test
+ // 1802 merge
+
+ public void testHoming_success_2AR1Vnf() throws Exception {
+
+ mockSNIRO(wireMockServer);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariables(variables);
+
+ invokeSubProcess("Homing", businessKey, variables);
+
+ injectWorkflowMessages(callbacks, "sniro");
+
+ waitForProcessEnd(businessKey, 10000);
+
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ ServiceDecomposition serviceDecompositionExp =
+ (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
+ String expectedSniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
+
+ Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
+ HomingSolution resourceARHoming = resourceAR.getHomingSolution();
+ Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
+ HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
+ Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
+ HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
+ String resourceARHomingString = resourceARHoming.toString();
+ resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
+ String resourceARHoming2String = resourceARHoming2.toString();
+ resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
+ String resourceVNFHomingString = resourceVNFHoming.toString();
+ resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
+ expectedSniroRequest = expectedSniroRequest.replaceAll("\\s+", "");
+
+ assertNull(workflowException);
+ assertEquals(
+ homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0",
+ "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
+ resourceARHomingString);
+ assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2",
+ "testAicClli2", "3.0", null, null), resourceARHoming2String);
+ assertEquals(
+ homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0",
+ "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
+ resourceVNFHomingString);
+ assertEquals(verifySniroRequest(), expectedSniroRequest);
+
+ }
+
+ @Test
+ // 1802 merge
+
+ public void testHoming_success_2AR1Vnf2Net() throws Exception {
+
+ mockSNIRO(wireMockServer);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariables2(variables);
+
+ invokeSubProcess("Homing", businessKey, variables);
+
+ injectWorkflowMessages(callbacks, "sniro2");
+
+ waitForProcessEnd(businessKey, 10000);
+
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ ServiceDecomposition serviceDecompositionExp =
+ (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
+ String expectedSniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
+
+ Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
+ HomingSolution resourceARHoming = resourceAR.getHomingSolution();
+ Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
+ HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
+ Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
+ HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
+ Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet");
+ HomingSolution resourceNetHoming = resourceNet.getHomingSolution();
+ Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2");
+ HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution();
+
+ String resourceARHomingString = resourceARHoming.toString();
+ resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
+ String resourceARHoming2String = resourceARHoming2.toString();
+ resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
+ String resourceVNFHomingString = resourceVNFHoming.toString();
+ resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
+ String resourceNetHomingString = resourceNetHoming.toString();
+ resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " ");
+ String resourceNetHoming2String = resourceNetHoming2.toString();
+ resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " ");
+ expectedSniroRequest = expectedSniroRequest.replaceAll("\\s+", "");
+
+ assertNull(workflowException);
+ assertEquals(
+ homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0",
+ "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
+ resourceARHomingString);
+ assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2",
+ "testAicClli2", "3.0", null, null), resourceARHoming2String);
+ assertEquals(
+ homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0",
+ "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
+ resourceVNFHomingString);
+ assertEquals(homingSolutionService("service", "testServiceInstanceIdNet", "testVnfHostNameNet", "aic",
+ "testCloudRegionIdNet", "testAicClliNet", "3.0", null, null), resourceNetHomingString);
+ assertEquals(
+ homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionIdNet2", "testAicClliNet2", "3.0",
+ "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"",
+ "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""),
+ resourceNetHoming2String);
+ assertEquals(verifySniroRequest(), expectedSniroRequest);
+ }
+
+ @Test
+ // 1802 merge
+
+ public void testHoming_success_vnfResourceList() throws Exception {
+
+ // Create a Service Decomposition
+ MockGetServiceResourcesCatalogDataByModelUuid(wireMockServer, "2f7f309d-c842-4644-a2e4-34167be5eeb4",
+ "/BuildingBlocks/catalogResp.json");
+ String busKey = UUID.randomUUID().toString();
+ Map<String, Object> vars = new HashMap<>();
+ setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
+ invokeSubProcess("DecomposeService", busKey, vars);
+
+ ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition");
+ List<VnfResource> vnfResourceList = sd.getVnfResources();
+ vnfResourceList.get(0).setResourceId("test-resource-id-000");
+
+ // Invoke Homing
+
+ mockSNIRO(wireMockServer);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("homingService", "sniro");
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("msoRequestId", "testRequestId");
+ variables.put("serviceInstanceId", "testServiceInstanceId");
+ variables.put("serviceDecomposition", sd);
+ variables.put("subscriberInfo", subscriber2);
+
+ invokeSubProcess("Homing", businessKey, variables);
+ injectWorkflowMessages(callbacks, "sniro3");
+ waitForProcessEnd(businessKey, 10000);
+
+ // Get Variables
+
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ ServiceDecomposition serviceDecompositionExp =
+ (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
+
+ Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000");
+ HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution();
+
+ String resourceVnfHomingString = resourceVnfHoming.toString();
+ resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " ");
+
+ assertNull(workflowException);
+
+ // Verify request
+ String sniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
+ assertEquals(
+ FileUtil.readResourceFile("__files/BuildingBlocks/sniroRequest_infravnf").replaceAll("\n", "")
+ .replaceAll("\r", "").replaceAll("\t", ""),
+ sniroRequest.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""));
+
+ assertEquals(homingSolutionService("service", "service-instance-01234", "MDTNJ01", "CloudOwner", "mtmnj1a",
+ "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
+ resourceVnfHomingString);
+ }
+
+ @Test
+
+ public void testHoming_success_existingLicense() throws Exception {
+
+ mockSNIRO(wireMockServer);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<String, Object>();
+ setVariablesExistingLicense(variables);
+
+ invokeSubProcess("Homing", businessKey, variables);
+
+ injectWorkflowMessages(callbacks, "sniro");
+
+ waitForProcessEnd(businessKey, 10000);
+
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ ServiceDecomposition serviceDecompositionExp =
+ (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
+ String sniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
- waitForProcessEnd(businessKey, 10000);
+ Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
+ HomingSolution resourceARHoming = resourceAR.getHomingSolution();
+ Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
+ HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
+ Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
+ HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
+ String resourceARHomingString = resourceARHoming.toString();
+ resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
+ String resourceARHoming2String = resourceARHoming2.toString();
+ resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
+ String resourceVNFHomingString = resourceVNFHoming.toString();
+ resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
+ sniroRequest = sniroRequest.replaceAll("\\s+", "");
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
- String sniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
+ assertNull(workflowException);
+ assertEquals(
+ homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0",
+ "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""),
+ resourceARHomingString);
+ assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2",
+ "testAicClli2", "3.0", null, null), resourceARHoming2String);
+ assertEquals(
+ homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0",
+ "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"",
+ "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""),
+ resourceVNFHomingString);
+ assertEquals(verifySniroRequest_existingLicense(), sniroRequest);
- Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
- HomingSolution resourceARHoming = resourceAR.getHomingSolution();
- Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
- HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
- Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
- HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
- String resourceARHomingString = resourceARHoming.toString();
- resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
- String resourceARHoming2String = resourceARHoming2.toString();
- resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
- String resourceVNFHomingString = resourceVNFHoming.toString();
- resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
- sniroRequest = sniroRequest.replaceAll("\\s+", "");
+ }
- assertNull(workflowException);
- assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString);
- assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String);
- assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString);
- assertEquals(verifySniroRequest_existingLicense(), sniroRequest);
- }
+ @Test
+ public void testHoming_error_inputVariable() throws Exception {
- @Test
-
- public void testHoming_error_inputVariable() throws Exception {
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariables3(variables);
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariables3(variables);
+ invokeSubProcess("Homing", businessKey, variables);
- invokeSubProcess("Homing", businessKey, variables);
+ waitForProcessEnd(businessKey, 10000);
- waitForProcessEnd(businessKey, 10000);
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ assertEquals(
+ "WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required input variable is missing or null]",
+ workflowException.toString());
+ }
- assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required input variable is missing or null]", workflowException.toString());
- }
+ @Test
- @Test
-
- public void testHoming_error_badResponse() throws Exception {
- mockSNIRO_500(wireMockServer);
+ public void testHoming_error_badResponse() throws Exception {
+ mockSNIRO_500(wireMockServer);
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariables(variables);
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariables(variables);
- invokeSubProcess("Homing", businessKey, variables);
+ invokeSubProcess("Homing", businessKey, variables);
- waitForProcessEnd(businessKey, 10000);
+ waitForProcessEnd(businessKey, 10000);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- assertEquals("WorkflowException[processKey=Homing,errorCode=500,errorMessage=Received a Bad Sync Response from Sniro/OOF.]", workflowException.toString());
- }
+ assertEquals(
+ "WorkflowException[processKey=Homing,errorCode=500,errorMessage=Received a Bad Sync Response from Sniro/OOF.]",
+ workflowException.toString());
+ }
- @Test
- // 1802 merge
-
- public void testHoming_error_sniroNoSolution() throws Exception {
- mockSNIRO(wireMockServer);
+ @Test
+ // 1802 merge
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariables(variables);
+ public void testHoming_error_sniroNoSolution() throws Exception {
+ mockSNIRO(wireMockServer);
- invokeSubProcess("Homing", businessKey, variables);
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariables(variables);
- injectWorkflowMessages(callbacks, "sniroNoSol");
+ invokeSubProcess("Homing", businessKey, variables);
- waitForProcessEnd(businessKey, 10000);
+ injectWorkflowMessages(callbacks, "sniroNoSol");
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ waitForProcessEnd(businessKey, 10000);
- assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=No solution found for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8]", workflowException.toString());
- }
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+
+ assertEquals(
+ "WorkflowException[processKey=Homing,errorCode=400,errorMessage=No solution found for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8]",
+ workflowException.toString());
+ }
- @Test
-
- public void testHoming_error_sniroPolicyException() throws Exception {
- mockSNIRO(wireMockServer);
+ @Test
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariables(variables);
+ public void testHoming_error_sniroPolicyException() throws Exception {
+ mockSNIRO(wireMockServer);
- invokeSubProcess("Homing", businessKey, variables);
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariables(variables);
- injectWorkflowMessages(callbacks, "sniroPolicyEx");
+ invokeSubProcess("Homing", businessKey, variables);
- waitForProcessEnd(businessKey, 10000);
+ injectWorkflowMessages(callbacks, "sniroPolicyEx");
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ waitForProcessEnd(businessKey, 10000);
- assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=Sniro Async Callback Response contains a Request Error Policy Exception: Message content size exceeds the allowable limit]", workflowException.toString());
- }
-
- @Test
-
- public void testHoming_error_sniroServiceException() throws Exception {
- mockSNIRO(wireMockServer);
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariables(variables);
+ assertEquals(
+ "WorkflowException[processKey=Homing,errorCode=400,errorMessage=Sniro Async Callback Response contains a Request Error Policy Exception: Message content size exceeds the allowable limit]",
+ workflowException.toString());
+ }
- invokeSubProcess("Homing", businessKey, variables);
+ @Test
- injectWorkflowMessages(callbacks, "sniroServiceEx");
+ public void testHoming_error_sniroServiceException() throws Exception {
+ mockSNIRO(wireMockServer);
- waitForProcessEnd(businessKey, 10000);
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariables(variables);
- //Get Variables
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
-
- assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=Sniro Async Callback Response contains a Request Error Service Exception: SNIROPlacementError: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://135.21.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]", workflowException.toString());
- }
-
-
-
- private void setVariables(Map<String, Object> variables) {
- variables.put("homingService", "sniro");
- variables.put("isDebugLogEnabled", "true");
- // variables.put("mso-request-id", "testRequestId");
- variables.put("msoRequestId", "testRequestId");
- variables.put("serviceInstanceId", "testServiceInstanceId");
- variables.put("serviceDecomposition", serviceDecomposition);
- variables.put("subscriberInfo", subscriber2);
-
- }
-
- private void setVariables2(Map<String, Object> variables) {
- List<NetworkResource> netList = new ArrayList<NetworkResource>();
- NetworkResource net = new NetworkResource();
- net.setResourceId("testResourceIdNet");
- ModelInfo netModel = new ModelInfo();
- netModel.setModelCustomizationUuid("testModelCustomizationUuidNet");
- netModel.setModelInvariantUuid("testModelInvariantIdNet");
- netModel.setModelName("testModelNameNet");
- netModel.setModelVersion("testModelVersionNet");
- net.setModelInfo(netModel);
- netList.add(net);
- NetworkResource net2 = new NetworkResource();
- net2.setResourceId("testResourceIdNet2");
- ModelInfo netModel2 = new ModelInfo();
- netModel2.setModelCustomizationUuid("testModelCustomizationUuidNet2");
- netModel2.setModelInvariantUuid("testModelInvariantIdNet2");
- netModel2.setModelName("testModelNameNet2");
- netModel2.setModelVersion("testModelVersionNet2");
- net2.setModelInfo(netModel2);
- netList.add(net2);
- serviceDecomposition.setNetworkResources(netList);
-
- variables.put("homingService", "sniro");
- variables.put("isDebugLogEnabled", "true");
- variables.put("msoRequestId", "testRequestId");
- variables.put("serviceInstanceId", "testServiceInstanceId");
- variables.put("serviceDecomposition", serviceDecomposition);
- variables.put("subscriberInfo", subscriber2);
- }
-
- private void setVariables3(Map<String, Object> variables) {
- variables.put("homingService", "sniro");
- variables.put("isDebugLogEnabled", "true");
- // variables.put("mso-request-id", "testRequestId");
- variables.put("msoRequestId", "testRequestId");
- variables.put("serviceInstanceId", "testServiceInstanceId");
- variables.put("serviceDecomposition", null);
- variables.put("subscriberInfo", subscriber2);
-
- }
-
- private void setVariablesExistingLicense(Map<String, Object> variables) {
- HomingSolution currentHomingSolution = new HomingSolution();
- serviceDecomposition.getVnfResources().get(0).setCurrentHomingSolution(currentHomingSolution);
- serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId1");
- serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId2");
-
- serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId1");
- serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId2");
-
- variables.put("isDebugLogEnabled", "true");
- // variables.put("mso-request-id", "testRequestId");
- variables.put("msoRequestId", "testRequestId");
- variables.put("serviceInstanceId", "testServiceInstanceId");
- variables.put("serviceDecomposition", serviceDecomposition);
- variables.put("subscriberInfo", subscriber2);
-
- }
-
- private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname, String cloudOwner, String cloudRegionId, String aicClli, String aicVersion, String enList, String licenseList){
- String solution = "";
- if(enList == null){
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + serviceInstanceId + "\", \"vnfHostname\" : \"" + vnfHostname + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { }, \"rehome\" : false } }";
- }else{
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + serviceInstanceId + "\", \"vnfHostname\" : \"" + vnfHostname + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }";
- }
- return solution;
- }
-
- private String homingSolutionCloud(String type, String serviceInstanceId, String vnfHostname, String cloudOwner, String cloudRegionId, String aicClli, String aicVersion, String enList, String licenseList){
- String solution = "";
- if(enList == null){
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { }, \"rehome\" : false } }";
- }else{
- solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }";
- }
- return solution;
- }
-
- private void setVariablesForServiceDecomposition(Map<String, Object> variables, String requestId, String siId) {
- variables.put("homingService", "sniro");
- variables.put("isDebugLogEnabled", "true");
- variables.put("mso-request-id", requestId);
- variables.put("msoRequestId", requestId);
- variables.put("serviceInstanceId",siId);
-
- String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," +
- "\"modelInvariantUuid\": \"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\"," +
- "\"modelUuid\": \"2f7f309d-c842-4644-a2e4-34167be5eeb4\"," +
- "\"modelName\": \"ADIOD vRouter vCE 011017 Service\"," +
- "\"modelVersion\": \"5.0\"," +
- "}";
- variables.put("serviceModelInfo", serviceModelInfo);
- }
-
- private String verifySniroRequest(){
- String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\",\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\",\"sourceId\":\"mso\",\"requestType\":\"initial\",\"optimizer\":[\"placement\",\"license\"],\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\",\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\",\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\",\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\",\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\",\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\",\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\",\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\",\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}}]},\"policyId\":[],\"serviceInstanceId\":\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";
- return request;
- }
-
- private String verifySniroRequest_existingLicense(){
- String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\",\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\",\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"],\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\",\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\",\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\",\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\",\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\",\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\",\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\",\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\",\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"},\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\",\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\",\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";
- return request;
- }
+ invokeSubProcess("Homing", businessKey, variables);
+
+ injectWorkflowMessages(callbacks, "sniroServiceEx");
+
+ waitForProcessEnd(businessKey, 10000);
+
+ // Get Variables
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+
+ assertEquals(
+ "WorkflowException[processKey=Homing,errorCode=400,errorMessage=Sniro Async Callback Response contains a Request Error Service Exception: SNIROPlacementError: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://135.21.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]",
+ workflowException.toString());
+ }
+
+
+
+ private void setVariables(Map<String, Object> variables) {
+ variables.put("homingService", "sniro");
+ variables.put("isDebugLogEnabled", "true");
+ // variables.put("mso-request-id", "testRequestId");
+ variables.put("msoRequestId", "testRequestId");
+ variables.put("serviceInstanceId", "testServiceInstanceId");
+ variables.put("serviceDecomposition", serviceDecomposition);
+ variables.put("subscriberInfo", subscriber2);
+
+ }
+
+ private void setVariables2(Map<String, Object> variables) {
+ List<NetworkResource> netList = new ArrayList<NetworkResource>();
+ NetworkResource net = new NetworkResource();
+ net.setResourceId("testResourceIdNet");
+ ModelInfo netModel = new ModelInfo();
+ netModel.setModelCustomizationUuid("testModelCustomizationUuidNet");
+ netModel.setModelInvariantUuid("testModelInvariantIdNet");
+ netModel.setModelName("testModelNameNet");
+ netModel.setModelVersion("testModelVersionNet");
+ net.setModelInfo(netModel);
+ netList.add(net);
+ NetworkResource net2 = new NetworkResource();
+ net2.setResourceId("testResourceIdNet2");
+ ModelInfo netModel2 = new ModelInfo();
+ netModel2.setModelCustomizationUuid("testModelCustomizationUuidNet2");
+ netModel2.setModelInvariantUuid("testModelInvariantIdNet2");
+ netModel2.setModelName("testModelNameNet2");
+ netModel2.setModelVersion("testModelVersionNet2");
+ net2.setModelInfo(netModel2);
+ netList.add(net2);
+ serviceDecomposition.setNetworkResources(netList);
+
+ variables.put("homingService", "sniro");
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("msoRequestId", "testRequestId");
+ variables.put("serviceInstanceId", "testServiceInstanceId");
+ variables.put("serviceDecomposition", serviceDecomposition);
+ variables.put("subscriberInfo", subscriber2);
+ }
+
+ private void setVariables3(Map<String, Object> variables) {
+ variables.put("homingService", "sniro");
+ variables.put("isDebugLogEnabled", "true");
+ // variables.put("mso-request-id", "testRequestId");
+ variables.put("msoRequestId", "testRequestId");
+ variables.put("serviceInstanceId", "testServiceInstanceId");
+ variables.put("serviceDecomposition", null);
+ variables.put("subscriberInfo", subscriber2);
+
+ }
+
+ private void setVariablesExistingLicense(Map<String, Object> variables) {
+ HomingSolution currentHomingSolution = new HomingSolution();
+ serviceDecomposition.getVnfResources().get(0).setCurrentHomingSolution(currentHomingSolution);
+ serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
+ .addEntitlementPool("testEntitlementPoolId1");
+ serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
+ .addEntitlementPool("testEntitlementPoolId2");
+
+ serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
+ .addLicenseKeyGroup("testLicenseKeyGroupId1");
+ serviceDecomposition.getVnfResources().get(0).getCurrentHomingSolution().getLicense()
+ .addLicenseKeyGroup("testLicenseKeyGroupId2");
+
+ variables.put("isDebugLogEnabled", "true");
+ // variables.put("mso-request-id", "testRequestId");
+ variables.put("msoRequestId", "testRequestId");
+ variables.put("serviceInstanceId", "testServiceInstanceId");
+ variables.put("serviceDecomposition", serviceDecomposition);
+ variables.put("subscriberInfo", subscriber2);
+
+ }
+
+ private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname, String cloudOwner,
+ String cloudRegionId, String aicClli, String aicVersion, String enList, String licenseList) {
+ String solution = "";
+ if (enList == null) {
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \""
+ + serviceInstanceId + "\", \"vnfHostname\" : \"" + vnfHostname + "\", \"cloudOwner\" : \""
+ + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli
+ + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { }, \"rehome\" : false } }";
+ } else {
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \""
+ + serviceInstanceId + "\", \"vnfHostname\" : \"" + vnfHostname + "\", \"cloudOwner\" : \""
+ + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli
+ + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { \"entitlementPoolList\" : [ "
+ + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }";
+ }
+ return solution;
+ }
+
+ private String homingSolutionCloud(String type, String serviceInstanceId, String vnfHostname, String cloudOwner,
+ String cloudRegionId, String aicClli, String aicVersion, String enList, String licenseList) {
+ String solution = "";
+ if (enList == null) {
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
+ + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli
+ + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { }, \"rehome\" : false } }";
+ } else {
+ solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner
+ + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli
+ + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { \"entitlementPoolList\" : [ "
+ + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }";
+ }
+ return solution;
+ }
+
+ private void setVariablesForServiceDecomposition(Map<String, Object> variables, String requestId, String siId) {
+ variables.put("homingService", "sniro");
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("mso-request-id", requestId);
+ variables.put("msoRequestId", requestId);
+ variables.put("serviceInstanceId", siId);
+
+ String serviceModelInfo = "{ " + "\"modelType\": \"service\","
+ + "\"modelInvariantUuid\": \"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\","
+ + "\"modelUuid\": \"2f7f309d-c842-4644-a2e4-34167be5eeb4\","
+ + "\"modelName\": \"ADIOD vRouter vCE 011017 Service\"," + "\"modelVersion\": \"5.0\"," + "}";
+ variables.put("serviceModelInfo", serviceModelInfo);
+ }
+
+ private String verifySniroRequest() {
+ String request =
+ "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\",\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\",\"sourceId\":\"mso\",\"requestType\":\"initial\",\"optimizer\":[\"placement\",\"license\"],\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\",\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\",\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\",\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\",\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\",\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\",\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\",\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\",\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}}]},\"policyId\":[],\"serviceInstanceId\":\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";
+ return request;
+ }
+
+ private String verifySniroRequest_existingLicense() {
+ String request =
+ "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\",\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\",\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"],\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\",\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\",\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\",\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\",\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\",\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\",\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\",\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\",\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"},\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\",\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\",\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";
+ return request;
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java
index 5015a1351a..fc991bd50e 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
@@ -28,12 +28,10 @@ import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchGenericVnf;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutGenericVnf_Bad;
-
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.test.Deployment;
import org.junit.Assert;
import org.junit.Ignore;
@@ -49,129 +47,134 @@ import org.slf4j.LoggerFactory;
*/
public class UpdateAAIGenericVnfIT extends BaseIntegrationTest {
-
- Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class);
-
-
- /**
- * Test the happy path through the flow.
- */
- @Test
-
- public void happyPath() throws IOException {
- logStart();
-
- String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
- MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
- MockPutGenericVnf(wireMockServer, "/skask", 200);
- MockPatchGenericVnf(wireMockServer, "skask");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
- invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponseCode");
- logger.debug("Subflow response code: {}", responseCode);
- logger.debug("Subflow response: {}", response);
- Assert.assertEquals(200, responseCode.intValue());
-
- logEnd();
- }
-
- /**
- * Test the happy path through the flow.
- */
- @Test
-
- public void personaMismatch() throws IOException {
-
- logStart();
-
- String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
- updateAAIGenericVnfRequest = updateAAIGenericVnfRequest.replaceFirst("introvert", "extrovert");
-
- MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
- invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- logger.debug("Workflow Exception: {}", workflowException);
- Assert.assertNotNull(workflowException);
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI returns a 404.
- */
- @Test
-
- public void badGet() throws IOException {
-
- logStart();
-
- String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
-
- MockGetGenericVnfById_404(wireMockServer, "skask[?]depth=1");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
- invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_getGenericVnfResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_getGenericVnfResponseCode");
- logger.debug("Subflow response code: {}", responseCode);
- logger.debug("Subflow response: {}", response);
- Assert.assertEquals(404, responseCode.intValue());
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
- */
- @Test
-
- public void badPatch() throws IOException {
-
- logStart();
-
- String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
-
- MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
- MockPutGenericVnf_Bad(wireMockServer, "skask", 404);
- MockAAIVfModuleBadPatch(wireMockServer, "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask", 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
- invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponseCode");
- logger.debug("Subflow response code: {}", responseCode);
- logger.debug("Subflow response: {}", response);
- Assert.assertEquals(404, responseCode.intValue());
-
- logEnd();
- }
+
+ Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class);
+
+
+ /**
+ * Test the happy path through the flow.
+ */
+ @Test
+
+ public void happyPath() throws IOException {
+ logStart();
+
+ String updateAAIGenericVnfRequest =
+ FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
+ MockPutGenericVnf(wireMockServer, "/skask", 200);
+ MockPatchGenericVnf(wireMockServer, "skask");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
+ invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponse");
+ Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponseCode");
+ logger.debug("Subflow response code: {}", responseCode);
+ logger.debug("Subflow response: {}", response);
+ Assert.assertEquals(200, responseCode.intValue());
+
+ logEnd();
+ }
+
+ /**
+ * Test the happy path through the flow.
+ */
+ @Test
+
+ public void personaMismatch() throws IOException {
+
+ logStart();
+
+ String updateAAIGenericVnfRequest =
+ FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
+ updateAAIGenericVnfRequest = updateAAIGenericVnfRequest.replaceFirst("introvert", "extrovert");
+
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
+ invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ WorkflowException workflowException =
+ (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ logger.debug("Workflow Exception: {}", workflowException);
+ Assert.assertNotNull(workflowException);
+
+ logEnd();
+ }
+
+ /**
+ * Test the case where the GET to AAI returns a 404.
+ */
+ @Test
+
+ public void badGet() throws IOException {
+
+ logStart();
+
+ String updateAAIGenericVnfRequest =
+ FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
+
+ MockGetGenericVnfById_404(wireMockServer, "skask[?]depth=1");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
+ invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_getGenericVnfResponse");
+ Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_getGenericVnfResponseCode");
+ logger.debug("Subflow response code: {}", responseCode);
+ logger.debug("Subflow response: {}", response);
+ Assert.assertEquals(404, responseCode.intValue());
+
+ logEnd();
+ }
+
+ /**
+ * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
+ */
+ @Test
+
+ public void badPatch() throws IOException {
+
+ logStart();
+
+ String updateAAIGenericVnfRequest =
+ FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
+
+ MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
+ MockPutGenericVnf_Bad(wireMockServer, "skask", 404);
+ MockAAIVfModuleBadPatch(wireMockServer, "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask", 404);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
+ invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponse");
+ Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponseCode");
+ logger.debug("Subflow response code: {}", responseCode);
+ logger.debug("Subflow response: {}", response);
+ Assert.assertEquals(404, responseCode.intValue());
+
+ logEnd();
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java
index 0a3931a12f..ebf8799121 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
@@ -28,12 +28,10 @@ import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPri
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchVfModuleId;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
-
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.test.Deployment;
import org.junit.Assert;
import org.junit.Ignore;
@@ -48,98 +46,105 @@ import org.slf4j.LoggerFactory;
*/
public class UpdateAAIVfModuleIT extends BaseIntegrationTest {
-
- Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class);
-
-
- /**
- * Test the happy path through the flow.
- */
- @Test
-
- public void happyPath() throws IOException {
- logStart();
-
- String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfByIdWithPriority(wireMockServer, "/skask/vf-modules/vf-module/supercool", 200, "VfModularity/VfModule-supercool.xml");
- MockPutGenericVnf(wireMockServer, "/skask/vf-modules/vf-module/supercool", "PCRF", 200);
- MockPatchVfModuleId(wireMockServer, "skask", "supercool");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
- invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
- logger.debug("Subflow response code: {}", responseCode);
- logger.debug("Subflow response: {}", response);
- Assert.assertEquals(200, responseCode.intValue());
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI returns a 404.
- */
- @Test
-
- public void badGet() throws IOException {
-
- logStart();
-
- String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfById(wireMockServer, "/skask/vf-modules/vf-module/.*", "VfModularity/VfModule-supercool.xml", 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
- invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponseCode");
- logger.debug("Subflow response code: {}", responseCode);
- logger.debug("Subflow response: {}", response);
- Assert.assertEquals(404, responseCode.intValue());
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
- */
- @Test
-
- public void badPatch() throws IOException {
-
- logStart();
-
- String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfById_404(wireMockServer, "/skask/vf-modules/vf-module/supercool");
- MockGetGenericVnfById(wireMockServer, "/skask/vf-modules/vf-module/supercool", "VfModularity/VfModule-supercool.xml", 200);
- MockAAIVfModuleBadPatch(wireMockServer, "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
- invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
- logger.debug("Subflow response code: {}", responseCode);
- logger.debug("Subflow response: {}", response);
- Assert.assertEquals(404, responseCode.intValue());
-
- logEnd();
- }
+
+ Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class);
+
+
+ /**
+ * Test the happy path through the flow.
+ */
+ @Test
+
+ public void happyPath() throws IOException {
+ logStart();
+
+ String updateAAIVfModuleRequest =
+ FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
+ MockGetGenericVnfByIdWithPriority(wireMockServer, "/skask/vf-modules/vf-module/supercool", 200,
+ "VfModularity/VfModule-supercool.xml");
+ MockPutGenericVnf(wireMockServer, "/skask/vf-modules/vf-module/supercool", "PCRF", 200);
+ MockPatchVfModuleId(wireMockServer, "skask", "supercool");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
+ invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
+ Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
+ logger.debug("Subflow response code: {}", responseCode);
+ logger.debug("Subflow response: {}", response);
+ Assert.assertEquals(200, responseCode.intValue());
+
+ logEnd();
+ }
+
+ /**
+ * Test the case where the GET to AAI returns a 404.
+ */
+ @Test
+
+ public void badGet() throws IOException {
+
+ logStart();
+
+ String updateAAIVfModuleRequest =
+ FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
+ MockGetGenericVnfById(wireMockServer, "/skask/vf-modules/vf-module/.*", "VfModularity/VfModule-supercool.xml",
+ 404);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
+ invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponse");
+ Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponseCode");
+ logger.debug("Subflow response code: {}", responseCode);
+ logger.debug("Subflow response: {}", response);
+ Assert.assertEquals(404, responseCode.intValue());
+
+ logEnd();
+ }
+
+ /**
+ * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
+ */
+ @Test
+
+ public void badPatch() throws IOException {
+
+ logStart();
+
+ String updateAAIVfModuleRequest =
+ FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
+ MockGetGenericVnfById_404(wireMockServer, "/skask/vf-modules/vf-module/supercool");
+ MockGetGenericVnfById(wireMockServer, "/skask/vf-modules/vf-module/supercool",
+ "VfModularity/VfModule-supercool.xml", 200);
+ MockAAIVfModuleBadPatch(wireMockServer,
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
+ invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
+ Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
+ logger.debug("Subflow response code: {}", responseCode);
+ logger.debug("Subflow response: {}", response);
+ Assert.assertEquals(404, responseCode.intValue());
+
+ logEnd();
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java
index c0482a52ca..0cefdca9ca 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java
@@ -18,7 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
@@ -29,12 +29,10 @@ import static org.onap.so.bpmn.mock.StubResponseVNFAdapter.mockVNFDelete;
import static org.onap.so.bpmn.mock.StubResponseVNFAdapter.mockVNFPost;
import static org.onap.so.bpmn.mock.StubResponseVNFAdapter.mockVNFPut;
import static org.onap.so.bpmn.mock.StubResponseVNFAdapter.mockVNFRollbackDelete;
-
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.test.Deployment;
import org.junit.Ignore;
import org.junit.Test;
@@ -48,347 +46,261 @@ import org.slf4j.LoggerFactory;
*/
public class VnfAdapterRestV1IT extends BaseIntegrationTest {
-
- Logger logger = LoggerFactory.getLogger(VnfAdapterRestV1IT.class);
-
-
- private static final String EOL = "\n";
-
- private final CallbackSet callbacks = new CallbackSet();
-
- private final String CREATE_VF_MODULE_REQUEST =
- "<createVfModuleRequest>" + EOL +
- " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL +
- " <cloudOwner>cloudOwner</cloudOwner>" + EOL +
- " <tenantId>tenantId</tenantId>" + EOL +
- " <vnfId>vnfId</vnfId>" + EOL +
- " <vfModuleName>vfModuleName</vfModuleName>" + EOL +
- " <vfModuleId>vfModuleId</vfModuleId>" + EOL +
- " <vnfType>vnfType</vnfType>" + EOL +
- " <vnfVersion>vnfVersion</vnfVersion>" + EOL +
- " <vfModuleType>vfModuleType</vfModuleType>" + EOL +
- " <volumeGroupId>volumeGroupId</volumeGroupId>" + EOL +
- " <volumeGroupStackId>volumeGroupStackId</volumeGroupStackId>" + EOL +
- " <baseVfModuleId>baseVfModuleId</baseVfModuleId>" + EOL +
- " <baseVfModuleStackId>baseVfModuleStackId</baseVfModuleStackId>" + EOL +
- " <skipAAI>true</skipAAI>" + EOL +
- " <backout>false</backout>" + EOL +
- " <failIfExists>true</failIfExists>" + EOL +
- " <vfModuleParams>" + EOL +
- " <entry>" + EOL +
- " <key>key1</key>" + EOL +
- " <value>value1</value>" + EOL +
- " </entry>" + EOL +
- " <entry>" + EOL +
- " <key>key2</key>" + EOL +
- " <value>value2</value>" + EOL +
- " </entry>" + EOL +
- " </vfModuleParams>" + EOL +
- " <msoRequest>" + EOL +
- " <requestId>requestId</requestId>" + EOL +
- " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL +
- " </msoRequest>" + EOL +
- " <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
- " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL +
- "</createVfModuleRequest>" + EOL;
-
- private final String UPDATE_VF_MODULE_REQUEST =
- "<updateVfModuleRequest>" + EOL +
- " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL +
- " <cloudOwner>cloudOwner</cloudOwner>" + EOL +
- " <tenantId>tenantId</tenantId>" + EOL +
- " <vnfId>vnfId</vnfId>" + EOL +
- " <vfModuleName>vfModuleName</vfModuleName>" + EOL +
- " <vfModuleId>vfModuleId</vfModuleId>" + EOL +
- " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL +
- " <vnfType>vnfType</vnfType>" + EOL +
- " <vnfVersion>vnfVersion</vnfVersion>" + EOL +
- " <vfModuleType>vfModuleType</vfModuleType>" + EOL +
- " <volumeGroupId>volumeGroupId</volumeGroupId>" + EOL +
- " <volumeGroupStackId>volumeGroupStackId</volumeGroupStackId>" + EOL +
- " <baseVfModuleId>baseVfModuleId</baseVfModuleId>" + EOL +
- " <baseVfModuleStackId>baseVfModuleStackId</baseVfModuleStackId>" + EOL +
- " <skipAAI>true</skipAAI>" + EOL +
- " <backout>false</backout>" + EOL +
- " <failIfExists>true</failIfExists>" + EOL +
- " <vfModuleParams>" + EOL +
- " <entry>" + EOL +
- " <key>key1</key>" + EOL +
- " <value>value1</value>" + EOL +
- " </entry>" + EOL +
- " <entry>" + EOL +
- " <key>key2</key>" + EOL +
- " <value>value2</value>" + EOL +
- " </entry>" + EOL +
- " </vfModuleParams>" + EOL +
- " <msoRequest>" + EOL +
- " <requestId>requestId</requestId>" + EOL +
- " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL +
- " </msoRequest>" + EOL +
- " <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
- " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL +
- "</updateVfModuleRequest>" + EOL;
-
- private final String DELETE_VF_MODULE_REQUEST =
- "<deleteVfModuleRequest>" + EOL +
- " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL +
- " <cloudOwner>cloudOwner</cloudOwner>" + EOL +
- " <tenantId>tenantId</tenantId>" + EOL +
- " <vnfId>vnfId</vnfId>" + EOL +
- " <vfModuleId>vfModuleId</vfModuleId>" + EOL +
- " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL +
- " <skipAAI>true</skipAAI>" + EOL +
- " <msoRequest>" + EOL +
- " <requestId>requestId</requestId>" + EOL +
- " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL +
- " </msoRequest>" + EOL +
- " <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
- " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL +
- "</deleteVfModuleRequest>" + EOL;
-
- private final String ROLLBACK_VF_MODULE_REQUEST =
- "<rollbackVfModuleRequest>" + EOL +
- " <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
- " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL +
- " <skipAAI>true</skipAAI>" + EOL +
- " <vfModuleRollback>" + EOL +
- " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL +
- " <cloudOwner>cloudOwner</cloudOwner>" + EOL +
- " <tenantId>tenantId</tenantId>" + EOL +
- " <vnfId>vnfId</vnfId>" + EOL +
- " <vfModuleId>vfModuleId</vfModuleId>" + EOL +
- " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL +
- " <msoRequest>" + EOL +
- " <requestId>requestId</requestId>" + EOL +
- " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL +
- " </msoRequest>" + EOL +
- " <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
- " <vfModuleCreated>true</vfModuleCreated>" + EOL +
- " </vfModuleRollback>" + EOL +
- "</rollbackVfModuleRequest>" + EOL;
-
- public VnfAdapterRestV1IT() throws IOException {
- callbacks.put("createVfModule",
- "<createVfModuleResponse>" + EOL +
- " <vnfId>vnfId</vnfId>" + EOL +
- " <vfModuleId>vfModuleId</vfModuleId>" + EOL +
- " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL +
- " <vfModuleCreated>true</vfModuleCreated>" + EOL +
- " <vfModuleOutputs>" + EOL +
- " <entry>" + EOL +
- " <key>key1</key>" + EOL +
- " <value>value1</value>" + EOL +
- " </entry>" + EOL +
- " <entry>" + EOL +
- " <key>key2</key>" + EOL +
- " <value>value2</value>" + EOL +
- " </entry>" + EOL +
- " </vfModuleOutputs>" + EOL +
- " <rollback>" + EOL +
- " <vnfId>vnfId</vnfId>" + EOL +
- " <vfModuleId>vfModuleId</vfModuleId>" + EOL +
- " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL +
- " <vfModuleCreated>true</vfModuleCreated>" + EOL +
- " <tenantId>tenantId</tenantId>" + EOL +
- " <cloudOwner>cloudOwner</cloudOwner>" + EOL +
- " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL +
- " <msoRequest>" + EOL +
- " <requestId>requestId</requestId>" + EOL +
- " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL +
- " </msoRequest>" + EOL +
- " <messageId>messageId</messageId>" + EOL +
- " </rollback>" + EOL +
- " <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
- "</createVfModuleResponse>" + EOL);
-
- callbacks.put("updateVfModule",
- "<updateVfModuleResponse>" + EOL +
- " <vnfId>vnfId</vnfId>" + EOL +
- " <vfModuleId>vfModuleId</vfModuleId>" + EOL +
- " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL +
- " <vfModuleOutputs>" + EOL +
- " <entry>" + EOL +
- " <key>key1</key>" + EOL +
- " <value>value1</value>" + EOL +
- " </entry>" + EOL +
- " <entry>" + EOL +
- " <key>key2</key>" + EOL +
- " <value>value2</value>" + EOL +
- " </entry>" + EOL +
- " </vfModuleOutputs>" + EOL +
- " <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
- "</updateVfModuleResponse>" + EOL);
-
- callbacks.put("deleteVfModule",
- "<deleteVfModuleResponse>" + EOL +
- " <vnfId>vnfId</vnfId>" + EOL +
- " <vfModuleId>vfModuleId</vfModuleId>" + EOL +
- " <vfModuleDeleted>true</vfModuleDeleted>" + EOL +
- " <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
- "</deleteVfModuleResponse>" + EOL);
-
- callbacks.put("rollbackVfModule",
- "<rollbackVfModuleResponse>" + EOL +
- " <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
- " <vfModuleRolledback>true</vfModuleRolledback>" + EOL +
- "</rollbackVfModuleResponse>" + EOL);
-
- callbacks.put("vfModuleException",
- "<vfModuleException>" + EOL +
- " <message>message</message>" + EOL +
- " <category>category</category>" + EOL +
- " <rolledBack>false</rolledBack>" + EOL +
- " <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
- "</vfModuleException>" + EOL);
- }
-
- @Test
-
- public void testCreateVfModuleSuccess() throws Exception {
- logStart();
-
- mockVNFPost(wireMockServer, "", 202, "vnfId");
-
- String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
- String messageId = requestId + "-" + System.currentTimeMillis();
- String request = CREATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", requestId);
- variables.put("isDebugLogEnabled", "true");
- variables.put("vnfAdapterRestV1Request", request);
-
- invokeSubProcess("vnfAdapterRestV1", businessKey, variables);
- injectVNFRestCallbacks(callbacks, "createVfModule");
- waitForProcessEnd(businessKey, 10000);
-
- String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response");
- logger.debug("Response:\n{}", response);
- assertTrue(response!=null && response.contains("<createVfModuleResponse>"));
- assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator"));
-
- logEnd();
- }
-
- @Test
-
- public void testUpdateVfModuleSuccess() throws Exception {
- logStart();
-
- mockVNFPut(wireMockServer, "/vfModuleId", 202);
-
- String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
- String messageId = requestId + "-" + System.currentTimeMillis();
- String request = UPDATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", requestId);
- variables.put("isDebugLogEnabled", "true");
- variables.put("vnfAdapterRestV1Request", request);
-
- invokeSubProcess("vnfAdapterRestV1", businessKey, variables);
- injectVNFRestCallbacks(callbacks, "updateVfModule");
- waitForProcessEnd(businessKey, 10000);
-
- String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response");
- logger.debug("Response:\n{}", response);
- assertTrue(response.contains("<updateVfModuleResponse>"));
- assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator"));
-
- logEnd();
- }
-
- @Test
-
- public void testDeleteVfModuleSuccess() throws Exception {
- logStart();
-
- mockVNFDelete(wireMockServer, "vnfId", "/vfModuleId", 202);
-
- String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
- String messageId = requestId + "-" + System.currentTimeMillis();
- String request = DELETE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", requestId);
- variables.put("isDebugLogEnabled", "true");
- variables.put("vnfAdapterRestV1Request", request);
-
- invokeSubProcess("vnfAdapterRestV1", businessKey, variables);
- injectVNFRestCallbacks(callbacks, "deleteVfModule");
- waitForProcessEnd(businessKey, 10000);
-
- String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response");
- logger.debug("Response:\n{}", response);
- assertTrue(response.contains("<deleteVfModuleResponse>"));
- assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator"));
-
- logEnd();
- }
-
- @Test
-
- public void testRollbackVfModuleSuccess() throws Exception {
- logStart();
-
- mockVNFRollbackDelete(wireMockServer, "/vfModuleId", 202);
-
- String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
- String messageId = requestId + "-" + System.currentTimeMillis();
- String request = ROLLBACK_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", requestId);
- variables.put("isDebugLogEnabled", "true");
- variables.put("vnfAdapterRestV1Request", request);
-
- invokeSubProcess("vnfAdapterRestV1", businessKey, variables);
- injectVNFRestCallbacks(callbacks, "rollbackVfModule");
- waitForProcessEnd(businessKey, 10000);
-
- String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response");
- logger.debug("Response:\n{}", response);
- assertTrue(response.contains("<rollbackVfModuleResponse>"));
- assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator"));
-
- logEnd();
- }
-
- @Test
-
- public void testCreateVfModuleException() throws Exception {
- logStart();
-
- mockVNFPost(wireMockServer, "", 202, "vnfId");
-
- String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
- String messageId = requestId + "-" + System.currentTimeMillis();
- String request = CREATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", requestId);
- variables.put("isDebugLogEnabled", "true");
- variables.put("vnfAdapterRestV1Request", request);
-
- invokeSubProcess("vnfAdapterRestV1", businessKey, variables);
- injectVNFRestCallbacks(callbacks, "vfModuleException");
- waitForProcessEnd(businessKey, 10000);
-
- WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- assertNotNull(wfe);
- logger.debug(wfe.toString());
-
- String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse");
- logger.debug("Response:\n{}", response);
- assertTrue(response.contains("<vfModuleException>"));
- assertFalse((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator"));
- logEnd();
- }
+ Logger logger = LoggerFactory.getLogger(VnfAdapterRestV1IT.class);
+
+
+ private static final String EOL = "\n";
+
+ private final CallbackSet callbacks = new CallbackSet();
+
+ private final String CREATE_VF_MODULE_REQUEST = "<createVfModuleRequest>" + EOL
+ + " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + " <cloudOwner>cloudOwner</cloudOwner>" + EOL
+ + " <tenantId>tenantId</tenantId>" + EOL + " <vnfId>vnfId</vnfId>" + EOL
+ + " <vfModuleName>vfModuleName</vfModuleName>" + EOL + " <vfModuleId>vfModuleId</vfModuleId>" + EOL
+ + " <vnfType>vnfType</vnfType>" + EOL + " <vnfVersion>vnfVersion</vnfVersion>" + EOL
+ + " <vfModuleType>vfModuleType</vfModuleType>" + EOL + " <volumeGroupId>volumeGroupId</volumeGroupId>"
+ + EOL + " <volumeGroupStackId>volumeGroupStackId</volumeGroupStackId>" + EOL
+ + " <baseVfModuleId>baseVfModuleId</baseVfModuleId>" + EOL
+ + " <baseVfModuleStackId>baseVfModuleStackId</baseVfModuleStackId>" + EOL + " <skipAAI>true</skipAAI>"
+ + EOL + " <backout>false</backout>" + EOL + " <failIfExists>true</failIfExists>" + EOL
+ + " <vfModuleParams>" + EOL + " <entry>" + EOL + " <key>key1</key>" + EOL
+ + " <value>value1</value>" + EOL + " </entry>" + EOL + " <entry>" + EOL + " <key>key2</key>"
+ + EOL + " <value>value2</value>" + EOL + " </entry>" + EOL + " </vfModuleParams>" + EOL
+ + " <msoRequest>" + EOL + " <requestId>requestId</requestId>" + EOL
+ + " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + " </msoRequest>" + EOL
+ + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL
+ + " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL
+ + "</createVfModuleRequest>" + EOL;
+
+ private final String UPDATE_VF_MODULE_REQUEST = "<updateVfModuleRequest>" + EOL
+ + " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + " <cloudOwner>cloudOwner</cloudOwner>" + EOL
+ + " <tenantId>tenantId</tenantId>" + EOL + " <vnfId>vnfId</vnfId>" + EOL
+ + " <vfModuleName>vfModuleName</vfModuleName>" + EOL + " <vfModuleId>vfModuleId</vfModuleId>" + EOL
+ + " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + " <vnfType>vnfType</vnfType>" + EOL
+ + " <vnfVersion>vnfVersion</vnfVersion>" + EOL + " <vfModuleType>vfModuleType</vfModuleType>" + EOL
+ + " <volumeGroupId>volumeGroupId</volumeGroupId>" + EOL
+ + " <volumeGroupStackId>volumeGroupStackId</volumeGroupStackId>" + EOL
+ + " <baseVfModuleId>baseVfModuleId</baseVfModuleId>" + EOL
+ + " <baseVfModuleStackId>baseVfModuleStackId</baseVfModuleStackId>" + EOL + " <skipAAI>true</skipAAI>"
+ + EOL + " <backout>false</backout>" + EOL + " <failIfExists>true</failIfExists>" + EOL
+ + " <vfModuleParams>" + EOL + " <entry>" + EOL + " <key>key1</key>" + EOL
+ + " <value>value1</value>" + EOL + " </entry>" + EOL + " <entry>" + EOL + " <key>key2</key>"
+ + EOL + " <value>value2</value>" + EOL + " </entry>" + EOL + " </vfModuleParams>" + EOL
+ + " <msoRequest>" + EOL + " <requestId>requestId</requestId>" + EOL
+ + " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + " </msoRequest>" + EOL
+ + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL
+ + " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL
+ + "</updateVfModuleRequest>" + EOL;
+
+ private final String DELETE_VF_MODULE_REQUEST = "<deleteVfModuleRequest>" + EOL
+ + " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + " <cloudOwner>cloudOwner</cloudOwner>" + EOL
+ + " <tenantId>tenantId</tenantId>" + EOL + " <vnfId>vnfId</vnfId>" + EOL
+ + " <vfModuleId>vfModuleId</vfModuleId>" + EOL + " <vfModuleStackId>vfModuleStackId</vfModuleStackId>"
+ + EOL + " <skipAAI>true</skipAAI>" + EOL + " <msoRequest>" + EOL + " <requestId>requestId</requestId>"
+ + EOL + " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + " </msoRequest>" + EOL
+ + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL
+ + " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL
+ + "</deleteVfModuleRequest>" + EOL;
+
+ private final String ROLLBACK_VF_MODULE_REQUEST = "<rollbackVfModuleRequest>" + EOL
+ + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL
+ + " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL
+ + " <skipAAI>true</skipAAI>" + EOL + " <vfModuleRollback>" + EOL
+ + " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + " <cloudOwner>cloudOwner</cloudOwner>" + EOL
+ + " <tenantId>tenantId</tenantId>" + EOL + " <vnfId>vnfId</vnfId>" + EOL
+ + " <vfModuleId>vfModuleId</vfModuleId>" + EOL + " <vfModuleStackId>vfModuleStackId</vfModuleStackId>"
+ + EOL + " <msoRequest>" + EOL + " <requestId>requestId</requestId>" + EOL
+ + " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + " </msoRequest>" + EOL
+ + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + " <vfModuleCreated>true</vfModuleCreated>" + EOL
+ + " </vfModuleRollback>" + EOL + "</rollbackVfModuleRequest>" + EOL;
+
+ public VnfAdapterRestV1IT() throws IOException {
+ callbacks.put("createVfModule", "<createVfModuleResponse>" + EOL + " <vnfId>vnfId</vnfId>" + EOL
+ + " <vfModuleId>vfModuleId</vfModuleId>" + EOL + " <vfModuleStackId>vfModuleStackId</vfModuleStackId>"
+ + EOL + " <vfModuleCreated>true</vfModuleCreated>" + EOL + " <vfModuleOutputs>" + EOL + " <entry>"
+ + EOL + " <key>key1</key>" + EOL + " <value>value1</value>" + EOL + " </entry>" + EOL
+ + " <entry>" + EOL + " <key>key2</key>" + EOL + " <value>value2</value>" + EOL
+ + " </entry>" + EOL + " </vfModuleOutputs>" + EOL + " <rollback>" + EOL
+ + " <vnfId>vnfId</vnfId>" + EOL + " <vfModuleId>vfModuleId</vfModuleId>" + EOL
+ + " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL
+ + " <vfModuleCreated>true</vfModuleCreated>" + EOL + " <tenantId>tenantId</tenantId>" + EOL
+ + " <cloudOwner>cloudOwner</cloudOwner>" + EOL + " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL
+ + " <msoRequest>" + EOL + " <requestId>requestId</requestId>" + EOL
+ + " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + " </msoRequest>" + EOL
+ + " <messageId>messageId</messageId>" + EOL + " </rollback>" + EOL
+ + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + "</createVfModuleResponse>" + EOL);
+
+ callbacks.put("updateVfModule",
+ "<updateVfModuleResponse>" + EOL + " <vnfId>vnfId</vnfId>" + EOL
+ + " <vfModuleId>vfModuleId</vfModuleId>" + EOL
+ + " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + " <vfModuleOutputs>" + EOL
+ + " <entry>" + EOL + " <key>key1</key>" + EOL + " <value>value1</value>" + EOL
+ + " </entry>" + EOL + " <entry>" + EOL + " <key>key2</key>" + EOL
+ + " <value>value2</value>" + EOL + " </entry>" + EOL + " </vfModuleOutputs>" + EOL
+ + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + "</updateVfModuleResponse>" + EOL);
+
+ callbacks.put("deleteVfModule",
+ "<deleteVfModuleResponse>" + EOL + " <vnfId>vnfId</vnfId>" + EOL
+ + " <vfModuleId>vfModuleId</vfModuleId>" + EOL + " <vfModuleDeleted>true</vfModuleDeleted>"
+ + EOL + " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + "</deleteVfModuleResponse>" + EOL);
+
+ callbacks.put("rollbackVfModule", "<rollbackVfModuleResponse>" + EOL + " <messageId>{{MESSAGE-ID}}</messageId>"
+ + EOL + " <vfModuleRolledback>true</vfModuleRolledback>" + EOL + "</rollbackVfModuleResponse>" + EOL);
+
+ callbacks.put("vfModuleException",
+ "<vfModuleException>" + EOL + " <message>message</message>" + EOL + " <category>category</category>"
+ + EOL + " <rolledBack>false</rolledBack>" + EOL + " <messageId>{{MESSAGE-ID}}</messageId>"
+ + EOL + "</vfModuleException>" + EOL);
+ }
+
+ @Test
+
+ public void testCreateVfModuleSuccess() throws Exception {
+ logStart();
+
+ mockVNFPost(wireMockServer, "", 202, "vnfId");
+
+ String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
+ String messageId = requestId + "-" + System.currentTimeMillis();
+ String request = CREATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", requestId);
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("vnfAdapterRestV1Request", request);
+
+ invokeSubProcess("vnfAdapterRestV1", businessKey, variables);
+ injectVNFRestCallbacks(callbacks, "createVfModule");
+ waitForProcessEnd(businessKey, 10000);
+
+ String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response");
+ logger.debug("Response:\n{}", response);
+ assertTrue(response != null && response.contains("<createVfModuleResponse>"));
+ assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator"));
+
+ logEnd();
+ }
+
+ @Test
+
+ public void testUpdateVfModuleSuccess() throws Exception {
+ logStart();
+
+ mockVNFPut(wireMockServer, "/vfModuleId", 202);
+
+ String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
+ String messageId = requestId + "-" + System.currentTimeMillis();
+ String request = UPDATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", requestId);
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("vnfAdapterRestV1Request", request);
+
+ invokeSubProcess("vnfAdapterRestV1", businessKey, variables);
+ injectVNFRestCallbacks(callbacks, "updateVfModule");
+ waitForProcessEnd(businessKey, 10000);
+
+ String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response");
+ logger.debug("Response:\n{}", response);
+ assertTrue(response.contains("<updateVfModuleResponse>"));
+ assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator"));
+
+ logEnd();
+ }
+
+ @Test
+
+ public void testDeleteVfModuleSuccess() throws Exception {
+ logStart();
+
+ mockVNFDelete(wireMockServer, "vnfId", "/vfModuleId", 202);
+
+ String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
+ String messageId = requestId + "-" + System.currentTimeMillis();
+ String request = DELETE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", requestId);
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("vnfAdapterRestV1Request", request);
+
+ invokeSubProcess("vnfAdapterRestV1", businessKey, variables);
+ injectVNFRestCallbacks(callbacks, "deleteVfModule");
+ waitForProcessEnd(businessKey, 10000);
+
+ String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response");
+ logger.debug("Response:\n{}", response);
+ assertTrue(response.contains("<deleteVfModuleResponse>"));
+ assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator"));
+
+ logEnd();
+ }
+
+ @Test
+
+ public void testRollbackVfModuleSuccess() throws Exception {
+ logStart();
+
+ mockVNFRollbackDelete(wireMockServer, "/vfModuleId", 202);
+
+ String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
+ String messageId = requestId + "-" + System.currentTimeMillis();
+ String request = ROLLBACK_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", requestId);
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("vnfAdapterRestV1Request", request);
+
+ invokeSubProcess("vnfAdapterRestV1", businessKey, variables);
+ injectVNFRestCallbacks(callbacks, "rollbackVfModule");
+ waitForProcessEnd(businessKey, 10000);
+
+ String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response");
+ logger.debug("Response:\n{}", response);
+ assertTrue(response.contains("<rollbackVfModuleResponse>"));
+ assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator"));
+
+ logEnd();
+ }
+
+ @Test
+
+ public void testCreateVfModuleException() throws Exception {
+ logStart();
+
+ mockVNFPost(wireMockServer, "", 202, "vnfId");
+
+ String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312";
+ String messageId = requestId + "-" + System.currentTimeMillis();
+ String request = CREATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("mso-request-id", requestId);
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("vnfAdapterRestV1Request", request);
+
+ invokeSubProcess("vnfAdapterRestV1", businessKey, variables);
+ injectVNFRestCallbacks(callbacks, "vfModuleException");
+ waitForProcessEnd(businessKey, 10000);
+
+ WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+ assertNotNull(wfe);
+ logger.debug(wfe.toString());
+
+ String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse");
+ logger.debug("Response:\n{}", response);
+ assertTrue(response.contains("<vfModuleException>"));
+ assertFalse((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator"));
+
+ logEnd();
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowAsyncResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowAsyncResourceTest.java
index a746bbb48e..cc2d6ab640 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowAsyncResourceTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowAsyncResourceTest.java
@@ -16,16 +16,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
import static org.junit.Assert.assertEquals;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
import org.junit.Ignore;
@@ -36,49 +34,53 @@ import org.onap.so.bpmn.common.workflow.service.WorkflowAsyncResource;
@Ignore
public class WorkflowAsyncResourceTest extends WorkflowTest {
- @Test
- @Deployment(resources = { "testAsyncResource.bpmn" })
- public void asyncRequestSuccess() throws InterruptedException {
- //it can be any request which asynchronously processed by the workflow
- String request = "<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns5=\"http://org.onap/so/request/types/v1\"> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.onap/so/request/types/v1\"> <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type> <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id> <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>";
-
- Map<String,String> variables = new HashMap<>();
- variables.put("testAsyncRequestMsg", request);
- variables.put("mso-request-id", UUID.randomUUID().toString());
- variables.put("mso-service-request-timeout", "5");
-
- WorkflowResponse workflowResponse = BPMNUtil.executeAsyncWorkflow(processEngineRule, "testAsyncProcess", variables);
- assertEquals("Received the request, the process is getting executed, request message<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns5=\"http://org.onap/so/request/types/v1\"> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.onap/so/request/types/v1\"> <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type> <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id> <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>", workflowResponse.getResponse());
- assertEquals(200, workflowResponse.getMessageCode());
- }
-
- private void executeWorkflow(String request, String requestId, String processKey) throws InterruptedException {
- WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
- VariableMapImpl variableMap = new VariableMapImpl();
-
- Map<String, Object> variableValueType = new HashMap<>();
-
- Map<String, Object> requestMsg = new HashMap<>();
- requestMsg.put("value", request);
- requestMsg.put("type", "String");
-
- Map<String, Object> msorequestId = new HashMap<>();
- msorequestId.put("type", "String");
- msorequestId.put("value",requestId);
-
- Map<String, Object> timeout = new HashMap<>();
- timeout.put("type", "String");
- timeout.put("value","5");
-
- variableValueType.put("testAsyncRequestMsg", requestMsg);
- variableValueType.put("mso-request-id", msorequestId);
- variableValueType.put("mso-service-request-timeout", timeout);
-
- variableMap.put("variables", variableValueType);
-
- workflowResource.setProcessEngineServices4junit(processEngineRule);
- workflowResource.startProcessInstanceByKey( processKey, variableMap);
- }
-
-
+ @Test
+ @Deployment(resources = {"testAsyncResource.bpmn"})
+ public void asyncRequestSuccess() throws InterruptedException {
+ // it can be any request which asynchronously processed by the workflow
+ String request =
+ "<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns5=\"http://org.onap/so/request/types/v1\"> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.onap/so/request/types/v1\"> <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type> <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id> <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>";
+
+ Map<String, String> variables = new HashMap<>();
+ variables.put("testAsyncRequestMsg", request);
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ variables.put("mso-service-request-timeout", "5");
+
+ WorkflowResponse workflowResponse =
+ BPMNUtil.executeAsyncWorkflow(processEngineRule, "testAsyncProcess", variables);
+ assertEquals(
+ "Received the request, the process is getting executed, request message<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns5=\"http://org.onap/so/request/types/v1\"> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.onap/so/request/types/v1\"> <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type> <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id> <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>",
+ workflowResponse.getResponse());
+ assertEquals(200, workflowResponse.getMessageCode());
+ }
+
+ private void executeWorkflow(String request, String requestId, String processKey) throws InterruptedException {
+ WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
+ VariableMapImpl variableMap = new VariableMapImpl();
+
+ Map<String, Object> variableValueType = new HashMap<>();
+
+ Map<String, Object> requestMsg = new HashMap<>();
+ requestMsg.put("value", request);
+ requestMsg.put("type", "String");
+
+ Map<String, Object> msorequestId = new HashMap<>();
+ msorequestId.put("type", "String");
+ msorequestId.put("value", requestId);
+
+ Map<String, Object> timeout = new HashMap<>();
+ timeout.put("type", "String");
+ timeout.put("value", "5");
+
+ variableValueType.put("testAsyncRequestMsg", requestMsg);
+ variableValueType.put("mso-request-id", msorequestId);
+ variableValueType.put("mso-service-request-timeout", timeout);
+
+ variableMap.put("variables", variableValueType);
+
+ workflowResource.setProcessEngineServices4junit(processEngineRule);
+ workflowResource.startProcessInstanceByKey(processKey, variableMap);
+ }
+
+
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowContextHolderTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowContextHolderTest.java
index 0efecac254..23f9818669 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowContextHolderTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowContextHolderTest.java
@@ -16,14 +16,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
import java.util.UUID;
-
import org.junit.Assert;
import org.junit.Test;
import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse;
@@ -35,35 +34,35 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowResponse;
public class WorkflowContextHolderTest {
- @Test
- public void testProcessCallback() throws Exception {
- String requestId = UUID.randomUUID().toString();
- String message = "TEST MESSATGE";
- String responseMessage = "Successfully processed request";
- int testCode = 200;
-
-
- WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance();
-
- WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
- callbackResponse.setMessage(message);
- callbackResponse.setResponse(responseMessage);
- callbackResponse.setStatusCode(testCode);
-
- contextHolder.processCallback("testAsyncProcess","process-instance-id",requestId,callbackResponse);
-
- //same object returned
- WorkflowContext contextFound = contextHolder.getWorkflowContext(requestId);
- if(contextFound == null)
- throw new Exception("Expected to find Context Object");
-
- WorkflowResponse testResponse = contextFound.getWorkflowResponse();
- Assert.assertEquals(200,testResponse.getMessageCode());
- Assert.assertEquals(message, testResponse.getMessage());
- Assert.assertEquals(responseMessage, testResponse.getResponse());
-
-
-
- }
+ @Test
+ public void testProcessCallback() throws Exception {
+ String requestId = UUID.randomUUID().toString();
+ String message = "TEST MESSATGE";
+ String responseMessage = "Successfully processed request";
+ int testCode = 200;
+
+
+ WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance();
+
+ WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
+ callbackResponse.setMessage(message);
+ callbackResponse.setResponse(responseMessage);
+ callbackResponse.setStatusCode(testCode);
+
+ contextHolder.processCallback("testAsyncProcess", "process-instance-id", requestId, callbackResponse);
+
+ // same object returned
+ WorkflowContext contextFound = contextHolder.getWorkflowContext(requestId);
+ if (contextFound == null)
+ throw new Exception("Expected to find Context Object");
+
+ WorkflowResponse testResponse = contextFound.getWorkflowResponse();
+ Assert.assertEquals(200, testResponse.getMessageCode());
+ Assert.assertEquals(message, testResponse.getMessage());
+ Assert.assertEquals(responseMessage, testResponse.getResponse());
+
+
+
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
index eed2978bc7..389f931901 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
@@ -26,7 +26,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.onap.so.bpmn.core.json.JsonUtils.getJsonValue;
import static org.onap.so.bpmn.core.json.JsonUtils.updJsonValue;
-
import java.io.IOException;
import java.io.StringReader;
import java.lang.management.ManagementFactory;
@@ -37,7 +36,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import javax.ws.rs.core.Response;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.NamespaceContext;
@@ -50,7 +48,6 @@ import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-
import org.camunda.bpm.engine.HistoryService;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.ProcessEngineException;
@@ -98,2158 +95,2108 @@ import org.xml.sax.SAXException;
/**
* A base class for Workflow tests.
* <p>
- * WireMock response transformers may be specified by declaring public
- * static fields with the @WorkflowTestTransformer annotation. For example:
+ * WireMock response transformers may be specified by declaring public static fields with the @WorkflowTestTransformer
+ * annotation. For example:
+ *
* <pre>
- * @WorkflowTestTransformer
- * public static final ResponseTransformer sdncAdapterMockTransformer =
- * new SDNCAdapterMockTransformer();
+ * &#64;WorkflowTestTransformer
+ * public static final ResponseTransformer sdncAdapterMockTransformer = new SDNCAdapterMockTransformer();
* </pre>
*/
public abstract class WorkflowTest {
- private static final Logger logger = LoggerFactory.getLogger(WorkflowTest.class);
-
- //TODO this is not used anymore, can maybe be removed
- @Rule
- public ProcessEngineRule processEngineRule;
-
- @Autowired
- protected WorkflowResource workflowResourceSync;
-
- @Autowired
- protected ProcessEngine processEngine;
-
- @Autowired
- protected RuntimeService runtimeService;
-
- @Autowired
- protected HistoryService historyService;
-
- @Autowired
- private WorkflowAsyncResource workflowResource;
-
- @Autowired
- private WorkflowMessageResource workflowMessageResource;
-
- @Autowired
- SDNCAdapterCallbackServiceImpl callbackService;
- /**
- * Content-Type for XML.
- */
- protected static final String XML = "application/xml";
-
- /**
- * Content-Type for JSON.
- */
- protected static final String JSON = "application/json; charset=UTF-8";
-
- private static final int timeout = 2000;
-
- /**
- * Constructor.
- */
- public WorkflowTest() throws RuntimeException {
- }
-
- /**
- * The current request ID. Normally set when an "invoke" method is called.
- */
- protected volatile String msoRequestId = null;
-
- /**
- * The current service instance ID. Normally set when an "invoke" method
- * is called.
- */
- protected volatile String msoServiceInstanceId = null;
-
- /**
- * Logs a test start method.
- */
- protected void logStart() {
- logger.debug("STARTED TEST");
- }
-
- /**
- * Logs a test end method.
- */
- protected void logEnd() {
- logger.debug("ENDED TEST");
- }
-
- /**
- * Invokes a subprocess.
- * @param processKey the process key
- * @param businessKey a unique key that will identify the process instance
- * @param injectedVariables variables to inject into the process
- */
- protected void invokeSubProcess(String processKey, String businessKey, Map<String, Object> injectedVariables) {
- RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
- List<String> arguments = runtimeMxBean.getInputArguments();
- logger.debug("JVM args = {}", arguments);
-
- msoRequestId = (String) injectedVariables.get("mso-request-id");
- String requestId = (String) injectedVariables.get("msoRequestId");
-
- if (msoRequestId == null && requestId == null) {
- String msg = "mso-request-id variable was not provided";
- logger.debug(msg);
- fail(msg);
- }
-
- // Note: some scenarios don't have a service-instance-id, may be null
- msoServiceInstanceId = (String) injectedVariables.get("mso-service-instance-id");
-
-
- runtimeService.startProcessInstanceByKey(processKey, businessKey, injectedVariables);
- }
-
- protected String invokeSubProcess(String processKey, Map<String, Object> injectedVariables) {
- RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
- List<String> arguments = runtimeMxBean.getInputArguments();
- logger.debug("JVM args = {}", arguments);
-
- msoRequestId = (String) injectedVariables.get("mso-request-id");
- String requestId = (String) injectedVariables.get("msoRequestId");
-
- if (msoRequestId == null && requestId == null) {
- String msg = "mso-request-id variable was not provided";
- logger.debug(msg);
- fail(msg);
- }
-
- // Note: some scenarios don't have a service-instance-id, may be null
- msoServiceInstanceId = (String) injectedVariables.get("mso-service-instance-id");
-
-
- ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processKey, msoRequestId, injectedVariables);
- return processInstance.getId();
- }
-
- /**
- * Invokes an asynchronous process.
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param processKey the process key
- * @param schemaVersion the API schema version, e.g. "v1"
- * @param businessKey a unique key that will identify the process instance
- * @param request the request
- * @return a TestAsyncResponse object associated with the test
- * @throws InterruptedException
- */
- protected TestAsyncResponse invokeAsyncProcess(String processKey,
- String schemaVersion, String businessKey, String request) throws InterruptedException {
- return invokeAsyncProcess(processKey, schemaVersion, businessKey, request, null);
- }
-
- /**
- * Invokes an asynchronous process.
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param processKey the process key
- * @param schemaVersion the API schema version, e.g. "v1"
- * @param businessKey a unique key that will identify the process instance
- * @param request the request
- * @param injectedVariables optional variables to inject into the process
- * @return a TestAsyncResponse object associated with the test
- * @throws InterruptedException
- */
- protected TestAsyncResponse invokeAsyncProcess(String processKey,
- String schemaVersion, String businessKey, String request,
- Map<String, Object> injectedVariables) {
-
- RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
- List<String> arguments = runtimeMxBean.getInputArguments();
- logger.debug("JVM args = {}", arguments);
-
- Map<String, Object> variables = createVariables(schemaVersion, businessKey,
- request, injectedVariables, false);
- VariableMapImpl variableMapImpl = createVariableMapImpl(variables);
-
- logger.debug("Sending {} to {} process", request, processKey);
-
- TestAsyncResponse asyncResponse = new TestAsyncResponse();
-
- asyncResponse.setResponse(workflowResource.startProcessInstanceByKey( processKey, variableMapImpl));
-
- return asyncResponse;
- }
-
- /**
- * Invokes an asynchronous process.
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param processKey the process key
- * @param schemaVersion the API schema version, e.g. "v1"
- * @param businessKey a unique key that will identify the process instance
- * @param request the request
- * @param injectedVariables optional variables to inject into the process
- * @param serviceInstantiationModel indicates whether this method is being
- * invoked for a flow that is designed using the service instantiation model
- * @return a TestAsyncResponse object associated with the test
- * @throws InterruptedException
- */
- protected Response invokeAsyncProcess(String processKey,
- String schemaVersion, String businessKey, String request,
- Map<String, Object> injectedVariables, boolean serviceInstantiationModel) {
-
- RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
- List<String> arguments = runtimeMxBean.getInputArguments();
- logger.debug("JVM args = {}", arguments);
-
- Map<String, Object> variables = createVariables(schemaVersion, businessKey,
- request, injectedVariables, serviceInstantiationModel);
- VariableMapImpl variableMapImpl = createVariableMapImpl(variables);
-
- logger.debug("Sending {} to {} process", request, processKey);
-
- return workflowResource.startProcessInstanceByKey( processKey, variableMapImpl);
-
- }
-
- /**
- * Private helper method that creates a variable map for a request.
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param schemaVersion the API schema version, e.g. "v1"
- * @param businessKey a unique key that will identify the process instance
- * @param request the request
- * @param injectedVariables optional variables to inject into the process
- * @param serviceInstantiationModel indicates whether this method is being
- * invoked for a flow that is designed using the service instantiation model
- * @return a variable map
- */
- private Map<String, Object> createVariables(String schemaVersion,
- String businessKey, String request, Map<String, Object> injectedVariables,
- boolean serviceInstantiationModel) {
-
- Map<String, Object> variables = new HashMap<>();
-
- // These variables may be overridded by injected variables.
- variables.put("mso-service-request-timeout", "180");
- variables.put("isDebugLogEnabled", "true");
-
- // These variables may not be overridded by injected variables.
- String[] notAllowed = new String[] {
- "mso-schema-version",
- "mso-business-key",
- "bpmnRequest",
- "mso-request-id",
- "mso-service-instance-id"
- };
-
- if (injectedVariables != null) {
- for (String key : injectedVariables.keySet()) {
- for (String var : notAllowed) {
- if (var.equals(key)) {
- String msg = "Cannot specify " + var + " in injected variables";
- logger.debug(msg);
- fail(msg);
- }
- }
-
- variables.put(key, injectedVariables.get(key));
- }
- }
-
- variables.put("mso-schema-version", schemaVersion);
- variables.put("mso-business-key", businessKey);
- variables.put("bpmnRequest", request);
-
- if (serviceInstantiationModel) {
-
- /*
- * The request ID and the service instance ID are generated for flows
- * that follow the service instantiation model unless "requestId" and
- * "serviceInstanceId" are injected variables.
- */
-
- try {
- msoRequestId = (String) injectedVariables.get("requestId");
- variables.put("mso-request-id", msoRequestId);
- msoServiceInstanceId = (String) injectedVariables.get("serviceInstanceId");
- variables.put("mso-service-instance-id", msoServiceInstanceId);
- }
- catch(Exception e) {
- }
- if (msoRequestId == null || msoRequestId.trim().equals("")) {
- logger.debug("No requestId element in injectedVariables");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- }
- if (msoServiceInstanceId == null || msoServiceInstanceId.trim().equals("")) {
- logger.debug("No seviceInstanceId element in injectedVariables");
- variables.put("mso-service-instance-id", UUID.randomUUID().toString());
- }
-
- } else {
- msoRequestId = getXMLTextElement(request, "request-id");
-
- if (msoRequestId == null) {
- //check in injected variables
- try {
- msoRequestId = (String) injectedVariables.get("requestId");
- }
- catch(Exception e) {
- }
- if (msoRequestId == null || msoRequestId.trim().equals("")) {
- String msg = "No request-id element in " + request;
- logger.debug(msg);
- fail(msg);
- }
- }
-
- variables.put("mso-request-id", msoRequestId);
-
- // Note: some request types don't have a service-instance-id
- msoServiceInstanceId = getXMLTextElement(request, "service-instance-id");
-
- if (msoServiceInstanceId != null) {
- variables.put("mso-service-instance-id", msoServiceInstanceId);
- }
- }
-
- return variables;
- }
-
- /**
- * Private helper method that creates a camunda VariableMapImpl from a simple
- * variable map.
- * @param variables the simple variable map
- * @return a VariableMap
- */
- private VariableMapImpl createVariableMapImpl(Map<String, Object> variables) {
- Map<String, Object> wrappedVariables = new HashMap<>();
-
- for (String key : variables.keySet()) {
- Object value = variables.get(key);
- wrappedVariables.put(key, wrapVariableValue(value));
- }
-
- VariableMapImpl variableMapImpl = new VariableMapImpl();
- variableMapImpl.put("variables", wrappedVariables);
- return variableMapImpl;
- }
-
- /**
- * Private helper method that wraps a variable value for inclusion in a
- * camunda VariableMapImpl.
- * @param value the variable value
- * @return the wrapped variable
- */
- private Map<String, Object> wrapVariableValue(Object value) {
- HashMap<String, Object> valueMap = new HashMap<>();
- valueMap.put("value", value);
- return valueMap;
- }
-
- /**
- * Receives a response from an asynchronous process.
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param businessKey the process business key
- * @param asyncResponse the TestAsyncResponse object associated with the test
- * @param timeout the timeout in milliseconds
- * @return the WorkflowResponse
- */
- protected WorkflowResponse receiveResponse(String businessKey,
- TestAsyncResponse asyncResponse, long timeout) {
- logger.debug("Waiting {}ms for process with business key {} to send a response", timeout, businessKey);
-
- long now = System.currentTimeMillis() + timeout;
- long endTime = now + timeout;
-
- while (now <= endTime) {
- Response response = asyncResponse.getResponse();
-
- if (response != null) {
- logger.debug("Received a response from process with business key {}", businessKey);
-
- Object entity = response.getEntity();
-
- if (!(entity instanceof WorkflowResponse)) {
- String msg = "Response entity is " +
- (entity == null ? "null" : entity.getClass().getName()) +
- ", expected WorkflowResponse";
- logger.debug(msg);
- fail(msg);
- return null; // unreachable
- }
-
- return (WorkflowResponse) entity;
- }
-
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- String msg = "Interrupted waiting for a response from process with business key " +
- businessKey;
- logger.debug(msg);
- fail(msg);
- return null; // unreachable
- }
-
- now = System.currentTimeMillis();
- }
-
- String msg = "No response received from process with business key " + businessKey +
- " within " + timeout + "ms";
- logger.debug(msg);
- fail("Process with business key " + businessKey + " did not end within 10000ms");
- return null; // unreachable
- }
-
- /**
- * Runs a program to inject SDNC callback data into the test environment.
- * A program is essentially just a list of keys that identify callback data
- * to be injected, in sequence. An example program:
- * <pre>
- * reserve, assign, delete:ERR
- * </pre>
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param callbacks an object containing callback data for the program
- * @param program the program to execute
- */
- protected void injectSDNCRestCallbacks(CallbackSet callbacks, String program) {
-
- String[] cmds = program.replaceAll("\\s+", "").split(",");
-
- for (String cmd : cmds) {
- String action = cmd;
- String modifier = "STD";
-
- if (cmd.contains(":")) {
- String[] parts = cmd.split(":");
- action = parts[0];
- modifier = parts[1];
- }
-
- String content = null;
- String contentType = null;
-
- if ("STD".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No callback defined for '" + action + "' SDNC request";
- logger.debug(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- contentType = callbackData.getContentType();
- } else if ("ERR".equals(modifier)) {
- content = "{\"SDNCServiceError\":{\"sdncRequestId\":\"((REQUEST-ID))\",\"responseCode\":\"500\",\"responseMessage\":\"SIMULATED ERROR FROM SDNC ADAPTER\",\"ackFinalIndicator\":\"Y\"}}";
- contentType = JSON;
- } else {
- String msg = "Invalid SDNC program modifier: '" + modifier + "'";
- logger.debug(msg);
- fail(msg);
- }
-
- if (contentType == null) {
- // Default for backward compatibility with existing tests.
- contentType = JSON;
- }
-
- if (!injectSDNCRestCallback(contentType, content, 10000)) {
- fail("Failed to inject SDNC '" + action + "' callback");
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail("Interrupted after injection of SDNC '" + action + "' callback");
- }
- }
- }
-
- /**
- * Runs a program to inject SDNC events into the test environment.
- * A program is essentially just a list of keys that identify event data
- * to be injected, in sequence. An example program:
- * <pre>
- * event1, event2
- * </pre>
- * NOTE: Each callback must have a message type associated with it, e.g.
- * "SDNCAEvent".
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param callbacks an object containing event data for the program
- * @param program the program to execute
- */
- protected void injectSDNCEvents(CallbackSet callbacks, String program) {
- injectWorkflowMessages(callbacks, program);
- }
-
- /**
- * Runs a program to inject SDNC callback data into the test environment.
- * A program is essentially just a list of keys that identify callback data
- * to be injected, in sequence. An example program:
- * <pre>
- * reserve, assign, delete:ERR
- * </pre>
- * Errors are handled with junit assertions and will cause the test to fail.
- * Uses the static/default timeout value for backward compatibility.
- * @param callbacks an object containing callback data for the program
- * @param program the program to execute
- */
- protected void injectSDNCCallbacks(CallbackSet callbacks, String program) {
- injectSDNCCallbacks(callbacks, program, timeout);
- }
-
- /**
- * Runs a program to inject SDNC callback data into the test environment.
- * A program is essentially just a list of keys that identify callback data
- * to be injected, in sequence. An example program:
- * <pre>
- * reserve, assign, delete:ERR
- * </pre>
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param callbacks an object containing callback data for the program
- * @param program the program to execute
- * @param timeout a timeout value to wait for the callback
- */
- protected void injectSDNCCallbacks(CallbackSet callbacks, String program, int timeout) {
-
- String[] cmds = program.replaceAll("\\s+", "").split(",");
-
- for (String cmd : cmds) {
- String action = cmd;
- String modifier = "STD";
-
- if (cmd.contains(":")) {
- String[] parts = cmd.split(":");
- action = parts[0];
- modifier = parts[1];
- }
-
- String content = null;
- int respCode = 200;
- String respMsg = "OK";
-
- if ("STD".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No callback defined for '" + action + "' SDNC request";
- logger.debug(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- respCode = 200;
- respMsg = "OK";
- } else if ("CREATED".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No callback defined for '" + action + "' SDNC request";
- logger.debug(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- respCode = 201;
- respMsg = "Created";
- } else if ("ERR".equals(modifier)) {
- content = "<svc-request-id>((REQUEST-ID))</svc-request-id><response-code>500</response-code><response-message>SIMULATED ERROR FROM SDNC ADAPTER</response-message>";
- respCode = 500;
- respMsg = "SERVER ERROR";
- } else {
- String msg = "Invalid SDNC program modifier: '" + modifier + "'";
- logger.debug(msg);
- fail(msg);
- }
-
- if (!injectSDNCCallback(respCode, respMsg, content, 10000)) {
- fail("Failed to inject SDNC '" + action + "' callback");
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail("Interrupted after injection of SDNC '" + action + "' callback");
- }
- }
- }
-
- /**
- * Runs a program to inject VNF adapter REST callback data into the test environment.
- * A program is essentially just a list of keys that identify callback data
- * to be injected, in sequence. An example program:
- * <pre>
- * create, rollback
- * </pre>
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param callbacks an object containing callback data for the program
- * @param program the program to execute
- */
- protected void injectVNFRestCallbacks(CallbackSet callbacks, String program) {
-
- String[] cmds = program.replaceAll("\\s+", "").split(",");
-
- for (String cmd : cmds) {
- String action = cmd;
- String modifier = "STD";
-
- if (cmd.contains(":")) {
- String[] parts = cmd.split(":");
- action = parts[0];
- modifier = parts[1];
- }
-
- String content = null;
- String contentType = null;
-
- if ("STD".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No callback defined for '" + action + "' VNF REST request";
- logger.debug(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- contentType = callbackData.getContentType();
- } else if ("ERR".equals(modifier)) {
- content = "SIMULATED ERROR FROM VNF ADAPTER";
- contentType = "text/plain";
- } else {
- String msg = "Invalid VNF REST program modifier: '" + modifier + "'";
- logger.debug(msg);
- fail(msg);
- }
-
- if (contentType == null) {
- // Default for backward compatibility with existing tests.
- contentType = XML;
- }
-
- if (!injectVnfAdapterRestCallback(contentType, content, 10000)) {
- fail("Failed to inject VNF REST '" + action + "' callback");
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail("Interrupted after injection of VNF REST '" + action + "' callback");
- }
- }
- }
-
- /**
- * Runs a program to inject VNF callback data into the test environment.
- * A program is essentially just a list of keys that identify callback data
- * to be injected, in sequence. An example program:
- * <pre>
- * createVnf, deleteVnf
- * </pre>
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param callbacks an object containing callback data for the program
- * @param program the program to execute
- */
- protected void injectVNFCallbacks(CallbackSet callbacks, String program) {
-
- String[] cmds = program.replaceAll("\\s+", "").split(",");
-
- for (String cmd : cmds) {
- String action = cmd;
- String modifier = "STD";
-
- if (cmd.contains(":")) {
- String[] parts = cmd.split(":");
- action = parts[0];
- modifier = parts[1];
- }
-
- String content = null;
-
- if ("STD".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No callback defined for '" + action + "' VNF request";
- logger.debug(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- } else if ("ERR".equals(modifier)) {
- String msg = "Currently unsupported VNF program modifier: '" + modifier + "'";
- logger.debug(msg);
- fail(msg);
- } else {
- String msg = "Invalid VNF program modifier: '" + modifier + "'";
- logger.debug(msg);
- fail(msg);
- }
-
- boolean injected = false;
-
- if (content.contains("createVnfNotification")) {
- injected = injectCreateVNFCallback(content, 10000);
- } else if (content.contains("deleteVnfNotification")) {
- injected = injectDeleteVNFCallback(content, 10000);
- } else if (content.contains("updateVnfNotification")) {
- injected = injectUpdateVNFCallback(content, 10000);
- }
-
- if (!injected) {
- String msg = "Failed to inject VNF '" + action + "' callback";
- logger.debug(msg);
- fail(msg);
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail("Interrupted after injection of VNF '" + action + "' callback");
- }
- }
- }
-
- /**
- * Waits for the number of running processes with the specified process
- * definition key to equal a particular count.
- * @param processKey the process definition key
- * @param count the desired count
- * @param timeout the timeout in milliseconds
- */
- protected void waitForRunningProcessCount(String processKey, int count, long timeout) {
- logger.debug("Waiting {}ms for there to be {} {} instances", timeout, count, processKey);
-
- long now = System.currentTimeMillis() + timeout;
- long endTime = now + timeout;
- int last = -1;
-
- while (now <= endTime) {
- int actual = runtimeService
- .createProcessInstanceQuery()
- .processDefinitionKey(processKey)
- .list().size();
-
- if (actual != last) {
- logger.debug("There are now {} {} instances", actual, processKey);
- last = actual;
- }
-
- if (actual == count) {
- return;
- }
-
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- String msg = "Interrupted waiting for there to be " + count + " "
- + processKey + " instances";
- logger.debug(msg);
- fail(msg);
- }
-
- now = System.currentTimeMillis();
- }
-
- String msg = "Timed out waiting for there to be " + count + " "
- + processKey + " instances";
- logger.debug(msg);
- fail(msg);
- }
-
- /**
- * Waits for the specified process variable to be set.
- * @param processKey the process definition key
- * @param variable the variable name
- * @param timeout the timeout in milliseconds
- * @return the variable value, or null if it cannot be obtained
- * in the specified time
- */
- protected Object getProcessVariable(String processKey, String variable,
- long timeout) {
-
- logger.debug("Waiting " + timeout + "ms for " + processKey + "." + variable + " to be set");
-
- long now = System.currentTimeMillis() + timeout;
- long endTime = now + timeout;
-
- ProcessInstance processInstance = null;
- Object value = null;
-
- while (value == null) {
- if (now > endTime) {
- if (processInstance == null) {
- logger.debug("Timed out waiting for "
- + processKey + " to start");
- } else {
- logger.debug("Timed out waiting for "
- + processKey + "[" + processInstance.getId()
- + "]." + variable + " to be set");
- }
-
- return null;
- }
-
- ProcessInstanceQuery processInstanceQuery = null;
- if (processInstance == null) {
- processInstanceQuery = runtimeService
- .createProcessInstanceQuery()
- .processDefinitionKey(processKey);
- }
-
- if(processInstanceQuery.count() == 1 || processInstanceQuery.count() == 0){
- processInstance = processInstanceQuery.singleResult();
- }else{
- //TODO There shouldnt be more than one in the list but seems to be happening, need to figure out why happening and best way to get correct one from list
- logger.debug("Process Instance Query returned {} instance. Getting the last instance in the list",
- processInstanceQuery.count());
- List<ProcessInstance> processList = processInstanceQuery.list();
- processInstance = processList.get((processList.size() - 1));
- }
-
-
- if (processInstance != null) {
- value = runtimeService
- .getVariable(processInstance.getId(), variable);
- }
-
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- logger.debug("Interrupted waiting for {}.{} to be set", processKey, variable);
- return null;
- }
-
- now = System.currentTimeMillis();
- }
-
- logger.debug(processKey + "["
- + processInstance.getId() + "]." + variable + "="
- + value);
-
- return value;
- }
-
- /**
- * Injects a single SDNC adapter callback request. The specified callback data
- * may contain the placeholder string ((REQUEST-ID)) which is replaced with
- * the actual SDNC request ID. Note: this is not the requestId in the original
- * MSO request.
- * @param contentType the HTTP content type for the callback
- * @param content the content of the callback
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- */
- protected boolean injectSDNCRestCallback(String contentType, String content, long timeout) {
- String sdncRequestId = (String) getProcessVariable("SDNCAdapterRestV1",
- "SDNCAResponse_CORRELATOR", timeout);
-
- if (sdncRequestId == null) {
- sdncRequestId = (String) getProcessVariable("SDNCAdapterRestV2",
- "SDNCAResponse_CORRELATOR", timeout);
- }
-
- if (sdncRequestId == null) {
- return false;
- }
-
- content = content.replace("((REQUEST-ID))", sdncRequestId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{REQUEST-ID}}", sdncRequestId);
-
- logger.debug("Injecting SDNC adapter callback");
-
- Response response = workflowMessageResource.deliver(contentType, "SDNCAResponse", sdncRequestId, content);
- logger.debug("Workflow response to SDNC adapter callback: " + response);
- return true;
- }
-
- /**
- * Injects a single SDNC adapter callback request. The specified callback data
- * may contain the placeholder string ((REQUEST-ID)) which is replaced with
- * the actual SDNC request ID. Note: this is not the requestId in the original
- * MSO request.
- * @param content the content of the callback
- * @param respCode the response code (normally 200)
- * @param respMsg the response message (normally "OK")
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- */
- protected boolean injectSDNCCallback(int respCode, String respMsg,
- String content, long timeout) {
-
- String sdncRequestId = (String) getProcessVariable("sdncAdapter",
- "SDNCA_requestId", timeout);
-
- if (sdncRequestId == null) {
- return false;
- }
-
- content = content.replace("((REQUEST-ID))", sdncRequestId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{REQUEST-ID}}", sdncRequestId);
-
- // TODO this needs to be fixed. It is causing double tags and content
- // Need to parse content before setting below since content includes not just RequestData or modify callback files to only contain RequestData contents.
-
- logger.debug("Injecting SDNC adapter callback");
- CallbackHeader callbackHeader = new CallbackHeader();
- callbackHeader.setRequestId(sdncRequestId);
- callbackHeader.setResponseCode(String.valueOf(respCode));
- callbackHeader.setResponseMessage(respMsg);
- SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest();
- sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader);
- sdncAdapterCallbackRequest.setRequestData(content);
- SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest);
- logger.debug("Workflow response to SDNC adapter callback: " + sdncAdapterResponse);
-
- return true;
- }
-
- /**
- * Injects a single VNF adapter callback request. The specified callback data
- * may contain the placeholder string ((MESSAGE-ID)) which is replaced with
- * the actual message ID. Note: this is not the requestId in the original
- * MSO request.
- * @param contentType the HTTP content type for the callback
- * @param content the content of the callback
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- */
- protected boolean injectVnfAdapterRestCallback(String contentType, String content, long timeout) {
- String messageId = (String) getProcessVariable("vnfAdapterRestV1",
- "VNFAResponse_CORRELATOR", timeout);
-
- if (messageId == null) {
- return false;
- }
-
- content = content.replace("((MESSAGE-ID))", messageId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{MESSAGE-ID}}", messageId);
-
- logger.debug("Injecting VNF adapter callback");
-
- Response response = workflowMessageResource.deliver(contentType, "VNFAResponse", messageId, content);
- logger.debug("Workflow response to VNF adapter callback: {}", response);
- return true;
- }
-
- /**
- * Injects a Create VNF adapter callback request. The specified callback data
- * may contain the placeholder string ((MESSAGE-ID)) which is replaced with
- * the actual message ID. It may also contain the placeholder string
- * ((REQUEST-ID)) which is replaced request ID of the original MSO request.
- * @param content the content of the callback
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- * @throws JAXBException if the content does not adhere to the schema
- */
- protected boolean injectCreateVNFCallback(String content, long timeout) {
-
- String messageId = (String) getProcessVariable("vnfAdapterCreateV1",
- "VNFC_messageId", timeout);
-
- if (messageId == null) {
- return false;
- }
-
- content = content.replace("((MESSAGE-ID))", messageId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{MESSAGE-ID}}", messageId);
-
- if(content.contains("((REQUEST-ID))")){
- content = content.replace("((REQUEST-ID))", msoRequestId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{REQUEST-ID}}", msoRequestId);
- }
-
- logger.debug("Injecting VNF adapter callback");
-
- // Is it possible to unmarshal this with JAXB? I couldn't.
-
- CreateVnfNotification createVnfNotification = new CreateVnfNotification();
- XPathTool xpathTool = new VnfNotifyXPathTool();
- xpathTool.setXML(content);
-
- try {
- String completed = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:completed/text()");
- createVnfNotification.setCompleted("true".equals(completed));
-
- String vnfId = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:vnfId/text()");
- createVnfNotification.setVnfId(vnfId);
-
- NodeList entries = (NodeList) xpathTool.evaluate(
- "/tns:createVnfNotification/tns:outputs/tns:entry",
- XPathConstants.NODESET);
-
- CreateVnfNotificationOutputs outputs = new CreateVnfNotificationOutputs();
-
- for (int i = 0; i < entries.getLength(); i++) {
- Node node = entries.item(i);
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element entry = (Element) node;
- String key = entry.getElementsByTagNameNS("*", "key").item(0).getTextContent();
- String value = entry.getElementsByTagNameNS("*", "value").item(0).getTextContent();
- outputs.add(key, value);
- }
- }
-
- createVnfNotification.setOutputs(outputs);
-
- VnfRollback rollback = new VnfRollback();
-
- String cloudSiteId = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:cloudSiteId/text()");
- rollback.setCloudSiteId(cloudSiteId);
-
- String cloudOwner = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:cloudOwner/text()");
- rollback.setCloudOwner(cloudOwner);
-
- String requestId = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:msoRequest/tns:requestId/text()");
- String serviceInstanceId = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:msoRequest/tns:serviceInstanceId/text()");
-
- if (requestId != null || serviceInstanceId != null) {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestId);
- msoRequest.setServiceInstanceId(serviceInstanceId);
- rollback.setMsoRequest(msoRequest);
- }
-
- String tenantCreated = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:tenantCreated/text()");
- rollback.setTenantCreated("true".equals(tenantCreated));
-
- String tenantId = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:tenantId/text()");
- rollback.setTenantId(tenantId);
-
- String vnfCreated = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:vnfCreated/text()");
- rollback.setVnfCreated("true".equals(vnfCreated));
-
- String rollbackVnfId = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:vnfId/text()");
- rollback.setVnfId(rollbackVnfId);
-
- createVnfNotification.setRollback(rollback);
-
- } catch (Exception e) {
- logger.debug("Failed to unmarshal VNF callback content:");
- logger.debug(content);
- return false;
- }
-
- VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl();
-
-
- notifyService.createVnfNotification(
- messageId,
- createVnfNotification.isCompleted(),
- createVnfNotification.getException(),
- createVnfNotification.getErrorMessage(),
- createVnfNotification.getVnfId(),
- createVnfNotification.getOutputs(),
- createVnfNotification.getRollback());
-
- return true;
- }
-
- /**
- * Injects a Delete VNF adapter callback request. The specified callback data
- * may contain the placeholder string ((MESSAGE-ID)) which is replaced with
- * the actual message ID. It may also contain the placeholder string
- * ((REQUEST-ID)) which is replaced request ID of the original MSO request.
- * @param content the content of the callback
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- * @throws JAXBException if the content does not adhere to the schema
- */
- protected boolean injectDeleteVNFCallback(String content, long timeout) {
-
- String messageId = (String) getProcessVariable("vnfAdapterDeleteV1",
- "VNFDEL_uuid", timeout);
-
- if (messageId == null) {
- return false;
- }
-
- content = content.replace("((MESSAGE-ID))", messageId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{MESSAGE-ID}}", messageId);
-
- logger.debug("Injecting VNF adapter delete callback");
-
- // Is it possible to unmarshal this with JAXB? I couldn't.
-
- DeleteVnfNotification deleteVnfNotification = new DeleteVnfNotification();
- XPathTool xpathTool = new VnfNotifyXPathTool();
- xpathTool.setXML(content);
-
- try {
- String completed = xpathTool.evaluate(
- "/tns:deleteVnfNotification/tns:completed/text()");
- deleteVnfNotification.setCompleted("true".equals(completed));
- // if notification failure, set the exception and error message
- if (deleteVnfNotification.isCompleted() == false) {
- deleteVnfNotification.setException(MsoExceptionCategory.INTERNAL);
- deleteVnfNotification.setErrorMessage(xpathTool.evaluate(
- "/tns:deleteVnfNotification/tns:errorMessage/text()")) ;
- }
-
- } catch (Exception e) {
- logger.debug("Failed to unmarshal VNF Delete callback content:");
- logger.debug(content);
- return false;
- }
-
- VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl();
-
-
- notifyService.deleteVnfNotification(
- messageId,
- deleteVnfNotification.isCompleted(),
- deleteVnfNotification.getException(),
- deleteVnfNotification.getErrorMessage());
-
- return true;
- }
-
- /**
- * Injects a Update VNF adapter callback request. The specified callback data
- * may contain the placeholder string ((MESSAGE-ID)) which is replaced with
- * the actual message ID. It may also contain the placeholder string
- * ((REQUEST-ID)) which is replaced request ID of the original MSO request.
- * @param content the content of the callback
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- * @throws JAXBException if the content does not adhere to the schema
- */
- protected boolean injectUpdateVNFCallback(String content, long timeout) {
-
- String messageId = (String) getProcessVariable("vnfAdapterUpdate",
- "VNFU_messageId", timeout);
-
- if (messageId == null) {
- return false;
- }
-
- content = content.replace("((MESSAGE-ID))", messageId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{MESSAGE-ID}}", messageId);
-
- content = content.replace("((REQUEST-ID))", msoRequestId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{REQUEST-ID}}", msoRequestId);
-
- logger.debug("Injecting VNF adapter callback");
-
- // Is it possible to unmarshal this with JAXB? I couldn't.
-
- UpdateVnfNotification updateVnfNotification = new UpdateVnfNotification();
- XPathTool xpathTool = new VnfNotifyXPathTool();
- xpathTool.setXML(content);
-
- try {
- String completed = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:completed/text()");
- updateVnfNotification.setCompleted("true".equals(completed));
-
- NodeList entries = (NodeList) xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:outputs/tns:entry",
- XPathConstants.NODESET);
-
- UpdateVnfNotificationOutputs outputs = new UpdateVnfNotificationOutputs();
-
- for (int i = 0; i < entries.getLength(); i++) {
- Node node = entries.item(i);
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element entry = (Element) node;
- String key = entry.getElementsByTagNameNS("*", "key").item(0).getTextContent();
- String value = entry.getElementsByTagNameNS("*", "value").item(0).getTextContent();
- outputs.add(key, value);
- }
- }
-
- updateVnfNotification.setOutputs(outputs);
-
- VnfRollback rollback = new VnfRollback();
-
- String cloudSiteId = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:cloudSiteId/text()");
- rollback.setCloudSiteId(cloudSiteId);
-
- String cloudOwner = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:cloudOwner/text()");
- rollback.setCloudOwner(cloudOwner);
-
- String requestId = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:msoRequest/tns:requestId/text()");
- String serviceInstanceId = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:msoRequest/tns:serviceInstanceId/text()");
-
- if (requestId != null || serviceInstanceId != null) {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestId);
- msoRequest.setServiceInstanceId(serviceInstanceId);
- rollback.setMsoRequest(msoRequest);
- }
-
- String tenantCreated = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:tenantCreated/text()");
- rollback.setTenantCreated("true".equals(tenantCreated));
-
- String tenantId = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:tenantId/text()");
- rollback.setTenantId(tenantId);
-
- String vnfCreated = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:vnfCreated/text()");
- rollback.setVnfCreated("true".equals(vnfCreated));
-
- String rollbackVnfId = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:vnfId/text()");
- rollback.setVnfId(rollbackVnfId);
-
- updateVnfNotification.setRollback(rollback);
-
- } catch (Exception e) {
- logger.debug("Failed to unmarshal VNF callback content:");
- logger.debug(content);
- return false;
- }
-
- VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl();
-
-
- notifyService.updateVnfNotification(
- messageId,
- updateVnfNotification.isCompleted(),
- updateVnfNotification.getException(),
- updateVnfNotification.getErrorMessage(),
- updateVnfNotification.getOutputs(),
- updateVnfNotification.getRollback());
-
- return true;
- }
-
- /**
- * Runs a program to inject workflow messages into the test environment.
- * A program is essentially just a list of keys that identify event data
- * to be injected, in sequence. An example program:
- * <pre>
- * event1, event2
- * </pre>
- * Errors are handled with junit assertions and will cause the test to fail.
- * NOTE: Each callback must have a workflow message type associated with it.
- * @param callbacks an object containing event data for the program
- * @param program the program to execute
- */
- protected void injectWorkflowMessages(CallbackSet callbacks, String program) {
-
- String[] cmds = program.replaceAll("\\s+", "").split(",");
-
- for (String cmd : cmds) {
- String action = cmd;
- String modifier = "STD";
-
- if (cmd.contains(":")) {
- String[] parts = cmd.split(":");
- action = parts[0];
- modifier = parts[1];
- }
-
- String messageType = null;
- String content = null;
- String contentType = null;
-
- if ("STD".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No '" + action + "' workflow message callback is defined";
- logger.debug(msg);
- fail(msg);
- }
-
- messageType = callbackData.getMessageType();
-
- if (messageType == null || messageType.trim().equals("")) {
- String msg = "No workflow message type is defined in the '" + action + "' callback";
- logger.debug(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- contentType = callbackData.getContentType();
- } else {
- String msg = "Invalid workflow message program modifier: '" + modifier + "'";
- logger.debug(msg);
- fail(msg);
- }
-
- if (!injectWorkflowMessage(contentType, messageType, content, 10000)) {
- fail("Failed to inject '" + action + "' workflow message");
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail("Interrupted after injection of '" + action + "' workflow message");
- }
- }
- }
-
- /**
- * Injects a workflow message. The specified callback data may contain the
- * placeholder string ((CORRELATOR)) which is replaced with the actual
- * correlator value.
- * @param contentType the HTTP contentType for the message (possibly null)
- * @param messageType the message type
- * @param content the message content (possibly null)
- * @param timeout the timeout in milliseconds
- * @return true if the message could be injected, false otherwise
- */
- protected boolean injectWorkflowMessage(String contentType, String messageType, String content, long timeout) {
- String correlator = (String) getProcessVariable("ReceiveWorkflowMessage",
- messageType + "_CORRELATOR", timeout);
-
- if (correlator == null) {
- return false;
- }
-
- if (content != null) {
- content = content.replace("((CORRELATOR))", correlator);
- }
-
- logger.debug("Injecting " + messageType + " message");
-
- Response response = workflowMessageResource.deliver(contentType, messageType, correlator, content);
- logger.debug("Workflow response to {} message: {}", messageType, response);
- return true;
- }
-
- /**
- * Runs a program to inject sniro workflow messages into the test environment.
- * A program is essentially just a list of keys that identify event data
- * to be injected, in sequence. For more details, see
- * injectSNIROCallbacks(String contentType, String messageType, String content, long timeout)
- *
- * Errors are handled with junit assertions and will cause the test to fail.
- * NOTE: Each callback must have a workflow message type associated with it.
- *
- * @param callbacks an object containing event data for the program
- * @param program the program to execute
- */
- protected void injectSNIROCallbacks(CallbackSet callbacks, String program) {
-
- String[] cmds = program.replaceAll("\\s+", "").split(",");
-
- for (String cmd : cmds) {
- String action = cmd;
- String modifier = "STD";
-
- if (cmd.contains(":")) {
- String[] parts = cmd.split(":");
- action = parts[0];
- modifier = parts[1];
- }
-
- String messageType = null;
- String content = null;
- String contentType = null;
-
- if ("STD".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No '" + action + "' workflow message callback is defined";
- logger.debug(msg);
- fail(msg);
- }
-
- messageType = callbackData.getMessageType();
-
- if (messageType == null || messageType.trim().equals("")) {
- String msg = "No workflow message type is defined in the '" + action + "' callback";
- logger.debug(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- contentType = callbackData.getContentType();
- } else {
- String msg = "Invalid workflow message program modifier: '" + modifier + "'";
- logger.debug(msg);
- fail(msg);
- }
-
- if (!injectSNIROCallbacks(contentType, messageType, content, 10000)) {
- fail("Failed to inject '" + action + "' workflow message");
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail("Interrupted after injection of '" + action + "' workflow message");
- }
- }
- }
-
- /**
- * Injects a sniro workflow message. The specified callback response may
- * contain the placeholder strings ((CORRELATOR)) and ((SERVICE_RESOURCE_ID))
- * The ((CORRELATOR)) is replaced with the actual correlator value from the
- * request. The ((SERVICE_RESOURCE_ID)) is replaced with the actual serviceResourceId
- * value from the sniro request. Currently this only works with sniro request
- * that contain only 1 resource.
- *
- * @param contentType the HTTP contentType for the message (possibly null)
- * @param messageType the message type
- * @param content the message content (possibly null)
- * @param timeout the timeout in milliseconds
- * @return true if the message could be injected, false otherwise
- */
- protected boolean injectSNIROCallbacks(String contentType, String messageType, String content, long timeout) {
- String correlator = (String) getProcessVariable("ReceiveWorkflowMessage",
- messageType + "_CORRELATOR", timeout);
-
- if (correlator == null) {
- return false;
- }
- if (content != null) {
- content = content.replace("((CORRELATOR))", correlator);
- if(messageType.equalsIgnoreCase("SNIROResponse")){
- ServiceDecomposition decomp = (ServiceDecomposition) getProcessVariable("Homing", "serviceDecomposition", timeout);
- List<Resource> resourceList = decomp.getServiceResources();
- if(resourceList.size() == 1){
- String resourceId = "";
- for(Resource resource:resourceList){
- resourceId = resource.getResourceId();
- }
- String homingList = getJsonValue(content, "solutionInfo.placementInfo");
- JSONArray placementArr = null;
- try {
- placementArr = new JSONArray(homingList);
- }
- catch (Exception e) {
- return false;
- }
- if(placementArr.length() == 1){
- content = content.replace("((SERVICE_RESOURCE_ID))", resourceId);
- }
- String licenseInfoList = getJsonValue(content, "solutionInfo.licenseInfo");
- JSONArray licenseArr = null;
- try {
- licenseArr = new JSONArray(licenseInfoList);
- }
- catch (Exception e) {
- return false;
- }
- if(licenseArr.length() == 1){
- content = content.replace("((SERVICE_RESOURCE_ID))", resourceId);
- }
- }
- else {
- try {
- String homingList = getJsonValue(content, "solutionInfo.placementInfo");
- String licenseInfoList = getJsonValue(content, "solutionInfo.licenseInfo");
- JSONArray placementArr = new JSONArray(homingList);
- JSONArray licenseArr = new JSONArray(licenseInfoList);
- for (Resource resource: resourceList) {
- String resourceModuleName = resource.getModelInfo().getModelInstanceName();
- String resourceId = resource.getResourceId();
-
- for (int i=0; i<placementArr.length(); i++) {
- JSONObject placementObj = placementArr.getJSONObject(i);
- String placementModuleName = placementObj.getString("resourceModuleName");
- if (placementModuleName.equalsIgnoreCase(resourceModuleName)) {
- String placementString = placementObj.toString();
- placementString = placementString.replace("((SERVICE_RESOURCE_ID))", resourceId);
- JSONObject newPlacementObj = new JSONObject(placementString);
- placementArr.put(i, newPlacementObj);
- }
- }
-
- for (int i=0; i<licenseArr.length(); i++) {
- JSONObject licenseObj = licenseArr.getJSONObject(i);
- String licenseModuleName = licenseObj.getString("resourceModuleName");
- if (licenseModuleName.equalsIgnoreCase(resourceModuleName)) {
- String licenseString = licenseObj.toString();
- licenseString = licenseString.replace("((SERVICE_RESOURCE_ID))", resourceId);
- JSONObject newLicenseObj = new JSONObject(licenseString);
- licenseArr.put(i, newLicenseObj);
- }
- }
- }
- String newPlacementInfos = placementArr.toString();
- String newLicenseInfos = licenseArr.toString();
- content = updJsonValue(content, "solutionInfo.placementInfo", newPlacementInfos);
- content = updJsonValue(content, "solutionInfo.licenseInfo", newLicenseInfos);
- }
- catch(Exception e) {
- return false;
- }
-
- }
- }
- }
- logger.debug("Injecting " + messageType + " message");
-
- Response response = workflowMessageResource.deliver(contentType, messageType, correlator, content);
- logger.debug("Workflow response to {} message: {}", messageType, response);
- return true;
- }
-
-
- /**
- * Wait for the process to end.
- * @param businessKey the process business key
- * @param timeout the amount of time to wait, in milliseconds
- */
- protected void waitForProcessEnd(String businessKey, long timeout) {
- logger.debug("Waiting {}ms for process with business key {} to end", timeout, businessKey);
-
- long now = System.currentTimeMillis() + timeout;
- long endTime = now + timeout;
-
- while (now <= endTime) {
- if (isProcessEnded(businessKey)) {
- logger.debug("Process with business key {} has ended", businessKey);
- return;
- }
-
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- String msg = "Interrupted waiting for process with business key " +
- businessKey + " to end";
- logger.debug(msg);
- fail(msg);
- }
-
- now = System.currentTimeMillis();
- }
-
- String msg = "Process with business key " + businessKey +
- " did not end within " + timeout + "ms";
- logger.debug(msg);
- fail(msg);
- }
-
- /**
- * Wait for the process to end. Must be used when multiple process instances exist with
- * this same business key such as when its passed to subflows or shared across multiple
- * processes.
- *
- * @param businessKey the process business key
- * @param processName the process definition name
- * @param timeout the amount of time to wait, in milliseconds
- * @author cb645j
- */
- protected void waitForProcessEnd(String businessKey, String processName, long timeout) {
- logger.debug("Waiting {}ms for process with business key {} to end", timeout, businessKey);
-
- long now = System.currentTimeMillis() + timeout;
- long endTime = now + timeout;
-
- while (now <= endTime) {
- if (isProcessEnded(businessKey, processName)) {
- logger.debug("Process with business key {} has ended", businessKey);
- return;
- }
-
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- String msg = "Interrupted waiting for process with business key " +
- businessKey + " to end";
- logger.debug(msg);
- fail(msg);
- }
-
- now = System.currentTimeMillis();
- }
-
- String msg = "Process with business key " + businessKey +
- " did not end within " + timeout + "ms";
- logger.debug(msg);
- fail(msg);
- }
-
- /**
- * Verifies that the specified historic process variable has the specified value.
- * If the variable does not have the specified value, the test is failed.
- *
- * @param businessKey the process business key
- * @param variable the variable name
- * @param value the expected variable value
- */
- protected void checkVariable(String businessKey, String variable, Object value) {
- if (!isProcessEnded(businessKey)) {
- fail("Cannot get historic variable " + variable + " because process with business key " +
- businessKey + " has not ended");
- }
-
- Object variableValue = getVariableFromHistory(businessKey, variable);
- assertEquals(value, variableValue);
- }
-
- /**
- * Checks to see if the specified process is ended.
- * @param businessKey the process business Key
- * @return true if the process is ended
- */
- protected boolean isProcessEnded(String businessKey) {
- HistoricProcessInstance processInstance = historyService
- .createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).singleResult();
- return processInstance != null && processInstance.getEndTime() != null;
- }
-
- /**
- * Checks to see if the specified process is ended.
- *
- * @param processInstanceId the process Instance Id
- * @return true if the process is ended
- */
- protected boolean isProcessEndedByProcessInstanceId(String processInstanceId) {
- HistoricProcessInstance processInstance = historyService
- .createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
- return processInstance != null && processInstance.getEndTime() != null;
- }
-
- /**
- * Checks to see if the specified process is ended.
- *
- * @author cb645j
- */
- //TODO combine into 1
- private boolean isProcessEnded(String businessKey, String processName) {
- HistoricProcessInstance processInstance = historyService
- .createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).processDefinitionName(processName).singleResult();
- return processInstance != null && processInstance.getEndTime() != null;
- }
-
- /**
- * Gets a variable value from a historical process instance. The business key must be unique.
- *
- * @param businessKey the process business key
- * @param variableName the variable name
- * @return the variable value or null if the variable does not exist
- */
- protected Object getVariableFromHistory(String businessKey, String variableName) {
- try {
- HistoricProcessInstance processInstance = historyService
- .createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).singleResult();
-
- if (processInstance == null) {
- return null;
- }
-
- HistoricVariableInstance v = historyService
- .createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId())
- .variableName(variableName).singleResult();
- return v == null ? null : v.getValue();
- } catch (Exception e) {
- logger.debug("Error retrieving variable {} from historical process with business key {}: ", variableName, businessKey,
- e);
- return null;
- }
- }
-
- /**
- * Gets a variable value from a process instance based on businessKey and process name.
- * Must be used when multiple instances exist with the same business key such as when
- * business key is passed to subflows or shared across multiple processes. This method
- * can obtain variables from mainflows and from subflows.
- *
- * @param businessKey the process business key
- * @param processName the process definition name
- * @param variableName the variable name
- * @return the variable value or null if the variable does not exist
- * @author cb645j
- */
- protected Object getVariableFromHistory(String businessKey, String processName, String variableName){
- try{
- HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).processDefinitionName(processName)
- .singleResult();
-
- if(processInstance == null){
- return null;
- }
- HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName(variableName).singleResult();
-
- return variable == null ? null : variable.getValue();
- }catch(ProcessEngineException e){
- logger.debug("Multiple proccess instances exist with process name {} and business key {}. Must pass instance "
- + "index as a parameter.", processName, businessKey);
- return null;
- }catch(Exception e){
- logger.debug("Error retrieving variable {} from historical process for process {} with business key {}: ",
- variableName, processName, businessKey, e);
- return null;
- }
- }
-
- /**
- * Gets the value of a process variable from x instance of y process. Must be used when
- * multiple instances exist with the same business key AND process name. This method
- * shall be used primarily for obtaining subflow variables when the business key is
- * passed to the subflow AND the subflow is called multiple times in a given flow.
- *
- * @param businessKey the process business key
- * @param processName the name of the subflow that contains the variable
- * @param variableName the variable name
- * @param processInstanceIndex the instance in which the subprocess was called
- * @return the variable value or null if the variable does not exist
- * @author cb645j
- */
- protected Object getVariableFromHistory(String businessKey, int subflowInstanceIndex, String processName, String variableName){
- try{
- List<HistoricProcessInstance> processInstanceList = historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).processDefinitionName(processName)
- .list();
-
- if(processInstanceList == null){
- return null;
- }
- processInstanceList.sort((m1, m2) -> m1.getStartTime().compareTo(m2.getStartTime()));
-
- HistoricProcessInstance processInstance = processInstanceList.get(subflowInstanceIndex);
- HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId())
- .variableName(variableName).singleResult();
-
- return variable == null ? null : variable.getValue();
- }catch(Exception e) {
- logger.debug("Error retrieving variable {} from historical process for process {} with business key {}: ",
- variableName, processName, businessKey, e);
- return null;
- }
- }
-
-
- /**
- * Gets the value of a subflow variable from the specified subflow's
- * historical process instance.
- *
- * DEPRECATED - Use method getVariableFromHistory(businessKey, processName, variableName) instead
- *
- * @param subflowName - the name of the subflow that contains the variable
- * @param variableName the variable name
- *
- * @return the variable value, or null if the variable could not be obtained
- *
- */
- @Deprecated
- protected Object getVariableFromSubflowHistory(String subflowName, String variableName) {
- try {
- List<HistoricProcessInstance> processInstanceList = historyService
- .createHistoricProcessInstanceQuery().processDefinitionName(subflowName).list();
-
- if (processInstanceList == null) {
- return null;
- }
-
- processInstanceList.sort((m1, m2) -> m1.getStartTime().compareTo(m2.getStartTime()));
-
- HistoricProcessInstance processInstance = processInstanceList.get(0);
-
- HistoricVariableInstance v = historyService
- .createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId())
- .variableName(variableName).singleResult();
- return v == null ? null : v.getValue();
- } catch (Exception e) {
- logger.debug("Error retrieving variable {} from sub flow: {}, Exception is: ", variableName, subflowName, e);
- return null;
- }
- }
-
- /**
- * Gets the value of a subflow variable from the subflow's
- * historical process x instance.
- *
- * DEPRECATED: Use method getVariableFromHistory(businessKey, processInstanceIndex, processName, variableName) instead
- *
- * @param subflowName - the name of the subflow that contains the variable
- * @param variableName the variable name
- * @param subflowInstanceIndex - the instance of the subflow (use when same subflow is called more than once from mainflow)
- *
- * @return the variable value, or null if the variable could not be obtained
- */
- @Deprecated
- protected Object getVariableFromSubflowHistory(int subflowInstanceIndex, String subflowName, String variableName) {
- try {
- List<HistoricProcessInstance> processInstanceList = historyService.createHistoricProcessInstanceQuery().processDefinitionName(subflowName).list();
-
- if (processInstanceList == null) {
- return null;
- }
-
- processInstanceList.sort((m1, m2) -> m1.getStartTime().compareTo(m2.getStartTime()));
-
- HistoricProcessInstance processInstance = processInstanceList.get(subflowInstanceIndex);
-
- HistoricVariableInstance v = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId())
- .variableName(variableName).singleResult();
- return v == null ? null : v.getValue();
- } catch (Exception e) {
- logger.debug("Error retrieving variable {} from {} instance index of sub flow: {}, Exception is: ", variableName,
- subflowInstanceIndex, subflowName, e);
- return null;
- }
- }
-
- /**
- * Extracts text from an XML element. This method is not namespace aware
- * (namespaces are ignored). The first matching element is selected.
- * @param xml the XML document or fragment
- * @param tag the desired element, e.g. "<name>"
- * @return the element text, or null if the element was not found
- */
- protected String getXMLTextElement(String xml, String tag) {
- xml = removeXMLNamespaces(xml);
-
- if (!tag.startsWith("<")) {
- tag = "<" + tag + ">";
- }
-
- int start = xml.indexOf(tag);
-
- if (start == -1) {
- return null;
- }
-
- int end = xml.indexOf('<', start + tag.length());
-
- if (end == -1) {
- return null;
- }
-
- return xml.substring(start + tag.length(), end);
- }
-
- /**
- * Removes namespace definitions and prefixes from XML, if any.
- */
- private String removeXMLNamespaces(String xml) {
- // remove xmlns declaration
- xml = xml.replaceAll("xmlns.*?(\"|\').*?(\"|\')", "");
-
- // remove opening tag prefix
- xml = xml.replaceAll("(<)(\\w+:)(.*?>)", "$1$3");
-
- // remove closing tags prefix
- xml = xml.replaceAll("(</)(\\w+:)(.*?>)", "$1$3");
-
- // remove extra spaces left when xmlns declarations are removed
- xml = xml.replaceAll("\\s+>", ">");
-
- return xml;
- }
-
- /**
- * Asserts that two XML documents are semantically equivalent. Differences
- * in whitespace or in namespace usage do not affect the comparison.
- * @param expected the expected XML
- * @param actual the XML to test
- * @throws SAXException
- * @throws IOException
- */
- public static void assertXMLEquals(String expected, String actual)
- throws SAXException, IOException {
- XMLUnit.setIgnoreWhitespace(true);
- XMLUnit.setIgnoreAttributeOrder(true);
- DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expected, actual));
- List<?> allDifferences = diff.getAllDifferences();
- assertEquals("Differences found: " + diff.toString(), 0, allDifferences.size());
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowTest.class);
+
+ // TODO this is not used anymore, can maybe be removed
+ @Rule
+ public ProcessEngineRule processEngineRule;
+
+ @Autowired
+ protected WorkflowResource workflowResourceSync;
+
+ @Autowired
+ protected ProcessEngine processEngine;
+
+ @Autowired
+ protected RuntimeService runtimeService;
+
+ @Autowired
+ protected HistoryService historyService;
+
+ @Autowired
+ private WorkflowAsyncResource workflowResource;
+
+ @Autowired
+ private WorkflowMessageResource workflowMessageResource;
+
+ @Autowired
+ SDNCAdapterCallbackServiceImpl callbackService;
+ /**
+ * Content-Type for XML.
+ */
+ protected static final String XML = "application/xml";
+
+ /**
+ * Content-Type for JSON.
+ */
+ protected static final String JSON = "application/json; charset=UTF-8";
+
+ private static final int timeout = 2000;
+
+ /**
+ * Constructor.
+ */
+ public WorkflowTest() throws RuntimeException {}
+
+ /**
+ * The current request ID. Normally set when an "invoke" method is called.
+ */
+ protected volatile String msoRequestId = null;
+
+ /**
+ * The current service instance ID. Normally set when an "invoke" method is called.
+ */
+ protected volatile String msoServiceInstanceId = null;
+
+ /**
+ * Logs a test start method.
+ */
+ protected void logStart() {
+ logger.debug("STARTED TEST");
+ }
+
+ /**
+ * Logs a test end method.
+ */
+ protected void logEnd() {
+ logger.debug("ENDED TEST");
+ }
+
+ /**
+ * Invokes a subprocess.
+ *
+ * @param processKey the process key
+ * @param businessKey a unique key that will identify the process instance
+ * @param injectedVariables variables to inject into the process
+ */
+ protected void invokeSubProcess(String processKey, String businessKey, Map<String, Object> injectedVariables) {
+ RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
+ List<String> arguments = runtimeMxBean.getInputArguments();
+ logger.debug("JVM args = {}", arguments);
+
+ msoRequestId = (String) injectedVariables.get("mso-request-id");
+ String requestId = (String) injectedVariables.get("msoRequestId");
+
+ if (msoRequestId == null && requestId == null) {
+ String msg = "mso-request-id variable was not provided";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ // Note: some scenarios don't have a service-instance-id, may be null
+ msoServiceInstanceId = (String) injectedVariables.get("mso-service-instance-id");
+
+
+ runtimeService.startProcessInstanceByKey(processKey, businessKey, injectedVariables);
+ }
+
+ protected String invokeSubProcess(String processKey, Map<String, Object> injectedVariables) {
+ RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
+ List<String> arguments = runtimeMxBean.getInputArguments();
+ logger.debug("JVM args = {}", arguments);
+
+ msoRequestId = (String) injectedVariables.get("mso-request-id");
+ String requestId = (String) injectedVariables.get("msoRequestId");
+
+ if (msoRequestId == null && requestId == null) {
+ String msg = "mso-request-id variable was not provided";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ // Note: some scenarios don't have a service-instance-id, may be null
+ msoServiceInstanceId = (String) injectedVariables.get("mso-service-instance-id");
+
+
+ ProcessInstance processInstance =
+ runtimeService.startProcessInstanceByKey(processKey, msoRequestId, injectedVariables);
+ return processInstance.getId();
+ }
+
+ /**
+ * Invokes an asynchronous process. Errors are handled with junit assertions and will cause the test to fail.
+ *
+ * @param processKey the process key
+ * @param schemaVersion the API schema version, e.g. "v1"
+ * @param businessKey a unique key that will identify the process instance
+ * @param request the request
+ * @return a TestAsyncResponse object associated with the test
+ * @throws InterruptedException
+ */
+ protected TestAsyncResponse invokeAsyncProcess(String processKey, String schemaVersion, String businessKey,
+ String request) throws InterruptedException {
+ return invokeAsyncProcess(processKey, schemaVersion, businessKey, request, null);
+ }
+
+ /**
+ * Invokes an asynchronous process. Errors are handled with junit assertions and will cause the test to fail.
+ *
+ * @param processKey the process key
+ * @param schemaVersion the API schema version, e.g. "v1"
+ * @param businessKey a unique key that will identify the process instance
+ * @param request the request
+ * @param injectedVariables optional variables to inject into the process
+ * @return a TestAsyncResponse object associated with the test
+ * @throws InterruptedException
+ */
+ protected TestAsyncResponse invokeAsyncProcess(String processKey, String schemaVersion, String businessKey,
+ String request, Map<String, Object> injectedVariables) {
+
+ RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
+ List<String> arguments = runtimeMxBean.getInputArguments();
+ logger.debug("JVM args = {}", arguments);
+
+ Map<String, Object> variables = createVariables(schemaVersion, businessKey, request, injectedVariables, false);
+ VariableMapImpl variableMapImpl = createVariableMapImpl(variables);
+
+ logger.debug("Sending {} to {} process", request, processKey);
+
+ TestAsyncResponse asyncResponse = new TestAsyncResponse();
+
+ asyncResponse.setResponse(workflowResource.startProcessInstanceByKey(processKey, variableMapImpl));
+
+ return asyncResponse;
+ }
+
+ /**
+ * Invokes an asynchronous process. Errors are handled with junit assertions and will cause the test to fail.
+ *
+ * @param processKey the process key
+ * @param schemaVersion the API schema version, e.g. "v1"
+ * @param businessKey a unique key that will identify the process instance
+ * @param request the request
+ * @param injectedVariables optional variables to inject into the process
+ * @param serviceInstantiationModel indicates whether this method is being invoked for a flow that is designed using
+ * the service instantiation model
+ * @return a TestAsyncResponse object associated with the test
+ * @throws InterruptedException
+ */
+ protected Response invokeAsyncProcess(String processKey, String schemaVersion, String businessKey, String request,
+ Map<String, Object> injectedVariables, boolean serviceInstantiationModel) {
+
+ RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
+ List<String> arguments = runtimeMxBean.getInputArguments();
+ logger.debug("JVM args = {}", arguments);
+
+ Map<String, Object> variables =
+ createVariables(schemaVersion, businessKey, request, injectedVariables, serviceInstantiationModel);
+ VariableMapImpl variableMapImpl = createVariableMapImpl(variables);
+
+ logger.debug("Sending {} to {} process", request, processKey);
+
+ return workflowResource.startProcessInstanceByKey(processKey, variableMapImpl);
+
+ }
+
+ /**
+ * Private helper method that creates a variable map for a request. Errors are handled with junit assertions and
+ * will cause the test to fail.
+ *
+ * @param schemaVersion the API schema version, e.g. "v1"
+ * @param businessKey a unique key that will identify the process instance
+ * @param request the request
+ * @param injectedVariables optional variables to inject into the process
+ * @param serviceInstantiationModel indicates whether this method is being invoked for a flow that is designed using
+ * the service instantiation model
+ * @return a variable map
+ */
+ private Map<String, Object> createVariables(String schemaVersion, String businessKey, String request,
+ Map<String, Object> injectedVariables, boolean serviceInstantiationModel) {
+
+ Map<String, Object> variables = new HashMap<>();
+
+ // These variables may be overridded by injected variables.
+ variables.put("mso-service-request-timeout", "180");
+ variables.put("isDebugLogEnabled", "true");
+
+ // These variables may not be overridded by injected variables.
+ String[] notAllowed = new String[] {"mso-schema-version", "mso-business-key", "bpmnRequest", "mso-request-id",
+ "mso-service-instance-id"};
+
+ if (injectedVariables != null) {
+ for (String key : injectedVariables.keySet()) {
+ for (String var : notAllowed) {
+ if (var.equals(key)) {
+ String msg = "Cannot specify " + var + " in injected variables";
+ logger.debug(msg);
+ fail(msg);
+ }
+ }
+
+ variables.put(key, injectedVariables.get(key));
+ }
+ }
+
+ variables.put("mso-schema-version", schemaVersion);
+ variables.put("mso-business-key", businessKey);
+ variables.put("bpmnRequest", request);
+
+ if (serviceInstantiationModel) {
+
+ /*
+ * The request ID and the service instance ID are generated for flows that follow the service instantiation
+ * model unless "requestId" and "serviceInstanceId" are injected variables.
+ */
+
+ try {
+ msoRequestId = (String) injectedVariables.get("requestId");
+ variables.put("mso-request-id", msoRequestId);
+ msoServiceInstanceId = (String) injectedVariables.get("serviceInstanceId");
+ variables.put("mso-service-instance-id", msoServiceInstanceId);
+ } catch (Exception e) {
+ }
+ if (msoRequestId == null || msoRequestId.trim().equals("")) {
+ logger.debug("No requestId element in injectedVariables");
+ variables.put("mso-request-id", UUID.randomUUID().toString());
+ }
+ if (msoServiceInstanceId == null || msoServiceInstanceId.trim().equals("")) {
+ logger.debug("No seviceInstanceId element in injectedVariables");
+ variables.put("mso-service-instance-id", UUID.randomUUID().toString());
+ }
+
+ } else {
+ msoRequestId = getXMLTextElement(request, "request-id");
+
+ if (msoRequestId == null) {
+ // check in injected variables
+ try {
+ msoRequestId = (String) injectedVariables.get("requestId");
+ } catch (Exception e) {
+ }
+ if (msoRequestId == null || msoRequestId.trim().equals("")) {
+ String msg = "No request-id element in " + request;
+ logger.debug(msg);
+ fail(msg);
+ }
+ }
+
+ variables.put("mso-request-id", msoRequestId);
+
+ // Note: some request types don't have a service-instance-id
+ msoServiceInstanceId = getXMLTextElement(request, "service-instance-id");
+
+ if (msoServiceInstanceId != null) {
+ variables.put("mso-service-instance-id", msoServiceInstanceId);
+ }
+ }
+
+ return variables;
+ }
+
+ /**
+ * Private helper method that creates a camunda VariableMapImpl from a simple variable map.
+ *
+ * @param variables the simple variable map
+ * @return a VariableMap
+ */
+ private VariableMapImpl createVariableMapImpl(Map<String, Object> variables) {
+ Map<String, Object> wrappedVariables = new HashMap<>();
+
+ for (String key : variables.keySet()) {
+ Object value = variables.get(key);
+ wrappedVariables.put(key, wrapVariableValue(value));
+ }
+
+ VariableMapImpl variableMapImpl = new VariableMapImpl();
+ variableMapImpl.put("variables", wrappedVariables);
+ return variableMapImpl;
+ }
+
+ /**
+ * Private helper method that wraps a variable value for inclusion in a camunda VariableMapImpl.
+ *
+ * @param value the variable value
+ * @return the wrapped variable
+ */
+ private Map<String, Object> wrapVariableValue(Object value) {
+ HashMap<String, Object> valueMap = new HashMap<>();
+ valueMap.put("value", value);
+ return valueMap;
+ }
+
+ /**
+ * Receives a response from an asynchronous process. Errors are handled with junit assertions and will cause the
+ * test to fail.
+ *
+ * @param businessKey the process business key
+ * @param asyncResponse the TestAsyncResponse object associated with the test
+ * @param timeout the timeout in milliseconds
+ * @return the WorkflowResponse
+ */
+ protected WorkflowResponse receiveResponse(String businessKey, TestAsyncResponse asyncResponse, long timeout) {
+ logger.debug("Waiting {}ms for process with business key {} to send a response", timeout, businessKey);
+
+ long now = System.currentTimeMillis() + timeout;
+ long endTime = now + timeout;
+
+ while (now <= endTime) {
+ Response response = asyncResponse.getResponse();
+
+ if (response != null) {
+ logger.debug("Received a response from process with business key {}", businessKey);
+
+ Object entity = response.getEntity();
+
+ if (!(entity instanceof WorkflowResponse)) {
+ String msg = "Response entity is " + (entity == null ? "null" : entity.getClass().getName())
+ + ", expected WorkflowResponse";
+ logger.debug(msg);
+ fail(msg);
+ return null; // unreachable
+ }
+
+ return (WorkflowResponse) entity;
+ }
+
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ String msg = "Interrupted waiting for a response from process with business key " + businessKey;
+ logger.debug(msg);
+ fail(msg);
+ return null; // unreachable
+ }
+
+ now = System.currentTimeMillis();
+ }
+
+ String msg = "No response received from process with business key " + businessKey + " within " + timeout + "ms";
+ logger.debug(msg);
+ fail("Process with business key " + businessKey + " did not end within 10000ms");
+ return null; // unreachable
+ }
+
+ /**
+ * Runs a program to inject SDNC callback data into the test environment. A program is essentially just a list of
+ * keys that identify callback data to be injected, in sequence. An example program:
+ *
+ * <pre>
+ * reserve, assign, delete:ERR
+ * </pre>
+ *
+ * Errors are handled with junit assertions and will cause the test to fail.
+ *
+ * @param callbacks an object containing callback data for the program
+ * @param program the program to execute
+ */
+ protected void injectSDNCRestCallbacks(CallbackSet callbacks, String program) {
+
+ String[] cmds = program.replaceAll("\\s+", "").split(",");
+
+ for (String cmd : cmds) {
+ String action = cmd;
+ String modifier = "STD";
+
+ if (cmd.contains(":")) {
+ String[] parts = cmd.split(":");
+ action = parts[0];
+ modifier = parts[1];
+ }
+
+ String content = null;
+ String contentType = null;
+
+ if ("STD".equals(modifier)) {
+ CallbackData callbackData = callbacks.get(action);
+
+ if (callbackData == null) {
+ String msg = "No callback defined for '" + action + "' SDNC request";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ content = callbackData.getContent();
+ contentType = callbackData.getContentType();
+ } else if ("ERR".equals(modifier)) {
+ content =
+ "{\"SDNCServiceError\":{\"sdncRequestId\":\"((REQUEST-ID))\",\"responseCode\":\"500\",\"responseMessage\":\"SIMULATED ERROR FROM SDNC ADAPTER\",\"ackFinalIndicator\":\"Y\"}}";
+ contentType = JSON;
+ } else {
+ String msg = "Invalid SDNC program modifier: '" + modifier + "'";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ if (contentType == null) {
+ // Default for backward compatibility with existing tests.
+ contentType = JSON;
+ }
+
+ if (!injectSDNCRestCallback(contentType, content, 10000)) {
+ fail("Failed to inject SDNC '" + action + "' callback");
+ }
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ fail("Interrupted after injection of SDNC '" + action + "' callback");
+ }
+ }
+ }
+
+ /**
+ * Runs a program to inject SDNC events into the test environment. A program is essentially just a list of keys that
+ * identify event data to be injected, in sequence. An example program:
+ *
+ * <pre>
+ * event1, event2
+ * </pre>
+ *
+ * NOTE: Each callback must have a message type associated with it, e.g. "SDNCAEvent". Errors are handled with junit
+ * assertions and will cause the test to fail.
+ *
+ * @param callbacks an object containing event data for the program
+ * @param program the program to execute
+ */
+ protected void injectSDNCEvents(CallbackSet callbacks, String program) {
+ injectWorkflowMessages(callbacks, program);
+ }
+
+ /**
+ * Runs a program to inject SDNC callback data into the test environment. A program is essentially just a list of
+ * keys that identify callback data to be injected, in sequence. An example program:
+ *
+ * <pre>
+ * reserve, assign, delete:ERR
+ * </pre>
+ *
+ * Errors are handled with junit assertions and will cause the test to fail. Uses the static/default timeout value
+ * for backward compatibility.
+ *
+ * @param callbacks an object containing callback data for the program
+ * @param program the program to execute
+ */
+ protected void injectSDNCCallbacks(CallbackSet callbacks, String program) {
+ injectSDNCCallbacks(callbacks, program, timeout);
+ }
+
+ /**
+ * Runs a program to inject SDNC callback data into the test environment. A program is essentially just a list of
+ * keys that identify callback data to be injected, in sequence. An example program:
+ *
+ * <pre>
+ * reserve, assign, delete:ERR
+ * </pre>
+ *
+ * Errors are handled with junit assertions and will cause the test to fail.
+ *
+ * @param callbacks an object containing callback data for the program
+ * @param program the program to execute
+ * @param timeout a timeout value to wait for the callback
+ */
+ protected void injectSDNCCallbacks(CallbackSet callbacks, String program, int timeout) {
+
+ String[] cmds = program.replaceAll("\\s+", "").split(",");
+
+ for (String cmd : cmds) {
+ String action = cmd;
+ String modifier = "STD";
+
+ if (cmd.contains(":")) {
+ String[] parts = cmd.split(":");
+ action = parts[0];
+ modifier = parts[1];
+ }
+
+ String content = null;
+ int respCode = 200;
+ String respMsg = "OK";
+
+ if ("STD".equals(modifier)) {
+ CallbackData callbackData = callbacks.get(action);
+
+ if (callbackData == null) {
+ String msg = "No callback defined for '" + action + "' SDNC request";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ content = callbackData.getContent();
+ respCode = 200;
+ respMsg = "OK";
+ } else if ("CREATED".equals(modifier)) {
+ CallbackData callbackData = callbacks.get(action);
+
+ if (callbackData == null) {
+ String msg = "No callback defined for '" + action + "' SDNC request";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ content = callbackData.getContent();
+ respCode = 201;
+ respMsg = "Created";
+ } else if ("ERR".equals(modifier)) {
+ content =
+ "<svc-request-id>((REQUEST-ID))</svc-request-id><response-code>500</response-code><response-message>SIMULATED ERROR FROM SDNC ADAPTER</response-message>";
+ respCode = 500;
+ respMsg = "SERVER ERROR";
+ } else {
+ String msg = "Invalid SDNC program modifier: '" + modifier + "'";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ if (!injectSDNCCallback(respCode, respMsg, content, 10000)) {
+ fail("Failed to inject SDNC '" + action + "' callback");
+ }
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ fail("Interrupted after injection of SDNC '" + action + "' callback");
+ }
+ }
+ }
+
+ /**
+ * Runs a program to inject VNF adapter REST callback data into the test environment. A program is essentially just
+ * a list of keys that identify callback data to be injected, in sequence. An example program:
+ *
+ * <pre>
+ * create, rollback
+ * </pre>
+ *
+ * Errors are handled with junit assertions and will cause the test to fail.
+ *
+ * @param callbacks an object containing callback data for the program
+ * @param program the program to execute
+ */
+ protected void injectVNFRestCallbacks(CallbackSet callbacks, String program) {
+
+ String[] cmds = program.replaceAll("\\s+", "").split(",");
+
+ for (String cmd : cmds) {
+ String action = cmd;
+ String modifier = "STD";
+
+ if (cmd.contains(":")) {
+ String[] parts = cmd.split(":");
+ action = parts[0];
+ modifier = parts[1];
+ }
+
+ String content = null;
+ String contentType = null;
+
+ if ("STD".equals(modifier)) {
+ CallbackData callbackData = callbacks.get(action);
+
+ if (callbackData == null) {
+ String msg = "No callback defined for '" + action + "' VNF REST request";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ content = callbackData.getContent();
+ contentType = callbackData.getContentType();
+ } else if ("ERR".equals(modifier)) {
+ content = "SIMULATED ERROR FROM VNF ADAPTER";
+ contentType = "text/plain";
+ } else {
+ String msg = "Invalid VNF REST program modifier: '" + modifier + "'";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ if (contentType == null) {
+ // Default for backward compatibility with existing tests.
+ contentType = XML;
+ }
+
+ if (!injectVnfAdapterRestCallback(contentType, content, 10000)) {
+ fail("Failed to inject VNF REST '" + action + "' callback");
+ }
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ fail("Interrupted after injection of VNF REST '" + action + "' callback");
+ }
+ }
+ }
+
+ /**
+ * Runs a program to inject VNF callback data into the test environment. A program is essentially just a list of
+ * keys that identify callback data to be injected, in sequence. An example program:
+ *
+ * <pre>
+ * createVnf, deleteVnf
+ * </pre>
+ *
+ * Errors are handled with junit assertions and will cause the test to fail.
+ *
+ * @param callbacks an object containing callback data for the program
+ * @param program the program to execute
+ */
+ protected void injectVNFCallbacks(CallbackSet callbacks, String program) {
+
+ String[] cmds = program.replaceAll("\\s+", "").split(",");
+
+ for (String cmd : cmds) {
+ String action = cmd;
+ String modifier = "STD";
+
+ if (cmd.contains(":")) {
+ String[] parts = cmd.split(":");
+ action = parts[0];
+ modifier = parts[1];
+ }
+
+ String content = null;
+
+ if ("STD".equals(modifier)) {
+ CallbackData callbackData = callbacks.get(action);
+
+ if (callbackData == null) {
+ String msg = "No callback defined for '" + action + "' VNF request";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ content = callbackData.getContent();
+ } else if ("ERR".equals(modifier)) {
+ String msg = "Currently unsupported VNF program modifier: '" + modifier + "'";
+ logger.debug(msg);
+ fail(msg);
+ } else {
+ String msg = "Invalid VNF program modifier: '" + modifier + "'";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ boolean injected = false;
+
+ if (content.contains("createVnfNotification")) {
+ injected = injectCreateVNFCallback(content, 10000);
+ } else if (content.contains("deleteVnfNotification")) {
+ injected = injectDeleteVNFCallback(content, 10000);
+ } else if (content.contains("updateVnfNotification")) {
+ injected = injectUpdateVNFCallback(content, 10000);
+ }
+
+ if (!injected) {
+ String msg = "Failed to inject VNF '" + action + "' callback";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ fail("Interrupted after injection of VNF '" + action + "' callback");
+ }
+ }
+ }
+
+ /**
+ * Waits for the number of running processes with the specified process definition key to equal a particular count.
+ *
+ * @param processKey the process definition key
+ * @param count the desired count
+ * @param timeout the timeout in milliseconds
+ */
+ protected void waitForRunningProcessCount(String processKey, int count, long timeout) {
+ logger.debug("Waiting {}ms for there to be {} {} instances", timeout, count, processKey);
+
+ long now = System.currentTimeMillis() + timeout;
+ long endTime = now + timeout;
+ int last = -1;
+
+ while (now <= endTime) {
+ int actual = runtimeService.createProcessInstanceQuery().processDefinitionKey(processKey).list().size();
+
+ if (actual != last) {
+ logger.debug("There are now {} {} instances", actual, processKey);
+ last = actual;
+ }
+
+ if (actual == count) {
+ return;
+ }
+
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ String msg = "Interrupted waiting for there to be " + count + " " + processKey + " instances";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ now = System.currentTimeMillis();
+ }
+
+ String msg = "Timed out waiting for there to be " + count + " " + processKey + " instances";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ /**
+ * Waits for the specified process variable to be set.
+ *
+ * @param processKey the process definition key
+ * @param variable the variable name
+ * @param timeout the timeout in milliseconds
+ * @return the variable value, or null if it cannot be obtained in the specified time
+ */
+ protected Object getProcessVariable(String processKey, String variable, long timeout) {
+
+ logger.debug("Waiting " + timeout + "ms for " + processKey + "." + variable + " to be set");
+
+ long now = System.currentTimeMillis() + timeout;
+ long endTime = now + timeout;
+
+ ProcessInstance processInstance = null;
+ Object value = null;
+
+ while (value == null) {
+ if (now > endTime) {
+ if (processInstance == null) {
+ logger.debug("Timed out waiting for " + processKey + " to start");
+ } else {
+ logger.debug("Timed out waiting for " + processKey + "[" + processInstance.getId() + "]." + variable
+ + " to be set");
+ }
+
+ return null;
+ }
+
+ ProcessInstanceQuery processInstanceQuery = null;
+ if (processInstance == null) {
+ processInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionKey(processKey);
+ }
+
+ if (processInstanceQuery.count() == 1 || processInstanceQuery.count() == 0) {
+ processInstance = processInstanceQuery.singleResult();
+ } else {
+ // TODO There shouldnt be more than one in the list but seems to be happening, need to figure out why
+ // happening and best way to get correct one from list
+ logger.debug("Process Instance Query returned {} instance. Getting the last instance in the list",
+ processInstanceQuery.count());
+ List<ProcessInstance> processList = processInstanceQuery.list();
+ processInstance = processList.get((processList.size() - 1));
+ }
+
+
+ if (processInstance != null) {
+ value = runtimeService.getVariable(processInstance.getId(), variable);
+ }
+
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ logger.debug("Interrupted waiting for {}.{} to be set", processKey, variable);
+ return null;
+ }
+
+ now = System.currentTimeMillis();
+ }
+
+ logger.debug(processKey + "[" + processInstance.getId() + "]." + variable + "=" + value);
+
+ return value;
+ }
+
+ /**
+ * Injects a single SDNC adapter callback request. The specified callback data may contain the placeholder string
+ * ((REQUEST-ID)) which is replaced with the actual SDNC request ID. Note: this is not the requestId in the original
+ * MSO request.
+ *
+ * @param contentType the HTTP content type for the callback
+ * @param content the content of the callback
+ * @param timeout the timeout in milliseconds
+ * @return true if the callback could be injected, false otherwise
+ */
+ protected boolean injectSDNCRestCallback(String contentType, String content, long timeout) {
+ String sdncRequestId = (String) getProcessVariable("SDNCAdapterRestV1", "SDNCAResponse_CORRELATOR", timeout);
+
+ if (sdncRequestId == null) {
+ sdncRequestId = (String) getProcessVariable("SDNCAdapterRestV2", "SDNCAResponse_CORRELATOR", timeout);
+ }
+
+ if (sdncRequestId == null) {
+ return false;
+ }
+
+ content = content.replace("((REQUEST-ID))", sdncRequestId);
+ // Deprecated usage. All test code should switch to the (( ... )) syntax.
+ content = content.replace("{{REQUEST-ID}}", sdncRequestId);
+
+ logger.debug("Injecting SDNC adapter callback");
+
+ Response response = workflowMessageResource.deliver(contentType, "SDNCAResponse", sdncRequestId, content);
+ logger.debug("Workflow response to SDNC adapter callback: " + response);
+ return true;
+ }
+
+ /**
+ * Injects a single SDNC adapter callback request. The specified callback data may contain the placeholder string
+ * ((REQUEST-ID)) which is replaced with the actual SDNC request ID. Note: this is not the requestId in the original
+ * MSO request.
+ *
+ * @param content the content of the callback
+ * @param respCode the response code (normally 200)
+ * @param respMsg the response message (normally "OK")
+ * @param timeout the timeout in milliseconds
+ * @return true if the callback could be injected, false otherwise
+ */
+ protected boolean injectSDNCCallback(int respCode, String respMsg, String content, long timeout) {
+
+ String sdncRequestId = (String) getProcessVariable("sdncAdapter", "SDNCA_requestId", timeout);
+
+ if (sdncRequestId == null) {
+ return false;
+ }
+
+ content = content.replace("((REQUEST-ID))", sdncRequestId);
+ // Deprecated usage. All test code should switch to the (( ... )) syntax.
+ content = content.replace("{{REQUEST-ID}}", sdncRequestId);
+
+ // TODO this needs to be fixed. It is causing double tags and content
+ // Need to parse content before setting below since content includes not just RequestData or modify callback
+ // files to only contain RequestData contents.
+
+ logger.debug("Injecting SDNC adapter callback");
+ CallbackHeader callbackHeader = new CallbackHeader();
+ callbackHeader.setRequestId(sdncRequestId);
+ callbackHeader.setResponseCode(String.valueOf(respCode));
+ callbackHeader.setResponseMessage(respMsg);
+ SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest();
+ sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader);
+ sdncAdapterCallbackRequest.setRequestData(content);
+ SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest);
+ logger.debug("Workflow response to SDNC adapter callback: " + sdncAdapterResponse);
+
+ return true;
+ }
+
+ /**
+ * Injects a single VNF adapter callback request. The specified callback data may contain the placeholder string
+ * ((MESSAGE-ID)) which is replaced with the actual message ID. Note: this is not the requestId in the original MSO
+ * request.
+ *
+ * @param contentType the HTTP content type for the callback
+ * @param content the content of the callback
+ * @param timeout the timeout in milliseconds
+ * @return true if the callback could be injected, false otherwise
+ */
+ protected boolean injectVnfAdapterRestCallback(String contentType, String content, long timeout) {
+ String messageId = (String) getProcessVariable("vnfAdapterRestV1", "VNFAResponse_CORRELATOR", timeout);
+
+ if (messageId == null) {
+ return false;
+ }
+
+ content = content.replace("((MESSAGE-ID))", messageId);
+ // Deprecated usage. All test code should switch to the (( ... )) syntax.
+ content = content.replace("{{MESSAGE-ID}}", messageId);
+
+ logger.debug("Injecting VNF adapter callback");
+
+ Response response = workflowMessageResource.deliver(contentType, "VNFAResponse", messageId, content);
+ logger.debug("Workflow response to VNF adapter callback: {}", response);
+ return true;
+ }
+
+ /**
+ * Injects a Create VNF adapter callback request. The specified callback data may contain the placeholder string
+ * ((MESSAGE-ID)) which is replaced with the actual message ID. It may also contain the placeholder string
+ * ((REQUEST-ID)) which is replaced request ID of the original MSO request.
+ *
+ * @param content the content of the callback
+ * @param timeout the timeout in milliseconds
+ * @return true if the callback could be injected, false otherwise
+ * @throws JAXBException if the content does not adhere to the schema
+ */
+ protected boolean injectCreateVNFCallback(String content, long timeout) {
+
+ String messageId = (String) getProcessVariable("vnfAdapterCreateV1", "VNFC_messageId", timeout);
+
+ if (messageId == null) {
+ return false;
+ }
+
+ content = content.replace("((MESSAGE-ID))", messageId);
+ // Deprecated usage. All test code should switch to the (( ... )) syntax.
+ content = content.replace("{{MESSAGE-ID}}", messageId);
+
+ if (content.contains("((REQUEST-ID))")) {
+ content = content.replace("((REQUEST-ID))", msoRequestId);
+ // Deprecated usage. All test code should switch to the (( ... )) syntax.
+ content = content.replace("{{REQUEST-ID}}", msoRequestId);
+ }
+
+ logger.debug("Injecting VNF adapter callback");
+
+ // Is it possible to unmarshal this with JAXB? I couldn't.
+
+ CreateVnfNotification createVnfNotification = new CreateVnfNotification();
+ XPathTool xpathTool = new VnfNotifyXPathTool();
+ xpathTool.setXML(content);
+
+ try {
+ String completed = xpathTool.evaluate("/tns:createVnfNotification/tns:completed/text()");
+ createVnfNotification.setCompleted("true".equals(completed));
+
+ String vnfId = xpathTool.evaluate("/tns:createVnfNotification/tns:vnfId/text()");
+ createVnfNotification.setVnfId(vnfId);
+
+ NodeList entries = (NodeList) xpathTool.evaluate("/tns:createVnfNotification/tns:outputs/tns:entry",
+ XPathConstants.NODESET);
+
+ CreateVnfNotificationOutputs outputs = new CreateVnfNotificationOutputs();
+
+ for (int i = 0; i < entries.getLength(); i++) {
+ Node node = entries.item(i);
+
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element entry = (Element) node;
+ String key = entry.getElementsByTagNameNS("*", "key").item(0).getTextContent();
+ String value = entry.getElementsByTagNameNS("*", "value").item(0).getTextContent();
+ outputs.add(key, value);
+ }
+ }
+
+ createVnfNotification.setOutputs(outputs);
+
+ VnfRollback rollback = new VnfRollback();
+
+ String cloudSiteId = xpathTool.evaluate("/tns:createVnfNotification/tns:rollback/tns:cloudSiteId/text()");
+ rollback.setCloudSiteId(cloudSiteId);
+
+ String cloudOwner = xpathTool.evaluate("/tns:createVnfNotification/tns:rollback/tns:cloudOwner/text()");
+ rollback.setCloudOwner(cloudOwner);
+
+ String requestId =
+ xpathTool.evaluate("/tns:createVnfNotification/tns:rollback/tns:msoRequest/tns:requestId/text()");
+ String serviceInstanceId = xpathTool
+ .evaluate("/tns:createVnfNotification/tns:rollback/tns:msoRequest/tns:serviceInstanceId/text()");
+
+ if (requestId != null || serviceInstanceId != null) {
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestId);
+ msoRequest.setServiceInstanceId(serviceInstanceId);
+ rollback.setMsoRequest(msoRequest);
+ }
+
+ String tenantCreated =
+ xpathTool.evaluate("/tns:createVnfNotification/tns:rollback/tns:tenantCreated/text()");
+ rollback.setTenantCreated("true".equals(tenantCreated));
+
+ String tenantId = xpathTool.evaluate("/tns:createVnfNotification/tns:rollback/tns:tenantId/text()");
+ rollback.setTenantId(tenantId);
+
+ String vnfCreated = xpathTool.evaluate("/tns:createVnfNotification/tns:rollback/tns:vnfCreated/text()");
+ rollback.setVnfCreated("true".equals(vnfCreated));
+
+ String rollbackVnfId = xpathTool.evaluate("/tns:createVnfNotification/tns:rollback/tns:vnfId/text()");
+ rollback.setVnfId(rollbackVnfId);
+
+ createVnfNotification.setRollback(rollback);
+
+ } catch (Exception e) {
+ logger.debug("Failed to unmarshal VNF callback content:");
+ logger.debug(content);
+ return false;
+ }
+
+ VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl();
+
+
+ notifyService.createVnfNotification(messageId, createVnfNotification.isCompleted(),
+ createVnfNotification.getException(), createVnfNotification.getErrorMessage(),
+ createVnfNotification.getVnfId(), createVnfNotification.getOutputs(),
+ createVnfNotification.getRollback());
+
+ return true;
}
- /**
- * A test implementation of AsynchronousResponse.
- */
- public class TestAsyncResponse {
- Response response = null;
-
- /**
- * {@inheritDoc}
- */
- public synchronized void setResponse(Response response) {
- this.response = response;
- }
-
- /**
- * Gets the response.
- * @return the response, or null if none has been produced yet
- */
- public synchronized Response getResponse() {
- return response;
- }
- }
-
- /**
- * An object that contains callback data for a "program".
- */
- public class CallbackSet {
- private final Map<String, CallbackData> map = new HashMap<>();
-
- /**
- * Add untyped callback data to the set.
- * @param action the action with which the data is associated
- * @param content the callback data
- */
- public void put(String action, String content) {
- map.put(action, new CallbackData(null, null, content));
- }
-
- /**
- * Add callback data to the set.
- * @param action the action with which the data is associated
- * @param messageType the callback message type
- * @param content the callback data
- */
- public void put(String action, String messageType, String content) {
- map.put(action, new CallbackData(null, messageType, content));
- }
-
- /**
- * Add callback data to the set.
- * @param action the action with which the data is associated
- * @param contentType the callback HTTP content type
- * @param messageType the callback message type
- * @param content the callback data
- */
- public void put(String action, String contentType, String messageType, String content) {
- map.put(action, new CallbackData(contentType, messageType, content));
- }
-
- /**
- * Retrieve callback data from the set.
- * @param action the action with which the data is associated
- * @return the callback data, or null if there is none for the specified operation
- */
- public CallbackData get(String action) {
- return map.get(action);
- }
- }
-
- /**
- * Represents a callback data item.
- */
- public class CallbackData {
- private final String contentType;
- private final String messageType;
- private final String content;
-
- /**
- * Constructor
- * @param contentType the HTTP content type (optional)
- * @param messageType the callback message type (optional)
- * @param content the content
- */
- public CallbackData(String contentType, String messageType, String content) {
- this.contentType = contentType;
- this.messageType = messageType;
- this.content = content;
- }
-
- /**
- * Gets the callback HTTP content type, possibly null.
- */
- public String getContentType() {
- return contentType;
- }
-
- /**
- * Gets the callback message type, possibly null.
- */
- public String getMessageType() {
- return messageType;
- }
-
- /**
- * Gets the callback content.
- */
- public String getContent() {
- return content;
- }
- }
-
- /**
- * A tool for evaluating XPath expressions.
- */
- protected class XPathTool {
- private final DocumentBuilderFactory factory;
- private final SimpleNamespaceContext context = new SimpleNamespaceContext();
- private final XPath xpath = XPathFactory.newInstance().newXPath();
- private String xml = null;
- private Document doc = null;
-
- /**
- * Constructor.
- */
- public XPathTool() {
- factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- xpath.setNamespaceContext(context);
- }
-
- /**
- * Adds a namespace.
- * @param prefix the namespace prefix
- * @param uri the namespace uri
- */
- public synchronized void addNamespace(String prefix, String uri) {
- context.add(prefix, uri);
- }
-
- /**
- * Sets the XML content to be operated on.
- * @param xml the XML content
- */
- public synchronized void setXML(String xml) {
- this.xml = xml;
- this.doc = null;
- }
-
- /**
- * Returns the document object.
- * @return the document object, or null if XML has not been set
- * @throws SAXException
- * @throws IOException
- * @throws ParserConfigurationException
- */
- public synchronized Document getDocument()
- throws ParserConfigurationException, IOException, SAXException {
- if (xml == null) {
- return null;
- }
-
- buildDocument();
- return doc;
- }
-
- /**
- * Evaluates the specified XPath expression and returns a string result.
- * This method throws exceptions on error.
- * @param expression the expression
- * @return the result object
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
- * @throws XPathExpressionException on error
- */
- public synchronized String evaluate(String expression)
- throws ParserConfigurationException, SAXException,
- IOException, XPathExpressionException {
- return (String) evaluate(expression, XPathConstants.STRING);
- }
-
- /**
- * Evaluates the specified XPath expression.
- * This method throws exceptions on error.
- * @param expression the expression
- * @param returnType the return type
- * @return the result object
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
- * @throws XPathExpressionException on error
- */
- public synchronized Object evaluate(String expression, QName returnType)
- throws ParserConfigurationException, SAXException,
- IOException, XPathExpressionException {
-
- buildDocument();
- XPathExpression expr = xpath.compile(expression);
- return expr.evaluate(doc, returnType);
- }
-
- /**
- * Private helper method that builds the document object.
- * Assumes the calling method is synchronized.
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
- */
- private void buildDocument() throws ParserConfigurationException,
- IOException, SAXException {
- if (doc == null) {
- if (xml == null) {
- throw new IOException("XML input is null");
- }
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- InputSource source = new InputSource(new StringReader(xml));
- doc = builder.parse(source);
- }
- }
- }
-
- /**
- * A NamespaceContext class based on a Map.
- */
- private class SimpleNamespaceContext implements NamespaceContext {
- private Map<String, String> prefixMap = new HashMap<>();
- private Map<String, String> uriMap = new HashMap<>();
-
- public synchronized void add(String prefix, String uri) {
- prefixMap.put(prefix, uri);
- uriMap.put(uri, prefix);
- }
-
- @Override
- public synchronized String getNamespaceURI(String prefix) {
- return prefixMap.get(prefix);
- }
-
- @Override
- public Iterator<String> getPrefixes(String uri) {
- List<String> list = new ArrayList<>();
- String prefix = uriMap.get(uri);
- if (prefix != null) {
- list.add(prefix);
- }
- return list.iterator();
- }
-
- @Override
- public String getPrefix(String uri) {
- return uriMap.get(uri);
- }
- }
-
- /**
- * A VnfNotify XPathTool.
- */
- protected class VnfNotifyXPathTool extends XPathTool {
- public VnfNotifyXPathTool() {
- addNamespace("tns", "http://org.onap.so/vnfNotify");
- }
- }
-
- /**
- * Helper class to make it easier to create this type.
- */
- private static class CreateVnfNotificationOutputs
- extends CreateVnfNotification.Outputs {
- public void add(String key, String value) {
- Entry entry = new Entry();
- entry.setKey(key);
- entry.setValue(value);
- getEntry().add(entry);
- }
- }
-
- /**
- * Helper class to make it easier to create this type.
- */
- private static class UpdateVnfNotificationOutputs
- extends UpdateVnfNotification.Outputs {
- public void add(String key, String value) {
- Entry entry = new Entry();
- entry.setKey(key);
- entry.setValue(value);
- getEntry().add(entry);
- }
- }
+ /**
+ * Injects a Delete VNF adapter callback request. The specified callback data may contain the placeholder string
+ * ((MESSAGE-ID)) which is replaced with the actual message ID. It may also contain the placeholder string
+ * ((REQUEST-ID)) which is replaced request ID of the original MSO request.
+ *
+ * @param content the content of the callback
+ * @param timeout the timeout in milliseconds
+ * @return true if the callback could be injected, false otherwise
+ * @throws JAXBException if the content does not adhere to the schema
+ */
+ protected boolean injectDeleteVNFCallback(String content, long timeout) {
+
+ String messageId = (String) getProcessVariable("vnfAdapterDeleteV1", "VNFDEL_uuid", timeout);
+
+ if (messageId == null) {
+ return false;
+ }
+
+ content = content.replace("((MESSAGE-ID))", messageId);
+ // Deprecated usage. All test code should switch to the (( ... )) syntax.
+ content = content.replace("{{MESSAGE-ID}}", messageId);
+
+ logger.debug("Injecting VNF adapter delete callback");
+
+ // Is it possible to unmarshal this with JAXB? I couldn't.
+
+ DeleteVnfNotification deleteVnfNotification = new DeleteVnfNotification();
+ XPathTool xpathTool = new VnfNotifyXPathTool();
+ xpathTool.setXML(content);
+
+ try {
+ String completed = xpathTool.evaluate("/tns:deleteVnfNotification/tns:completed/text()");
+ deleteVnfNotification.setCompleted("true".equals(completed));
+ // if notification failure, set the exception and error message
+ if (deleteVnfNotification.isCompleted() == false) {
+ deleteVnfNotification.setException(MsoExceptionCategory.INTERNAL);
+ deleteVnfNotification
+ .setErrorMessage(xpathTool.evaluate("/tns:deleteVnfNotification/tns:errorMessage/text()"));
+ }
+
+ } catch (Exception e) {
+ logger.debug("Failed to unmarshal VNF Delete callback content:");
+ logger.debug(content);
+ return false;
+ }
+
+ VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl();
+
+
+ notifyService.deleteVnfNotification(messageId, deleteVnfNotification.isCompleted(),
+ deleteVnfNotification.getException(), deleteVnfNotification.getErrorMessage());
+
+ return true;
+ }
+
+ /**
+ * Injects a Update VNF adapter callback request. The specified callback data may contain the placeholder string
+ * ((MESSAGE-ID)) which is replaced with the actual message ID. It may also contain the placeholder string
+ * ((REQUEST-ID)) which is replaced request ID of the original MSO request.
+ *
+ * @param content the content of the callback
+ * @param timeout the timeout in milliseconds
+ * @return true if the callback could be injected, false otherwise
+ * @throws JAXBException if the content does not adhere to the schema
+ */
+ protected boolean injectUpdateVNFCallback(String content, long timeout) {
+
+ String messageId = (String) getProcessVariable("vnfAdapterUpdate", "VNFU_messageId", timeout);
+
+ if (messageId == null) {
+ return false;
+ }
+
+ content = content.replace("((MESSAGE-ID))", messageId);
+ // Deprecated usage. All test code should switch to the (( ... )) syntax.
+ content = content.replace("{{MESSAGE-ID}}", messageId);
+
+ content = content.replace("((REQUEST-ID))", msoRequestId);
+ // Deprecated usage. All test code should switch to the (( ... )) syntax.
+ content = content.replace("{{REQUEST-ID}}", msoRequestId);
+
+ logger.debug("Injecting VNF adapter callback");
+
+ // Is it possible to unmarshal this with JAXB? I couldn't.
+
+ UpdateVnfNotification updateVnfNotification = new UpdateVnfNotification();
+ XPathTool xpathTool = new VnfNotifyXPathTool();
+ xpathTool.setXML(content);
+
+ try {
+ String completed = xpathTool.evaluate("/tns:updateVnfNotification/tns:completed/text()");
+ updateVnfNotification.setCompleted("true".equals(completed));
+
+ NodeList entries = (NodeList) xpathTool.evaluate("/tns:updateVnfNotification/tns:outputs/tns:entry",
+ XPathConstants.NODESET);
+
+ UpdateVnfNotificationOutputs outputs = new UpdateVnfNotificationOutputs();
+
+ for (int i = 0; i < entries.getLength(); i++) {
+ Node node = entries.item(i);
+
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element entry = (Element) node;
+ String key = entry.getElementsByTagNameNS("*", "key").item(0).getTextContent();
+ String value = entry.getElementsByTagNameNS("*", "value").item(0).getTextContent();
+ outputs.add(key, value);
+ }
+ }
+
+ updateVnfNotification.setOutputs(outputs);
+
+ VnfRollback rollback = new VnfRollback();
+
+ String cloudSiteId = xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:cloudSiteId/text()");
+ rollback.setCloudSiteId(cloudSiteId);
+
+ String cloudOwner = xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:cloudOwner/text()");
+ rollback.setCloudOwner(cloudOwner);
+
+ String requestId =
+ xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:msoRequest/tns:requestId/text()");
+ String serviceInstanceId = xpathTool
+ .evaluate("/tns:updateVnfNotification/tns:rollback/tns:msoRequest/tns:serviceInstanceId/text()");
+
+ if (requestId != null || serviceInstanceId != null) {
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId(requestId);
+ msoRequest.setServiceInstanceId(serviceInstanceId);
+ rollback.setMsoRequest(msoRequest);
+ }
+
+ String tenantCreated =
+ xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:tenantCreated/text()");
+ rollback.setTenantCreated("true".equals(tenantCreated));
+
+ String tenantId = xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:tenantId/text()");
+ rollback.setTenantId(tenantId);
+
+ String vnfCreated = xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:vnfCreated/text()");
+ rollback.setVnfCreated("true".equals(vnfCreated));
+
+ String rollbackVnfId = xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:vnfId/text()");
+ rollback.setVnfId(rollbackVnfId);
+
+ updateVnfNotification.setRollback(rollback);
+
+ } catch (Exception e) {
+ logger.debug("Failed to unmarshal VNF callback content:");
+ logger.debug(content);
+ return false;
+ }
+
+ VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl();
+
+
+ notifyService.updateVnfNotification(messageId, updateVnfNotification.isCompleted(),
+ updateVnfNotification.getException(), updateVnfNotification.getErrorMessage(),
+ updateVnfNotification.getOutputs(), updateVnfNotification.getRollback());
+
+ return true;
+ }
+
+ /**
+ * Runs a program to inject workflow messages into the test environment. A program is essentially just a list of
+ * keys that identify event data to be injected, in sequence. An example program:
+ *
+ * <pre>
+ * event1, event2
+ * </pre>
+ *
+ * Errors are handled with junit assertions and will cause the test to fail. NOTE: Each callback must have a
+ * workflow message type associated with it.
+ *
+ * @param callbacks an object containing event data for the program
+ * @param program the program to execute
+ */
+ protected void injectWorkflowMessages(CallbackSet callbacks, String program) {
+
+ String[] cmds = program.replaceAll("\\s+", "").split(",");
+
+ for (String cmd : cmds) {
+ String action = cmd;
+ String modifier = "STD";
+
+ if (cmd.contains(":")) {
+ String[] parts = cmd.split(":");
+ action = parts[0];
+ modifier = parts[1];
+ }
+
+ String messageType = null;
+ String content = null;
+ String contentType = null;
+
+ if ("STD".equals(modifier)) {
+ CallbackData callbackData = callbacks.get(action);
+
+ if (callbackData == null) {
+ String msg = "No '" + action + "' workflow message callback is defined";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ messageType = callbackData.getMessageType();
+
+ if (messageType == null || messageType.trim().equals("")) {
+ String msg = "No workflow message type is defined in the '" + action + "' callback";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ content = callbackData.getContent();
+ contentType = callbackData.getContentType();
+ } else {
+ String msg = "Invalid workflow message program modifier: '" + modifier + "'";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ if (!injectWorkflowMessage(contentType, messageType, content, 10000)) {
+ fail("Failed to inject '" + action + "' workflow message");
+ }
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ fail("Interrupted after injection of '" + action + "' workflow message");
+ }
+ }
+ }
+
+ /**
+ * Injects a workflow message. The specified callback data may contain the placeholder string ((CORRELATOR)) which
+ * is replaced with the actual correlator value.
+ *
+ * @param contentType the HTTP contentType for the message (possibly null)
+ * @param messageType the message type
+ * @param content the message content (possibly null)
+ * @param timeout the timeout in milliseconds
+ * @return true if the message could be injected, false otherwise
+ */
+ protected boolean injectWorkflowMessage(String contentType, String messageType, String content, long timeout) {
+ String correlator = (String) getProcessVariable("ReceiveWorkflowMessage", messageType + "_CORRELATOR", timeout);
+
+ if (correlator == null) {
+ return false;
+ }
+
+ if (content != null) {
+ content = content.replace("((CORRELATOR))", correlator);
+ }
+
+ logger.debug("Injecting " + messageType + " message");
+
+ Response response = workflowMessageResource.deliver(contentType, messageType, correlator, content);
+ logger.debug("Workflow response to {} message: {}", messageType, response);
+ return true;
+ }
+
+ /**
+ * Runs a program to inject sniro workflow messages into the test environment. A program is essentially just a list
+ * of keys that identify event data to be injected, in sequence. For more details, see injectSNIROCallbacks(String
+ * contentType, String messageType, String content, long timeout)
+ *
+ * Errors are handled with junit assertions and will cause the test to fail. NOTE: Each callback must have a
+ * workflow message type associated with it.
+ *
+ * @param callbacks an object containing event data for the program
+ * @param program the program to execute
+ */
+ protected void injectSNIROCallbacks(CallbackSet callbacks, String program) {
+
+ String[] cmds = program.replaceAll("\\s+", "").split(",");
+
+ for (String cmd : cmds) {
+ String action = cmd;
+ String modifier = "STD";
+
+ if (cmd.contains(":")) {
+ String[] parts = cmd.split(":");
+ action = parts[0];
+ modifier = parts[1];
+ }
+
+ String messageType = null;
+ String content = null;
+ String contentType = null;
+
+ if ("STD".equals(modifier)) {
+ CallbackData callbackData = callbacks.get(action);
+
+ if (callbackData == null) {
+ String msg = "No '" + action + "' workflow message callback is defined";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ messageType = callbackData.getMessageType();
+
+ if (messageType == null || messageType.trim().equals("")) {
+ String msg = "No workflow message type is defined in the '" + action + "' callback";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ content = callbackData.getContent();
+ contentType = callbackData.getContentType();
+ } else {
+ String msg = "Invalid workflow message program modifier: '" + modifier + "'";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ if (!injectSNIROCallbacks(contentType, messageType, content, 10000)) {
+ fail("Failed to inject '" + action + "' workflow message");
+ }
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ fail("Interrupted after injection of '" + action + "' workflow message");
+ }
+ }
+ }
+
+ /**
+ * Injects a sniro workflow message. The specified callback response may contain the placeholder strings
+ * ((CORRELATOR)) and ((SERVICE_RESOURCE_ID)) The ((CORRELATOR)) is replaced with the actual correlator value from
+ * the request. The ((SERVICE_RESOURCE_ID)) is replaced with the actual serviceResourceId value from the sniro
+ * request. Currently this only works with sniro request that contain only 1 resource.
+ *
+ * @param contentType the HTTP contentType for the message (possibly null)
+ * @param messageType the message type
+ * @param content the message content (possibly null)
+ * @param timeout the timeout in milliseconds
+ * @return true if the message could be injected, false otherwise
+ */
+ protected boolean injectSNIROCallbacks(String contentType, String messageType, String content, long timeout) {
+ String correlator = (String) getProcessVariable("ReceiveWorkflowMessage", messageType + "_CORRELATOR", timeout);
+
+ if (correlator == null) {
+ return false;
+ }
+ if (content != null) {
+ content = content.replace("((CORRELATOR))", correlator);
+ if (messageType.equalsIgnoreCase("SNIROResponse")) {
+ ServiceDecomposition decomp =
+ (ServiceDecomposition) getProcessVariable("Homing", "serviceDecomposition", timeout);
+ List<Resource> resourceList = decomp.getServiceResources();
+ if (resourceList.size() == 1) {
+ String resourceId = "";
+ for (Resource resource : resourceList) {
+ resourceId = resource.getResourceId();
+ }
+ String homingList = getJsonValue(content, "solutionInfo.placementInfo");
+ JSONArray placementArr = null;
+ try {
+ placementArr = new JSONArray(homingList);
+ } catch (Exception e) {
+ return false;
+ }
+ if (placementArr.length() == 1) {
+ content = content.replace("((SERVICE_RESOURCE_ID))", resourceId);
+ }
+ String licenseInfoList = getJsonValue(content, "solutionInfo.licenseInfo");
+ JSONArray licenseArr = null;
+ try {
+ licenseArr = new JSONArray(licenseInfoList);
+ } catch (Exception e) {
+ return false;
+ }
+ if (licenseArr.length() == 1) {
+ content = content.replace("((SERVICE_RESOURCE_ID))", resourceId);
+ }
+ } else {
+ try {
+ String homingList = getJsonValue(content, "solutionInfo.placementInfo");
+ String licenseInfoList = getJsonValue(content, "solutionInfo.licenseInfo");
+ JSONArray placementArr = new JSONArray(homingList);
+ JSONArray licenseArr = new JSONArray(licenseInfoList);
+ for (Resource resource : resourceList) {
+ String resourceModuleName = resource.getModelInfo().getModelInstanceName();
+ String resourceId = resource.getResourceId();
+
+ for (int i = 0; i < placementArr.length(); i++) {
+ JSONObject placementObj = placementArr.getJSONObject(i);
+ String placementModuleName = placementObj.getString("resourceModuleName");
+ if (placementModuleName.equalsIgnoreCase(resourceModuleName)) {
+ String placementString = placementObj.toString();
+ placementString = placementString.replace("((SERVICE_RESOURCE_ID))", resourceId);
+ JSONObject newPlacementObj = new JSONObject(placementString);
+ placementArr.put(i, newPlacementObj);
+ }
+ }
+
+ for (int i = 0; i < licenseArr.length(); i++) {
+ JSONObject licenseObj = licenseArr.getJSONObject(i);
+ String licenseModuleName = licenseObj.getString("resourceModuleName");
+ if (licenseModuleName.equalsIgnoreCase(resourceModuleName)) {
+ String licenseString = licenseObj.toString();
+ licenseString = licenseString.replace("((SERVICE_RESOURCE_ID))", resourceId);
+ JSONObject newLicenseObj = new JSONObject(licenseString);
+ licenseArr.put(i, newLicenseObj);
+ }
+ }
+ }
+ String newPlacementInfos = placementArr.toString();
+ String newLicenseInfos = licenseArr.toString();
+ content = updJsonValue(content, "solutionInfo.placementInfo", newPlacementInfos);
+ content = updJsonValue(content, "solutionInfo.licenseInfo", newLicenseInfos);
+ } catch (Exception e) {
+ return false;
+ }
+
+ }
+ }
+ }
+ logger.debug("Injecting " + messageType + " message");
+
+ Response response = workflowMessageResource.deliver(contentType, messageType, correlator, content);
+ logger.debug("Workflow response to {} message: {}", messageType, response);
+ return true;
+ }
+
+
+ /**
+ * Wait for the process to end.
+ *
+ * @param businessKey the process business key
+ * @param timeout the amount of time to wait, in milliseconds
+ */
+ protected void waitForProcessEnd(String businessKey, long timeout) {
+ logger.debug("Waiting {}ms for process with business key {} to end", timeout, businessKey);
+
+ long now = System.currentTimeMillis() + timeout;
+ long endTime = now + timeout;
+
+ while (now <= endTime) {
+ if (isProcessEnded(businessKey)) {
+ logger.debug("Process with business key {} has ended", businessKey);
+ return;
+ }
+
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ String msg = "Interrupted waiting for process with business key " + businessKey + " to end";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ now = System.currentTimeMillis();
+ }
+
+ String msg = "Process with business key " + businessKey + " did not end within " + timeout + "ms";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ /**
+ * Wait for the process to end. Must be used when multiple process instances exist with this same business key such
+ * as when its passed to subflows or shared across multiple processes.
+ *
+ * @param businessKey the process business key
+ * @param processName the process definition name
+ * @param timeout the amount of time to wait, in milliseconds
+ * @author cb645j
+ */
+ protected void waitForProcessEnd(String businessKey, String processName, long timeout) {
+ logger.debug("Waiting {}ms for process with business key {} to end", timeout, businessKey);
+
+ long now = System.currentTimeMillis() + timeout;
+ long endTime = now + timeout;
+
+ while (now <= endTime) {
+ if (isProcessEnded(businessKey, processName)) {
+ logger.debug("Process with business key {} has ended", businessKey);
+ return;
+ }
+
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ String msg = "Interrupted waiting for process with business key " + businessKey + " to end";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ now = System.currentTimeMillis();
+ }
+
+ String msg = "Process with business key " + businessKey + " did not end within " + timeout + "ms";
+ logger.debug(msg);
+ fail(msg);
+ }
+
+ /**
+ * Verifies that the specified historic process variable has the specified value. If the variable does not have the
+ * specified value, the test is failed.
+ *
+ * @param businessKey the process business key
+ * @param variable the variable name
+ * @param value the expected variable value
+ */
+ protected void checkVariable(String businessKey, String variable, Object value) {
+ if (!isProcessEnded(businessKey)) {
+ fail("Cannot get historic variable " + variable + " because process with business key " + businessKey
+ + " has not ended");
+ }
+
+ Object variableValue = getVariableFromHistory(businessKey, variable);
+ assertEquals(value, variableValue);
+ }
+
+ /**
+ * Checks to see if the specified process is ended.
+ *
+ * @param businessKey the process business Key
+ * @return true if the process is ended
+ */
+ protected boolean isProcessEnded(String businessKey) {
+ HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery()
+ .processInstanceBusinessKey(businessKey).singleResult();
+ return processInstance != null && processInstance.getEndTime() != null;
+ }
+
+ /**
+ * Checks to see if the specified process is ended.
+ *
+ * @param processInstanceId the process Instance Id
+ * @return true if the process is ended
+ */
+ protected boolean isProcessEndedByProcessInstanceId(String processInstanceId) {
+ HistoricProcessInstance processInstance =
+ historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+ return processInstance != null && processInstance.getEndTime() != null;
+ }
+
+ /**
+ * Checks to see if the specified process is ended.
+ *
+ * @author cb645j
+ */
+ // TODO combine into 1
+ private boolean isProcessEnded(String businessKey, String processName) {
+ HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery()
+ .processInstanceBusinessKey(businessKey).processDefinitionName(processName).singleResult();
+ return processInstance != null && processInstance.getEndTime() != null;
+ }
+
+ /**
+ * Gets a variable value from a historical process instance. The business key must be unique.
+ *
+ * @param businessKey the process business key
+ * @param variableName the variable name
+ * @return the variable value or null if the variable does not exist
+ */
+ protected Object getVariableFromHistory(String businessKey, String variableName) {
+ try {
+ HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery()
+ .processInstanceBusinessKey(businessKey).singleResult();
+
+ if (processInstance == null) {
+ return null;
+ }
+
+ HistoricVariableInstance v = historyService.createHistoricVariableInstanceQuery()
+ .processInstanceId(processInstance.getId()).variableName(variableName).singleResult();
+ return v == null ? null : v.getValue();
+ } catch (Exception e) {
+ logger.debug("Error retrieving variable {} from historical process with business key {}: ", variableName,
+ businessKey, e);
+ return null;
+ }
+ }
+
+ /**
+ * Gets a variable value from a process instance based on businessKey and process name. Must be used when multiple
+ * instances exist with the same business key such as when business key is passed to subflows or shared across
+ * multiple processes. This method can obtain variables from mainflows and from subflows.
+ *
+ * @param businessKey the process business key
+ * @param processName the process definition name
+ * @param variableName the variable name
+ * @return the variable value or null if the variable does not exist
+ * @author cb645j
+ */
+ protected Object getVariableFromHistory(String businessKey, String processName, String variableName) {
+ try {
+ HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery()
+ .processInstanceBusinessKey(businessKey).processDefinitionName(processName).singleResult();
+
+ if (processInstance == null) {
+ return null;
+ }
+ HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery()
+ .processInstanceId(processInstance.getId()).variableName(variableName).singleResult();
+
+ return variable == null ? null : variable.getValue();
+ } catch (ProcessEngineException e) {
+ logger.debug(
+ "Multiple proccess instances exist with process name {} and business key {}. Must pass instance "
+ + "index as a parameter.",
+ processName, businessKey);
+ return null;
+ } catch (Exception e) {
+ logger.debug("Error retrieving variable {} from historical process for process {} with business key {}: ",
+ variableName, processName, businessKey, e);
+ return null;
+ }
+ }
+
+ /**
+ * Gets the value of a process variable from x instance of y process. Must be used when multiple instances exist
+ * with the same business key AND process name. This method shall be used primarily for obtaining subflow variables
+ * when the business key is passed to the subflow AND the subflow is called multiple times in a given flow.
+ *
+ * @param businessKey the process business key
+ * @param processName the name of the subflow that contains the variable
+ * @param variableName the variable name
+ * @param processInstanceIndex the instance in which the subprocess was called
+ * @return the variable value or null if the variable does not exist
+ * @author cb645j
+ */
+ protected Object getVariableFromHistory(String businessKey, int subflowInstanceIndex, String processName,
+ String variableName) {
+ try {
+ List<HistoricProcessInstance> processInstanceList = historyService.createHistoricProcessInstanceQuery()
+ .processInstanceBusinessKey(businessKey).processDefinitionName(processName).list();
+
+ if (processInstanceList == null) {
+ return null;
+ }
+ processInstanceList.sort((m1, m2) -> m1.getStartTime().compareTo(m2.getStartTime()));
+
+ HistoricProcessInstance processInstance = processInstanceList.get(subflowInstanceIndex);
+ HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery()
+ .processInstanceId(processInstance.getId()).variableName(variableName).singleResult();
+
+ return variable == null ? null : variable.getValue();
+ } catch (Exception e) {
+ logger.debug("Error retrieving variable {} from historical process for process {} with business key {}: ",
+ variableName, processName, businessKey, e);
+ return null;
+ }
+ }
+
+
+ /**
+ * Gets the value of a subflow variable from the specified subflow's historical process instance.
+ *
+ * DEPRECATED - Use method getVariableFromHistory(businessKey, processName, variableName) instead
+ *
+ * @param subflowName - the name of the subflow that contains the variable
+ * @param variableName the variable name
+ *
+ * @return the variable value, or null if the variable could not be obtained
+ *
+ */
+ @Deprecated
+ protected Object getVariableFromSubflowHistory(String subflowName, String variableName) {
+ try {
+ List<HistoricProcessInstance> processInstanceList =
+ historyService.createHistoricProcessInstanceQuery().processDefinitionName(subflowName).list();
+
+ if (processInstanceList == null) {
+ return null;
+ }
+
+ processInstanceList.sort((m1, m2) -> m1.getStartTime().compareTo(m2.getStartTime()));
+
+ HistoricProcessInstance processInstance = processInstanceList.get(0);
+
+ HistoricVariableInstance v = historyService.createHistoricVariableInstanceQuery()
+ .processInstanceId(processInstance.getId()).variableName(variableName).singleResult();
+ return v == null ? null : v.getValue();
+ } catch (Exception e) {
+ logger.debug("Error retrieving variable {} from sub flow: {}, Exception is: ", variableName, subflowName,
+ e);
+ return null;
+ }
+ }
+
+ /**
+ * Gets the value of a subflow variable from the subflow's historical process x instance.
+ *
+ * DEPRECATED: Use method getVariableFromHistory(businessKey, processInstanceIndex, processName, variableName)
+ * instead
+ *
+ * @param subflowName - the name of the subflow that contains the variable
+ * @param variableName the variable name
+ * @param subflowInstanceIndex - the instance of the subflow (use when same subflow is called more than once from
+ * mainflow)
+ *
+ * @return the variable value, or null if the variable could not be obtained
+ */
+ @Deprecated
+ protected Object getVariableFromSubflowHistory(int subflowInstanceIndex, String subflowName, String variableName) {
+ try {
+ List<HistoricProcessInstance> processInstanceList =
+ historyService.createHistoricProcessInstanceQuery().processDefinitionName(subflowName).list();
+
+ if (processInstanceList == null) {
+ return null;
+ }
+
+ processInstanceList.sort((m1, m2) -> m1.getStartTime().compareTo(m2.getStartTime()));
+
+ HistoricProcessInstance processInstance = processInstanceList.get(subflowInstanceIndex);
+
+ HistoricVariableInstance v = historyService.createHistoricVariableInstanceQuery()
+ .processInstanceId(processInstance.getId()).variableName(variableName).singleResult();
+ return v == null ? null : v.getValue();
+ } catch (Exception e) {
+ logger.debug("Error retrieving variable {} from {} instance index of sub flow: {}, Exception is: ",
+ variableName, subflowInstanceIndex, subflowName, e);
+ return null;
+ }
+ }
+
+ /**
+ * Extracts text from an XML element. This method is not namespace aware (namespaces are ignored). The first
+ * matching element is selected.
+ *
+ * @param xml the XML document or fragment
+ * @param tag the desired element, e.g. "<name>"
+ * @return the element text, or null if the element was not found
+ */
+ protected String getXMLTextElement(String xml, String tag) {
+ xml = removeXMLNamespaces(xml);
+
+ if (!tag.startsWith("<")) {
+ tag = "<" + tag + ">";
+ }
+
+ int start = xml.indexOf(tag);
+
+ if (start == -1) {
+ return null;
+ }
+
+ int end = xml.indexOf('<', start + tag.length());
+
+ if (end == -1) {
+ return null;
+ }
+
+ return xml.substring(start + tag.length(), end);
+ }
+
+ /**
+ * Removes namespace definitions and prefixes from XML, if any.
+ */
+ private String removeXMLNamespaces(String xml) {
+ // remove xmlns declaration
+ xml = xml.replaceAll("xmlns.*?(\"|\').*?(\"|\')", "");
+
+ // remove opening tag prefix
+ xml = xml.replaceAll("(<)(\\w+:)(.*?>)", "$1$3");
+
+ // remove closing tags prefix
+ xml = xml.replaceAll("(</)(\\w+:)(.*?>)", "$1$3");
+
+ // remove extra spaces left when xmlns declarations are removed
+ xml = xml.replaceAll("\\s+>", ">");
+
+ return xml;
+ }
+
+ /**
+ * Asserts that two XML documents are semantically equivalent. Differences in whitespace or in namespace usage do
+ * not affect the comparison.
+ *
+ * @param expected the expected XML
+ * @param actual the XML to test
+ * @throws SAXException
+ * @throws IOException
+ */
+ public static void assertXMLEquals(String expected, String actual) throws SAXException, IOException {
+ XMLUnit.setIgnoreWhitespace(true);
+ XMLUnit.setIgnoreAttributeOrder(true);
+ DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expected, actual));
+ List<?> allDifferences = diff.getAllDifferences();
+ assertEquals("Differences found: " + diff.toString(), 0, allDifferences.size());
+ }
+
+ /**
+ * A test implementation of AsynchronousResponse.
+ */
+ public class TestAsyncResponse {
+ Response response = null;
+
+ /**
+ * {@inheritDoc}
+ */
+ public synchronized void setResponse(Response response) {
+ this.response = response;
+ }
+
+ /**
+ * Gets the response.
+ *
+ * @return the response, or null if none has been produced yet
+ */
+ public synchronized Response getResponse() {
+ return response;
+ }
+ }
+
+ /**
+ * An object that contains callback data for a "program".
+ */
+ public class CallbackSet {
+ private final Map<String, CallbackData> map = new HashMap<>();
+
+ /**
+ * Add untyped callback data to the set.
+ *
+ * @param action the action with which the data is associated
+ * @param content the callback data
+ */
+ public void put(String action, String content) {
+ map.put(action, new CallbackData(null, null, content));
+ }
+
+ /**
+ * Add callback data to the set.
+ *
+ * @param action the action with which the data is associated
+ * @param messageType the callback message type
+ * @param content the callback data
+ */
+ public void put(String action, String messageType, String content) {
+ map.put(action, new CallbackData(null, messageType, content));
+ }
+
+ /**
+ * Add callback data to the set.
+ *
+ * @param action the action with which the data is associated
+ * @param contentType the callback HTTP content type
+ * @param messageType the callback message type
+ * @param content the callback data
+ */
+ public void put(String action, String contentType, String messageType, String content) {
+ map.put(action, new CallbackData(contentType, messageType, content));
+ }
+
+ /**
+ * Retrieve callback data from the set.
+ *
+ * @param action the action with which the data is associated
+ * @return the callback data, or null if there is none for the specified operation
+ */
+ public CallbackData get(String action) {
+ return map.get(action);
+ }
+ }
+
+ /**
+ * Represents a callback data item.
+ */
+ public class CallbackData {
+ private final String contentType;
+ private final String messageType;
+ private final String content;
+
+ /**
+ * Constructor
+ *
+ * @param contentType the HTTP content type (optional)
+ * @param messageType the callback message type (optional)
+ * @param content the content
+ */
+ public CallbackData(String contentType, String messageType, String content) {
+ this.contentType = contentType;
+ this.messageType = messageType;
+ this.content = content;
+ }
+
+ /**
+ * Gets the callback HTTP content type, possibly null.
+ */
+ public String getContentType() {
+ return contentType;
+ }
+
+ /**
+ * Gets the callback message type, possibly null.
+ */
+ public String getMessageType() {
+ return messageType;
+ }
+
+ /**
+ * Gets the callback content.
+ */
+ public String getContent() {
+ return content;
+ }
+ }
+
+ /**
+ * A tool for evaluating XPath expressions.
+ */
+ protected class XPathTool {
+ private final DocumentBuilderFactory factory;
+ private final SimpleNamespaceContext context = new SimpleNamespaceContext();
+ private final XPath xpath = XPathFactory.newInstance().newXPath();
+ private String xml = null;
+ private Document doc = null;
+
+ /**
+ * Constructor.
+ */
+ public XPathTool() {
+ factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ xpath.setNamespaceContext(context);
+ }
+
+ /**
+ * Adds a namespace.
+ *
+ * @param prefix the namespace prefix
+ * @param uri the namespace uri
+ */
+ public synchronized void addNamespace(String prefix, String uri) {
+ context.add(prefix, uri);
+ }
+
+ /**
+ * Sets the XML content to be operated on.
+ *
+ * @param xml the XML content
+ */
+ public synchronized void setXML(String xml) {
+ this.xml = xml;
+ this.doc = null;
+ }
+
+ /**
+ * Returns the document object.
+ *
+ * @return the document object, or null if XML has not been set
+ * @throws SAXException
+ * @throws IOException
+ * @throws ParserConfigurationException
+ */
+ public synchronized Document getDocument() throws ParserConfigurationException, IOException, SAXException {
+ if (xml == null) {
+ return null;
+ }
+
+ buildDocument();
+ return doc;
+ }
+
+ /**
+ * Evaluates the specified XPath expression and returns a string result. This method throws exceptions on error.
+ *
+ * @param expression the expression
+ * @return the result object
+ * @throws ParserConfigurationException
+ * @throws IOException
+ * @throws SAXException
+ * @throws XPathExpressionException on error
+ */
+ public synchronized String evaluate(String expression)
+ throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
+ return (String) evaluate(expression, XPathConstants.STRING);
+ }
+
+ /**
+ * Evaluates the specified XPath expression. This method throws exceptions on error.
+ *
+ * @param expression the expression
+ * @param returnType the return type
+ * @return the result object
+ * @throws ParserConfigurationException
+ * @throws IOException
+ * @throws SAXException
+ * @throws XPathExpressionException on error
+ */
+ public synchronized Object evaluate(String expression, QName returnType)
+ throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
+
+ buildDocument();
+ XPathExpression expr = xpath.compile(expression);
+ return expr.evaluate(doc, returnType);
+ }
+
+ /**
+ * Private helper method that builds the document object. Assumes the calling method is synchronized.
+ *
+ * @throws ParserConfigurationException
+ * @throws IOException
+ * @throws SAXException
+ */
+ private void buildDocument() throws ParserConfigurationException, IOException, SAXException {
+ if (doc == null) {
+ if (xml == null) {
+ throw new IOException("XML input is null");
+ }
+
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ InputSource source = new InputSource(new StringReader(xml));
+ doc = builder.parse(source);
+ }
+ }
+ }
+
+ /**
+ * A NamespaceContext class based on a Map.
+ */
+ private class SimpleNamespaceContext implements NamespaceContext {
+ private Map<String, String> prefixMap = new HashMap<>();
+ private Map<String, String> uriMap = new HashMap<>();
+
+ public synchronized void add(String prefix, String uri) {
+ prefixMap.put(prefix, uri);
+ uriMap.put(uri, prefix);
+ }
+
+ @Override
+ public synchronized String getNamespaceURI(String prefix) {
+ return prefixMap.get(prefix);
+ }
+
+ @Override
+ public Iterator<String> getPrefixes(String uri) {
+ List<String> list = new ArrayList<>();
+ String prefix = uriMap.get(uri);
+ if (prefix != null) {
+ list.add(prefix);
+ }
+ return list.iterator();
+ }
+
+ @Override
+ public String getPrefix(String uri) {
+ return uriMap.get(uri);
+ }
+ }
+
+ /**
+ * A VnfNotify XPathTool.
+ */
+ protected class VnfNotifyXPathTool extends XPathTool {
+ public VnfNotifyXPathTool() {
+ addNamespace("tns", "http://org.onap.so/vnfNotify");
+ }
+ }
+
+ /**
+ * Helper class to make it easier to create this type.
+ */
+ private static class CreateVnfNotificationOutputs extends CreateVnfNotification.Outputs {
+ public void add(String key, String value) {
+ Entry entry = new Entry();
+ entry.setKey(key);
+ entry.setValue(value);
+ getEntry().add(entry);
+ }
+ }
+
+ /**
+ * Helper class to make it easier to create this type.
+ */
+ private static class UpdateVnfNotificationOutputs extends UpdateVnfNotification.Outputs {
+ public void add(String key, String value) {
+ Entry entry = new Entry();
+ entry.setKey(key);
+ entry.setValue(value);
+ getEntry().add(entry);
+ }
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTestTransformer.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTestTransformer.java
index dbad35a6a4..794e772dcd 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTestTransformer.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTestTransformer.java
@@ -26,16 +26,15 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Allows a subclass of WorkflowTest to specify one or more WireMock
- * response transformers. A transformer must be declared as a public
- * static field in the subclass. For example:
+ * Allows a subclass of WorkflowTest to specify one or more WireMock response transformers. A transformer must be
+ * declared as a public static field in the subclass. For example:
+ *
* <pre>
- * @WorkflowTestTransformer
- * public static final ResponseTransformer sdncAdapterMockTransformer =
- * new SDNCAdapterMockTransformer();
+ * &#64;WorkflowTestTransformer
+ * public static final ResponseTransformer sdncAdapterMockTransformer = new SDNCAdapterMockTransformer();
* </pre>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface WorkflowTestTransformer {
-} \ No newline at end of file
+}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/adapter/sdnc/ObjectFactoryTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/adapter/sdnc/ObjectFactoryTest.java
index bdc48392af..d95a5883c8 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/adapter/sdnc/ObjectFactoryTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/adapter/sdnc/ObjectFactoryTest.java
@@ -20,7 +20,6 @@
package org.onap.so.bpmn.common.adapter.sdnc;
import static org.junit.Assert.assertEquals;
-
import org.junit.Before;
import org.junit.Test;
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerServiceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerServiceTest.java
index 051107bb13..c58af6b02f 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerServiceTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerServiceTest.java
@@ -23,7 +23,6 @@ package org.onap.so.bpmn.common.workflow.service;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java
index ff5e18c210..62b582ea8e 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java
@@ -16,20 +16,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common.workflow.service;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import javax.ws.rs.core.Response;
-
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
import org.junit.Test;
@@ -38,41 +35,41 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowResponse;
public class WorkflowAsyncResourceExceptionHandlingTest {
- @Test
- @Deployment(resources = { "testAsyncResource.bpmn" })
- public void asyncRequestSuccess() throws InterruptedException {
- VariableMapImpl variableMap = new VariableMapImpl();
+ @Test
+ @Deployment(resources = {"testAsyncResource.bpmn"})
+ public void asyncRequestSuccess() throws InterruptedException {
+ VariableMapImpl variableMap = new VariableMapImpl();
- Map<String, Object> variableValueType = new HashMap<>();
+ Map<String, Object> variableValueType = new HashMap<>();
- Map<String, Object> requestMsg = new HashMap<>();
- requestMsg.put("value", "");
- requestMsg.put("type", "String");
+ Map<String, Object> requestMsg = new HashMap<>();
+ requestMsg.put("value", "");
+ requestMsg.put("type", "String");
- Map<String, Object> msorequestId = new HashMap<>();
- msorequestId.put("type", "String");
- msorequestId.put("value",UUID.randomUUID().toString());
+ Map<String, Object> msorequestId = new HashMap<>();
+ msorequestId.put("type", "String");
+ msorequestId.put("value", UUID.randomUUID().toString());
- Map<String, Object> timeout = new HashMap<>();
- timeout.put("type", "String");
- timeout.put("value","5");
+ Map<String, Object> timeout = new HashMap<>();
+ timeout.put("type", "String");
+ timeout.put("value", "5");
- variableValueType.put("testAsyncRequestMsg", requestMsg);
- variableValueType.put("mso-request-id", msorequestId);
- variableValueType.put("mso-service-request-timeout", timeout);
+ variableValueType.put("testAsyncRequestMsg", requestMsg);
+ variableValueType.put("mso-request-id", msorequestId);
+ variableValueType.put("mso-service-request-timeout", timeout);
- variableMap.put("variables", variableValueType);
- WorkflowAsyncResource workflowAsyncResource = new WorkflowAsyncResource();
- workflowAsyncResource.setProcessor(new WorkflowProcessor());
- Response res = workflowAsyncResource.startProcessInstanceByKey("randomKey", variableMap);
- assertEquals(500,res.getStatus());
- WorkflowResponse workflowResponse = (WorkflowResponse)res.getEntity();
- assertNotNull(workflowResponse);
- assertEquals(500, workflowResponse.getMessageCode());
- assertTrue(workflowResponse.getResponse().startsWith("Error occurred while executing the process:"));
- assertEquals("Fail", workflowResponse.getMessage());
+ variableMap.put("variables", variableValueType);
+ WorkflowAsyncResource workflowAsyncResource = new WorkflowAsyncResource();
+ workflowAsyncResource.setProcessor(new WorkflowProcessor());
+ Response res = workflowAsyncResource.startProcessInstanceByKey("randomKey", variableMap);
+ assertEquals(500, res.getStatus());
+ WorkflowResponse workflowResponse = (WorkflowResponse) res.getEntity();
+ assertNotNull(workflowResponse);
+ assertEquals(500, workflowResponse.getMessageCode());
+ assertTrue(workflowResponse.getResponse().startsWith("Error occurred while executing the process:"));
+ assertEquals("Fail", workflowResponse.getMessage());
- }
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/FlakyTests.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/FlakyTests.java
index 5b5e17c5fc..1c3583d452 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/FlakyTests.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/FlakyTests.java
@@ -21,5 +21,5 @@
package org.onap.so.bpmn.infrastructure;
public interface FlakyTests {
- /* category marker */
+ /* category marker */
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java
index 5cc0281407..3734510eed 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java
@@ -25,10 +25,8 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate;
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
-
import java.util.HashMap;
import java.util.Map;
-
import java.util.UUID;
import org.assertj.core.api.Assertions;
import org.assertj.core.data.MapEntry;
@@ -64,25 +62,17 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
// given
variables.put(PNF_CORRELATION_ID, PnfManagementTestImpl.ID_WITH_ENTRY);
// when
- ProcessInstance instance = runtimeService
- .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
+ ProcessInstance instance =
+ runtimeService.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
dmaapClientTestImpl.sendMessage();
// then
- assertThat(instance).isEnded().hasPassedInOrder(
- "CreateAndActivatePnf_StartEvent",
- "CheckInputs",
- "CheckAiiForPnfCorrelationId",
- "DoesAaiContainInfoAboutPnf",
- "AaiEntryExists",
- "InformDmaapClient",
- "WaitForDmaapPnfReadyNotification",
- "CreateRelationId",
- "AaiEntryUpdated"
- );
- Assertions.assertThat(pnfManagementTest.getServiceAndPnfRelationMap()).
- containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID, PnfManagementTestImpl.ID_WITH_ENTRY));
+ assertThat(instance).isEnded().hasPassedInOrder("CreateAndActivatePnf_StartEvent", "CheckInputs",
+ "CheckAiiForPnfCorrelationId", "DoesAaiContainInfoAboutPnf", "AaiEntryExists", "InformDmaapClient",
+ "WaitForDmaapPnfReadyNotification", "CreateRelationId", "AaiEntryUpdated");
+ Assertions.assertThat(pnfManagementTest.getServiceAndPnfRelationMap())
+ .containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID, PnfManagementTestImpl.ID_WITH_ENTRY));
}
@Test
@@ -90,26 +80,17 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
// given
variables.put(PNF_CORRELATION_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY);
// when
- ProcessInstance instance = runtimeService
- .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
+ ProcessInstance instance =
+ runtimeService.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
dmaapClientTestImpl.sendMessage();
// then
- assertThat(instance).isEnded().hasPassedInOrder(
- "CreateAndActivatePnf_StartEvent",
- "CheckInputs",
- "CheckAiiForPnfCorrelationId",
- "DoesAaiContainInfoAboutPnf",
- "CreatePnfEntryInAai",
- "AaiEntryExists",
- "InformDmaapClient",
- "WaitForDmaapPnfReadyNotification",
- "CreateRelationId",
- "AaiEntryUpdated"
- );
+ assertThat(instance).isEnded().hasPassedInOrder("CreateAndActivatePnf_StartEvent", "CheckInputs",
+ "CheckAiiForPnfCorrelationId", "DoesAaiContainInfoAboutPnf", "CreatePnfEntryInAai", "AaiEntryExists",
+ "InformDmaapClient", "WaitForDmaapPnfReadyNotification", "CreateRelationId", "AaiEntryUpdated");
Assertions.assertThat(pnfManagementTest.getCreated()).containsOnlyKeys(PnfManagementTestImpl.ID_WITHOUT_ENTRY);
- Assertions.assertThat(pnfManagementTest.getServiceAndPnfRelationMap()).
- containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY));
+ Assertions.assertThat(pnfManagementTest.getServiceAndPnfRelationMap())
+ .containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY));
}
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
index 6a5f9fac74..e7ff69ab3b 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
import java.util.Objects;
-
import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/AbstractTestBase.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/AbstractTestBase.java
index 8c31a021ae..65b1962048 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/AbstractTestBase.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/AbstractTestBase.java
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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
+ * 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.
+ * 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=========================================================
*/
@@ -22,26 +17,25 @@ package org.onap.so.bpmn.vcpe;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.bpmn.infrastructure.FlakyTests;
-
import groovy.lang.Category;
@Category(FlakyTests.class)
public class AbstractTestBase extends BaseIntegrationTest {
-
-
- public static final String CUST = "SDN-ETHERNET-INTERNET";
- public static final String SVC = "123456789";
- public static final String INST = "MIS%252F1604%252F0026%252FSW_INTERNET";
- public static final String PARENT_INST = "MIS%252F1604%252F0027%252FSW_INTERNET";
- public static final String ARID = "arId-1";
- public static final String ARVERS = "1490627351232";
-
- public static final String DEC_INST = "MIS%2F1604%2F0026%2FSW_INTERNET";
- public static final String DEC_PARENT_INST = "MIS%2F1604%2F0027%2FSW_INTERNET";
-
- public static final String VAR_SUCCESS_IND = "SuccessIndicator";
- public static final String VAR_WFEX = "SavedWorkflowException1";
- public static final String VAR_RESP_CODE = "CMSO_ResponseCode";
- public static final String VAR_COMP_REQ = "CompleteMsoProcessRequest";
+
+
+ public static final String CUST = "SDN-ETHERNET-INTERNET";
+ public static final String SVC = "123456789";
+ public static final String INST = "MIS%252F1604%252F0026%252FSW_INTERNET";
+ public static final String PARENT_INST = "MIS%252F1604%252F0027%252FSW_INTERNET";
+ public static final String ARID = "arId-1";
+ public static final String ARVERS = "1490627351232";
+
+ public static final String DEC_INST = "MIS%2F1604%2F0026%2FSW_INTERNET";
+ public static final String DEC_PARENT_INST = "MIS%2F1604%2F0027%2FSW_INTERNET";
+
+ public static final String VAR_SUCCESS_IND = "SuccessIndicator";
+ public static final String VAR_WFEX = "SavedWorkflowException1";
+ public static final String VAR_RESP_CODE = "CMSO_ResponseCode";
+ public static final String VAR_COMP_REQ = "CompleteMsoProcessRequest";
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/CreateVcpeResCustServiceIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/CreateVcpeResCustServiceIT.java
index aa65474acc..bdc24875f0 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/CreateVcpeResCustServiceIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/CreateVcpeResCustServiceIT.java
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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
+ * 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.
+ * 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=========================================================
*/
@@ -50,12 +45,10 @@ import static org.onap.so.bpmn.mock.StubResponseDatabase.MockPostRequestDB;
import static org.onap.so.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
import static org.onap.so.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
import static org.onap.so.bpmn.mock.StubResponseVNFAdapter.mockVNFPost;
-
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.so.bpmn.common.BPMNUtil;
@@ -65,58 +58,68 @@ import org.onap.so.bpmn.mock.StubResponseOof;
public class CreateVcpeResCustServiceIT extends AbstractTestBase {
- private static final String PROCNAME = "CreateVcpeResCustService";
- private static final String Prefix = "CVRCS_";
-
- private final CallbackSet callbacks = new CallbackSet();
- private final String request;
-
- @Before
- public void init(){
- BPMNUtil.cleanHistory(processEngine);
- }
-
- public CreateVcpeResCustServiceIT() throws IOException {
-
- callbacks.put("oof", JSON, "oofResponse", FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/oofCallbackInfraVnf.json"));
- callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyAssignCallback.xml"));
- callbacks.put("create", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyCreateCallback.xml"));
- callbacks.put("activate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyActivateCallback.xml"));
- callbacks.put("queryTXC", FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryTXCCallback.xml"));
- callbacks.put("queryBRG", FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryBRGCallback.xml"));
- callbacks.put("deactivate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
- callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
- callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
-
- callbacks.put("query", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyQueryCallback.xml"));
- callbacks.put("queryVnf", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyQueryCallbackVnf.xml"));
- callbacks.put("queryModuleNoVnf", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyQueryCallbackVfModuleNoVnf.xml"));
- callbacks.put("queryModule", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml"));
- callbacks.put("vnfCreate", FileUtil.readResourceFile("__files/VfModularity/VNFAdapterRestCreateCallback.xml"));
-
- request = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/requestNoSIName.json");
- }
-
- @Test
- public void testCreateVcpeResCustService_Success() throws Exception {
- System.out.println("starting: testCreateVcpeResCustService_Success\n");
- MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2","VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
- MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
- MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
- StubResponseOof.mockOof(wireMockServer);
- // TODO: the SI should NOT have to be URL-encoded yet again!
- MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
-
- MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ private static final String PROCNAME = "CreateVcpeResCustService";
+ private static final String Prefix = "CVRCS_";
+
+ private final CallbackSet callbacks = new CallbackSet();
+ private final String request;
+
+ @Before
+ public void init() {
+ BPMNUtil.cleanHistory(processEngine);
+ }
+
+ public CreateVcpeResCustServiceIT() throws IOException {
+
+ callbacks.put("oof", JSON, "oofResponse",
+ FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/oofCallbackInfraVnf.json"));
+ callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyAssignCallback.xml"));
+ callbacks.put("create", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyCreateCallback.xml"));
+ callbacks.put("activate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyActivateCallback.xml"));
+ callbacks.put("queryTXC",
+ FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryTXCCallback.xml"));
+ callbacks.put("queryBRG",
+ FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryBRGCallback.xml"));
+ callbacks.put("deactivate",
+ FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
+ callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
+ callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
+
+ callbacks.put("query", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyQueryCallback.xml"));
+ callbacks.put("queryVnf", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyQueryCallbackVnf.xml"));
+ callbacks.put("queryModuleNoVnf",
+ FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyQueryCallbackVfModuleNoVnf.xml"));
+ callbacks.put("queryModule",
+ FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml"));
+ callbacks.put("vnfCreate", FileUtil.readResourceFile("__files/VfModularity/VNFAdapterRestCreateCallback.xml"));
+
+ request = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/requestNoSIName.json");
+ }
+
+ @Test
+ public void testCreateVcpeResCustService_Success() throws Exception {
+ System.out.println("starting: testCreateVcpeResCustService_Success\n");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2",
+ "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef",
+ "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
+ MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
+ StubResponseOof.mockOof(wireMockServer);
+ // TODO: the SI should NOT have to be URL-encoded yet again!
+ MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
+ "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
+ "GenericFlows/getServiceInstance.xml");
+
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
MockGetGenericVnfByIdWithDepth(wireMockServer, ".*", 1, "VCPE/CreateVcpeResCustService/GenericVnf.xml");
- MockPutGenericVnf(wireMockServer, ".*");
+ MockPutGenericVnf(wireMockServer, ".*");
MockPatchGenericVnf(wireMockServer, ".*");
MockGetGenericVnfByIdWithPriority(wireMockServer, ".*", ".*", 200, "VfModularity/VfModule-new.xml", 5);
@@ -124,46 +127,52 @@ public class CreateVcpeResCustServiceIT extends AbstractTestBase {
MockPutVfModuleIdNoResponse(wireMockServer, ".*", "PCRF", ".*");
MockPutNetwork(wireMockServer, ".*", "VfModularity/AddNetworkPolicy_AAIResponse_Success.xml", 200);
- MockGetNetworkPolicyfqdn(wireMockServer, ".*","CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml",200);
- MockNodeQueryServiceInstanceByName_404(wireMockServer, ".*");
-
- mockVNFPost(wireMockServer, "", 202, ".*");
+ MockGetNetworkPolicyfqdn(wireMockServer, ".*",
+ "CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200);
+ MockNodeQueryServiceInstanceByName_404(wireMockServer, ".*");
+
+ mockVNFPost(wireMockServer, "", 202, ".*");
+
+ wireMockServer.stubFor(post(urlMatching("/services/rest/v1/vnfs" + ".*" + "/vf-modules"))
+ .willReturn(aResponse().withStatus(202)));
+ wireMockServer
+ .stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
+ wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(
+ ".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
+ MockPostRequestDB(wireMockServer);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+ mockSDNCAdapter(wireMockServer, 200);
- wireMockServer.stubFor(post(urlMatching("/services/rest/v1/vnfs" + ".*" + "/vf-modules" )).willReturn(aResponse().withStatus(202)));
- wireMockServer.stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
- wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*")).willReturn(aResponse().withStatus(200)));
- wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship")).willReturn(aResponse().withStatus(200)));
- wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
- MockPostRequestDB(wireMockServer);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
- mockSDNCAdapter(wireMockServer, 200);
-
- Map<String, Object> variables = setupVariables();
+ Map<String, Object> variables = setupVariables();
- String businessKey = UUID.randomUUID().toString();
- invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
+ String businessKey = UUID.randomUUID().toString();
+ invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
injectWorkflowMessages(callbacks, "oof");
- // for SI
- injectSDNCCallbacks(callbacks, "assign");
- // for TXC
- injectSDNCCallbacks(callbacks, "assign");
- injectSDNCCallbacks(callbacks, "create");
- injectSDNCCallbacks(callbacks, "activate");
- injectSDNCCallbacks(callbacks, "queryTXC");
+ // for SI
+ injectSDNCCallbacks(callbacks, "assign");
+ // for TXC
+ injectSDNCCallbacks(callbacks, "assign");
+ injectSDNCCallbacks(callbacks, "create");
+ injectSDNCCallbacks(callbacks, "activate");
+ injectSDNCCallbacks(callbacks, "queryTXC");
// For VNF
injectSDNCCallbacks(callbacks, "assign");
injectSDNCCallbacks(callbacks, "assign");
injectSDNCCallbacks(callbacks, "queryModule");
injectSDNCCallbacks(callbacks, "activate");
- //VF Module
+ // VF Module
injectSDNCCallbacks(callbacks, "queryModule");
injectSDNCCallbacks(callbacks, "assign");
injectSDNCCallbacks(callbacks, "queryModule");
injectSDNCCallbacks(callbacks, "queryModule");
- injectSDNCCallbacks(callbacks, "assign");
- injectSDNCCallbacks(callbacks, "queryModuleNoVnf");
+ injectSDNCCallbacks(callbacks, "assign");
+ injectSDNCCallbacks(callbacks, "queryModuleNoVnf");
injectVNFRestCallbacks(callbacks, "vnfCreate");
injectSDNCCallbacks(callbacks, "activate");
@@ -173,208 +182,233 @@ public class CreateVcpeResCustServiceIT extends AbstractTestBase {
injectSDNCCallbacks(callbacks, "activate");
injectSDNCCallbacks(callbacks, "queryBRG");
- waitForProcessEnd(businessKey, 10000);
-
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
- System.out.println("workflowException:\n" + workflowException);
-
- String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix+VAR_COMP_REQ);
- System.out.println("completionReq:\n" + completionReq);
-
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME+VAR_SUCCESS_IND));
- assertEquals("200", BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
- assertEquals(null, workflowException);
- assertTrue(completionReq.indexOf("request-id>testRequestId<") >= 0);
- assertTrue(completionReq.indexOf("action>CREATE<") >= 0);
- assertTrue(completionReq.indexOf("source>VID<") >= 0);
-
- assertEquals("1", BPMNUtil.getVariable(processEngine, PROCNAME, Prefix+"VnfsCreatedCount"));
- }
-
- @Test
- public void testCreateVcpeResCustService_NoParts() throws Exception {
- System.out.println("starting: testCreateVcpeResCustService_NoParts\n" );
- MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json");
- MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json");
- MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
-
- // TODO: the SI should NOT have to be URL-encoded yet again!
- MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
-
- MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
-
- // TODO: should these really be PARENT_INST, or should they be INST?
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
-
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+ waitForProcessEnd(businessKey, 10000);
+
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
+ System.out.println("workflowException:\n" + workflowException);
+
+ String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + VAR_COMP_REQ);
+ System.out.println("completionReq:\n" + completionReq);
+
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME + VAR_SUCCESS_IND));
+ assertEquals("200", BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
+ assertEquals(null, workflowException);
+ assertTrue(completionReq.indexOf("request-id>testRequestId<") >= 0);
+ assertTrue(completionReq.indexOf("action>CREATE<") >= 0);
+ assertTrue(completionReq.indexOf("source>VID<") >= 0);
+
+ assertEquals("1", BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + "VnfsCreatedCount"));
+ }
+
+ @Test
+ public void testCreateVcpeResCustService_NoParts() throws Exception {
+ System.out.println("starting: testCreateVcpeResCustService_NoParts\n");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2",
+ "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef",
+ "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json");
+ MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
+
+ // TODO: the SI should NOT have to be URL-encoded yet again!
+ MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
+ "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
+ "GenericFlows/getServiceInstance.xml");
+
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+
+ // TODO: should these really be PARENT_INST, or should they be INST?
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
StubResponseOof.mockOof(wireMockServer);
- wireMockServer.stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
- wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*")).willReturn(aResponse().withStatus(200)));
- wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship")).willReturn(aResponse().withStatus(200)));
+ wireMockServer
+ .stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
+ wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(
+ ".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship"))
+ .willReturn(aResponse().withStatus(200)));
wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
MockPostRequestDB(wireMockServer);
mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = setupVariables();
- String businessKey = UUID.randomUUID().toString();
- invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
+ Map<String, Object> variables = setupVariables();
+
+ String businessKey = UUID.randomUUID().toString();
+ invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
+
+ injectWorkflowMessages(callbacks, "oof");
+ // for SI
+ injectSDNCCallbacks(callbacks, "assign");
+
+ waitForProcessEnd(businessKey, 10000);
+
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
+ System.out.println("workflowException:\n" + workflowException);
+
+ String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + VAR_COMP_REQ);
+ System.out.println("completionReq:\n" + completionReq);
+
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME + VAR_SUCCESS_IND));
+ assertEquals("200", BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
+ assertEquals(null, workflowException);
+ assertTrue(completionReq.indexOf("request-id>testRequestId<") >= 0);
+ assertTrue(completionReq.indexOf("action>CREATE<") >= 0);
+ assertTrue(completionReq.indexOf("source>VID<") >= 0);
+
+ assertEquals("0", BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + "VnfsCreatedCount"));
+ }
+
+ @Test
+ public void testCreateVcpeResCustService_Fault_NoRollback() throws Exception {
+ System.out.println("starting: testCreateVcpeResCustService_Fault_NoRollback\n");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2",
+ "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef",
+ "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
+ MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
+
+ // TODO: the SI should NOT have to be URL-encoded yet again!
+ MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
+ "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
+ "GenericFlows/getServiceInstance.xml");
+
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance_500(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+
+ mockSDNCAdapter(wireMockServer, 404);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ StubResponseOof.mockOof(wireMockServer);
+ wireMockServer
+ .stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
+ wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(
+ ".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
+ MockPostRequestDB(wireMockServer);
+
+ Map<String, Object> variables = setupVariables();
+
+ String businessKey = UUID.randomUUID().toString();
+ invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
injectWorkflowMessages(callbacks, "oof");
- // for SI
- injectSDNCCallbacks(callbacks, "assign");
-
- waitForProcessEnd(businessKey, 10000);
-
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
- System.out.println("workflowException:\n" + workflowException);
-
- String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix+VAR_COMP_REQ);
- System.out.println("completionReq:\n" + completionReq);
-
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME+VAR_SUCCESS_IND));
- assertEquals("200", BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
- assertEquals(null, workflowException);
- assertTrue(completionReq.indexOf("request-id>testRequestId<") >= 0);
- assertTrue(completionReq.indexOf("action>CREATE<") >= 0);
- assertTrue(completionReq.indexOf("source>VID<") >= 0);
-
- assertEquals("0", BPMNUtil.getVariable(processEngine, PROCNAME, Prefix+"VnfsCreatedCount"));
- }
-
- @Test
- public void testCreateVcpeResCustService_Fault_NoRollback() throws Exception {
- System.out.println("starting: testCreateVcpeResCustService_Fault_NoRollback\n");
- MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
- MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
- MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
-
- // TODO: the SI should NOT have to be URL-encoded yet again!
- MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
-
- MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance_500(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
-
- mockSDNCAdapter(wireMockServer, 404);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ waitForProcessEnd(businessKey, 100000);
+
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
+ System.out.println("workflowException:\n" + workflowException);
+
+ String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + VAR_COMP_REQ);
+ System.out.println("completionReq:\n" + completionReq);
+
+ assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME + VAR_SUCCESS_IND));
+ assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
+ assertNotNull(workflowException);
+
+ BPMNUtil.assertNoProcessInstance(processEngine, "DoCreateAllottedResourceBRGRollback");
+ BPMNUtil.assertNoProcessInstance(processEngine, "DoCreateVnfAndModulesRollback");
+ BPMNUtil.assertNoProcessInstance(processEngine, "DoCreateAllottedResourceTXCRollback");
+ }
+
+ @Test
+ public void testCreateVcpeResCustService_Fault_Rollback() throws Exception {
+ System.out.println("starting: testCreateVcpeResCustService_Fault_Rollback\n");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2",
+ "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
+ MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef",
+ "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
+ MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
+
+ // TODO: the SI should NOT have to be URL-encoded yet again!
+ MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
+ "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
+ "GenericFlows/getServiceInstance.xml");
+
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/CreateVcpeResCustService/arGetById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID,
+ "VCPE/CreateVcpeResCustService/arGetById.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID, ARVERS);
+
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
StubResponseOof.mockOof(wireMockServer);
- wireMockServer.stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
- wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*")).willReturn(aResponse().withStatus(200)));
- wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship")).willReturn(aResponse().withStatus(200)));
+ wireMockServer
+ .stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
+ wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(put(urlMatching(
+ ".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship"))
+ .willReturn(aResponse().withStatus(200)));
wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
MockPostRequestDB(wireMockServer);
-
- Map<String, Object> variables = setupVariables();
+ String req = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/requestRollback.json");
+
+ Map<String, Object> variables = setupVariables();
- String businessKey = UUID.randomUUID().toString();
- invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
+ String businessKey = UUID.randomUUID().toString();
+ invokeAsyncProcess(PROCNAME, "v1", businessKey, req, variables);
injectWorkflowMessages(callbacks, "oof");
-
- waitForProcessEnd(businessKey, 100000);
-
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
- System.out.println("workflowException:\n" + workflowException);
-
- String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix+VAR_COMP_REQ);
- System.out.println("completionReq:\n" + completionReq);
-
- assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME+VAR_SUCCESS_IND));
- assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
- assertNotNull(workflowException);
-
- BPMNUtil.assertNoProcessInstance(processEngine, "DoCreateAllottedResourceBRGRollback");
- BPMNUtil.assertNoProcessInstance(processEngine, "DoCreateVnfAndModulesRollback");
- BPMNUtil.assertNoProcessInstance(processEngine, "DoCreateAllottedResourceTXCRollback");
- }
-
- @Test
- public void testCreateVcpeResCustService_Fault_Rollback() throws Exception {
- System.out.println("starting: testCreateVcpeResCustService_Fault_Rollback\n");
- MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
- MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
- MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
-
- // TODO: the SI should NOT have to be URL-encoded yet again!
- MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml");
-
- MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/CreateVcpeResCustService/arGetById.xml");
- MockGetAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID, "VCPE/CreateVcpeResCustService/arGetById.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID, ARVERS);
-
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- StubResponseOof.mockOof(wireMockServer);
- wireMockServer.stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
- wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*")).willReturn(aResponse().withStatus(200)));
- wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship")).willReturn(aResponse().withStatus(200)));
- wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
- MockPostRequestDB(wireMockServer);
- String req = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/requestRollback.json");
-
- Map<String, Object> variables = setupVariables();
-
- String businessKey = UUID.randomUUID().toString();
- invokeAsyncProcess(PROCNAME, "v1", businessKey, req, variables);
-
- injectWorkflowMessages(callbacks, "oof");
- // for SI
- injectSDNCCallbacks(callbacks, "assign");
-
- // for TXC
- injectSDNCCallbacks(callbacks, "assign");
- injectSDNCCallbacks(callbacks, "create");
-
- waitForProcessEnd(businessKey, 10000);
-
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
- System.out.println("workflowException:\n" + workflowException);
-
- String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix+VAR_COMP_REQ);
- System.out.println("completionReq:\n" + completionReq);
-
- assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME+VAR_SUCCESS_IND));
- assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
- assertEquals(null, completionReq);
- assertNotNull(workflowException);
-
- BPMNUtil.assertAnyProcessInstanceFinished(processEngine, "DoCreateServiceInstanceRollback");
- }
-
- // *****************
- // Utility Section
- // *****************
-
- // Success Scenario
- private Map<String, Object> setupVariables() {
- Map<String, Object> variables = new HashMap<>();
- variables.put("requestId", "testRequestId");
- variables.put("request-id", "testRequestId");
- variables.put("serviceInstanceId", DEC_INST);
- variables.put("allottedResourceId", ARID);
- variables.put("URN_mso_workflow_aai_distribution_delay", "PT5S");
- return variables;
-
- }
+ // for SI
+ injectSDNCCallbacks(callbacks, "assign");
+
+ // for TXC
+ injectSDNCCallbacks(callbacks, "assign");
+ injectSDNCCallbacks(callbacks, "create");
+
+ waitForProcessEnd(businessKey, 10000);
+
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
+ System.out.println("workflowException:\n" + workflowException);
+
+ String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + VAR_COMP_REQ);
+ System.out.println("completionReq:\n" + completionReq);
+
+ assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME + VAR_SUCCESS_IND));
+ assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
+ assertEquals(null, completionReq);
+ assertNotNull(workflowException);
+
+ BPMNUtil.assertAnyProcessInstanceFinished(processEngine, "DoCreateServiceInstanceRollback");
+ }
+
+ // *****************
+ // Utility Section
+ // *****************
+
+ // Success Scenario
+ private Map<String, Object> setupVariables() {
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("requestId", "testRequestId");
+ variables.put("request-id", "testRequestId");
+ variables.put("serviceInstanceId", DEC_INST);
+ variables.put("allottedResourceId", ARID);
+ variables.put("URN_mso_workflow_aai_distribution_delay", "PT5S");
+ return variables;
+
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DeleteVcpeResCustServiceIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DeleteVcpeResCustServiceIT.java
index aaabf59e6b..4a03aa9fd4 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DeleteVcpeResCustServiceIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DeleteVcpeResCustServiceIT.java
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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
+ * 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.
+ * 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=========================================================
*/
@@ -37,255 +32,244 @@ import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceById;
import static org.onap.so.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
import static org.onap.so.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
-
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.so.bpmn.common.BPMNUtil;
import org.onap.so.bpmn.mock.FileUtil;
-
import com.github.tomakehurst.wiremock.stubbing.Scenario;
public class DeleteVcpeResCustServiceIT extends AbstractTestBase {
- private static final String PROCNAME = "DeleteVcpeResCustService";
- private static final String Prefix = "DVRCS_";
- private static final String AR_BRG_ID = "ar-brgB";
- private static final String AR_TXC_ID = "ar-txcA";
-
- private final CallbackSet callbacks = new CallbackSet();
- private final String request;
-
- public DeleteVcpeResCustServiceIT() throws IOException {
- callbacks.put("deactivate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
- callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
- callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
-
- request = FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/request.json");
- }
-
- @Before
- public void init(){
- BPMNUtil.cleanHistory(processEngine);
- }
-
- @Test
- public void testDeleteVcpeResCustService_Success() throws Exception {
- logStart();
- MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
-
- // TODO: use INST instead of DEC_INST
- /*
- * Seems to be a bug as they
- * fail to URL-encode the SI id before performing the query so we'll
- * add a stub for that case, too.
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
-
- /*
- * cannot use MockGetServiceInstance(wireMockServer, ), because we need to return
- * different responses as we traverse through the flow
- */
-
- // initially, the SI includes the ARs
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST))
- .inScenario("SI retrieval")
- .whenScenarioStateIs(Scenario.STARTED)
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VCPE/DeleteVcpeResCustService/getSI.xml"))
- .willSetStateTo("ARs Deleted"));
-
- // once the ARs have been deleted, the SI should be empty
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST))
- .inScenario("SI retrieval")
- .whenScenarioStateIs("ARs Deleted")
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml")));
-
- // for BRG
- MockQueryAllottedResourceById(wireMockServer, AR_BRG_ID, "VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml");
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, AR_BRG_ID, "VCPE/DeleteVcpeResCustService/arGetBRGById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, AR_BRG_ID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, AR_BRG_ID, ARVERS);
-
- // for TXC
- MockQueryAllottedResourceById(wireMockServer, AR_TXC_ID, "VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml");
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, AR_TXC_ID, "VCPE/DeleteVcpeResCustService/arGetTXCById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, AR_TXC_ID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, AR_TXC_ID, ARVERS);
-
- //MockGetGenericVnfById("vnfX.*", "GenericFlows/getGenericVnfByNameResponse.xml");
+ private static final String PROCNAME = "DeleteVcpeResCustService";
+ private static final String Prefix = "DVRCS_";
+ private static final String AR_BRG_ID = "ar-brgB";
+ private static final String AR_TXC_ID = "ar-txcA";
+
+ private final CallbackSet callbacks = new CallbackSet();
+ private final String request;
+
+ public DeleteVcpeResCustServiceIT() throws IOException {
+ callbacks.put("deactivate",
+ FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
+ callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
+ callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
+
+ request = FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/request.json");
+ }
+
+ @Before
+ public void init() {
+ BPMNUtil.cleanHistory(processEngine);
+ }
+
+ @Test
+ public void testDeleteVcpeResCustService_Success() throws Exception {
+ logStart();
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
+
+ // TODO: use INST instead of DEC_INST
+ /*
+ * Seems to be a bug as they fail to URL-encode the SI id before performing the query so we'll add a stub for
+ * that case, too.
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+
+ /*
+ * cannot use MockGetServiceInstance(wireMockServer, ), because we need to return different responses as we
+ * traverse through the flow
+ */
+
+ // initially, the SI includes the ARs
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + CUST
+ + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST))
+ .inScenario("SI retrieval").whenScenarioStateIs(Scenario.STARTED)
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VCPE/DeleteVcpeResCustService/getSI.xml"))
+ .willSetStateTo("ARs Deleted"));
+
+ // once the ARs have been deleted, the SI should be empty
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + CUST
+ + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST))
+ .inScenario("SI retrieval").whenScenarioStateIs("ARs Deleted")
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml")));
+
+ // for BRG
+ MockQueryAllottedResourceById(wireMockServer, AR_BRG_ID, "VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, AR_BRG_ID,
+ "VCPE/DeleteVcpeResCustService/arGetBRGById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, AR_BRG_ID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, AR_BRG_ID, ARVERS);
+
+ // for TXC
+ MockQueryAllottedResourceById(wireMockServer, AR_TXC_ID, "VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, AR_TXC_ID,
+ "VCPE/DeleteVcpeResCustService/arGetTXCById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, AR_TXC_ID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, AR_TXC_ID, ARVERS);
+
+ // MockGetGenericVnfById("vnfX.*", "GenericFlows/getGenericVnfByNameResponse.xml");
wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
.withBodyFile("GenericFlows/getGenericVnfByNameResponse.xml")));
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
- .willReturn(aResponse()
- .withStatus(204)
- .withHeader("Content-Type", "text/xml")));
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
+ .willReturn(aResponse().withStatus(204).withHeader("Content-Type", "text/xml")));
- MockDeleteServiceInstance(wireMockServer, CUST,SVC,INST,SVC);
+ MockDeleteServiceInstance(wireMockServer, CUST, SVC, INST, SVC);
mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = setupVariables(businessKey);
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = setupVariables(businessKey);
- invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
+ invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
- // for BRG
- injectSDNCCallbacks(callbacks, "deactivate");
- injectSDNCCallbacks(callbacks, "delete");
- injectSDNCCallbacks(callbacks, "unassign");
+ // for BRG
+ injectSDNCCallbacks(callbacks, "deactivate");
+ injectSDNCCallbacks(callbacks, "delete");
+ injectSDNCCallbacks(callbacks, "unassign");
- // for VNF1
- injectSDNCCallbacks(callbacks, "deactivate");
- injectSDNCCallbacks(callbacks, "unassign");
+ // for VNF1
+ injectSDNCCallbacks(callbacks, "deactivate");
+ injectSDNCCallbacks(callbacks, "unassign");
- // for VNF2
- injectSDNCCallbacks(callbacks, "deactivate");
- injectSDNCCallbacks(callbacks, "unassign");
+ // for VNF2
+ injectSDNCCallbacks(callbacks, "deactivate");
+ injectSDNCCallbacks(callbacks, "unassign");
- // for TXC
- injectSDNCCallbacks(callbacks, "deactivate");
- injectSDNCCallbacks(callbacks, "delete");
- injectSDNCCallbacks(callbacks, "unassign");
+ // for TXC
+ injectSDNCCallbacks(callbacks, "deactivate");
+ injectSDNCCallbacks(callbacks, "delete");
+ injectSDNCCallbacks(callbacks, "unassign");
- // for SI
- injectSDNCCallbacks(callbacks, "deactivate");
- injectSDNCCallbacks(callbacks, "delete");
+ // for SI
+ injectSDNCCallbacks(callbacks, "deactivate");
+ injectSDNCCallbacks(callbacks, "delete");
- waitForProcessEnd(businessKey, 70000);
- assertTrue(isProcessEnded(businessKey));
+ waitForProcessEnd(businessKey, 70000);
+ assertTrue(isProcessEnded(businessKey));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
- System.out.println("workflowException:\n" + workflowException);
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
+ System.out.println("workflowException:\n" + workflowException);
- String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix+VAR_COMP_REQ);
- System.out.println("completionReq:\n" + completionReq);
+ String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + VAR_COMP_REQ);
+ System.out.println("completionReq:\n" + completionReq);
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME+VAR_SUCCESS_IND));
- assertEquals("200", BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
- assertNull(workflowException);
- assertTrue(completionReq.contains("<request-id>"+businessKey+"<"));
- assertTrue(completionReq.contains("<action>DELETE<"));
- assertTrue(completionReq.contains("<source>VID<"));
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME + VAR_SUCCESS_IND));
+ assertEquals("200", BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
+ assertNull(workflowException);
+ assertTrue(completionReq.contains("<request-id>" + businessKey + "<"));
+ assertTrue(completionReq.contains("<action>DELETE<"));
+ assertTrue(completionReq.contains("<source>VID<"));
- assertEquals("2", BPMNUtil.getVariable(processEngine, PROCNAME, Prefix+"vnfsDeletedCount"));
+ assertEquals("2", BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + "vnfsDeletedCount"));
- BPMNUtil.assertAnyProcessInstanceFinished(processEngine, "DoDeleteVnfAndModules");
- logEnd();
- }
+ BPMNUtil.assertAnyProcessInstanceFinished(processEngine, "DoDeleteVnfAndModules");
+ logEnd();
+ }
- @Test
- public void testDeleteVcpeResCustService_NoBRG_NoTXC_NoVNF() throws Exception {
- logStart();
- MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
+ @Test
+ public void testDeleteVcpeResCustService_NoBRG_NoTXC_NoVNF() throws Exception {
+ logStart();
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
- // TODO: use INST instead of DEC_INST
- /*
- * Seems to be a bug as they
- * fail to URL-encode the SI id before performing the query so we'll
- * add a stub for that case, too.
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ // TODO: use INST instead of DEC_INST
+ /*
+ * Seems to be a bug as they fail to URL-encode the SI id before performing the query so we'll add a stub for
+ * that case, too.
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml");
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = setupVariables(businessKey);
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = setupVariables(businessKey);
- invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
+ invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
- // for SI
- injectSDNCCallbacks(callbacks, "deactivate");
- injectSDNCCallbacks(callbacks, "delete");
+ // for SI
+ injectSDNCCallbacks(callbacks, "deactivate");
+ injectSDNCCallbacks(callbacks, "delete");
- waitForProcessEnd(businessKey, 70000);
+ waitForProcessEnd(businessKey, 70000);
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
- System.out.println("workflowException:\n" + workflowException);
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
+ System.out.println("workflowException:\n" + workflowException);
- String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix+VAR_COMP_REQ);
- System.out.println("completionReq:\n" + completionReq);
+ String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + VAR_COMP_REQ);
+ System.out.println("completionReq:\n" + completionReq);
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME+VAR_SUCCESS_IND));
- assertEquals("200", BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
- assertNull( workflowException);
- assertTrue(completionReq.contains("<request-id>"+businessKey+"<"));
- assertTrue(completionReq.contains("<action>DELETE<"));
- assertTrue(completionReq.contains("<source>VID<"));
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME + VAR_SUCCESS_IND));
+ assertEquals("200", BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
+ assertNull(workflowException);
+ assertTrue(completionReq.contains("<request-id>" + businessKey + "<"));
+ assertTrue(completionReq.contains("<action>DELETE<"));
+ assertTrue(completionReq.contains("<source>VID<"));
- assertEquals("0", BPMNUtil.getVariable(processEngine, PROCNAME, Prefix+"vnfsDeletedCount"));
+ assertEquals("0", BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + "vnfsDeletedCount"));
- BPMNUtil.assertNoProcessInstance(processEngine, "DoDeleteVnfAndModules");
- logEnd();
- }
+ BPMNUtil.assertNoProcessInstance(processEngine, "DoDeleteVnfAndModules");
+ logEnd();
+ }
- @Test
- public void testDeleteVcpeResCustService_Fault() throws Exception {
- logStart();
- MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
+ @Test
+ public void testDeleteVcpeResCustService_Fault() throws Exception {
+ logStart();
+ MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
- // TODO: use INST instead of DEC_INST
- /*
- * Seems to be a bug as they
- * fail to URL-encode the SI id before performing the query so we'll
- * add a stub for that case, too.
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ // TODO: use INST instead of DEC_INST
+ /*
+ * Seems to be a bug as they fail to URL-encode the SI id before performing the query so we'll add a stub for
+ * that case, too.
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml");
- // generate failure
- mockSDNCAdapter(wireMockServer, 404);
+ // generate failure
+ mockSDNCAdapter(wireMockServer, 404);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = setupVariables(businessKey);
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = setupVariables(businessKey);
- invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
+ invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
- waitForProcessEnd(businessKey, 70000);
+ waitForProcessEnd(businessKey, 70000);
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
- System.out.println("workflowException:\n" + workflowException);
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
+ System.out.println("workflowException:\n" + workflowException);
- String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix+VAR_COMP_REQ);
- System.out.println("completionReq:\n" + completionReq);
+ String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + VAR_COMP_REQ);
+ System.out.println("completionReq:\n" + completionReq);
- assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME+VAR_SUCCESS_IND));
- assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
- assertNotNull(workflowException);
- logEnd();
- }
+ assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME + VAR_SUCCESS_IND));
+ assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
+ assertNotNull(workflowException);
+ logEnd();
+ }
- private Map<String, Object> setupVariables(String requestId) throws UnsupportedEncodingException {
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled", "true");
- variables.put("requestId", requestId);
- variables.put("serviceInstanceId", DEC_INST);
- variables.put("sdncVersion", "1802");
- variables.put("serviceInstanceName", "some-junk-name");
- return variables;
- }
+ private Map<String, Object> setupVariables(String requestId) throws UnsupportedEncodingException {
+ Map<String, Object> variables = new HashMap<>();
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("requestId", requestId);
+ variables.put("serviceInstanceId", DEC_INST);
+ variables.put("sdncVersion", "1802");
+ variables.put("serviceInstanceName", "some-junk-name");
+ return variables;
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGIT.java
index da9b45c8c8..291613bc1a 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGIT.java
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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
+ * 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.
+ * 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=========================================================
*/
@@ -29,10 +24,8 @@ import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource;
import static org.onap.so.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
import static org.onap.so.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
-
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Test;
import org.onap.so.bpmn.common.BPMNUtil;
import org.onap.so.bpmn.mock.FileUtil;
@@ -40,227 +33,223 @@ import org.onap.so.bpmn.mock.FileUtil;
public class DoCreateAllottedResourceBRGIT extends AbstractTestBase {
- private static final String PROCNAME = "DoCreateAllottedResourceBRG";
- private final CallbackSet callbacks = new CallbackSet();
-
- public DoCreateAllottedResourceBRGIT() {
- callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyAssignCallback.xml"));
- callbacks.put("create", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyCreateCallback.xml"));
- callbacks.put("activate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyActivateCallback.xml"));
- callbacks.put("query", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml"));
- }
-
- @Test
- public void testDoCreateAllottedResourceBRG_Success() throws InterruptedException {
- logStart();
-
- // TODO: use INST instead of DEC_INST
- /*
- * should be INST instead of DEC_INST, but AAI utilities appear to
- * have a bug in that they don't URL-encode the SI id before using
- * it in the query
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
-
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables,"testRequestId123");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- injectSDNCCallbacks(callbacks, "assign");
- injectSDNCCallbacks(callbacks, "create");
- injectSDNCCallbacks(callbacks, "activate");
- injectSDNCCallbacks(callbacks, "query");
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- assertNull(workflowException);
-
- assertEquals("namefromrequest", BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceBRG_NoSI() throws Exception{
- logStart();
- // TODO: use INST instead of DEC_INST
- /*
- * should be INST instead of DEC_INST, but AAI utilities appear to
- * have a bug in that they don't URL-encode the SI id before using
- * it in the query
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getNotFound.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
-
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables,"testRequestId124");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- assertNotNull(workflowException);
-
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceBRG_ActiveAr() throws Exception{
- logStart();
- // TODO: use INST instead of DEC_INST
- /*
- * should be INST instead of DEC_INST, but AAI utilities appear to
- * have a bug in that they don't URL-encode the SI id before using
- * it in the query
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
-
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml");
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables,"testRequestId125");
-
- variables.put("failExists", "false");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
-
-
- injectSDNCCallbacks(callbacks, "query");
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- assertNull( workflowException);
-
- assertEquals("namefromrequest", BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceBRG_NoParentSI() throws Exception{
- logStart();
- // TODO: use INST instead of DEC_INST
- /*
- * should be INST instead of DEC_INST, but AAI utilities appear to
- * have a bug in that they don't URL-encode the SI id before using
- * it in the query
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getNotFound.xml");
-
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables,"testRequestId126");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- assertNotNull(workflowException);
-
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceBRG_SubProcessError() throws Exception{
- logStart();
- // TODO: use INST instead of DEC_INST
- /*
- * should be INST instead of DEC_INST, but AAI utilities appear to
- * have a bug in that they don't URL-encode the SI id before using
- * it in the query
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
-
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(wireMockServer, 404);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables,"testRequestId127");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- assertNotNull(workflowException);
-
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
- logEnd();
- }
-
- private void setVariablesSuccess(Map<String, Object> variables, String requestId) {
- variables.put("isDebugLogEnabled", "true");
- variables.put("failExists", "true");
- variables.put("disableRollback", "true");
- variables.put("msoRequestId", requestId);
- variables.put("mso-request-id", "requestId");
- variables.put("sourceNetworkId", "snId");
- variables.put("sourceNetworkRole", "snRole");
- variables.put("allottedResourceRole", "txc");
- variables.put("allottedResourceType", "BRG");
- variables.put("allottedResourceId", ARID);
- variables.put("vni", "BRG");
- variables.put("vgmuxBearerIP", "bearerip");
- variables.put("brgWanMacAddress", "wanmac");
-
- variables.put("serviceInstanceId", DEC_INST);
- variables.put("parentServiceInstanceId", DEC_PARENT_INST);
-
- variables.put("serviceChainServiceInstanceId", "scsiId");
-
- String arModelInfo = "{ "+ "\"modelType\": \"allotted-resource\"," +
- "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," +
- "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," +
- "\"modelName\": \"vSAMP12\"," +
- "\"modelVersion\": \"1.0\"," +
- "\"modelCustomizationUuid\": \"MODEL-ID-1234\"," +
- "}";
- variables.put("allottedResourceModelInfo", arModelInfo);
- }
+ private static final String PROCNAME = "DoCreateAllottedResourceBRG";
+ private final CallbackSet callbacks = new CallbackSet();
+
+ public DoCreateAllottedResourceBRGIT() {
+ callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyAssignCallback.xml"));
+ callbacks.put("create", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyCreateCallback.xml"));
+ callbacks.put("activate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyActivateCallback.xml"));
+ callbacks.put("query",
+ FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml"));
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRG_Success() throws InterruptedException {
+ logStart();
+
+ // TODO: use INST instead of DEC_INST
+ /*
+ * should be INST instead of DEC_INST, but AAI utilities appear to have a bug in that they don't URL-encode the
+ * SI id before using it in the query
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, "testRequestId123");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ injectSDNCCallbacks(callbacks, "assign");
+ injectSDNCCallbacks(callbacks, "create");
+ injectSDNCCallbacks(callbacks, "activate");
+ injectSDNCCallbacks(callbacks, "query");
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ assertNull(workflowException);
+
+ assertEquals("namefromrequest",
+ BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRG_NoSI() throws Exception {
+ logStart();
+ // TODO: use INST instead of DEC_INST
+ /*
+ * should be INST instead of DEC_INST, but AAI utilities appear to have a bug in that they don't URL-encode the
+ * SI id before using it in the query
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getNotFound.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, "testRequestId124");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ assertNotNull(workflowException);
+
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRG_ActiveAr() throws Exception {
+ logStart();
+ // TODO: use INST instead of DEC_INST
+ /*
+ * should be INST instead of DEC_INST, but AAI utilities appear to have a bug in that they don't URL-encode the
+ * SI id before using it in the query
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, "testRequestId125");
+
+ variables.put("failExists", "false");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+
+
+ injectSDNCCallbacks(callbacks, "query");
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ assertNull(workflowException);
+
+ assertEquals("namefromrequest",
+ BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRG_NoParentSI() throws Exception {
+ logStart();
+ // TODO: use INST instead of DEC_INST
+ /*
+ * should be INST instead of DEC_INST, but AAI utilities appear to have a bug in that they don't URL-encode the
+ * SI id before using it in the query
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getNotFound.xml");
+
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, "testRequestId126");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ assertNotNull(workflowException);
+
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRG_SubProcessError() throws Exception {
+ logStart();
+ // TODO: use INST instead of DEC_INST
+ /*
+ * should be INST instead of DEC_INST, but AAI utilities appear to have a bug in that they don't URL-encode the
+ * SI id before using it in the query
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 404);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, "testRequestId127");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ assertNotNull(workflowException);
+
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName", processId));
+ logEnd();
+ }
+
+ private void setVariablesSuccess(Map<String, Object> variables, String requestId) {
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("failExists", "true");
+ variables.put("disableRollback", "true");
+ variables.put("msoRequestId", requestId);
+ variables.put("mso-request-id", "requestId");
+ variables.put("sourceNetworkId", "snId");
+ variables.put("sourceNetworkRole", "snRole");
+ variables.put("allottedResourceRole", "txc");
+ variables.put("allottedResourceType", "BRG");
+ variables.put("allottedResourceId", ARID);
+ variables.put("vni", "BRG");
+ variables.put("vgmuxBearerIP", "bearerip");
+ variables.put("brgWanMacAddress", "wanmac");
+
+ variables.put("serviceInstanceId", DEC_INST);
+ variables.put("parentServiceInstanceId", DEC_PARENT_INST);
+
+ variables.put("serviceChainServiceInstanceId", "scsiId");
+
+ String arModelInfo = "{ " + "\"modelType\": \"allotted-resource\","
+ + "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\","
+ + "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + "\"modelName\": \"vSAMP12\","
+ + "\"modelVersion\": \"1.0\"," + "\"modelCustomizationUuid\": \"MODEL-ID-1234\"," + "}";
+ variables.put("allottedResourceModelInfo", arModelInfo);
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java
index f0d275c5cc..cd7004e3aa 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackIT.java
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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
+ * 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.
+ * 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=========================================================
*/
@@ -24,12 +19,10 @@ import org.junit.Test;
import org.onap.so.bpmn.common.BPMNUtil;
import org.onap.so.bpmn.core.RollbackData;
import org.onap.so.bpmn.mock.FileUtil;
-
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -43,281 +36,295 @@ import static org.onap.so.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
public class DoCreateAllottedResourceBRGRollbackIT extends AbstractTestBase {
- private static final String PROCNAME = "DoCreateAllottedResourceBRGRollback";
- private static final String RbType = "DCARBRG_";
- private final CallbackSet callbacks = new CallbackSet();
-
- public DoCreateAllottedResourceBRGRollbackIT() throws IOException {
- callbacks.put("deactivate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
- callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
- callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
- }
-
- @Test
- public void testDoCreateAllottedResourceBRGRollback_Success() throws Exception {
+ private static final String PROCNAME = "DoCreateAllottedResourceBRGRollback";
+ private static final String RbType = "DCARBRG_";
+ private final CallbackSet callbacks = new CallbackSet();
+
+ public DoCreateAllottedResourceBRGRollbackIT() throws IOException {
+ callbacks.put("deactivate",
+ FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
+ callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
+ callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRGRollback_Success() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, businessKey);
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ injectSDNCCallbacks(callbacks, "deactivate");
+ injectSDNCCallbacks(callbacks, "delete");
+ injectSDNCCallbacks(callbacks, "unassign");
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRGRollback_skipRollback() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
+
+ rollbackData.put(RbType, "rollbackAAI", "false");
+ rollbackData.put(RbType, "rollbackSDNCassign", "false");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRGRollback_DoNotRollBack() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
+
+ // this will cause "rollbackSDNC" to be set to false
+ rollbackData.put(RbType, "rollbackSDNCassign", "false");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRGRollback_NoDeactivate() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
+
+ rollbackData.put(RbType, "rollbackSDNCactivate", "false");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ injectSDNCCallbacks(callbacks, "delete");
+ injectSDNCCallbacks(callbacks, "unassign");
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRGRollback_NoDelete() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
+
+ rollbackData.put(RbType, "rollbackSDNCcreate", "false");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ injectSDNCCallbacks(callbacks, "deactivate");
+ injectSDNCCallbacks(callbacks, "unassign");
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRGRollback_NoUnassign() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
+
+ rollbackData.put(RbType, "rollbackSDNCassign", "false");
+
+ /*
+ * Note: if assign == false then the flow/script will set "skipRollback" to false, which will cause ALL of the
+ * SDNC steps to be skipped, not just the unassign step.
+ */
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRGRollback_SubProcessError() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ mockSDNCAdapter(wireMockServer, 404);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, businessKey);
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("false", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNotNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceBRGRollback_JavaException() throws Exception {
logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, businessKey);
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- injectSDNCCallbacks(callbacks, "deactivate");
- injectSDNCCallbacks(callbacks, "delete");
- injectSDNCCallbacks(callbacks, "unassign");
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceBRGRollback_skipRollback() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
-
- rollbackData.put(RbType, "rollbackAAI", "false");
- rollbackData.put(RbType, "rollbackSDNCassign", "false");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceBRGRollback_DoNotRollBack() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
-
- // this will cause "rollbackSDNC" to be set to false
- rollbackData.put(RbType, "rollbackSDNCassign", "false");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceBRGRollback_NoDeactivate() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
-
- rollbackData.put(RbType, "rollbackSDNCactivate", "false");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- injectSDNCCallbacks(callbacks, "delete");
- injectSDNCCallbacks(callbacks, "unassign");
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceBRGRollback_NoDelete() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
-
- rollbackData.put(RbType, "rollbackSDNCcreate", "false");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- injectSDNCCallbacks(callbacks, "deactivate");
- injectSDNCCallbacks(callbacks, "unassign");
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceBRGRollback_NoUnassign() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
-
- rollbackData.put(RbType, "rollbackSDNCassign", "false");
-
- /*
- * Note: if assign == false then the flow/script will set
- * "skipRollback" to false, which will cause ALL of the SDNC steps
- * to be skipped, not just the unassign step.
- */
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceBRGRollback_SubProcessError() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- mockSDNCAdapter(wireMockServer, 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, businessKey);
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("false", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNotNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceBRGRollback_JavaException() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, businessKey);
-
- variables.put("rollbackData", "string instead of rollback data");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("false", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNotNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- private RollbackData setVariablesSuccess(Map<String, Object> variables, String requestId) {
- variables.put("isDebugLogEnabled", "true");
- variables.put("failNotFound", "true");
- variables.put("msoRequestId", requestId);
- variables.put("mso-request-id", "requestId");
- variables.put("allottedResourceId", ARID);
-
- variables.put("serviceInstanceId", DEC_INST);
- variables.put("parentServiceInstanceId", DEC_PARENT_INST);
-
- RollbackData rollbackData = new RollbackData();
-
- rollbackData.put(RbType, "serviceInstanceId", DEC_INST);
- rollbackData.put(RbType, "serviceSubscriptionType", SVC);
- rollbackData.put(RbType, "disablerollback", "false");
- rollbackData.put(RbType, "rollbackAAI", "true");
- rollbackData.put(RbType, "rollbackSDNCassign", "true");
- rollbackData.put(RbType, "rollbackSDNCactivate", "true");
- rollbackData.put(RbType, "rollbackSDNCcreate", "true");
- rollbackData.put(RbType, "aaiARPath", "business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID);
-
- rollbackData.put(RbType, "sdncActivateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncActivateRollbackReq.xml"));
- rollbackData.put(RbType, "sdncCreateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncCreateRollbackReq.xml"));
- rollbackData.put(RbType, "sdncAssignRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncAssignRollbackReq.xml"));
-
- variables.put("rollbackData",rollbackData);
-
- return rollbackData;
- }
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, businessKey);
+
+ variables.put("rollbackData", "string instead of rollback data");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("false", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNotNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ private RollbackData setVariablesSuccess(Map<String, Object> variables, String requestId) {
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("failNotFound", "true");
+ variables.put("msoRequestId", requestId);
+ variables.put("mso-request-id", "requestId");
+ variables.put("allottedResourceId", ARID);
+
+ variables.put("serviceInstanceId", DEC_INST);
+ variables.put("parentServiceInstanceId", DEC_PARENT_INST);
+
+ RollbackData rollbackData = new RollbackData();
+
+ rollbackData.put(RbType, "serviceInstanceId", DEC_INST);
+ rollbackData.put(RbType, "serviceSubscriptionType", SVC);
+ rollbackData.put(RbType, "disablerollback", "false");
+ rollbackData.put(RbType, "rollbackAAI", "true");
+ rollbackData.put(RbType, "rollbackSDNCassign", "true");
+ rollbackData.put(RbType, "rollbackSDNCactivate", "true");
+ rollbackData.put(RbType, "rollbackSDNCcreate", "true");
+ rollbackData.put(RbType, "aaiARPath",
+ "business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC
+ + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/"
+ + ARID);
+
+ rollbackData.put(RbType, "sdncActivateRollbackReq", FileUtil
+ .readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncActivateRollbackReq.xml"));
+ rollbackData.put(RbType, "sdncCreateRollbackReq", FileUtil
+ .readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncCreateRollbackReq.xml"));
+ rollbackData.put(RbType, "sdncAssignRollbackReq", FileUtil
+ .readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncAssignRollbackReq.xml"));
+
+ variables.put("rollbackData", rollbackData);
+
+ return rollbackData;
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCIT.java
index 6ecec3240d..80c3fa16e8 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCIT.java
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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
+ * 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.
+ * 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=========================================================
*/
@@ -31,12 +26,10 @@ import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource;
import static org.onap.so.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
import static org.onap.so.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
-
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.camunda.bpm.engine.test.Deployment;
import org.junit.Assert;
import org.junit.Ignore;
@@ -46,231 +39,227 @@ import org.onap.so.bpmn.mock.FileUtil;
public class DoCreateAllottedResourceTXCIT extends AbstractTestBase {
- private static final String PROCNAME = "DoCreateAllottedResourceTXC";
- private final CallbackSet callbacks = new CallbackSet();
-
- public DoCreateAllottedResourceTXCIT() throws IOException {
- callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyAssignCallback.xml"));
- callbacks.put("create", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyCreateCallback.xml"));
- callbacks.put("activate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyActivateCallback.xml"));
- callbacks.put("query", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml"));
- }
-
- @Test
- public void testDoCreateAllottedResourceTXC_Success() throws Exception{
- logStart();
- // TODO: use INST instead of DEC_INST
- /*
- * should be INST instead of DEC_INST, but AAI utilities appear to
- * have a bug in that they don't URL-encode the SI id before using
- * it in the query
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
-
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, "testRequestId123");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- injectSDNCCallbacks(callbacks, "assign");
- injectSDNCCallbacks(callbacks, "create");
- injectSDNCCallbacks(callbacks, "activate");
- injectSDNCCallbacks(callbacks, "query");
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
-
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- assertEquals(null, workflowException);
-
- assertEquals("namefromrequest", BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
- assertEquals("my-vni", BPMNUtil.getVariable(processEngine, PROCNAME, "vni",processId));
- assertEquals("my-bearer-ip", BPMNUtil.getVariable(processEngine, PROCNAME, "vgmuxBearerIP",processId));
- assertEquals("my-lan-ip", BPMNUtil.getVariable(processEngine, PROCNAME, "vgmuxLanIP",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceTXC_NoSI() throws Exception{
- logStart();
- // TODO: use INST instead of DEC_INST
- /*
- * should be INST instead of DEC_INST, but AAI utilities appear to
- * have a bug in that they don't URL-encode the SI id before using
- * it in the query
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getNotFound.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
-
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, "testRequestId123");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- Assert.assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- assertNotNull(workflowException);
-
- assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceTXC_ActiveAr() throws Exception{
- logStart();
- // TODO: use INST instead of DEC_INST
- /*
- * should be INST instead of DEC_INST, but AAI utilities appear to
- * have a bug in that they don't URL-encode the SI id before using
- * it in the query
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
-
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml");
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, "testRequestId123");
-
- variables.put("failExists", "false");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- injectSDNCCallbacks(callbacks, "query");
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
- assertEquals(null, workflowException);
-
- assertEquals("namefromrequest", BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
- assertEquals("my-vni", BPMNUtil.getVariable(processEngine, PROCNAME, "vni",processId));
- assertEquals("my-bearer-ip", BPMNUtil.getVariable(processEngine, PROCNAME, "vgmuxBearerIP",processId));
- assertEquals("my-lan-ip", BPMNUtil.getVariable(processEngine, PROCNAME, "vgmuxLanIP",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceTXC_NoParentSI() throws Exception{
- logStart();
- // TODO: use INST instead of DEC_INST
- /*
- * should be INST instead of DEC_INST, but AAI utilities appear to
- * have a bug in that they don't URL-encode the SI id before using
- * it in the query
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
-
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getNotFound.xml");
-
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, "testRequestId123");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- assertNotNull(workflowException);
-
- assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceTXC_SubProcessError() throws Exception{
- logStart();
- // TODO: use INST instead of DEC_INST
- /*
- * should be INST instead of DEC_INST, but AAI utilities appear to
- * have a bug in that they don't URL-encode the SI id before using
- * it in the query
- */
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
- MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
-
- MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
- MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
- MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
- mockSDNCAdapter(wireMockServer, 404);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, "testRequestId123");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- assertNotNull(workflowException);
-
- assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
- logEnd();
- }
-
- private void setVariablesSuccess(Map<String, Object> variables, String requestId) {
- // TODO: need all of these?
- variables.put("isDebugLogEnabled", "true");
- variables.put("failExists", "true");
- variables.put("disableRollback", "true");
- variables.put("msoRequestId", requestId);
- variables.put("mso-request-id", "requestId");
- variables.put("sourceNetworkId", "snId");
- variables.put("sourceNetworkRole", "snRole");
- variables.put("allottedResourceRole", "brg");
- variables.put("allottedResourceType", "TXC");
- variables.put("allottedResourceId", ARID);
- variables.put("brgWanMacAddress", "wanmac");
-
- variables.put("serviceInstanceId", DEC_INST);
- variables.put("parentServiceInstanceId", DEC_PARENT_INST);
-
- variables.put("serviceChainServiceInstanceId", "scsiId");
-
- String arModelInfo = "{ "+ "\"modelType\": \"allotted-resource\"," +
- "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," +
- "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," +
- "\"modelName\": \"vSAMP12\"," +
- "\"modelVersion\": \"1.0\"," +
- "\"modelCustomizationUuid\": \"MODEL-ID-1234\"," +
- "}";
- variables.put("allottedResourceModelInfo", arModelInfo);
- }
+ private static final String PROCNAME = "DoCreateAllottedResourceTXC";
+ private final CallbackSet callbacks = new CallbackSet();
+
+ public DoCreateAllottedResourceTXCIT() throws IOException {
+ callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyAssignCallback.xml"));
+ callbacks.put("create", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyCreateCallback.xml"));
+ callbacks.put("activate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyActivateCallback.xml"));
+ callbacks.put("query",
+ FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml"));
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXC_Success() throws Exception {
+ logStart();
+ // TODO: use INST instead of DEC_INST
+ /*
+ * should be INST instead of DEC_INST, but AAI utilities appear to have a bug in that they don't URL-encode the
+ * SI id before using it in the query
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, "testRequestId123");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ injectSDNCCallbacks(callbacks, "assign");
+ injectSDNCCallbacks(callbacks, "create");
+ injectSDNCCallbacks(callbacks, "activate");
+ injectSDNCCallbacks(callbacks, "query");
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ assertEquals(null, workflowException);
+
+ assertEquals("namefromrequest",
+ BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName", processId));
+ assertEquals("my-vni", BPMNUtil.getVariable(processEngine, PROCNAME, "vni", processId));
+ assertEquals("my-bearer-ip", BPMNUtil.getVariable(processEngine, PROCNAME, "vgmuxBearerIP", processId));
+ assertEquals("my-lan-ip", BPMNUtil.getVariable(processEngine, PROCNAME, "vgmuxLanIP", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXC_NoSI() throws Exception {
+ logStart();
+ // TODO: use INST instead of DEC_INST
+ /*
+ * should be INST instead of DEC_INST, but AAI utilities appear to have a bug in that they don't URL-encode the
+ * SI id before using it in the query
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getNotFound.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, "testRequestId123");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ Assert.assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ assertNotNull(workflowException);
+
+ assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXC_ActiveAr() throws Exception {
+ logStart();
+ // TODO: use INST instead of DEC_INST
+ /*
+ * should be INST instead of DEC_INST, but AAI utilities appear to have a bug in that they don't URL-encode the
+ * SI id before using it in the query
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, "testRequestId123");
+
+ variables.put("failExists", "false");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ injectSDNCCallbacks(callbacks, "query");
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
+ assertEquals(null, workflowException);
+
+ assertEquals("namefromrequest",
+ BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName", processId));
+ assertEquals("my-vni", BPMNUtil.getVariable(processEngine, PROCNAME, "vni", processId));
+ assertEquals("my-bearer-ip", BPMNUtil.getVariable(processEngine, PROCNAME, "vgmuxBearerIP", processId));
+ assertEquals("my-lan-ip", BPMNUtil.getVariable(processEngine, PROCNAME, "vgmuxLanIP", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXC_NoParentSI() throws Exception {
+ logStart();
+ // TODO: use INST instead of DEC_INST
+ /*
+ * should be INST instead of DEC_INST, but AAI utilities appear to have a bug in that they don't URL-encode the
+ * SI id before using it in the query
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getNotFound.xml");
+
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, "testRequestId123");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ assertNotNull(workflowException);
+
+ assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXC_SubProcessError() throws Exception {
+ logStart();
+ // TODO: use INST instead of DEC_INST
+ /*
+ * should be INST instead of DEC_INST, but AAI utilities appear to have a bug in that they don't URL-encode the
+ * SI id before using it in the query
+ */
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
+ MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
+
+ MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
+ MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
+ MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
+ mockSDNCAdapter(wireMockServer, 404);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, "testRequestId123");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ assertNotNull(workflowException);
+
+ assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName", processId));
+ logEnd();
+ }
+
+ private void setVariablesSuccess(Map<String, Object> variables, String requestId) {
+ // TODO: need all of these?
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("failExists", "true");
+ variables.put("disableRollback", "true");
+ variables.put("msoRequestId", requestId);
+ variables.put("mso-request-id", "requestId");
+ variables.put("sourceNetworkId", "snId");
+ variables.put("sourceNetworkRole", "snRole");
+ variables.put("allottedResourceRole", "brg");
+ variables.put("allottedResourceType", "TXC");
+ variables.put("allottedResourceId", ARID);
+ variables.put("brgWanMacAddress", "wanmac");
+
+ variables.put("serviceInstanceId", DEC_INST);
+ variables.put("parentServiceInstanceId", DEC_PARENT_INST);
+
+ variables.put("serviceChainServiceInstanceId", "scsiId");
+
+ String arModelInfo = "{ " + "\"modelType\": \"allotted-resource\","
+ + "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\","
+ + "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + "\"modelName\": \"vSAMP12\","
+ + "\"modelVersion\": \"1.0\"," + "\"modelCustomizationUuid\": \"MODEL-ID-1234\"," + "}";
+ variables.put("allottedResourceModelInfo", arModelInfo);
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java
index 4f81a4f725..0b64f4938e 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackIT.java
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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
+ * 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.
+ * 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=========================================================
*/
@@ -24,12 +19,10 @@ import org.junit.Test;
import org.onap.so.bpmn.common.BPMNUtil;
import org.onap.so.bpmn.core.RollbackData;
import org.onap.so.bpmn.mock.FileUtil;
-
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -43,281 +36,295 @@ import static org.onap.so.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
public class DoCreateAllottedResourceTXCRollbackIT extends AbstractTestBase {
- private static final String PROCNAME = "DoCreateAllottedResourceTXCRollback";
- private static final String RbType = "DCARTXC_";
- private final CallbackSet callbacks = new CallbackSet();
-
- public DoCreateAllottedResourceTXCRollbackIT() throws IOException {
- callbacks.put("deactivate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
- callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
- callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
- }
-
- @Test
- public void testDoCreateAllottedResourceTXCRollback_Success() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, businessKey);
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- injectSDNCCallbacks(callbacks, "deactivate");
- injectSDNCCallbacks(callbacks, "delete");
- injectSDNCCallbacks(callbacks, "unassign");
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceTXCRollback_skipRollback() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
-
- rollbackData.put(RbType, "rollbackAAI", "false");
- rollbackData.put(RbType, "rollbackSDNCassign", "false");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceTXCRollback_DoNotRollBack() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
-
- // this will cause "rollbackSDNC" to be set to false
- rollbackData.put(RbType, "rollbackSDNCassign", "false");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceTXCRollback_NoDeactivate() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
-
- rollbackData.put(RbType, "rollbackSDNCactivate", "false");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- injectSDNCCallbacks(callbacks, "delete");
- injectSDNCCallbacks(callbacks, "unassign");
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceTXCRollback_NoDelete() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
-
- rollbackData.put(RbType, "rollbackSDNCcreate", "false");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- injectSDNCCallbacks(callbacks, "deactivate");
- injectSDNCCallbacks(callbacks, "unassign");
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceTXCRollback_NoUnassign() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
-
- rollbackData.put(RbType, "rollbackSDNCassign", "false");
-
- /*
- * Note: if assign == false then the flow/script will set
- * "skipRollback" to false, which will cause ALL of the SDNC steps
- * to be skipped, not just the unassign step.
- */
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceTXCRollback_SubProcessError() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- mockSDNCAdapter(wireMockServer, 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, businessKey);
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("false", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNotNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- @Test
- public void testDoCreateAllottedResourceTXCRollback_JavaException() throws Exception {
- logStart();
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables, businessKey);
-
- variables.put("rollbackData", "string instead of rollback data");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- waitForWorkflowToFinish(processEngine,processId);
-
- assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
- System.out.println("workflowException:\n" + workflowException);
- assertEquals(null, workflowException);
- assertEquals("false", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack",processId));
- assertNotNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError",processId));
- logEnd();
- }
-
- private RollbackData setVariablesSuccess(Map<String, Object> variables, String requestId) {
- variables.put("isDebugLogEnabled", "true");
- variables.put("failNotFound", "true");
- variables.put("msoRequestId", requestId);
- variables.put("mso-request-id", "requestId");
- variables.put("allottedResourceId", ARID);
-
- variables.put("serviceInstanceId", DEC_INST);
- variables.put("parentServiceInstanceId", DEC_PARENT_INST);
-
- RollbackData rollbackData = new RollbackData();
-
- rollbackData.put(RbType, "serviceInstanceId", DEC_INST);
- rollbackData.put(RbType, "serviceSubscriptionType", SVC);
- rollbackData.put(RbType, "disablerollback", "false");
- rollbackData.put(RbType, "rollbackAAI", "true");
- rollbackData.put(RbType, "rollbackSDNCassign", "true");
- rollbackData.put(RbType, "rollbackSDNCactivate", "true");
- rollbackData.put(RbType, "rollbackSDNCcreate", "true");
- rollbackData.put(RbType, "aaiARPath", "/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID);
-
- rollbackData.put(RbType, "sdncActivateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncActivateRollbackReq.xml"));
- rollbackData.put(RbType, "sdncCreateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncCreateRollbackReq.xml"));
- rollbackData.put(RbType, "sdncAssignRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncAssignRollbackReq.xml"));
-
- variables.put("rollbackData",rollbackData);
-
- return rollbackData;
- }
+ private static final String PROCNAME = "DoCreateAllottedResourceTXCRollback";
+ private static final String RbType = "DCARTXC_";
+ private final CallbackSet callbacks = new CallbackSet();
+
+ public DoCreateAllottedResourceTXCRollbackIT() throws IOException {
+ callbacks.put("deactivate",
+ FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
+ callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
+ callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXCRollback_Success() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, businessKey);
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ injectSDNCCallbacks(callbacks, "deactivate");
+ injectSDNCCallbacks(callbacks, "delete");
+ injectSDNCCallbacks(callbacks, "unassign");
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXCRollback_skipRollback() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
+
+ rollbackData.put(RbType, "rollbackAAI", "false");
+ rollbackData.put(RbType, "rollbackSDNCassign", "false");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXCRollback_DoNotRollBack() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
+
+ // this will cause "rollbackSDNC" to be set to false
+ rollbackData.put(RbType, "rollbackSDNCassign", "false");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXCRollback_NoDeactivate() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
+
+ rollbackData.put(RbType, "rollbackSDNCactivate", "false");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ injectSDNCCallbacks(callbacks, "delete");
+ injectSDNCCallbacks(callbacks, "unassign");
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXCRollback_NoDelete() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
+
+ rollbackData.put(RbType, "rollbackSDNCcreate", "false");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ injectSDNCCallbacks(callbacks, "deactivate");
+ injectSDNCCallbacks(callbacks, "unassign");
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXCRollback_NoUnassign() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ RollbackData rollbackData = setVariablesSuccess(variables, businessKey);
+
+ rollbackData.put(RbType, "rollbackSDNCassign", "false");
+
+ /*
+ * Note: if assign == false then the flow/script will set "skipRollback" to false, which will cause ALL of the
+ * SDNC steps to be skipped, not just the unassign step.
+ */
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXCRollback_SubProcessError() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ mockSDNCAdapter(wireMockServer, 404);
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, businessKey);
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("false", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNotNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ @Test
+ public void testDoCreateAllottedResourceTXCRollback_JavaException() throws Exception {
+ logStart();
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables, businessKey);
+
+ variables.put("rollbackData", "string instead of rollback data");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ waitForWorkflowToFinish(processEngine, processId);
+
+ assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX, processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertEquals(null, workflowException);
+ assertEquals("false", BPMNUtil.getVariable(processEngine, PROCNAME, "rolledBack", processId));
+ assertNotNull(BPMNUtil.getVariable(processEngine, PROCNAME, "rollbackError", processId));
+ logEnd();
+ }
+
+ private RollbackData setVariablesSuccess(Map<String, Object> variables, String requestId) {
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("failNotFound", "true");
+ variables.put("msoRequestId", requestId);
+ variables.put("mso-request-id", "requestId");
+ variables.put("allottedResourceId", ARID);
+
+ variables.put("serviceInstanceId", DEC_INST);
+ variables.put("parentServiceInstanceId", DEC_PARENT_INST);
+
+ RollbackData rollbackData = new RollbackData();
+
+ rollbackData.put(RbType, "serviceInstanceId", DEC_INST);
+ rollbackData.put(RbType, "serviceSubscriptionType", SVC);
+ rollbackData.put(RbType, "disablerollback", "false");
+ rollbackData.put(RbType, "rollbackAAI", "true");
+ rollbackData.put(RbType, "rollbackSDNCassign", "true");
+ rollbackData.put(RbType, "rollbackSDNCactivate", "true");
+ rollbackData.put(RbType, "rollbackSDNCcreate", "true");
+ rollbackData.put(RbType, "aaiARPath",
+ "/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC
+ + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/"
+ + ARID);
+
+ rollbackData.put(RbType, "sdncActivateRollbackReq", FileUtil
+ .readResourceFile("__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncActivateRollbackReq.xml"));
+ rollbackData.put(RbType, "sdncCreateRollbackReq", FileUtil
+ .readResourceFile("__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncCreateRollbackReq.xml"));
+ rollbackData.put(RbType, "sdncAssignRollbackReq", FileUtil
+ .readResourceFile("__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncAssignRollbackReq.xml"));
+
+ variables.put("rollbackData", rollbackData);
+
+ return rollbackData;
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceBRGIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceBRGIT.java
index 42f32b8ecc..e4dc5add03 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceBRGIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceBRGIT.java
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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
+ * 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.
+ * 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=========================================================
*/
@@ -24,11 +19,9 @@ import org.junit.Assert;
import org.junit.Test;
import org.onap.so.bpmn.common.BPMNUtil;
import org.onap.so.bpmn.mock.FileUtil;
-
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import static org.junit.Assert.*;
import static org.onap.so.bpmn.mock.StubResponseAAI.*;
import static org.onap.so.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
@@ -37,109 +30,114 @@ import static org.onap.so.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
public class DoDeleteAllottedResourceBRGIT extends AbstractTestBase {
- private static final String PROCNAME = "DoDeleteAllottedResourceBRG";
- private final CallbackSet callbacks = new CallbackSet();
-
- public DoDeleteAllottedResourceBRGIT() {
- callbacks.put("deactivate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
- callbacks.put("deactivateNF", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml"));
- callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
- callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
- }
-
- @Test
- public void testDoDeleteAllottedResourceBRG_Success() {
- logStart();
- MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables);
-
- invokeSubProcess(PROCNAME, businessKey, variables);
-
- injectSDNCCallbacks(callbacks, "deactivate");
- injectSDNCCallbacks(callbacks, "delete");
- injectSDNCCallbacks(callbacks, "unassign");
-
- waitForProcessEnd(businessKey, 10000);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
- System.out.println("workflowException:\n" + workflowException);
- assertNull(workflowException);
- logEnd();
- }
-
- @Test
- public void testDoDeleteAllottedResourceBRG_ARNotInSDNC() {
- logStart();
- MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables);
-
- variables.put("failNotFound", "false");
-
- invokeSubProcess(PROCNAME, businessKey, variables);
-
- injectSDNCCallbacks(callbacks, "deactivateNF");
-
- waitForProcessEnd(businessKey, 10000);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
- System.out.println("workflowException:\n" + workflowException);
- assertNull(workflowException);
- logEnd();
- }
-
-
- @Test
- public void testDoDeleteAllottedResourceBRG_SubProcessError() throws Exception {
- logStart();
- MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- mockSDNCAdapter(wireMockServer, 500);
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables);
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
-
- BPMNUtil.waitForWorkflowToFinish(processEngine,processId);
-
- Assert.assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, "WorkflowException",processId);
- System.out.println("workflowException:\n" + workflowException);
- assertNotNull(workflowException);
- logEnd();
- }
-
- private void setVariablesSuccess(Map<String, Object> variables) {
- variables.put("isDebugLogEnabled", "true");
- variables.put("failNotFound", "true");
- variables.put("msoRequestId", "testRequestId1");
- variables.put("mso-request-id", "requestId");
- variables.put("allottedResourceId", ARID);
- variables.put("serviceInstanceId", DEC_INST);
- variables.put("parentServiceInstanceId", DEC_PARENT_INST);
- }
+ private static final String PROCNAME = "DoDeleteAllottedResourceBRG";
+ private final CallbackSet callbacks = new CallbackSet();
+
+ public DoDeleteAllottedResourceBRGIT() {
+ callbacks.put("deactivate",
+ FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
+ callbacks.put("deactivateNF",
+ FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml"));
+ callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
+ callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
+ }
+
+ @Test
+ public void testDoDeleteAllottedResourceBRG_Success() {
+ logStart();
+ MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables);
+
+ invokeSubProcess(PROCNAME, businessKey, variables);
+
+ injectSDNCCallbacks(callbacks, "deactivate");
+ injectSDNCCallbacks(callbacks, "delete");
+ injectSDNCCallbacks(callbacks, "unassign");
+
+ waitForProcessEnd(businessKey, 10000);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
+ System.out.println("workflowException:\n" + workflowException);
+ assertNull(workflowException);
+ logEnd();
+ }
+
+ @Test
+ public void testDoDeleteAllottedResourceBRG_ARNotInSDNC() {
+ logStart();
+ MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ String businessKey = UUID.randomUUID().toString();
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables);
+
+ variables.put("failNotFound", "false");
+
+ invokeSubProcess(PROCNAME, businessKey, variables);
+
+ injectSDNCCallbacks(callbacks, "deactivateNF");
+
+ waitForProcessEnd(businessKey, 10000);
+
+ Assert.assertTrue(isProcessEnded(businessKey));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
+ System.out.println("workflowException:\n" + workflowException);
+ assertNull(workflowException);
+ logEnd();
+ }
+
+
+ @Test
+ public void testDoDeleteAllottedResourceBRG_SubProcessError() throws Exception {
+ logStart();
+ MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ mockSDNCAdapter(wireMockServer, 500);
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables);
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+
+ BPMNUtil.waitForWorkflowToFinish(processEngine, processId);
+
+ Assert.assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, "WorkflowException", processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertNotNull(workflowException);
+ logEnd();
+ }
+
+ private void setVariablesSuccess(Map<String, Object> variables) {
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("failNotFound", "true");
+ variables.put("msoRequestId", "testRequestId1");
+ variables.put("mso-request-id", "requestId");
+ variables.put("allottedResourceId", ARID);
+ variables.put("serviceInstanceId", DEC_INST);
+ variables.put("parentServiceInstanceId", DEC_PARENT_INST);
+ }
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceTXCIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceTXCIT.java
index 13ca58be03..106c2f0611 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceTXCIT.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/vcpe/DoDeleteAllottedResourceTXCIT.java
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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
+ * 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.
+ * 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=========================================================
*/
@@ -24,10 +19,8 @@ import org.junit.Assert;
import org.junit.Test;
import org.onap.so.bpmn.common.BPMNUtil;
import org.onap.so.bpmn.mock.FileUtil;
-
import java.util.HashMap;
import java.util.Map;
-
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.onap.so.bpmn.mock.StubResponseAAI.*;
@@ -37,104 +30,109 @@ import static org.onap.so.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
public class DoDeleteAllottedResourceTXCIT extends AbstractTestBase {
- private static final String PROCNAME = "DoDeleteAllottedResourceTXC";
- private final CallbackSet callbacks = new CallbackSet();
-
- public DoDeleteAllottedResourceTXCIT() {
- callbacks.put("deactivate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
- callbacks.put("deactivateNF", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml"));
- callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
- callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
- }
-
- @Test
- public void testDoDeleteAllottedResourceTXC_Success() throws Exception {
- logStart();
- MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables);
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- injectSDNCCallbacks(callbacks, "deactivate");
- injectSDNCCallbacks(callbacks, "delete");
- injectSDNCCallbacks(callbacks, "unassign");
-
- BPMNUtil.waitForWorkflowToFinish(processEngine,processId);
-
- Assert.assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, "WorkflowException",processId);
- System.out.println("workflowException:\n" + workflowException);
- assertNull(workflowException);
- logEnd();
- }
-
- @Test
- public void testDoDeleteAllottedResourceTXC_ARNotInSDNC() throws Exception {
- logStart();
- MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockSDNCAdapter(wireMockServer, 200);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables);
-
- variables.put("failNotFound", "false");
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- injectSDNCCallbacks(callbacks, "deactivateNF");
-
- BPMNUtil.waitForWorkflowToFinish(processEngine,processId);
-
- Assert.assertTrue(isProcessEndedByProcessInstanceId(processId));
- logEnd();
- }
-
-
- @Test
- public void testDoDeleteAllottedResourceTXC_SubProcessError() throws Exception {
- logStart();
- MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
- MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
- MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
- MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
- mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
-
- mockSDNCAdapter(wireMockServer, 500);
-
- Map<String, Object> variables = new HashMap<>();
- setVariablesSuccess(variables);
-
- String processId = invokeSubProcess(PROCNAME, variables);
-
- BPMNUtil.waitForWorkflowToFinish(processEngine,processId);
-
- Assert.assertTrue(isProcessEndedByProcessInstanceId(processId));
- String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, "WorkflowException",processId);
- System.out.println("workflowException:\n" + workflowException);
- assertNotNull(workflowException);
- logEnd();
- }
-
- private void setVariablesSuccess(Map<String, Object> variables) {
- variables.put("isDebugLogEnabled", "true");
- variables.put("failNotFound", "true");
- variables.put("msoRequestId", "testRequestId1");
- variables.put("mso-request-id", "requestId");
- variables.put("allottedResourceId", ARID);
-
- variables.put("serviceInstanceId", DEC_INST);
- variables.put("parentServiceInstanceId", DEC_PARENT_INST);
- }
+ private static final String PROCNAME = "DoDeleteAllottedResourceTXC";
+ private final CallbackSet callbacks = new CallbackSet();
+
+ public DoDeleteAllottedResourceTXCIT() {
+ callbacks.put("deactivate",
+ FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
+ callbacks.put("deactivateNF",
+ FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml"));
+ callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
+ callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
+ }
+
+ @Test
+ public void testDoDeleteAllottedResourceTXC_Success() throws Exception {
+ logStart();
+ MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables);
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ injectSDNCCallbacks(callbacks, "deactivate");
+ injectSDNCCallbacks(callbacks, "delete");
+ injectSDNCCallbacks(callbacks, "unassign");
+
+ BPMNUtil.waitForWorkflowToFinish(processEngine, processId);
+
+ Assert.assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, "WorkflowException", processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertNull(workflowException);
+ logEnd();
+ }
+
+ @Test
+ public void testDoDeleteAllottedResourceTXC_ARNotInSDNC() throws Exception {
+ logStart();
+ MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockSDNCAdapter(wireMockServer, 200);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables);
+
+ variables.put("failNotFound", "false");
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ injectSDNCCallbacks(callbacks, "deactivateNF");
+
+ BPMNUtil.waitForWorkflowToFinish(processEngine, processId);
+
+ Assert.assertTrue(isProcessEndedByProcessInstanceId(processId));
+ logEnd();
+ }
+
+
+ @Test
+ public void testDoDeleteAllottedResourceTXC_SubProcessError() throws Exception {
+ logStart();
+ MockQueryAllottedResourceById(wireMockServer, ARID, "GenericFlows/getARUrlById.xml");
+ MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID,
+ "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
+ MockPatchAllottedResource(wireMockServer, CUST, SVC, INST, ARID);
+ MockDeleteAllottedResource(wireMockServer, CUST, SVC, INST, ARID, ARVERS);
+ mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
+
+ mockSDNCAdapter(wireMockServer, 500);
+
+ Map<String, Object> variables = new HashMap<>();
+ setVariablesSuccess(variables);
+
+ String processId = invokeSubProcess(PROCNAME, variables);
+
+ BPMNUtil.waitForWorkflowToFinish(processEngine, processId);
+
+ Assert.assertTrue(isProcessEndedByProcessInstanceId(processId));
+ String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, "WorkflowException", processId);
+ System.out.println("workflowException:\n" + workflowException);
+ assertNotNull(workflowException);
+ logEnd();
+ }
+
+ private void setVariablesSuccess(Map<String, Object> variables) {
+ variables.put("isDebugLogEnabled", "true");
+ variables.put("failNotFound", "true");
+ variables.put("msoRequestId", "testRequestId1");
+ variables.put("mso-request-id", "requestId");
+ variables.put("allottedResourceId", ARID);
+
+ variables.put("serviceInstanceId", DEC_INST);
+ variables.put("parentServiceInstanceId", DEC_PARENT_INST);
+ }
}