summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml17
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml17
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml80
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java33
-rwxr-xr-xadapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java54
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java51
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java34
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml31
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java55
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml19
-rw-r--r--adapters/mso-vnfm-adapter/pom.xml22
-rw-r--r--adapters/pom.xml1
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy28
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy14
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy64
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy36
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy76
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy76
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy24
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy50
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy110
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy65
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DecomposeService.groovy39
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy69
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy78
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy39
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy170
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy50
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericNotificationService.groovy8
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy124
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy36
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy111
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy60
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy62
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RainyDayHandler.groovy61
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy44
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy88
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy91
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy81
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy97
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy46
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroUtils.groovy28
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy136
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy61
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy42
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModule.groovy10
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy42
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy28
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy96
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy18
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy1
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy2555
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy1267
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy1184
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy1818
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy1180
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy1667
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy1028
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy1020
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy139
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy49
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy53
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTestsTestSuite.java6
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json2
-rw-r--r--common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java10
-rw-r--r--common/src/test/java/org/onap/so/serviceinstancebeans/RequestStatusTest.java43
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java17
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java66
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json6
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java1
-rw-r--r--packages/docker/pom.xml30
76 files changed, 7576 insertions, 7355 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml
new file mode 100644
index 0000000000..c24c45c8cf
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml
@@ -0,0 +1,17 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.so.adapters</groupId>
+ <artifactId>mso-vnfm-adapter</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>mso-vnfm-adapter-api</artifactId>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
+ <name>mso-vnfm-adapter-api</name>
+ <description>MSO VNFM adapter API</description>
+</project>
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml
new file mode 100644
index 0000000000..0cf1ce72e2
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml
@@ -0,0 +1,17 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.so.adapters</groupId>
+ <artifactId>mso-vnfm-adapter</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>mso-vnfm-adapter-ext-clients</artifactId>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
+ <name>mso-vnfm-adapter-ext-clients</name>
+ <description>Clients for the vnfm adpater to use towards REST endpoints which are external to the VNFM adapter/</description>
+</project>
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml
new file mode 100644
index 0000000000..4554835b33
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml
@@ -0,0 +1,80 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.so.adapters</groupId>
+ <artifactId>mso-vnfm-adapter</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>mso-vnfm-etsi-adapter</artifactId>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
+ <name>mso-vnfm-etsi-adapter</name>
+ <description>MSO ETSI compliant VNFM Adapter</description>
+
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+ <mainClass>org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication</mainClass>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>original</id>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-security</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-tomcat</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so.adapters</groupId>
+ <artifactId>mso-adapters-rest-interface</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java
new file mode 100644
index 0000000000..cdf7de869e
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter;
+
+/**
+ * Adapter constants
+ */
+public class Constants {
+
+ public static final String SERVICE_NAME = "vnfm-adapter";
+ public static final String SERVICE_VERSION = "v1";
+ public static final String BASE_URL = "/so/" + SERVICE_NAME + "/" + SERVICE_VERSION;
+
+ private Constants() {}
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
new file mode 100755
index 0000000000..024e936cfb
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import org.onap.so.adapters.vnfmadapter.rest.VnfmAdapterController;
+import org.slf4j.Logger;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * The spring boot application for the VNFM (Virtual Network Function Manager) Adapter.
+ * <p>
+ * The VNFM Adapter receives requests through its REST API {@link VnfmAdapterController} which it adapts
+ * into ETSI SOL003 compliant LCM (Life Cycle Management) calls towards an ETSI compliant VNFM.
+ *
+ * @see <a href=
+ * "https://www.etsi.org/deliver/etsi_gs/NFV-SOL/001_099/003/02.05.01_60/gs_nfv-sol003v020501p.pdf">ETSI
+ * SOL003 v2.5.1</a>
+ */
+@SpringBootApplication(scanBasePackages = {"org.onap.so"})
+public class VnfmAdapterApplication {
+ private static final Logger logger = getLogger(VnfmAdapterApplication.class);
+
+
+ /**
+ * Entry point for the Spring boot application
+ *
+ * @param args arguments for the application
+ */
+ public static void main(final String[] args) {
+ new SpringApplication(VnfmAdapterApplication.class).run(args);
+ logger.info("VnfmAdapterApplication started!");
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java
new file mode 100644
index 0000000000..6baa672535
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter;
+
+import org.onap.so.security.MSOSpringFirewall;
+import org.onap.so.security.WebSecurityConfig;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.builders.WebSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.web.firewall.StrictHttpFirewall;
+import org.springframework.util.StringUtils;
+
+/**
+ * Configure the web security for the application.
+ */
+@EnableWebSecurity
+public class WebSecurityConfigImpl extends WebSecurityConfig {
+
+ @Override
+ protected void configure(final HttpSecurity http) throws Exception {
+ http.csrf().disable().authorizeRequests().antMatchers("/manage/health","/manage/info").permitAll()
+ .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and()
+ .httpBasic();
+ }
+
+ @Override
+ public void configure(final WebSecurity web) throws Exception {
+ super.configure(web);
+ final StrictHttpFirewall firewall = new MSOSpringFirewall();
+ web.httpFirewall(firewall);
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java
new file mode 100644
index 0000000000..4dabec3e9b
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.rest;
+
+import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Controller for handling requests to the VNFM (Virtual Network Function Manager) adapter REST API.
+ */
+@Controller
+@RequestMapping(value = BASE_URL)
+public class VnfmAdapterController {
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml
new file mode 100644
index 0000000000..7719c0c98c
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml
@@ -0,0 +1,31 @@
+# Copyright © 2019 Nordix Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+server:
+ port: 9092
+ tomcat:
+ max-threads: 50
+
+#Actuator
+management:
+ endpoints:
+ web:
+ base-path: /manage
+ exposure:
+ include: "*"
+ metrics:
+ se-global-registry: false
+ export:
+ prometheus:
+ enabled: true # Whether exporting of metrics to Prometheus is enabled.
+ step: 1m # Step size (i.e. reporting frequency) to use.
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java
new file mode 100644
index 0000000000..ee22e03f87
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.rest;
+
+import static org.junit.Assert.assertEquals;
+import java.net.URI;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.http.RequestEntity;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class HealthCheckTest {
+
+ @LocalServerPort
+ private int port;
+
+ private final TestRestTemplate restTemplate = new TestRestTemplate();
+
+ @Test
+ public void testHealthcheck() throws Exception {
+ final RequestEntity<Void> request =
+ RequestEntity.get(new URI("http://localhost:" + port + "/manage/health")).build();
+ final ResponseEntity<Void> response = restTemplate.exchange(request, Void.class);
+ assertEquals(200, response.getStatusCode().value());
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml
new file mode 100644
index 0000000000..cc5a068d69
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml
@@ -0,0 +1,19 @@
+# Copyright © 2019 Nordix Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+spring:
+ security:
+ usercredentials:
+ - username: test
+ password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu'
+ role: BPEL-Client \ No newline at end of file
diff --git a/adapters/mso-vnfm-adapter/pom.xml b/adapters/mso-vnfm-adapter/pom.xml
new file mode 100644
index 0000000000..9cc17056c2
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/pom.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.so</groupId>
+ <artifactId>adapters</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.onap.so.adapters</groupId>
+ <artifactId>mso-vnfm-adapter</artifactId>
+ <name>MSO VNFM Adapter</name>
+ <description>MSO Adapter for VNFM</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>mso-vnfm-adapter-api</module>
+ <module>mso-vnfm-adapter-ext-clients</module>
+ <module>mso-vnfm-etsi-adapter</module>
+ </modules>
+</project>
diff --git a/adapters/pom.xml b/adapters/pom.xml
index 634a1616e6..d00304b837 100644
--- a/adapters/pom.xml
+++ b/adapters/pom.xml
@@ -20,6 +20,7 @@
<module>mso-catalog-db-adapter</module>
<module>mso-vfc-adapter</module>
<module>mso-openstack-adapters</module>
+ <module>mso-vnfm-adapter</module>
</modules>
<dependencies>
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy
index 8a8e41247c..b9053b75da 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -38,12 +40,14 @@ import org.onap.so.client.aai.AAIVersion
import org.onap.so.client.aai.entities.uri.AAIUri
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import org.onap.so.openpojo.rules.HasToStringRule
import org.onap.so.utils.TargetEntity
@Deprecated
class AaiUtil {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AaiUtil.class);
+ private static final Logger logger = LoggerFactory.getLogger( AaiUtil.class);
public MsoUtils utils = new MsoUtils()
@@ -101,14 +105,14 @@ class AaiUtil {
String returnCode = apiResponse.getStatus()
String aaiResponseAsString = apiResponse.readEntity(String.class)
- msoLogger.debug("Call AAI Cloud Region Return code: " + returnCode)
+ logger.debug("Call AAI Cloud Region Return code: " + returnCode)
execution.setVariable(execution.getVariable("prefix")+"queryCloudRegionReturnCode", returnCode)
if(returnCode == "200"){
- msoLogger.debug("Call AAI Cloud Region is Successful.")
+ logger.debug("Call AAI Cloud Region is Successful.")
String regionVersion = taskProcessor.utils.getNodeText(aaiResponseAsString, "cloud-region-version")
- msoLogger.debug("Cloud Region Version from AAI for " + backend + " is: " + regionVersion)
+ logger.debug("Cloud Region Version from AAI for " + backend + " is: " + regionVersion)
if (backend == "PO") {
regionId = taskProcessor.utils.getNodeText(aaiResponseAsString, "cloud-region-id")
} else { // backend not "PO"
@@ -121,20 +125,24 @@ class AaiUtil {
if(regionId == null){
throw new BpmnError("MSOWorkflowException")
}
- msoLogger.debug("Cloud Region Id from AAI " + backend + " is: " + regionId)
+ logger.debug("Cloud Region Id from AAI " + backend + " is: " + regionId)
}else if (returnCode == "404"){ // not 200
if (backend == "PO") {
regionId = inputCloudRegion
}else{ // backend not "PO"
regionId = "AAIAIC25"
}
- msoLogger.debug("Cloud Region value for code='404' of " + backend + " is: " + regionId)
+ logger.debug("Cloud Region value for code='404' of " + backend + " is: " + regionId)
}else{
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Call AAI Cloud Region is NOT Successful.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Call AAI Cloud Region is NOT Successful.", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue());
throw new BpmnError("MSOWorkflowException")
}
}catch(Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while getting the Cloud Reqion.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.getMessage());
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception occured while getting the Cloud Reqion.", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e.getMessage());
(new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())
}
return regionId
@@ -157,7 +165,7 @@ class AaiUtil {
if (aaiVnfResponse != null) {
String vfModulesText = taskProcessor.utils.getNodeXml(aaiVnfResponse, "vf-modules")
if (aaiVnfResponse.getVfModules() == null || aaiVnfResponse.getVfModules().getVfModule().isEmpty()) {
- msoLogger.debug("There are no VF modules in this VNF yet")
+ logger.debug("There are no VF modules in this VNF yet")
return 0
}
else {
@@ -176,7 +184,7 @@ class AaiUtil {
}
}
matchingVfModules = matchingVfModules + "</vfModules>"
- msoLogger.debug("Matching VF Modules: " + matchingVfModules)
+ logger.debug("Matching VF Modules: " + matchingVfModules)
String lowestUnusedIndex = taskProcessor.utils.getLowestUnusedIndex(matchingVfModules)
return Integer.parseInt(lowestUnusedIndex)
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy
index 57af763ed5..c700fa70e1 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy
@@ -387,7 +387,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
/**
* Returns the process definition key (i.e. the process name) of the
* current process.
- *
+ *
* @param execution the execution
*/
public String getProcessKey(DelegateExecution execution) {
@@ -718,19 +718,19 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
'/' + UriUtils.encodePathSegment(messageType, 'UTF-8') +
'/' + UriUtils.encodePathSegment(correlator, 'UTF-8')
}
-
+
public void setRollbackEnabled(DelegateExecution execution, isDebugLogEnabled) {
-
+
// Rollback settings
def prefix = execution.getVariable('prefix')
def disableRollback = execution.getVariable("disableRollback")
def defaultRollback = UrnPropertiesReader.getVariable("mso.rollback", execution).toBoolean()
-
+
logDebug('disableRollback: ' + disableRollback, isDebugLogEnabled)
logDebug('defaultRollback: ' + defaultRollback, isDebugLogEnabled)
-
+
def rollbackEnabled
-
+
if(disableRollback == null || disableRollback == '' ) {
// get from default urn settings for mso_rollback
disableRollback = !defaultRollback
@@ -752,7 +752,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess
execution.setVariable(prefix+"backoutOnFailure", rollbackEnabled)
logDebug('rollbackEnabled (aka backoutOnFailure): ' + rollbackEnabled, isDebugLogEnabled)
}
-
+
public void setBasicDBAuthHeader(DelegateExecution execution, isDebugLogEnabled) {
try {
String basicAuthValueDB = UrnPropertiesReader.getVariable("mso.adapters.db.auth", execution)
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy
index a43a2b1f89..d0967cc327 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -39,11 +41,13 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
class AllottedResourceUtils {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AllottedResourceUtils.class);
+ private static final Logger logger = LoggerFactory.getLogger( AllottedResourceUtils.class);
private AbstractServiceTaskProcessor taskProcessor
@@ -65,7 +69,7 @@ class AllottedResourceUtils {
*/
public String getAROrchStatus (DelegateExecution execution) {
- msoLogger.trace("getAROrchStatus ")
+ logger.trace("getAROrchStatus ")
String msg = ""
String serviceInstanceId = execution.getVariable("serviceInstanceId")
String arType = execution.getVariable("allottedResourceType")
@@ -73,7 +77,7 @@ class AllottedResourceUtils {
String siXml = execution.getVariable("CSI_service")
String orchStatus = null
XmlParser xmlParser = new XmlParser()
- msoLogger.debug("getAROrchStatus siXml:" + siXml)
+ logger.debug("getAROrchStatus siXml:" + siXml)
try {
if (!isBlank(siXml)) {
def groovy.util.Node siNode = xmlParser.parseText(siXml)
@@ -83,7 +87,7 @@ class AllottedResourceUtils {
for (groovy.util.Node relationship in relationships) {
def groovy.util.Node relatedTo = utils.getChildNode(relationship, 'related-to')
if ((relatedTo != null) && (relatedTo.text().equals('allotted-resource'))) {
- msoLogger.debug("getARORchStatus AR found")
+ logger.debug("getARORchStatus AR found")
def groovy.util.Node relatedLink = utils.getChildNode(relationship, 'related-link')
if (relatedLink != null){
Optional<AllottedResource> ar = getARbyLink(execution, relatedLink.text(), arRole)
@@ -97,10 +101,10 @@ class AllottedResourceUtils {
}
}
}catch(Exception e){
- msoLogger.debug(" Error encountered in getAROrchStatus" + e.getMessage())
+ logger.debug(" Error encountered in getAROrchStatus" + e.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in getAROrchStatus" + e.getMessage())
}
- msoLogger.trace(" Exit getAROrchStatus - OrchStatus:" + orchStatus)
+ logger.trace(" Exit getAROrchStatus - OrchStatus:" + orchStatus)
return orchStatus
}
@@ -108,7 +112,7 @@ class AllottedResourceUtils {
// used on Delete - called from doDeleteAR
// setsVariable aaiARGetResponse
public boolean ifExistsAR(DelegateExecution execution, String allottedResourceId) {
- msoLogger.trace("ifExistsAR ")
+ logger.trace("ifExistsAR ")
try {
AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId)
AAIResultWrapper wrapper = getAAIClient().get(resourceUri)
@@ -127,24 +131,24 @@ class AllottedResourceUtils {
public String getPSIFmARLink(DelegateExecution execution, String arLink)
{
// Path: /aai/{version}/business/customers/customer/{cust}/service-subscriptions/service-subscription/{subs}/service-instances/service-instance/{psiid}/allotted-resources/allotted-resource/{arid}
- msoLogger.trace(" getPSIFmARLink - path:" + arLink)
+ logger.trace(" getPSIFmARLink - path:" + arLink)
String[] split = arLink.split("/service-instance/")
String[] splitB = split[1].split("/allotted-resources/")
String siId = splitB[0]
- msoLogger.trace(" Exit getPSIFmARLink - parentServiceInstanceId:" + siId )
+ logger.trace(" Exit getPSIFmARLink - parentServiceInstanceId:" + siId )
return siId
}
-
+
// get Allotted resource using Link
// used on Create called from getARORchStatus
// used on Delete called from ifExistsAR
// setsVariable aaiARPath - used for Patch in create
-
+
public Optional<AllottedResource> getARbyLink (DelegateExecution execution, String link, String role) {
- msoLogger.trace("getARbyLink ")
+ logger.trace("getARbyLink ")
Optional<AllottedResource> allottedResource = Optional.empty()
try {
- msoLogger.debug("GET AR Aai Path is: \n" + link)
+ logger.debug("GET AR Aai Path is: \n" + link)
AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(link).build())
allottedResource = getAAIClient().get(AllottedResource.class,uri);
if(allottedResource.isPresent()) {
@@ -152,16 +156,16 @@ class AllottedResourceUtils {
if (role == allottedResource.get().getRole()) {
setExecutionVariables(execution,allottedResource.get(),uri)
} else {
- msoLogger.debug("AAI AR does not match input role:" + role)
+ logger.debug("AAI AR does not match input role:" + role)
}
} else {
setExecutionVariables(execution,allottedResource.get(),uri)
}
}else{
- msoLogger.debug("GET AR received a Not Found (404) Response")
+ logger.debug("GET AR received a Not Found (404) Response")
}
}catch(Exception e){
- msoLogger.debug(" Error encountered within GetAaiAR" + e.getMessage())
+ logger.debug(" Error encountered within GetAaiAR" + e.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetAaiAR" + e.getMessage())
}
return allottedResource
@@ -181,45 +185,47 @@ class AllottedResourceUtils {
}
public void updateAROrchStatus(DelegateExecution execution, String status, String aaiARPath){
- msoLogger.trace("updaAROrchStatus ")
+ logger.trace("updaAROrchStatus ")
try{
AllottedResource allottedResource = new AllottedResource();
allottedResource.setOrchestrationStatus(status)
- msoLogger.debug('AAI AR URI: ' + aaiARPath)
+ logger.debug('AAI AR URI: ' + aaiARPath)
AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(aaiARPath).build())
getAAIClient().update(uri,allottedResource)
}catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in updateAR.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.getMessage());
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception in updateAR.", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e.getMessage());
exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error in updateAROrchStatus.' + e.getMessage())
}
- msoLogger.trace("Exit updateAROrchStatus ")
+ logger.trace("Exit updateAROrchStatus ")
}
//Sets Variable "wasDeleted"
public void deleteAR(DelegateExecution execution, String aaiARPath){
- msoLogger.trace(" deleteAR - aaiARPath:" + aaiARPath)
+ logger.trace(" deleteAR - aaiARPath:" + aaiARPath)
try {
AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(aaiARPath).build())
getAAIClient().delete(uri);
}catch(NotFoundException ex){
- msoLogger.debug(" Delete AR Received a Not Found (404) Response")
+ logger.debug(" Delete AR Received a Not Found (404) Response")
}catch(PreconditionFailedException ex){
- msoLogger.debug("Delete AR Received a Resource Version Mismatch Error: \n")
+ logger.debug("Delete AR Received a Resource Version Mismatch Error: \n")
exceptionUtil.buildAndThrowWorkflowException(execution, 412, "DeleteAR Received a resource-version Mismatch Error Response from AAI")
}catch(Exception e){
- msoLogger.debug(" Error encountered in deleteAR!" + e)
+ logger.debug(" Error encountered in deleteAR!" + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During Delete AR")
}
- msoLogger.debug(" Delete AR Received a Good Response")
+ logger.debug(" Delete AR Received a Good Response")
execution.setVariable("wasDeleted", "true")
- msoLogger.trace("Exit deleteAR ")
+ logger.trace("Exit deleteAR ")
}
public void buildAAIErrorResponse(DelegateExecution execution, String response, String errorMessage){
- msoLogger.trace("BuildAAIErrorResponse")
+ logger.trace("BuildAAIErrorResponse")
if((response != null) && (response.contains("Fault") || response.contains("RESTFault"))){
WorkflowException workflowException = exceptionUtil.MapAAIExceptionToWorkflowException(response, execution)
@@ -228,10 +234,10 @@ class AllottedResourceUtils {
exceptionUtil.buildWorkflowException(execution, 500, errorMessage)
}
- msoLogger.trace("Exit BuildAAIErrorResponse Process")
+ logger.trace("Exit BuildAAIErrorResponse Process")
throw new BpmnError("MSOWorkflowException")
}
-
+
public AAIResourcesClient getAAIClient(){
return new AAIResourcesClient()
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy
index 5cbbe0ab46..7beb24f692 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -27,6 +29,8 @@ import org.onap.appc.client.lcm.model.Action
import org.onap.so.client.appc.ApplicationControllerAction;
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
/**
* This groovy class supports the <class>AppCClient.bpmn</class> process.
@@ -49,22 +53,22 @@ import org.onap.so.logger.MsoLogger
*/
public class AppCClient extends AbstractServiceTaskProcessor{
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AppCClient.class);
+ private static final Logger logger = LoggerFactory.getLogger( AppCClient.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtils = new JsonUtils()
def prefix = "UPDVnfI_"
-
+
public void preProcessRequest(DelegateExecution execution){
}
-
+
public void runAppcCommand(DelegateExecution execution) {
- msoLogger.trace("Start runCommand ")
+ logger.trace("Start runCommand ")
def method = getClass().getSimpleName() + '.runAppcCommand(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
execution.setVariable("rollbackVnfStop", false)
execution.setVariable("rollbackVnfLock", false)
execution.setVariable("rollbackQuiesceTraffic", false)
@@ -83,7 +87,7 @@ public class AppCClient extends AbstractServiceTaskProcessor{
String vserverIdList = execution.getVariable("vserverIdList")
String identityUrl = execution.getVariable("identityUrl")
String controllerType = execution.getVariable("controllerType")
- String vfModuleId = execution.getVariable("vfModuleId")
+ String vfModuleId = execution.getVariable("vfModuleId")
HashMap<String, String> payloadInfo = new HashMap<String, String>();
payloadInfo.put("vnfName", vnfName)
payloadInfo.put("aicIdentity", aicIdentity)
@@ -93,8 +97,8 @@ public class AppCClient extends AbstractServiceTaskProcessor{
payloadInfo.put("identityUrl", identityUrl)
payloadInfo.put("vfModuleId",vfModuleId)
Optional<String> payload
- msoLogger.debug("Running APP-C action: " + action.toString())
- msoLogger.debug("VNFID: " + vnfId)
+ logger.debug("Running APP-C action: " + action.toString())
+ logger.debug("VNFID: " + vnfId)
execution.setVariable('msoRequestId', msoRequestId)
execution.setVariable("failedActivity", "APP-C")
execution.setVariable('workStep', action.toString())
@@ -108,17 +112,19 @@ public class AppCClient extends AbstractServiceTaskProcessor{
execution.setVariable('healthCheckIndex', healthCheckIndex + 1)
}
ApplicationControllerAction client = new ApplicationControllerAction()
- msoLogger.debug("Created Application Controller Action Object")
+ logger.debug("Created Application Controller Action Object")
//PayloadInfo contains extra information that adds on to payload before making request to appc
client.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType)
- msoLogger.debug("ran through the main method for Application Contoller")
+ logger.debug("ran through the main method for Application Contoller")
appcCode = client.getErrorCode()
appcMessage = client.getErrorMessage()
}
catch (BpmnError e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
appcMessage = e.getMessage()
- }
+ }
execution.setVariable("errorCode", appcCode)
if (appcCode == '0' && action != null) {
if (action.equals(Action.Lock)) {
@@ -142,8 +148,8 @@ public class AppCClient extends AbstractServiceTaskProcessor{
}
execution.setVariable("errorText", appcMessage)
execution.setVariable("responsePayload", responsePayload)
- msoLogger.debug("Error Message: " + appcMessage)
- msoLogger.debug("ERROR CODE: " + execution.getVariable("errorCode"))
- msoLogger.trace("End of runCommand ")
+ logger.debug("Error Message: " + appcMessage)
+ logger.debug("ERROR CODE: " + execution.getVariable("errorCode"))
+ logger.trace("End of runCommand ")
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy
index df0dfaee60..7511a855a4 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -31,6 +33,8 @@ import org.onap.so.client.HttpClient
import org.onap.so.client.HttpClientFactory
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import org.onap.so.utils.TargetEntity
import org.springframework.web.util.UriUtils
@@ -43,7 +47,7 @@ import javax.ws.rs.core.Response
*/
class CatalogDbUtils {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CatalogDbUtils.class);
+ private static final Logger logger = LoggerFactory.getLogger( CatalogDbUtils.class);
private HttpClientFactory httpClientFactory
private MsoUtils msoUtils
@@ -60,7 +64,7 @@ class CatalogDbUtils {
JSONArray vnfsList = null
String endPoint = "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8")
try {
- msoLogger.debug("ENDPOINT: " + endPoint)
+ logger.debug("ENDPOINT: " + endPoint)
String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
@@ -75,7 +79,9 @@ class CatalogDbUtils {
}
catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
throw e
}
@@ -111,7 +117,9 @@ class CatalogDbUtils {
return getResponseFromCatalogDb(execution, endPoint)
}
catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
throw e
}
}
@@ -133,7 +141,9 @@ class CatalogDbUtils {
}
catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
throw e
}
@@ -157,7 +167,9 @@ class CatalogDbUtils {
}
catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
throw e
}
@@ -167,7 +179,7 @@ class CatalogDbUtils {
private JSONArray parseNetworksJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
JSONArray modelInfos = null
- msoLogger.debug("parseNetworksJson - catalogUtilsVersion is " + catalogUtilsVersion)
+ logger.debug("parseNetworksJson - catalogUtilsVersion is " + catalogUtilsVersion)
try {
// Create array of jsons
@@ -202,10 +214,12 @@ class CatalogDbUtils {
}
String modelInfosString = modelInfos.toString()
- msoLogger.debug("Returning networks JSON: " + modelInfosString)
+ logger.debug("Returning networks JSON: " + modelInfosString)
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
}
return modelInfos
@@ -214,7 +228,7 @@ class CatalogDbUtils {
private JSONArray parseVnfsJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
JSONArray modelInfos = null
- msoLogger.debug("parseVnfsJson - catalogUtilsVersion is " + catalogUtilsVersion)
+ logger.debug("parseVnfsJson - catalogUtilsVersion is " + catalogUtilsVersion)
try {
// Create array of jsons
@@ -226,7 +240,7 @@ class CatalogDbUtils {
for (int i = 0; i < vnfs.length(); i++) {
JSONObject vnf = vnfs.getJSONObject(i)
- msoLogger.debug(vnf.toString(2))
+ logger.debug(vnf.toString(2))
JSONObject modelInfo = buildModelInfo("vnf", vnf, catalogUtilsVersion)
JSONObject modelJson = new JSONObject()
modelJson.put("modelInfo", modelInfo)
@@ -254,7 +268,7 @@ class CatalogDbUtils {
vfModules = vnf.getJSONArray("vfModules")
} catch (Exception e)
{
- msoLogger.debug("Cannot find VF MODULE ARRAY: " + i + ", exception is " + e.message)
+ logger.debug("Cannot find VF MODULE ARRAY: " + i + ", exception is " + e.message)
}
if (vfModules != null) {
@@ -279,10 +293,12 @@ class CatalogDbUtils {
}
String modelInfosString = modelInfos.toString()
- msoLogger.debug("Returning vnfs JSON: " + modelInfosString)
+ logger.debug("Returning vnfs JSON: " + modelInfosString)
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
}
return modelInfos
@@ -291,7 +307,7 @@ class CatalogDbUtils {
private JSONArray parseAllottedResourcesJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
JSONArray modelInfos = null
- msoLogger.debug("parseAllottedResourcesJson - catalogUtilsVersion is " + catalogUtilsVersion)
+ logger.debug("parseAllottedResourcesJson - catalogUtilsVersion is " + catalogUtilsVersion)
try {
// Create array of jsons
@@ -331,10 +347,12 @@ class CatalogDbUtils {
}
String modelInfosString = modelInfos.toString()
- msoLogger.debug("Returning allottedResources JSON: " + modelInfosString)
+ logger.debug("Returning allottedResources JSON: " + modelInfosString)
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
}
return modelInfos
@@ -358,10 +376,12 @@ class CatalogDbUtils {
JSONArray allottedResourcesArray = parseAllottedResourcesJson(serviceResourcesRoot.toString(), "serviceAllottedResources", catalogUtilsVersion)
serviceResources.put("serviceAllottedResources", allottedResourcesArray)
serviceResourcesObject.put("serviceResources", serviceResources)
- msoLogger.debug("Returning serviceResources JSON: " + serviceResourcesObject.toString())
+ logger.debug("Returning serviceResources JSON: " + serviceResourcesObject.toString())
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
}
return serviceResourcesObject
@@ -407,7 +427,9 @@ class CatalogDbUtils {
modelJson.put("modelInfo", modelInfo)
}
catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception while parsing model information", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception while parsing model information", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e.message);
}
return modelInfo
}
@@ -425,16 +447,16 @@ class CatalogDbUtils {
String basicAuthCred = execution.getVariable("BasicAuthHeaderValueDB")
client.addAdditionalHeader("Authorization", StringUtils.defaultIfEmpty(basicAuthCred, getBasicDBAuthHeader(execution)))
- msoLogger.debug('sending GET to Catalog DB endpoint: ' + endPoint)
+ logger.debug('sending GET to Catalog DB endpoint: ' + endPoint)
Response response = client.get()
responseData = response.readEntity(String.class)
if (responseData != null) {
- msoLogger.debug("Received data from Catalog DB: " + responseData)
+ logger.debug("Received data from Catalog DB: " + responseData)
}
- msoLogger.debug('Response code:' + response.getStatus())
- msoLogger.debug('Response:' + System.lineSeparator() + responseData)
+ logger.debug('Response code:' + response.getStatus())
+ logger.debug('Response:' + System.lineSeparator() + responseData)
if (response.getStatus() == 200) {
// parse response as needed
return responseData
@@ -444,7 +466,7 @@ class CatalogDbUtils {
}
}
catch (Exception e) {
- msoLogger.debug("ERROR WHILE QUERYING CATALOG DB: " + e.message)
+ logger.debug("ERROR WHILE QUERYING CATALOG DB: " + e.message)
throw e
}
@@ -457,7 +479,7 @@ class CatalogDbUtils {
String endPoint = "/resourceRecipe?resourceModelUuid=" + UriUtils.encode(resourceModelUuid, "UTF-8")+ "&action=" + UriUtils.encode(action, "UTF-8")
JSONObject responseJson = null
try {
- msoLogger.debug("ENDPOINT: " + endPoint)
+ logger.debug("ENDPOINT: " + endPoint)
String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
if (catalogDbResponse != null) {
@@ -488,4 +510,4 @@ class CatalogDbUtils {
return encodedString
}
-} \ No newline at end of file
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy
index 865b9ee8a7..b12230009d 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -24,9 +26,11 @@ import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CompleteMsoProcess.class);
+ private static final Logger logger = LoggerFactory.getLogger( CompleteMsoProcess.class);
String Prefix="CMSO_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -35,7 +39,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
public initializeProcessVariables(DelegateExecution execution){
def method = getClass().getSimpleName() + '.initializeProcessVariables(' +'execution=' + execution.getId() +')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
/* Initialize all the process request variables in this block */
@@ -70,7 +74,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
}
@@ -80,16 +84,16 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
initializeProcessVariables(execution)
def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'
- // msoLogger.trace("Started CompleteMsoProcess preProcessRequest Method ");
- msoLogger.trace('Entered ' + method)
-
+ // logger.trace("Started CompleteMsoProcess preProcessRequest Method ");
+ logger.trace('Entered ' + method)
+
setBasicDBAuthHeader(execution, execution.getVariable('isDebugLogEnabled'))
try {
def xml = execution.getVariable("CompleteMsoProcessRequest")
- msoLogger.debug("CompleteMsoProcess Request: " + xml)
- msoLogger.debug("Incoming Request is: "+ xml)
+ logger.debug("CompleteMsoProcess Request: " + xml)
+ logger.debug("Incoming Request is: "+ xml)
//mso-bpel-name from the incoming request
def msoBpelName = utils.getNodeText(xml,"mso-bpel-name")
@@ -142,18 +146,18 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
execution.setVariable("CMSO_source",utils.getNodeText(xml,"source"))
}
- msoLogger.trace("--> " + execution.getVariable(""))
- msoLogger.trace("--> " + execution.getVariable(""))
+ logger.trace("--> " + execution.getVariable(""))
+ logger.trace("--> " + execution.getVariable(""))
// set the DHV/Service Instantiation values if specified in the request
execution.setVariable("CMSO_is_srv_inst_req", String.valueOf("true".equals(utils.getNodeText(xml, "is-srv-inst-req"))))
- msoLogger.trace("--> " + execution.getVariable(""))
+ logger.trace("--> " + execution.getVariable(""))
execution.setVariable("CMSO_is_json_content", String.valueOf("JSON".equals(utils.getNodeText(xml, "resp-content-type"))))
- msoLogger.trace("--> " + execution.getVariable(""))
+ logger.trace("--> " + execution.getVariable(""))
execution.setVariable("CMSO_service_inst_id", utils.getNodeText(xml, "service-instance-id"))
- msoLogger.trace("--> " + execution.getVariable(""))
+ logger.trace("--> " + execution.getVariable(""))
execution.setVariable("CMSO_start_time", utils.getNodeText(xml, "start-time"))
- msoLogger.trace("--> " + execution.getVariable(""))
+ logger.trace("--> " + execution.getVariable(""))
// this variable is used by the camunda flow to set the Content-Type for the async response
if (execution.getVariable("CMSO_is_srv_inst_req").equals("true") &&
execution.getVariable("CMSO_is_json_content").equals("true")) {
@@ -162,11 +166,11 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
execution.setVariable("CMSO_content_type", "text/xml")
}
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.debug("Exception Occured During PreProcessRequest: " + e);
+ logger.debug("Exception Occured During PreProcessRequest: " + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in " + method)
}
}
@@ -174,7 +178,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
public void setUpdateDBstatustoSuccessPayload (DelegateExecution execution){
def method = getClass().getSimpleName() + '.setUpdateDBstatustoSuccessPayload(' +'execution=' + execution.getId() +')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
@@ -207,7 +211,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
}
idXml = utils.removeXmlPreamble(idXml)
idXml = utils.removeXmlNamespaces(idXml)
- msoLogger.debug("Incoming Instance Id Xml: " + idXml)
+ logger.debug("Incoming Instance Id Xml: " + idXml)
String payload = """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
@@ -225,22 +229,24 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
</soapenv:Envelope>"""
execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", payload)
- msoLogger.debug("Outgoing Update Mso Request Payload is: " + payload)
- msoLogger.debug("setUpdateDBstatustoSuccessPayload: " + payload)
+ logger.debug("Outgoing Update Mso Request Payload is: " + payload)
+ logger.debug("setUpdateDBstatustoSuccessPayload: " + payload)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
}
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
}
public void buildDataError (DelegateExecution execution, String message) {
def method = getClass().getSimpleName() + '.buildDataError(' +'execution=' + execution.getId() +')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
String msoCompletionResponse = """
@@ -252,17 +258,19 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
// Format Response
def xmlMsoCompletionResponse = utils.formatXml(msoCompletionResponse)
String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim()
- msoLogger.debug("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString)
+ logger.debug("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString)
execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString)
- msoLogger.debug("@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompletionHandlerResponse"))
+ logger.debug("@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompletionHandlerResponse"))
exceptionUtil.buildAndThrowWorkflowException(execution, 500, message)
} catch (BpmnError e) {
- msoLogger.debug("Rethrowing MSOWorkflowException")
+ logger.debug("Rethrowing MSOWorkflowException")
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
}
@@ -271,8 +279,8 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
public void postProcessResponse (DelegateExecution execution) {
def method = getClass().getSimpleName() + '.postProcessResponse(' +'execution=' + execution.getId() +')'
- msoLogger.trace('Entered ' + method)
- // msoLogger.trace("Started CompleteMsoProcess PostProcessRequest Method ");
+ logger.trace('Entered ' + method)
+ // logger.trace("Started CompleteMsoProcess PostProcessRequest Method ");
try {
String msoCompletionResponse = """
@@ -286,19 +294,21 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor {
String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim()
// TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead
execution.setVariable("WorkflowResponse", buildMsoCompletionResponseAsString)
- msoLogger.debug("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString)
+ logger.debug("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString)
execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString)
execution.setVariable("CMSO_ResponseCode", "200")
setSuccessIndicator(execution, true)
- msoLogger.debug("@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompleteMsoProcessResponse"))
+ logger.debug("@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompleteMsoProcessResponse"))
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy
index f4e7926c8e..7d18a8b1ce 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy
@@ -6,6 +6,8 @@
* ================================================================================
* Modifications Copyright 2018 Nokia
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -36,9 +38,11 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.constants.Defaults
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ConfirmVolumeGroupName.class);
+ private static final Logger logger = LoggerFactory.getLogger( ConfirmVolumeGroupName.class);
def static final Prefix = "CVGN_"
private final ExceptionUtil exceptionUtil
@@ -92,7 +96,7 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{
execution.setVariable("CVGN_queryVolumeGroupResponse", "Volume Group not Found!")
}
} catch (Exception ex) {
- msoLogger.debug("Exception occurred while executing AAI GET:" + ex.getMessage())
+ logger.debug("Exception occurred while executing AAI GET:" + ex.getMessage())
execution.setVariable("CVGN_queryVolumeGroupResponseCode", HttpStatus.INTERNAL_SERVER_ERROR.value())
execution.setVariable("CVGN_queryVolumeGroupResponse", "AAI GET Failed:" + ex.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, HttpStatus.INTERNAL_SERVER_ERROR.value(), "AAI GET Failed")
@@ -104,21 +108,21 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{
public void checkAAIQueryResult(DelegateExecution execution) {
def actualVolumeGroupName = ""
if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == HttpStatus.NOT_FOUND.value()) {
- msoLogger.debug('volumeGroupId does not exist in AAI')
+ logger.debug('volumeGroupId does not exist in AAI')
}
else if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == HttpStatus.OK.value()) {
VolumeGroup volumeGroup = execution.getVariable("CVGN_queryVolumeGroupResponse")
if (!Strings.isNullOrEmpty(volumeGroup.getVolumeGroupName())) {
actualVolumeGroupName = volumeGroup.getVolumeGroupName()
- msoLogger.debug("volumeGroupId exists in AAI")
+ logger.debug("volumeGroupId exists in AAI")
}
}
execution.setVariable("CVGN_volumeGroupNameMatches", false)
def volumeGroupName = execution.getVariable("CVGN_volumeGroupName")
if (!actualVolumeGroupName.isEmpty() && volumeGroupName.equals(actualVolumeGroupName)) {
- msoLogger.debug('Volume Group Name Matches AAI records')
+ logger.debug('Volume Group Name Matches AAI records')
execution.setVariable("CVGN_volumeGroupNameMatches", true)
}
}
@@ -126,20 +130,24 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{
// generates a WorkflowException if the A&AI query returns a response code other than 200/404
public void handleAAIQueryFailure(DelegateExecution execution) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Error occurred attempting to query AAI, Response Code " + execution.getVariable("CVGN_queryVolumeGroupResponseCode"), "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "ErrorResponse is:\n" + execution.getVariable("CVGN_queryVolumeGroupResponse"));
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Error occurred attempting to query AAI, Response Code " + execution.getVariable("CVGN_queryVolumeGroupResponseCode"),
+ "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(),
+ "ErrorResponse is:\n" + execution.getVariable("CVGN_queryVolumeGroupResponse"));
}
// generates a WorkflowException if the volume group name does not match AAI record for this volume group
public void handleVolumeGroupNameNoMatch(DelegateExecution execution) {
def errorNotAssociated = "Error occurred - volume group id ${execution.getVariable('CVGN_volumeGroupId')} " +
"is not associated with ${execution.getVariable('CVGN_volumeGroupName')}"
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, errorNotAssociated, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), errorNotAssociated, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, errorNotAssociated)
}
// sends a successful WorkflowResponse
public void reportSuccess(DelegateExecution execution) {
- msoLogger.debug("Sending 200 back to the caller")
+ logger.debug("Sending 200 back to the caller")
def responseXML = ""
execution.setVariable("WorkflowResponse", responseXML)
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy
index 47a4612672..9c6c5cd0aa 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -31,6 +33,8 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.constants.Defaults
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
/**
* Vnf Module Subflow for confirming the volume group belongs
@@ -41,16 +45,16 @@ import org.onap.so.logger.MsoLogger
*
*/
class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ConfirmVolumeGroupTenant.class);
+ private static final Logger logger = LoggerFactory.getLogger( ConfirmVolumeGroupTenant.class);
String Prefix="CVGT_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
public void preProcessRequest(DelegateExecution execution){
execution.setVariable("prefix", Prefix)
- msoLogger.trace("STARTED Confirm Volume Group Tenant Subflow ")
+ logger.trace("STARTED Confirm Volume Group Tenant Subflow ")
try{
- msoLogger.trace("Started QueryAAIForVolumeGroup Process ")
+ logger.trace("Started QueryAAIForVolumeGroup Process ")
String volumeGroupId = execution.getVariable("volumeGroupId")
String incomingGroupName = execution.getVariable("volumeGroupName")
@@ -71,46 +75,48 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{
}
//Determine if Tenant Ids match
if(incomingTenantId.equals(volumeGroupTenantId)){
- msoLogger.debug("Tenant Ids Match")
+ logger.debug("Tenant Ids Match")
execution.setVariable("tenantIdsMatch", true)
}else{
- msoLogger.debug("Tenant Ids DO NOT Match")
+ logger.debug("Tenant Ids DO NOT Match")
execution.setVariable("tenantIdsMatch", false)
}
//Determine if Volume Group Names match
String volumeGroupName = volumeGroup.get().getVolumeGroupName()
if(incomingGroupName == null || incomingGroupName.length() < 1){
- msoLogger.debug("Incoming Volume Group Name is NOT Provided.")
+ logger.debug("Incoming Volume Group Name is NOT Provided.")
execution.setVariable("groupNamesMatch", true)
}else{
- msoLogger.debug("Incoming Volume Group Name is: " + incomingGroupName)
+ logger.debug("Incoming Volume Group Name is: " + incomingGroupName)
if(volumeGroupName.equals(incomingGroupName)){
- msoLogger.debug("Volume Group Names Match.")
+ logger.debug("Volume Group Names Match.")
execution.setVariable("groupNamesMatch", true)
}else{
- msoLogger.debug("Volume Group Names DO NOT Match.")
+ logger.debug("Volume Group Names DO NOT Match.")
execution.setVariable("groupNamesMatch", false)
}
}
}else{
- msoLogger.debug("QueryAAIForVolumeGroup Bad REST Response!")
+ logger.debug("QueryAAIForVolumeGroup Bad REST Response!")
exceptionUtil.buildAndThrowWorkflowException(execution, 1, "Error Searching AAI for Volume Group. Received a Bad Response.")
}
}catch(BpmnError b){
throw b
}catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing queryAAIForVolumeGroup.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.getMessage());
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception Occured Processing queryAAIForVolumeGroup.", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e.getMessage());
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in preProcessRequest.")
}
- msoLogger.trace("COMPLETED queryAAIForVolumeGroup Process ")
+ logger.trace("COMPLETED queryAAIForVolumeGroup Process ")
}
public void assignVolumeHeatId(DelegateExecution execution){
execution.setVariable("prefix", Prefix)
try{
- msoLogger.trace("Started assignVolumeHeatId Process ")
+ logger.trace("Started assignVolumeHeatId Process ")
VolumeGroup volumeGroup = execution.getVariable("queryAAIVolumeGroupResponse")
String heatStackId = volumeGroup.getHeatStackId()
@@ -118,20 +124,22 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{
execution.setVariable("ConfirmVolumeGroupTenantResponse", heatStackId)
// TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead
execution.setVariable("WorkflowResponse", heatStackId)
- msoLogger.debug("Volume Heat Stack Id is: " + heatStackId)
+ logger.debug("Volume Heat Stack Id is: " + heatStackId)
}catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing assignVolumeHeatId.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception Occured Processing assignVolumeHeatId.", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e);
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in assignVolumeHeatId.")
}
- msoLogger.trace("COMPLETED assignVolumeHeatId Process ")
- msoLogger.trace("COMPLETED Confirm Volume Group Tenant Subflow ")
+ logger.trace("COMPLETED assignVolumeHeatId Process ")
+ logger.trace("COMPLETED Confirm Volume Group Tenant Subflow ")
}
public void assignWorkflowException(DelegateExecution execution, String message){
execution.setVariable("prefix", Prefix)
String processKey = getProcessKey(execution);
- msoLogger.trace("STARTED Assign Workflow Exception ")
+ logger.trace("STARTED Assign Workflow Exception ")
try{
String volumeGroupId = execution.getVariable("volumeGroupId")
int errorCode = 1
@@ -139,9 +147,11 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{
exceptionUtil.buildWorkflowException(execution, errorCode, errorMessage)
}catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing assignWorkflowException.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception Occured Processing assignWorkflowException.", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), e);
}
- msoLogger.trace("COMPLETED Assign Workflow Exception =")
+ logger.trace("COMPLETED Assign Workflow Exception =")
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy
index 370600755b..e608bbddbe 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -32,9 +34,11 @@ import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.db.catalog.beans.OrchestrationStatus
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateAAIVfModule.class);
+ private static final Logger logger = LoggerFactory.getLogger( CreateAAIVfModule.class);
def prefix="CAAIVfMod_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -119,13 +123,13 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
Boolean isBaseVfModule = false
String isBaseVfModuleString = execution.getVariable("isBaseVfModule")
if (isBaseVfModuleString != null && isBaseVfModuleString.equals("true")) {
- isBaseVfModule = true
+ isBaseVfModule = true
}
execution.setVariable("CAAIVfMod_isBaseVfModule", isBaseVfModule)
String isVidRequest = execution.getVariable("isVidRequest")
if (isVidRequest != null && "true".equals(isVidRequest)) {
- msoLogger.debug("VID Request received")
+ logger.debug("VID Request received")
}
execution.setVariable("CAAIVfMod_moduleName",execution.getVariable("vfModuleName"))
@@ -133,8 +137,8 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
AaiUtil aaiUriUtil = new AaiUtil(this)
String aaiNamespace = aaiUriUtil.getNamespace()
- msoLogger.debug('AAI namespace is: ' + aaiNamespace)
-
+ logger.debug('AAI namespace is: ' + aaiNamespace)
+
execution.setVariable("CAAIVfMod_aaiNamespace",aaiNamespace)
}
@@ -163,30 +167,30 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
execution.setVariable("CAAIVfMod_queryGenericVnfResponse", "Generic Vnf not Found!")
}
} catch (Exception ex) {
- msoLogger.debug("Exception occurred while executing AAI GET:" + ex.getMessage())
+ logger.debug("Exception occurred while executing AAI GET:" + ex.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in queryAAIForGenericVnf.")
}
}
-
+
// process the result from queryAAIForGenericVnf()
- // note: this method is primarily for logging as the actual decision logic is embedded in the bpmn flow
+ // note: this method is primarily for logging as the actual decision logic is embedded in the bpmn flow
public void processAAIGenericVnfQuery(DelegateExecution execution) {
if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 404 &&
execution.getVariable("CAAIVfMod_vnfId").isEmpty()) {
- msoLogger.debug("New Generic VNF requested and it does not already exist")
+ logger.debug("New Generic VNF requested and it does not already exist")
} else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 200 &&
!execution.getVariable("CAAIVfMod_vnfId").isEmpty()) {
- msoLogger.debug("Adding module to existing Generic VNF")
+ logger.debug("Adding module to existing Generic VNF")
} else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 200 &&
execution.getVariable("CAAIVfMod_vnfId").isEmpty()) {
- msoLogger.debug("Invalid request for new Generic VNF which already exists")
+ logger.debug("Invalid request for new Generic VNF which already exists")
execution.setVariable("CAAIVfMod_queryGenericVnfResponse",
"Invalid request for new Generic VNF which already exists, Vnf Name=" +
- execution.getVariable("CAAIVfMod_vnfName"))
+ execution.getVariable("CAAIVfMod_vnfName"))
} else { // execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 404 &&
// !execution.getVariable("CAAIVfMod_vnfId").isEmpty())
- msoLogger.debug("Invalid request for Add-on Module requested for non-existant Generic VNF")
+ logger.debug("Invalid request for Add-on Module requested for non-existant Generic VNF")
execution.setVariable("CAAIVfMod_createVfModuleResponse",
"Invalid request for Add-on Module requested for non-existant Generic VNF, VNF Id=" +
execution.getVariable("CAAIVfMod_vnfId"))
@@ -216,7 +220,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
execution.setVariable("CAAIVfMod_createGenericVnfResponse", "Vnf Created")
} catch (Exception ex) {
ex.printStackTrace()
- msoLogger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage())
+ logger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in createGenericVnf.")
}
}
@@ -224,7 +228,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
// construct and send a PUT request to A&AI to create a Base or Add-on VF Module
public void createVfModule(DelegateExecution execution, Boolean isBaseModule) {
// TBD - is this how we want to generate the Id for the new (Base) VF Module?
-
+
// Generate the new VF Module ID here if it has not been provided by the parent process
def newModuleId = execution.getVariable('newVfModuleId')
if (newModuleId == null || newModuleId.isEmpty()) {
@@ -249,7 +253,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
rollbackData.put("VFMODULE", "vnfName", execution.getVariable("CAAIVfMod_vnfName"))
rollbackData.put("VFMODULE", "isBaseModule", isBaseModule.toString())
execution.setVariable("RollbackData", rollbackData)
- msoLogger.debug("RollbackData:" + rollbackData)
+ logger.debug("RollbackData:" + rollbackData)
org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule()
vfModule.setVfModuleId(newModuleId)
@@ -276,14 +280,14 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
rollbackData.put("VFMODULE", "vfModuleId", newModuleId)
rollbackData.put("VFMODULE", "vfModuleName", execution.getVariable("CAAIVfMod_moduleName"))
execution.setVariable("RollbackData", rollbackData)
- msoLogger.debug("RollbackData:" + rollbackData)
-
+ logger.debug("RollbackData:" + rollbackData)
+
String responseOut = ""
-
+
String isVidRequest = execution.getVariable("isVidRequest")
def moduleIndexString = String.valueOf(moduleIndex)
- if (isBaseModule && (isVidRequest == null || "false".equals(isVidRequest))) {
-
+ if (isBaseModule && (isVidRequest == null || "false".equals(isVidRequest))) {
+
responseOut = """<CreateAAIVfModuleResponse>
<vnf-id>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfId"))}</vnf-id>
<vf-module-id>${MsoUtils.xmlEscape(newModuleId)}</vf-module-id>
@@ -300,13 +304,13 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
}
execution.setVariable("CreateAAIVfModuleResponse", responseOut)
- msoLogger.debug("CreateAAIVfModuleResponse:" + System.lineSeparator()+responseOut)
- msoLogger.debug("CreateAAIVfModule Response /n " + responseOut)
+ logger.debug("CreateAAIVfModuleResponse:" + System.lineSeparator()+responseOut)
+ logger.debug("CreateAAIVfModule Response /n " + responseOut)
}
} catch (Exception ex) {
execution.setVariable("CAAIVfMod_createVfModuleResponseCode", 500)
execution.setVariable("CAAIVfMod_createVfModuleResponse", ex.getMessage())
- msoLogger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage())
+ logger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in createVfModule.")
}
}
@@ -344,18 +348,18 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
GenericVnf genericVnf = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
def vnfNameFromAAI = genericVnf.getVnfName()
execution.setVariable("CAAIVfMod_vnfNameFromAAI", vnfNameFromAAI)
- msoLogger.debug("Obtained vnf-name from AAI for existing VNF: " + vnfNameFromAAI)
+ logger.debug("Obtained vnf-name from AAI for existing VNF: " + vnfNameFromAAI)
def newModuleName = execution.getVariable("CAAIVfMod_moduleName")
- msoLogger.debug("VF Module to be added: " + newModuleName)
+ logger.debug("VF Module to be added: " + newModuleName)
execution.setVariable("CAAIVfMod_moduleExists", false)
if (genericVnf !=null && genericVnf.getVfModules()!=null && !genericVnf.getVfModules().getVfModule().isEmpty()) {
def qryModuleList = genericVnf.getVfModules().getVfModule()
- msoLogger.debug("Existing VF Module List: " + qryModuleList)
+ logger.debug("Existing VF Module List: " + qryModuleList)
for (org.onap.aai.domain.yang.VfModule qryModule : qryModuleList) {
def qryModuleName = qryModule.getVfModuleName()
if (newModuleName.equals(qryModuleName)) {
// a module with the requested name already exists - failure
- msoLogger.debug("VF Module " + qryModuleName + " already exists for Generic VNF " + vnfNameFromAAI)
+ logger.debug("VF Module " + qryModuleName + " already exists for Generic VNF " + vnfNameFromAAI)
execution.setVariable("CAAIVfMod_moduleExists", true)
execution.setVariable("CAAIVfMod_parseModuleResponse",
"VF Module " + qryModuleName + " already exists for Generic VNF " + vnfNameFromAAI)
@@ -364,31 +368,31 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
}
}
if (execution.getVariable("CAAIVfMod_moduleExists") == false) {
- msoLogger.debug("VF Module " + execution.getVariable("CAAIVfMod_moduleName") + " does not exist for Generic VNF " + vnfNameFromAAI)
+ logger.debug("VF Module " + execution.getVariable("CAAIVfMod_moduleName") + " does not exist for Generic VNF " + vnfNameFromAAI)
execution.setVariable("CAAIVfMod_parseModuleResponse",
"VF Module " + newModuleName + " does not exist for Generic VNF " + vnfNameFromAAI)
- }
+ }
}
-
+
// parses the output from the result from queryAAIForGenericVnf() to determine if the vf-module-name
- // requested for an Add-on VF Module does not already exist for the specified Generic VNF;
+ // requested for an Add-on VF Module does not already exist for the specified Generic VNF;
// also retrieves VNF name from AAI response for existing VNF
public void parseForBaseModule(DelegateExecution execution) {
GenericVnf genericVnf = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
def vnfNameFromAAI = genericVnf.getVnfName()
execution.setVariable("CAAIVfMod_vnfNameFromAAI", vnfNameFromAAI)
- msoLogger.debug("Obtained vnf-name from AAI for existing VNF: " + vnfNameFromAAI)
+ logger.debug("Obtained vnf-name from AAI for existing VNF: " + vnfNameFromAAI)
def newModuleName = execution.getVariable("CAAIVfMod_moduleName")
- msoLogger.debug("VF Module to be added: " + newModuleName)
+ logger.debug("VF Module to be added: " + newModuleName)
def qryModuleList = genericVnf !=null ? genericVnf.getVfModules():null;
execution.setVariable("CAAIVfMod_moduleExists", false)
if (qryModuleList != null && !qryModuleList.getVfModule().isEmpty()) {
def qryModules = qryModuleList.getVfModule()
- msoLogger.debug("Existing VF Module List: " + qryModules)
+ logger.debug("Existing VF Module List: " + qryModules)
for (org.onap.aai.domain.yang.VfModule qryModule : qryModules) {
if (newModuleName.equals(qryModule.getVfModuleName())) {
// a module with the requested name already exists - failure
- msoLogger.debug("VF Module " + qryModule.getVfModuleName() + " already exists for Generic VNF " + vnfNameFromAAI)
+ logger.debug("VF Module " + qryModule.getVfModuleName() + " already exists for Generic VNF " + vnfNameFromAAI)
execution.setVariable("CAAIVfMod_baseModuleConflict", true)
execution.setVariable("CAAIVfMod_parseModuleResponse",
"VF Module " + qryModule.getVfModuleName() + " already exists for Generic VNF " + vnfNameFromAAI)
@@ -402,30 +406,32 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
for (org.onap.aai.domain.yang.VfModule qryModule : qryModules) {
if (qryModule.isBaseVfModule) {
// a base module already exists in this VNF - failure
- msoLogger.debug("Base VF Module already exists for Generic VNF " + vnfNameFromAAI)
+ logger.debug("Base VF Module already exists for Generic VNF " + vnfNameFromAAI)
execution.setVariable("CAAIVfMod_baseModuleConflict", true)
execution.setVariable("CAAIVfMod_parseModuleResponse",
"Base VF Module already exists for Generic VNF " + vnfNameFromAAI)
break
}
}
-
+
}
if (execution.getVariable("CAAIVfMod_baseModuleConflict") == false) {
- msoLogger.debug("VF Module " + execution.getVariable("CAAIVfMod_moduleName") + " does not exist for Generic VNF " + execution.getVariable("CAAIVfMod_vnfNameFromAAI"))
+ logger.debug("VF Module " + execution.getVariable("CAAIVfMod_moduleName") + " does not exist for Generic VNF " + execution.getVariable("CAAIVfMod_vnfNameFromAAI"))
execution.setVariable("CAAIVfMod_parseModuleResponse",
"VF Module " + newModuleName + " does not exist for Generic VNF " + vnfNameFromAAI)
- }
+ }
}
-
+
// generates a WorkflowException when the A&AI query returns a response code other than 200 or 404
public void handleAAIQueryFailure(DelegateExecution execution) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Error occurred attempting to query AAI, Response Code " + execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") + ", Error Response " + execution.getVariable("CAAIVfMod_queryGenericVnfResponse"), "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Error occurred attempting to query AAI, Response Code " + execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") + ", Error Response " + execution.getVariable("CAAIVfMod_queryGenericVnfResponse"),
+ "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
int code = execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode")
exceptionUtil.buildAndThrowWorkflowException(execution, code, "Error occurred attempting to query AAI")
}
-
+
// generates a WorkflowException if
// - the A&AI Generic VNF PUT returns a response code other than 200 or 201
// - the requested Generic VNF already exists but vnf-id == null
@@ -437,31 +443,31 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
def errorResponse
if (execution.getVariable("CAAIVfMod_createGenericVnfResponseCode") != null &&
!isOneOf(execution.getVariable("CAAIVfMod_createGenericVnfResponseCode"), 200, 201)) {
- msoLogger.debug("Failure creating Generic VNF: " + execution.getVariable("CAAIVfMod_createGenericVnfResponse"))
+ logger.debug("Failure creating Generic VNF: " + execution.getVariable("CAAIVfMod_createGenericVnfResponse"))
errorResponse = execution.getVariable("CAAIVfMod_createGenericVnfResponse")
errorCode = 5000
} else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponse") != null &&
execution.getVariable("CAAIVfMod_newGenericVnf") == true) {
// attempted to create a Generic VNF that already exists but vnf-id == null
- msoLogger.debug(execution.getVariable("CAAIVfMod_queryGenericVnfResponse"))
+ logger.debug(execution.getVariable("CAAIVfMod_queryGenericVnfResponse"))
errorResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
errorCode = 1002
} else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 404 &&
execution.getVariable("CAAIVfMod_newGenericVnf") == false) {
// attempted to create a Generic VNF where vnf-name does not exist but vnf-id != null
- msoLogger.debug(execution.getVariable("CAAIVfMod_queryGenericVnfResponse"))
+ logger.debug(execution.getVariable("CAAIVfMod_queryGenericVnfResponse"))
errorResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
errorCode = 1002
} else if (execution.getVariable("CAAIVfMod_createVfModuleResponseCode") != null) {
- msoLogger.debug("Failed to add VF Module: " + execution.getVariable("CAAIVfMod_createVfModuleResponse"))
+ logger.debug("Failed to add VF Module: " + execution.getVariable("CAAIVfMod_createVfModuleResponse"))
errorResponse = execution.getVariable("CAAIVfMod_createVfModuleResponse")
errorCode = 5000
} else if (execution.getVariable("CAAIVfMod_moduleExists") == true) {
- msoLogger.debug("Attempting to add VF Module that already exists: " + execution.getVariable("CAAIVfMod_parseModuleResponse"))
+ logger.debug("Attempting to add VF Module that already exists: " + execution.getVariable("CAAIVfMod_parseModuleResponse"))
errorResponse = execution.getVariable("CAAIVfMod_parseModuleResponse")
errorCode = 1002
} else if (execution.getVariable("CAAIVfMod_baseModuleConflict") == true) {
- msoLogger.debug("Attempting to add Base VF Module to VNF that already has a Base VF Module: " + execution.getVariable("CAAIVfMod_parseModuleResponse"))
+ logger.debug("Attempting to add Base VF Module to VNF that already has a Base VF Module: " + execution.getVariable("CAAIVfMod_parseModuleResponse"))
errorResponse = execution.getVariable("CAAIVfMod_parseModuleResponse")
errorCode = 1002
} else {
@@ -470,8 +476,10 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
errorCode = 2000
}
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Error occurred during CreateAAIVfModule flow", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, errorResponse);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Error occurred during CreateAAIVfModule flow", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), errorResponse);
exceptionUtil.buildAndThrowWorkflowException(execution, errorCode, errorResponse)
- msoLogger.debug("Workflow exception occurred in CreateAAIVfModule: " + errorResponse)
+ logger.debug("Workflow exception occurred in CreateAAIVfModule: " + errorResponse)
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy
index 075068513a..dc4871119e 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -25,10 +27,11 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
-import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateAAIVfModuleVolumeGroup.class);
+ private static final Logger logger = LoggerFactory.getLogger( CreateAAIVfModuleVolumeGroup.class);
private XmlParser xmlParser = new XmlParser()
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -59,12 +62,12 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.preProcessRequest(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def xml = execution.getVariable('CreateAAIVfModuleVolumeGroupRequest')
- msoLogger.debug('Received request xml:\n' + xml)
- msoLogger.debug("CreateAAIVfModuleVolume Received Request XML: " + xml)
+ logger.debug('Received request xml:\n' + xml)
+ logger.debug("CreateAAIVfModuleVolume Received Request XML: " + xml)
initProcessVariables(execution)
def vnfId = getRequiredNodeText(execution, xml,'vnf-id')
@@ -72,21 +75,21 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor {
def vfModuleId = getRequiredNodeText(execution, xml,'vf-module-id')
execution.setVariable('CAAIVfModVG_vfModuleId', vfModuleId)
-
+
def aicCloudRegion = getRequiredNodeText(execution, xml,'aic-cloud-region')
execution.setVariable('CAAIVfModVG_aicCloudRegion', aicCloudRegion)
-
+
def cloudOwner = getRequiredNodeText(execution, xml,'cloud-owner')
execution.setVariable('CAAIVfModVG_cloudOwner', cloudOwner)
-
+
def volumeGroupId = getRequiredNodeText(execution, xml,'volume-group-id')
execution.setVariable('CAAIVfModVG_volumeGroupId', volumeGroupId)
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(e);
+ logger.error(e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
}
@@ -102,7 +105,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.getVfModule(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def vnfId = execution.getVariable('CAAIVfModVG_vnfId')
@@ -119,15 +122,15 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor {
}
}catch (Exception ex) {
ex.printStackTrace()
- msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
execution.setVariable('CAAIVfModVG_getVfModuleResponseCode', 500)
execution.setVariable('CAAIVfModVG_getVfModuleResponse', 'AAI GET Failed:' + ex.getMessage())
}
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(e);
+ logger.error(e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getVfModule(): ' + e.getMessage())
}
}
@@ -142,7 +145,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.updateVfModule(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def vnfId = execution.getVariable('CAAIVfModVG_vnfId')
@@ -152,10 +155,10 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor {
// Confirm resource-version is in retrieved VF Module
if (vfModule.getResourceVersion() == null) {
def msg = 'Can\'t update VF Module ' + vfModuleId + ' since \'resource-version\' is missing'
- msoLogger.error( msg);
+ logger.error(msg);
throw new Exception(msg)
}
-
+
// Construct payload by creating a Volume Group relationhip and inserting it into the VF Module
def aicCloudRegion = execution.getVariable('CAAIVfModVG_aicCloudRegion')
def cloudOwner = execution.getVariable('CAAIVfModVG_cloudOwner')
@@ -164,31 +167,31 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor {
try {
AAIResourceUri vfModuleUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId,vfModuleId);
AAIResourceUri volumeGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwner, aicCloudRegion,volumeGroupId);
- msoLogger.debug("Creating relationship between Vf Module: " + vfModuleUri.build().toString() + " and Volume Group: " + volumeGroupUri.build().toString())
+ logger.debug("Creating relationship between Vf Module: " + vfModuleUri.build().toString() + " and Volume Group: " + volumeGroupUri.build().toString())
getAAIClient().connect(vfModuleUri,volumeGroupUri)
execution.setVariable('CAAIVfModVG_updateVfModuleResponseCode', 200)
execution.setVariable('CAAIVfModVG_updateVfModuleResponse', "Success")
- msoLogger.debug("CreateAAIVfModule Response code: " + 200)
- msoLogger.debug("CreateAAIVfModule Response: " + "Success")
+ logger.debug("CreateAAIVfModule Response code: " + 200)
+ logger.debug("CreateAAIVfModule Response: " + "Success")
} catch (Exception ex) {
ex.printStackTrace()
- msoLogger.debug('Exception occurred while executing AAI PUT:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI PUT:' + ex.getMessage())
execution.setVariable('CAAIVfModVG_updateVfModuleResponseCode', 500)
execution.setVariable('CAAIVfModVG_updateVfModuleResponse', 'AAI PUT Failed:' + ex.getMessage())
}
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(e);
+ logger.error(e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in updateVfModule(): ' + e.getMessage())
}
}
-
+
/**
* Find and return the value of the Volume Group ID for the specified VF Module. If
* the value of the Volume Group ID cannot be found for any reason, 'null' is returned.
- *
+ *
* @param vfModuleNode VF Module (as a Node) retrieved from AAI.
* @return the value of the Volume Group ID for the specified VF Module. If the
* value of the Volume Group ID cannot be found for any reason, 'null' is returned.
@@ -214,12 +217,12 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.handleAAIQueryFailure(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
- msoLogger.error( 'Error occurred attempting to query AAI, Response Code ' + execution.getVariable('CAAIVfModVG_getVfModuleResponseCode'));
+ logger.trace('Entered ' + method)
+ logger.error('Error occurred attempting to query AAI, Response Code ' + execution.getVariable('CAAIVfModVG_getVfModuleResponseCode'));
ExceptionUtil exceptionUtil = new ExceptionUtil()
exceptionUtil.buildWorkflowException(execution, 5000, execution.getVariable('CAAIVfModVG_getVfModuleResponse'))
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
}
/**
@@ -231,12 +234,12 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.handleUpdateVfModuleFailure(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
- msoLogger.error('Error occurred attempting to update VF Module in AAI, Response Code ' + execution.getVariable('CAAIVfModVG_updateVfModuleResponseCode'));
+ logger.error('Error occurred attempting to update VF Module in AAI, Response Code ' + execution.getVariable('CAAIVfModVG_updateVfModuleResponseCode'));
ExceptionUtil exceptionUtil = new ExceptionUtil()
exceptionUtil.buildWorkflowException(execution, 5000, execution.getVariable('CAAIVfModVG_updateVfModuleResponse'))
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DecomposeService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DecomposeService.groovy
index 1c1d5eb0e3..d8e4b7f6b1 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DecomposeService.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DecomposeService.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -26,7 +28,8 @@ import org.json.JSONObject;
import org.onap.so.bpmn.core.domain.ServiceDecomposition
import org.onap.so.bpmn.core.json.DecomposeJsonUtil;
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
/**
* This groovy class supports the <class>DecomposeService.bpmn</class> process.
@@ -48,7 +51,7 @@ import org.onap.so.logger.MsoLogger
*
*/
public class DecomposeService extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DecomposeService.class);
+ private static final Logger logger = LoggerFactory.getLogger( DecomposeService.class);
String Prefix="DDS_"
@@ -58,7 +61,7 @@ public class DecomposeService extends AbstractServiceTaskProcessor {
public void preProcessRequest (DelegateExecution execution) {
String msg = ""
- msoLogger.trace("preProcessRequest of DecomposeService ")
+ logger.trace("preProcessRequest of DecomposeService ")
setBasicDBAuthHeader(execution, execution.getVariable('isDebugLogEnabled'))
try {
@@ -80,15 +83,15 @@ public class DecomposeService extends AbstractServiceTaskProcessor {
throw e;
} catch (Exception ex){
msg = "Exception in preProcessRequest " + ex.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit preProcessRequest of DecomposeService ")
+ logger.trace("Exit preProcessRequest of DecomposeService ")
}
public void queryCatalogDb (DelegateExecution execution) {
String msg = ""
- msoLogger.trace("queryCatalogDB of DecomposeService ")
+ logger.trace("queryCatalogDB of DecomposeService ")
try {
@@ -97,8 +100,8 @@ public class DecomposeService extends AbstractServiceTaskProcessor {
String serviceModelUuid = execution.getVariable("DDS_serviceModelUuid")
String modelVersion = execution.getVariable("DDS_modelVersion")
- msoLogger.debug("serviceModelInvariantId: " + serviceModelInvariantId)
- msoLogger.debug("modelVersion: " + modelVersion)
+ logger.debug("serviceModelInvariantId: " + serviceModelInvariantId)
+ logger.debug("modelVersion: " + modelVersion)
JSONObject catalogDbResponse = null
if(serviceModelUuid != null && serviceModelUuid.length() > 0)
@@ -110,30 +113,30 @@ public class DecomposeService extends AbstractServiceTaskProcessor {
if (catalogDbResponse == null || catalogDbResponse.toString().equalsIgnoreCase("null")) {
msg = "No data found in Catalog DB"
- msoLogger.debug(msg)
+ logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
String catalogDbResponseString = catalogDbResponse.toString()
execution.setVariable("DDS_catalogDbResponse", catalogDbResponseString)
- msoLogger.debug("catalog DB response string: "+ catalogDbResponseString)
+ logger.debug("catalog DB response string: "+ catalogDbResponseString)
} catch (BpmnError e) {
throw e;
} catch (Exception ex){
msg = "Exception in queryCatalogDb " + ex.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit queryCatalogDb of DecomposeService ")
+ logger.trace("Exit queryCatalogDb of DecomposeService ")
}
public void actuallyDecomposeService (DelegateExecution execution) {
String msg = ""
- msoLogger.trace("actuallyDecomposeService of DecomposeService ")
+ logger.trace("actuallyDecomposeService of DecomposeService ")
try {
@@ -142,9 +145,9 @@ public class DecomposeService extends AbstractServiceTaskProcessor {
String serviceInstanceId = execution.getVariable("serviceInstanceId")
String serviceModelInvariantId = execution.getVariable("DDS_serviceModelInvariantId")
- msoLogger.debug("serviceModelInvariantId: " + serviceModelInvariantId)
+ logger.debug("serviceModelInvariantId: " + serviceModelInvariantId)
- msoLogger.debug("getting service decomposition")
+ logger.debug("getting service decomposition")
String catalogDbResponse = execution.getVariable("DDS_catalogDbResponse")
ServiceDecomposition serviceDecomposition = DecomposeJsonUtil.jsonToServiceDecomposition(catalogDbResponse, serviceInstanceId)
@@ -152,16 +155,16 @@ public class DecomposeService extends AbstractServiceTaskProcessor {
execution.setVariable("serviceDecomposition", serviceDecomposition)
execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonString())
- msoLogger.debug("service decomposition: "+ serviceDecomposition.toJsonString())
+ logger.debug("service decomposition: "+ serviceDecomposition.toJsonString())
} catch (BpmnError e) {
throw e;
} catch (Exception ex){
msg = "Exception in actuallyDecomposeService " + ex.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit actuallyDecomposeService of DecomposeService ")
+ logger.trace("Exit actuallyDecomposeService of DecomposeService ")
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy
index b8df241913..301c74d2eb 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -27,9 +29,11 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DeleteAAIVfModule.class);
+ private static final Logger logger = LoggerFactory.getLogger( DeleteAAIVfModule.class);
def Prefix="DAAIVfMod_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -55,20 +59,20 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
execution.setVariable("DAAIVfMod_deleteVfModuleResponse","")
}
-
+
// parse the incoming DELETE_VF_MODULE request and store the Generic Vnf
// and Vf Module Ids in the flow DelegateExecution
public void preProcessRequest(DelegateExecution execution) {
def xml = execution.getVariable("DeleteAAIVfModuleRequest")
- msoLogger.debug("DeleteAAIVfModule Request: " + xml)
- msoLogger.debug("input request xml:" + xml)
+ logger.debug("DeleteAAIVfModule Request: " + xml)
+ logger.debug("input request xml:" + xml)
initProcessVariables(execution)
def vnfId = utils.getNodeText(xml,"vnf-id")
def vfModuleId = utils.getNodeText(xml,"vf-module-id")
execution.setVariable("DAAIVfMod_vnfId", vnfId)
execution.setVariable("DAAIVfMod_vfModuleId", vfModuleId)
}
-
+
// send a GET request to AA&I to retrieve the Generic Vnf/Vf Module information based on a Vnf Id
// expect a 200 response with the information in the response body or a 404 if the Generic Vnf does not exist
public void queryAAIForGenericVnf(DelegateExecution execution) {
@@ -91,12 +95,12 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
}
} catch (Exception ex) {
- msoLogger.debug("Exception occurred while executing AAI GET:" + ex.getMessage())
+ logger.debug("Exception occurred while executing AAI GET:" + ex.getMessage())
execution.setVariable("DAAIVfMod_queryGenericVnfResponse", "AAI GET Failed:" + ex.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured during queryAAIForGenericVnf")
}
}
-
+
// construct and send a DELETE request to A&AI to delete a Generic Vnf
// note: to get here, all the modules associated with the Generic Vnf must already be deleted
public void deleteGenericVnf(DelegateExecution execution) {
@@ -109,7 +113,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
execution.setVariable("DAAIVfMod_deleteGenericVnfResponse", "Vnf Deleted")
} catch (Exception ex) {
ex.printStackTrace()
- msoLogger.debug("Exception occurred while executing AAI DELETE:" + ex.getMessage())
+ logger.debug("Exception occurred while executing AAI DELETE:" + ex.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured during deleteGenericVnf")
}
}
@@ -120,7 +124,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
try {
String vnfId = execution.getVariable("DAAIVfMod_vnfId")
String vfModuleId = execution.getVariable("DAAIVfMod_vfModuleId")
-
+
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)
getAAIClient().delete(uri)
@@ -128,19 +132,19 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
execution.setVariable("DAAIVfMod_deleteVfModuleResponse", "Vf Module Deleted")
} catch (Exception ex) {
ex.printStackTrace()
- msoLogger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage())
+ logger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured during deleteVfModule")
}
}
-
+
// parses the output from the result from queryAAIForGenericVnf() to determine if the Vf Module
// to be deleted exists for the specified Generic Vnf and if it is the Base Module,
// there are no Add-on Modules present
public void parseForVfModule(DelegateExecution execution) {
GenericVnf genericVnf = execution.getVariable("DAAIVfMod_queryGenericVnfResponse")
-
+
def delModuleId = execution.getVariable("DAAIVfMod_vfModuleId")
- msoLogger.debug("Vf Module to be deleted: " + delModuleId)
+ logger.debug("Vf Module to be deleted: " + delModuleId)
execution.setVariable("DAAIVfMod_genVnfRsrcVer", genericVnf.getResourceVersion())
@@ -179,30 +183,32 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
}
}
}
- msoLogger.debug(execution.getVariable("DAAIVfMod_parseModuleResponse"))
+ logger.debug(execution.getVariable("DAAIVfMod_parseModuleResponse"))
}
}
if (execution.getVariable("DAAIVfMod_moduleExists") == false) { // (execution.getVariable("DAAIVfMod_moduleExists") == false)
- msoLogger.debug("Vf Module Id " + delModuleId + " does not exist for Generic Vnf Id " + execution.getVariable("DAAIVfMod_vnfId"))
+ logger.debug("Vf Module Id " + delModuleId + " does not exist for Generic Vnf Id " + execution.getVariable("DAAIVfMod_vnfId"))
execution.setVariable("DAAIVfMod_parseModuleResponse",
"Vf Module Id " + delModuleId + " does not exist for Generic Vnf Id " +
execution.getVariable("DAAIVfMod_vnfName"))
}
}
-
+
// parses the output from the result from queryAAIForGenericVnf() to determine if the Vf Module
// to be deleted exists for the specified Generic Vnf and if it is the Base Module,
// there are no Add-on Modules present
public void parseForResourceVersion(DelegateExecution execution) {
GenericVnf genericVnf = execution.getVariable("DAAIVfMod_queryGenericVnfResponse")
execution.setVariable("DAAIVfMod_genVnfRsrcVer", genericVnf.getResourceVersion())
- msoLogger.debug("Latest Generic VNF Resource Version: " + genericVnf.getResourceVersion())
+ logger.debug("Latest Generic VNF Resource Version: " + genericVnf.getResourceVersion())
}
-
-
+
+
// generates a WorkflowException if the A&AI query returns a response code other than 200
public void handleAAIQueryFailure(DelegateExecution execution) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Error occurred attempting to query AAI, Response Code " + execution.getVariable("DAAIVfMod_queryGenericVnfResponseCode") + ", Error Response " + execution.getVariable("DAAIVfMod_queryGenericVnfResponse"), "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Error occurred attempting to query AAI, Response Code " + execution.getVariable("DAAIVfMod_queryGenericVnfResponseCode") + ", Error Response " + execution.getVariable("DAAIVfMod_queryGenericVnfResponse"),
+ "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
def errorCode = 5000
// set the errorCode to distinguish between a A&AI failure
// and the Generic Vnf Id not found
@@ -211,7 +217,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
}
exceptionUtil.buildAndThrowWorkflowException(execution, errorCode, execution.getVariable("DAAIVfMod_queryGenericVnfResponse"))
}
-
+
// generates a WorkflowException if
// - the A&AI Vf Module DELETE returns a response code other than 200
// - the Vf Module is a Base Module that is not the last Vf Module
@@ -221,24 +227,24 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
def errorResponse = ""
if (execution.getVariable("DAAIVfMod_deleteVfModuleResponseCode") != null &&
execution.getVariable("DAAIVfMod_deleteVfModuleResponseCode") != 200) {
- msoLogger.debug("AAI failure deleting a Vf Module: " + execution.getVariable("DAAIVfMod_deleteVfModuleResponse"))
+ logger.debug("AAI failure deleting a Vf Module: " + execution.getVariable("DAAIVfMod_deleteVfModuleResponse"))
errorResponse = execution.getVariable("DAAIVfMod_deleteVfModuleResponse")
- msoLogger.debug("DeleteAAIVfModule - deleteVfModuleResponse" + errorResponse)
+ logger.debug("DeleteAAIVfModule - deleteVfModuleResponse" + errorResponse)
errorCode = 5000
} else {
if (execution.getVariable("DAAIVfMod_isBaseModule", true) == true &&
execution.getVariable("DAAIVfMod_isLastModule") == false) {
// attempt to delete a Base Module that is not the last Vf Module
- msoLogger.debug(execution.getVariable("DAAIVfMod_parseModuleResponse"))
+ logger.debug(execution.getVariable("DAAIVfMod_parseModuleResponse"))
errorResponse = execution.getVariable("DAAIVfMod_parseModuleResponse")
- msoLogger.debug("DeleteAAIVfModule - parseModuleResponse" + errorResponse)
+ logger.debug("DeleteAAIVfModule - parseModuleResponse" + errorResponse)
errorCode = 1002
} else {
// attempt to delete a non-existant Vf Module
if (execution.getVariable("DAAIVfMod_moduleExists") == false) {
- msoLogger.debug(execution.getVariable("DAAIVfMod_parseModuleResponse"))
+ logger.debug(execution.getVariable("DAAIVfMod_parseModuleResponse"))
errorResponse = execution.getVariable("DAAIVfMod_parseModuleResponse")
- msoLogger.debug("DeleteAAIVfModule - parseModuleResponse" + errorResponse)
+ logger.debug("DeleteAAIVfModule - parseModuleResponse" + errorResponse)
errorCode = 1002
} else {
// if the responses get populated corerctly, we should never get here
@@ -247,7 +253,9 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
}
}
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Error occurred during DeleteAAIVfModule flow", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, errorResponse);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Error occurred during DeleteAAIVfModule flow", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), errorResponse);
exceptionUtil.buildAndThrowWorkflowException(execution, errorCode, errorResponse)
}
@@ -255,7 +263,10 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{
// generates a WorkflowException if
// - the A&AI Generic Vnf DELETE returns a response code other than 200
public void handleDeleteGenericVnfFailure(DelegateExecution execution) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "AAI error occurred deleting the Generic Vnf", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, execution.getVariable("DAAIVfMod_deleteGenericVnfResponse"));
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "AAI error occurred deleting the Generic Vnf", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(),
+ execution.getVariable("DAAIVfMod_deleteGenericVnfResponse"));
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, execution.getVariable("DAAIVfMod_deleteGenericVnfResponse"))
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy
index e132b411a5..a77320b771 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -30,6 +32,8 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
@@ -37,7 +41,7 @@ import org.onap.so.logger.MsoLogger
* @version 1.0
*/
class ExceptionUtil extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ExceptionUtil.class);
+ private static final Logger logger = LoggerFactory.getLogger( ExceptionUtil.class);
@@ -57,12 +61,12 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
def utils=new MsoUtils()
def prefix=execution.getVariable("prefix")
def errorMsg = execution.getVariable(prefix+"ErrorResponse")
- msoLogger.trace("Begin MapAAIExceptionToWorkflowException ")
+ logger.trace("Begin MapAAIExceptionToWorkflowException ")
String text = null
def variables
String errorCode = '5000'
WorkflowException wfex
- msoLogger.debug("response: " + response)
+ logger.debug("response: " + response)
try{
try {
//String msg = utils.getNodeXml(response, "Fault")
@@ -70,7 +74,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
text = utils.getNodeText(response, "text")
} catch (Exception ex) {
//Ignore the exception - cases include non xml payload
- msoLogger.debug("error mapping error, ignoring: " + ex)
+ logger.debug("error mapping error, ignoring: " + ex)
}
if(text != null) {
@@ -81,12 +85,13 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
text = text.replaceFirst("%4", variables[3])
}
String modifiedErrorMessage = 'Received error from A&amp;AI (' + text +')'
- msoLogger.debug("ModifiedErrorMessage " + modifiedErrorMessage)
+ logger.debug("ModifiedErrorMessage " + modifiedErrorMessage)
// let $ModifiedErrorMessage := concat( 'Received error from A',$exceptionaai:ampersand,'AI (' ,functx:replace-multi($ErrorMessage,$from,$Variables ),')')
buildWorkflowException(execution, 5000, modifiedErrorMessage)
wfex = execution.getVariable("WorkflowException")
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Fault", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, wfex.errorMessage);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(), wfex.errorMessage);
return wfex
} else {
try {
@@ -96,18 +101,19 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
int errorCodeInt = Integer.parseInt(errorCode)
buildWorkflowException(execution, errorCodeInt, mappedErrorMessage)
- msoLogger.debug("mappedErrorMessage " + mappedErrorMessage)
+ logger.debug("mappedErrorMessage " + mappedErrorMessage)
wfex = execution.getVariable("WorkflowException")
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Fault", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, wfex.errorMessage);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(), wfex.errorMessage);
return wfex
} catch(Exception ex) {
- msoLogger.debug("error mapping error, return null: " + ex)
+ logger.debug("error mapping error, return null: " + ex)
return null
}
}
}catch(Exception e){
- msoLogger.debug("Exception occured during MapAAIExceptionToWorkflowException: " + e)
+ logger.debug("Exception occured during MapAAIExceptionToWorkflowException: " + e)
buildWorkflowException(execution, 5000, "Error mapping AAI Response to WorkflowException")
}
}
@@ -125,7 +131,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
*/
WorkflowException MapAAIExceptionToWorkflowExceptionGeneric(DelegateExecution execution, String response, int resCode){
def utils=new MsoUtils()
- msoLogger.debug("Start MapAAIExceptionToWorkflowExceptionGeneric Process")
+ logger.debug("Start MapAAIExceptionToWorkflowExceptionGeneric Process")
WorkflowException wfex
try {
@@ -142,12 +148,12 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
buildWorkflowException(execution, resCode, "Received a bad response from AAI")
}
} catch (Exception ex) {
- msoLogger.debug("Exception Occured during MapAAIExceptionToWorkflowExceptionGeneric: " + ex)
+ logger.debug("Exception Occured during MapAAIExceptionToWorkflowExceptionGeneric: " + ex)
buildWorkflowException(execution, resCode, "Internal Error - Occured in MapAAIExceptionToWorkflowExceptionGeneric")
}
- msoLogger.debug("Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"))
- msoLogger.debug("Completed MapAAIExceptionToWorkflowExceptionGeneric Process")
+ logger.debug("Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"))
+ logger.debug("Completed MapAAIExceptionToWorkflowExceptionGeneric Process")
}
/**
@@ -269,11 +275,11 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
public void buildWorkflowException(DelegateExecution execution, int errorCode, String errorMessage) {
MsoUtils utils = new MsoUtils()
String processKey = getProcessKey(execution);
- msoLogger.debug("Building a WorkflowException for " + processKey)
+ logger.debug("Building a WorkflowException for " + processKey)
WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage);
execution.setVariable("WorkflowException", exception);
- msoLogger.debug("Outgoing WorkflowException is " + exception)
+ logger.debug("Outgoing WorkflowException is " + exception)
}
/**
@@ -287,12 +293,12 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
*/
public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage) {
String processKey = getProcessKey(execution);
- msoLogger.debug("Building a WorkflowException for Subflow " + processKey)
+ logger.debug("Building a WorkflowException for Subflow " + processKey)
WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage);
execution.setVariable("WorkflowException", exception);
- msoLogger.debug("Outgoing WorkflowException is " + exception)
- msoLogger.debug("Throwing MSOWorkflowException")
+ logger.debug("Outgoing WorkflowException is " + exception)
+ logger.debug("Throwing MSOWorkflowException")
throw new BpmnError(errorCode.toString(), String.format("MSOWorkflowException: %s", errorMessage))
}
@@ -308,16 +314,16 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
public void processSubflowsBPMNException(DelegateExecution execution){
String processKey = getProcessKey(execution)
try{
- msoLogger.debug("Started ProcessSubflowsBPMNException Method")
+ logger.debug("Started ProcessSubflowsBPMNException Method")
if(execution.getVariable("WorkflowException") == null){
buildWorkflowException(execution, 2500, "Internal Error - Occured During " + processKey)
}
- msoLogger.debug(processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"))
+ logger.debug(processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"))
}catch(Exception e){
- msoLogger.debug("Caught Exception during ProcessSubflowsBPMNException Method: " + e)
+ logger.debug("Caught Exception during ProcessSubflowsBPMNException Method: " + e)
}
- msoLogger.debug("Completed ProcessSubflowsBPMNException Method")
+ logger.debug("Completed ProcessSubflowsBPMNException Method")
}
/**
@@ -334,7 +340,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
public String processMainflowsBPMNException(DelegateExecution execution, String requestInfo){
String processKey = getProcessKey(execution)
try{
- msoLogger.debug("Started ProcessMainflowBPMNException Method")
+ logger.debug("Started ProcessMainflowBPMNException Method")
if(execution.getVariable("WorkflowException") == null || isBlank(requestInfo)){
buildWorkflowException(execution, 2500, "Internal Error - WorkflowException Object and/or RequestInfo is null! " + processKey)
}
@@ -354,16 +360,16 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
</aetgt:WorkflowException>
</aetgt:FalloutHandlerRequest>"""
- msoLogger.debug(processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"))
- msoLogger.debug(processKey + " Outgoing FalloutHandler Request is: " + falloutHandlerRequest)
+ logger.debug(processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"))
+ logger.debug(processKey + " Outgoing FalloutHandler Request is: " + falloutHandlerRequest)
return falloutHandlerRequest
}catch(Exception e){
- msoLogger.debug("Caught Exception during ProcessMainflowBPMNException Method: " + e)
+ logger.debug("Caught Exception during ProcessMainflowBPMNException Method: " + e)
return null
}
- msoLogger.debug("Completed ProcessMainflowBPMNException Method")
+ logger.debug("Completed ProcessMainflowBPMNException Method")
}
/**
@@ -377,8 +383,8 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
public void processJavaException(DelegateExecution execution){
String processKey = getProcessKey(execution)
try{
- msoLogger.debug("Caught a Java Exception in " + processKey)
- msoLogger.debug("Started processJavaException Method")
+ logger.debug("Caught a Java Exception in " + processKey)
+ logger.debug("Started processJavaException Method")
// if the BPMN flow java error handler sets "BPMN_javaExpMsg", append it to the WFE
String javaExpMsg = execution.getVariable("BPMN_javaExpMsg")
String errorMessage = execution.getVariable("gUnknownError")
@@ -387,20 +393,20 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
wfeExpMsg = wfeExpMsg + ": " + javaExpMsg
}
if (errorMessage != null && !errorMessage.empty) {
- msoLogger.error("Unknown Error: " + errorMessage);
+ logger.error("Unknown Error: " + errorMessage);
}
- msoLogger.error("Java Error: " + wfeExpMsg);
+ logger.error("Java Error: " + wfeExpMsg);
buildWorkflowException(execution, 2500, wfeExpMsg)
}catch(BpmnError b){
- msoLogger.error(b);
+ logger.error(b);
throw b
}catch(Exception e){
- msoLogger.error(e);
- msoLogger.debug("Caught Exception during processJavaException Method: " + e)
+ logger.error(e);
+ logger.debug("Caught Exception during processJavaException Method: " + e)
buildWorkflowException(execution, 2500, "Internal Error - During Process Java Exception")
}
- msoLogger.debug("Completed processJavaException Method")
+ logger.debug("Completed processJavaException Method")
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
index 94c82f5a0c..918bcdd4cc 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -25,7 +27,8 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.logging.ref.slf4j.ONAPLogConstants
import org.onap.so.client.HttpClient
import org.onap.so.client.HttpClientFactory
-import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import org.onap.so.utils.TargetEntity
import javax.ws.rs.core.MediaType
@@ -37,7 +40,7 @@ class ExternalAPIUtil {
String Prefix="EXTAPI_"
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ExternalAPIUtil.class)
+ private static final Logger logger = LoggerFactory.getLogger( ExternalAPIUtil.class);
private final HttpClientFactory httpClientFactory;
private final MsoUtils utils;
@@ -96,7 +99,7 @@ class ExternalAPIUtil {
//
// def uri = execution.getVariable("ExternalAPIURi")
// if(uri) {
-// msoLogger.debug("ExternalAPIUtil.getUri: " + uri)
+// logger.debug("ExternalAPIUtil.getUri: " + uri)
// return uri
// }
//
@@ -104,21 +107,21 @@ class ExternalAPIUtil {
// }
public String setTemplate(String template, Map<String, String> valueMap) {
- msoLogger.debug("ExternalAPIUtil setTemplate", true);
+ logger.debug("ExternalAPIUtil setTemplate", true);
StringBuffer result = new StringBuffer();
String pattern = "<.*>";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(template);
- msoLogger.debug("ExternalAPIUtil template:" + template, true);
+ logger.debug("ExternalAPIUtil template:" + template, true);
while (m.find()) {
String key = template.substring(m.start() + 1, m.end() - 1);
- msoLogger.debug("ExternalAPIUtil key:" + key + " contains key? " + valueMap.containsKey(key), true);
+ logger.debug("ExternalAPIUtil key:" + key + " contains key? " + valueMap.containsKey(key), true);
m.appendReplacement(result, valueMap.getOrDefault(key, "\"TBD\""));
}
m.appendTail(result);
- msoLogger.debug("ExternalAPIUtil return:" + result.toString(), true);
+ logger.debug("ExternalAPIUtil return:" + result.toString(), true);
return result.toString();
}
@@ -134,12 +137,12 @@ class ExternalAPIUtil {
*
*/
public Response executeExternalAPIGetCall(DelegateExecution execution, String url){
- msoLogger.debug(" ======== STARTED Execute ExternalAPI Get Process ======== ")
+ logger.debug(" ======== STARTED Execute ExternalAPI Get Process ======== ")
Response apiResponse = null
try{
String uuid = utils.getRequestID()
- msoLogger.debug( "Generated uuid is: " + uuid)
- msoLogger.debug( "URL to be used is: " + url)
+ logger.debug( "Generated uuid is: " + uuid)
+ logger.debug( "URL to be used is: " + url)
HttpClient client = httpClientFactory.newJsonClient(new URL(url), TargetEntity.EXTERNAL)
client.addBasicAuthHeader(execution.getVariable("URN_externalapi_auth"), execution.getVariable("URN_mso_msoKey"))
@@ -149,9 +152,9 @@ class ExternalAPIUtil {
apiResponse = client.get()
- msoLogger.debug( "======== COMPLETED Execute ExternalAPI Get Process ======== ")
+ logger.debug( "======== COMPLETED Execute ExternalAPI Get Process ======== ")
}catch(Exception e){
- msoLogger.debug("Exception occured while executing ExternalAPI Get Call. Exception is: \n" + e)
+ logger.debug("Exception occured while executing ExternalAPI Get Call. Exception is: \n" + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 9999, e.getMessage())
}
return apiResponse
@@ -170,12 +173,12 @@ class ExternalAPIUtil {
*
*/
public Response executeExternalAPIPostCall(DelegateExecution execution, String url, String payload){
- msoLogger.debug( " ======== Started Execute ExternalAPI Post Process ======== ")
+ logger.debug( " ======== Started Execute ExternalAPI Post Process ======== ")
Response apiResponse = null
try{
String uuid = utils.getRequestID()
- msoLogger.debug( "Generated uuid is: " + uuid)
- msoLogger.debug( "URL to be used is: " + url)
+ logger.debug( "Generated uuid is: " + uuid)
+ logger.debug( "URL to be used is: " + url)
HttpClient httpClient = httpClientFactory.newJsonClient(new URL(url), TargetEntity.AAI)
httpClient.addBasicAuthHeader(execution.getVariable("URN_externalapi_auth"), execution.getVariable("URN_mso_msoKey"))
@@ -184,9 +187,9 @@ class ExternalAPIUtil {
apiResponse = httpClient.post(payload)
- msoLogger.debug( "======== Completed Execute ExternalAPI Post Process ======== ")
+ logger.debug( "======== Completed Execute ExternalAPI Post Process ======== ")
}catch(Exception e){
- msoLogger.error("Exception occured while executing ExternalAPI Post Call. Exception is: \n" + e)
+ logger.error("Exception occured while executing ExternalAPI Post Call. Exception is: \n" + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 9999, e.getMessage())
}
return apiResponse
@@ -194,4 +197,4 @@ class ExternalAPIUtil {
-} \ No newline at end of file
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy
index 480dcd5e8f..2a8f8f1593 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -28,20 +30,22 @@ import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
public class FalloutHandler extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, FalloutHandler.class);
+ private static final Logger logger = LoggerFactory.getLogger( FalloutHandler.class);
String Prefix="FH_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
-
+
public initializeProcessVariables(DelegateExecution execution){
def method = getClass().getSimpleName() + '.initializeProcessVariables(' +'execution=' + execution.getId() +')'
- msoLogger.trace('Entered ' + method)
-
+ logger.trace('Entered ' + method)
+
try {
execution.setVariable("prefix",Prefix)
-
+
//These variables are form the input Message to the BPMN
execution.setVariable("FH_request_id","")
execution.setVariable("FH_request_action","")
@@ -83,42 +87,44 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
//Auth variables
execution.setVariable("BasicAuthHeaderValue","")
-
+
//Parameter list
execution.setVariable("FH_parameterList", "")
-
+
//Response variables
execution.setVariable("FalloutHandlerResponse","")
execution.setVariable("FH_ErrorResponse", null)
execution.setVariable("FH_ResponseCode", "")
-
+
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
// exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method)
}
}
-
+
public void preProcessRequest (DelegateExecution execution) {
def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'
- msoLogger.trace('Entered ' + method)
-
+ logger.trace('Entered ' + method)
+
// Initialize flow variables
initializeProcessVariables(execution)
setSuccessIndicator(execution, false)
-
+
setBasicDBAuthHeader(execution, execution.getVariable('isDebugLogEnabled'))
-
+
try {
def xml = execution.getVariable("FalloutHandlerRequest")
- msoLogger.debug(" XML --> " + xml)
- msoLogger.debug("FalloutHandler request: " + xml)
-
+ logger.debug(" XML --> " + xml)
+ logger.debug("FalloutHandler request: " + xml)
+
//Check the incoming request type
//Incoming request can be ACTIVE_REQUESTS (request-information node) or INFRA_ACTIVE_REQUESTS (request-info node)
if (utils.nodeExists(xml, "request-information")) {
execution.setVariable("FH_request_id-Ok", true) // Incoming request is for ACTIVE_REQUESTS
}
-
+
//Check notification-url for the incoming request type
//ACTIVE_REQUESTS may have notificationurl node
//INFRA_ACTIVE_REQUESTS notificationurl node does not exist
@@ -126,7 +132,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
if (utils.nodeExists(xml, "notification-url")) {
notificationurl = utils.getNodeText(xml,"notification-url")
if(notificationurl != null && !notificationurl.isEmpty()) {
- msoLogger.debug("********** Incoming notification Url is: " + notificationurl);
+ logger.debug("********** Incoming notification Url is: " + notificationurl);
execution.setVariable("FH_notification-url-Ok", true)
execution.setVariable("FH_notification-url",notificationurl)
}
@@ -139,8 +145,8 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
if (utils.nodeExists(xml, "request-id")) {
execution.setVariable("FH_request_id",utils.getNodeText(xml,"request-id"))
}
- msoLogger.debug("FH_request_id: " + execution.getVariable("FH_request_id"))
-
+ logger.debug("FH_request_id: " + execution.getVariable("FH_request_id"))
+
// INFRA_ACTIVE_REQUESTS have "action" element ... mandatory
// ACTIVE_REQUEST have "request-action" ... mandatory
if (utils.nodeExists(xml, "request-action")) {
@@ -148,8 +154,8 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
} else if (utils.nodeExists(xml, "action")) {
execution.setVariable("FH_request_action",utils.getNodeText(xml,"action"))
}
-
-
+
+
//Check source for the incoming request type
//For INFRA_ACTIVE_REQUESTS payload source IS optional
//For ACTIVE_REQUESTS payload source is NOT optional
@@ -157,7 +163,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
if (utils.nodeExists(xml, "source")) {
execution.setVariable("FH_source",utils.getNodeText(xml,"source"))
}
-
+
//Check if ErrorCode node exists. If yes, initialize it from request xml, if no, it will stay with defaulf value already set in initializeProcessVariables() method above.
def errorCode = ""
if (utils.nodeExists(xml, "ErrorCode")) {
@@ -166,8 +172,8 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
execution.setVariable("FH_ErrorCode", errorCode)
}
}
- msoLogger.debug("FH_ErrorCode: " + errorCode)
-
+ logger.debug("FH_ErrorCode: " + errorCode)
+
//Check if ErrorMessage node exists. If yes, initialize it from request xml, if no, it will stay with defaulf value already set in initializeProcessVariables() method above.
def errorMessage = ""
if (utils.nodeExists(xml, "ErrorMessage")) {
@@ -177,25 +183,25 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
execution.setVariable("FH_ErrorMessage", errorCode)
}
}
-
+
//Check for Parameter List
if (utils.nodeExists(xml, "parameter-list")) {
def parameterList = utils.getNodeXml(xml, "parameter-list", false)
execution.setVariable("FH_parameterList", parameterList)
}
-
- msoLogger.trace("--> " + execution.getVariable(""))
- msoLogger.debug("FH_request_id-OK --> " + execution.getVariable("FH_request_id-Ok"))
-
+
+ logger.trace("--> " + execution.getVariable(""))
+ logger.debug("FH_request_id-OK --> " + execution.getVariable("FH_request_id-Ok"))
+
// set the DHV/Service Instantiation values if specified in the request
execution.setVariable("FH_is_srv_inst_req", String.valueOf("true".equals(utils.getNodeText(xml, "is-srv-inst-req"))))
- msoLogger.trace("--> " + execution.getVariable(""))
+ logger.trace("--> " + execution.getVariable(""))
execution.setVariable("FH_is_json_content", String.valueOf("JSON".equals(utils.getNodeText(xml, "resp-content-type"))))
- msoLogger.trace("--> " + execution.getVariable(""))
+ logger.trace("--> " + execution.getVariable(""))
execution.setVariable("FH_service_inst_id", utils.getNodeText(xml, "service-instance-id"))
- msoLogger.trace("--> " + execution.getVariable(""))
+ logger.trace("--> " + execution.getVariable(""))
execution.setVariable("FH_start_time", utils.getNodeText(xml, "start-time"))
- msoLogger.trace("--> " + execution.getVariable(""))
+ logger.trace("--> " + execution.getVariable(""))
// this variable is used by the camunda flow to set the Content-Type for the async response
if (execution.getVariable("FH_is_srv_inst_req").equals("true") &&
execution.getVariable("FH_is_json_content").equals("true")) {
@@ -204,17 +210,19 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
execution.setVariable("FH_content_type", "text/xml")
}
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
// exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
}
-
- msoLogger.debug("OUTOF --> Initialize Variables Fallout Handler #########");
+
+ logger.debug("OUTOF --> Initialize Variables Fallout Handler #########");
}
-
+
public String updateRequestPayload (DelegateExecution execution){
def method = getClass().getSimpleName() + '.updateRequestPayload(' +'execution=' + execution.getId() +')'
- msoLogger.trace('Entered ' + method)
-
+ logger.trace('Entered ' + method)
+
try {
String payload = """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
@@ -231,19 +239,21 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
</soapenv:Body>
</soapenv:Envelope>
"""
-
- msoLogger.debug("updateRequestPayload: " + payload)
+
+ logger.debug("updateRequestPayload: " + payload)
execution.setVariable("FH_updateRequestPayload", payload)
return execution.getVariable("FH_updateRequestPayload")
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
// exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method)
}
}
-
+
public String updateRequestInfraPayload (DelegateExecution execution){
def method = getClass().getSimpleName() + '.updateRequestInfraPayload(' +'execution=' + execution.getId() +')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
String payload = """
@@ -262,18 +272,20 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
"""
execution.setVariable("FH_updateRequestInfraPayload", payload)
- msoLogger.debug("updateRequestInfraPayload: " + payload)
+ logger.debug("updateRequestInfraPayload: " + payload)
return execution.getVariable("FH_updateRequestInfraPayload")
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
// exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method)
}
}
-
+
public String updateRequestGammaPayload (DelegateExecution execution){
def method = getClass().getSimpleName() + '.updateRequestGammaPayload(' +'execution=' + execution.getId() +')'
- msoLogger.trace('Entered ' + method)
-
+ logger.trace('Entered ' + method)
+
try {
String payload = """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="${UrnPropertiesReader.getVariable("mso.default.adapter.namespace", execution)}/requestsdb">
@@ -289,20 +301,22 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
</soapenv:Body>
</soapenv:Envelope>
"""
-
+
execution.setVariable("FH_updateRequestGammaPayload", payload)
- msoLogger.debug("updateRequestGammaPayload: " + payload)
+ logger.debug("updateRequestGammaPayload: " + payload)
return execution.getVariable("FH_updateRequestGammaPayload")
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
// exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method)
}
}
-
+
public String updateResponseStatusPayload (DelegateExecution execution){
def method = getClass().getSimpleName() + '.updateResponseStatusPayload(' +'execution=' + execution.getId() +')'
- msoLogger.trace('Entered ' + method)
-
+ logger.trace('Entered ' + method)
+
try {
String payload = """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
@@ -316,22 +330,24 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
</soapenv:Body>
</soapenv:Envelope>
"""
-
+
execution.setVariable("FH_updateResponseStatusPayload", payload)
- msoLogger.debug("updateResponseStatusPayload: " + payload)
+ logger.debug("updateResponseStatusPayload: " + payload)
return execution.getVariable("FH_updateResponseStatusPayload")
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
// exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method)
}
}
-
+
public void buildDBWorkflowException(DelegateExecution execution, String responseCodeVariable) {
def method = getClass().getSimpleName() + '.buildDBWorkflowException(' +
'execution=' + execution.getId() +
', responseCodeVariable=' + responseCodeVariable + ')'
- msoLogger.trace('Entered ' + method)
-
+ logger.trace('Entered ' + method)
+
try {
def responseCode = execution.getVariable(responseCodeVariable)
// If the HTTP response code was null, it means a connection fault occurred (a java exception)
@@ -339,40 +355,44 @@ public class FalloutHandler extends AbstractServiceTaskProcessor {
def errorCode = responseCode == null ? 7000 : 7020
// exceptionUtil.buildWorkflowException(execution, errorCode, errorMessage)
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
// exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method)
}
}
-
+
/**
* Used to create a workflow response in success and failure cases.
*/
public void postProcessResponse (DelegateExecution execution) {
def method = getClass().getSimpleName() + '.postProcessResponse(' +'execution=' + execution.getId() +')'
- msoLogger.trace('Entered ' + method)
-
+ logger.trace('Entered ' + method)
+
try {
Boolean success = (Boolean) execution.getVariable("FH_success")
String out = success ? "Fallout Handler Succeeded" : "Fallout Handler Failed";
-
+
String falloutHandlerResponse = """
<workflow:FalloutHandlerResponse xmlns:workflow="http://org.onap/so/workflow/schema/v1">
<workflow:out>${MsoUtils.xmlEscape(out)}</workflow:out>
</workflow:FalloutHandlerResponse>
"""
-
+
falloutHandlerResponse = utils.formatXml(falloutHandlerResponse)
- msoLogger.debug("FalloutHandler Response: " + falloutHandlerResponse);
-
+ logger.debug("FalloutHandler Response: " + falloutHandlerResponse);
+
execution.setVariable("FalloutHandlerResponse", falloutHandlerResponse)
execution.setVariable("WorkflowResponse", falloutHandlerResponse)
execution.setVariable("FH_ResponseCode", success ? "200" : "500")
setSuccessIndicator(execution, success)
-
- msoLogger.debug("FalloutHandlerResponse =\n" + falloutHandlerResponse)
+
+ logger.debug("FalloutHandlerResponse =\n" + falloutHandlerResponse)
} catch (Exception e) {
// Do NOT throw WorkflowException!
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
}
}
-} \ No newline at end of file
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy
index 1be24c4ce0..4d7557bfcd 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -41,9 +43,11 @@ import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.utils.TargetEntity
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, GenerateVfModuleName.class);
+ private static final Logger logger = LoggerFactory.getLogger( GenerateVfModuleName.class);
def Prefix="GVFMN_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -53,13 +57,13 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
public void preProcessRequest(DelegateExecution execution) {
try {
def vnfId = execution.getVariable("vnfId")
- msoLogger.debug("vnfId is " + vnfId)
+ logger.debug("vnfId is " + vnfId)
def vnfName = execution.getVariable("vnfName")
- msoLogger.debug("vnfName is " + vnfName)
+ logger.debug("vnfName is " + vnfName)
def vfModuleLabel = execution.getVariable("vfModuleLabel")
- msoLogger.debug("vfModuleLabel is " + vfModuleLabel)
+ logger.debug("vfModuleLabel is " + vfModuleLabel)
def personaModelId = execution.getVariable("personaModelId")
- msoLogger.debug("personaModelId is " + personaModelId)
+ logger.debug("personaModelId is " + personaModelId)
execution.setVariable("GVFMN_vfModuleXml", "")
}catch(BpmnError b){
throw b
@@ -73,7 +77,7 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
def method = getClass().getSimpleName() + '.queryAAI(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def vnfId = execution.getVariable('vnfId')
@@ -84,7 +88,7 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
uri.depth(Depth.ONE)
String endPoint = aaiUtil.createAaiUri(uri)
- msoLogger.debug("AAI endPoint: " + endPoint)
+ logger.debug("AAI endPoint: " + endPoint)
try {
HttpClient client = new HttpClientFactory().newXmlClient(new URL(endPoint), TargetEntity.AAI)
@@ -96,29 +100,29 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
def responseData = ''
- msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'')
+ logger.debug('sending GET to AAI endpoint \'' + endPoint + '\'')
Response response = client.get()
- msoLogger.debug("GenerateVfModuleName - invoking httpGet() to AAI")
+ logger.debug("GenerateVfModuleName - invoking httpGet() to AAI")
responseData = response.readEntity(String.class)
if (responseData != null) {
- msoLogger.debug("Received generic VNF data: " + responseData)
+ logger.debug("Received generic VNF data: " + responseData)
}
- msoLogger.debug("GenerateVfModuleName - queryAAIVfModule Response: " + responseData)
- msoLogger.debug("GenerateVfModuleName - queryAAIVfModule ResponseCode: " + response.getStatus())
+ logger.debug("GenerateVfModuleName - queryAAIVfModule Response: " + responseData)
+ logger.debug("GenerateVfModuleName - queryAAIVfModule ResponseCode: " + response.getStatus())
execution.setVariable('GVFMN_queryAAIVfModuleResponseCode', response.getStatus())
execution.setVariable('GVFMN_queryAAIVfModuleResponse', responseData)
- msoLogger.debug('Response code:' + response.getStatus())
- msoLogger.debug('Response:' + System.lineSeparator() + responseData)
+ logger.debug('Response code:' + response.getStatus())
+ logger.debug('Response:' + System.lineSeparator() + responseData)
if (response.getStatus() == 200) {
// Set the VfModuleXML
if (responseData != null) {
String vfModulesText = utils.getNodeXml(responseData, "vf-modules")
if (vfModulesText == null || vfModulesText.isEmpty()) {
- msoLogger.debug("There are no VF modules in this VNF yet")
+ logger.debug("There are no VF modules in this VNF yet")
execution.setVariable("GVFMN_vfModuleXml", null)
}
else {
@@ -141,21 +145,23 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
}
}
matchingVfModules = matchingVfModules + "</vfModules>"
- msoLogger.debug("Matching VF Modules: " + matchingVfModules)
+ logger.debug("Matching VF Modules: " + matchingVfModules)
execution.setVariable("GVFMN_vfModuleXml", matchingVfModules)
}
}
}
} catch (Exception ex) {
ex.printStackTrace()
- msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
}
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAI(): ' + e.getMessage())
}
@@ -165,16 +171,16 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
def method = getClass().getSimpleName() + '.generateName() ' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
String vfModuleXml = execution.getVariable("GVFMN_vfModuleXml")
String moduleIndex = utils.getLowestUnusedIndex(vfModuleXml)
- msoLogger.debug("moduleIndex is: " + moduleIndex)
+ logger.debug("moduleIndex is: " + moduleIndex)
def vnfName = execution.getVariable("vnfName")
def vfModuleLabel = execution.getVariable("vfModuleLabel")
def vfModuleName = vnfName + "_" + vfModuleLabel + "_" + moduleIndex
- msoLogger.debug("vfModuleName is: " + vfModuleName)
+ logger.debug("vfModuleName is: " + vfModuleName)
execution.setVariable("vfModuleName", vfModuleName)
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericNotificationService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericNotificationService.groovy
index 591e76e491..1163b6bf08 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericNotificationService.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericNotificationService.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -27,16 +29,10 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
import java.text.SimpleDateFormat
-import org.onap.so.logger.MessageEnum
-import org.onap.so.logger.MsoLogger
public class GenericNotificationService extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, GenericNotificationService.class);
-
-
-
ExceptionUtil exceptionUtil = new ExceptionUtil()
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy
index 820364b1f7..7e04adbff2 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -43,6 +45,8 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.ruby.*
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
@@ -73,7 +77,7 @@ import org.onap.so.logger.MsoLogger
*
*/
public class ManualHandling extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ManualHandling.class);
+ private static final Logger logger = LoggerFactory.getLogger( ManualHandling.class);
String Prefix="MH_"
@@ -83,46 +87,46 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
public void preProcessRequest (DelegateExecution execution) {
String msg = ""
- msoLogger.trace("preProcessRequest of ManualHandling ")
+ logger.trace("preProcessRequest of ManualHandling ")
try {
execution.setVariable("prefix", Prefix)
setBasicDBAuthHeader(execution, execution.getVariable('isDebugLogEnabled'))
// check for required input
String requestId = execution.getVariable("msoRequestId")
- msoLogger.debug("msoRequestId is: " + requestId)
+ logger.debug("msoRequestId is: " + requestId)
def serviceType = execution.getVariable("serviceType")
- msoLogger.debug("serviceType is: " + serviceType)
+ logger.debug("serviceType is: " + serviceType)
def vnfType = execution.getVariable("vnfType")
- msoLogger.debug("vnftype is: " + vnfType)
+ logger.debug("vnftype is: " + vnfType)
def currentActivity = execution.getVariable("currentActivity")
- msoLogger.debug("currentActivity is: " + currentActivity)
+ logger.debug("currentActivity is: " + currentActivity)
def workStep = execution.getVariable("workStep")
- msoLogger.debug("workStep is: " + workStep)
+ logger.debug("workStep is: " + workStep)
def failedActivity = execution.getVariable("failedActivity")
- msoLogger.debug("failedActivity is: " + failedActivity)
+ logger.debug("failedActivity is: " + failedActivity)
def errorCode = execution.getVariable("errorCode")
- msoLogger.debug("errorCode is: " + errorCode)
+ logger.debug("errorCode is: " + errorCode)
def errorText = execution.getVariable("errorText")
- msoLogger.debug("errorText is: " + errorText)
+ logger.debug("errorText is: " + errorText)
def requestorId = execution.getVariable("requestorId")
- msoLogger.debug("requestorId is: " + requestorId)
+ logger.debug("requestorId is: " + requestorId)
def validResponses = execution.getVariable("validResponses")
- msoLogger.debug("validResponses is: " + validResponses)
+ logger.debug("validResponses is: " + validResponses)
} catch (BpmnError e) {
throw e;
} catch (Exception ex){
msg = "Exception in preProcessRequest " + ex.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit preProcessRequest of RainyDayHandler ")
+ logger.trace("Exit preProcessRequest of RainyDayHandler ")
}
public void createManualTask (DelegateExecution execution) {
String msg = ""
- msoLogger.trace("createManualTask of ManualHandling ")
+ logger.trace("createManualTask of ManualHandling ")
try {
String taskId = UUID.randomUUID()
@@ -139,7 +143,7 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
String buildingBlockStep = execution.getVariable("workStep")
String validResponses = execution.getVariable("validResponses")
- msoLogger.debug("Before creating task")
+ logger.debug("Before creating task")
Map<String, String> taskVariables = new HashMap<String, String>()
taskVariables.put("type", type)
@@ -158,16 +162,16 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
Task manualTask = taskService.newTask(taskId)
taskService.saveTask(manualTask)
taskService.setVariables(taskId, taskVariables)
- msoLogger.debug("successfully created task: "+ taskId)
+ logger.debug("successfully created task: "+ taskId)
} catch (BpmnError e) {
- msoLogger.debug("BPMN exception: " + e.errorMessage)
+ logger.debug("BPMN exception: " + e.errorMessage)
throw e;
} catch (Exception ex){
msg = "Exception in createManualTask " + ex.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit createManualTask of ManualHandling ")
+ logger.trace("Exit createManualTask of ManualHandling ")
}
public void setTaskVariables (DelegateTask task) {
@@ -175,9 +179,9 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
DelegateExecution execution = task.getExecution()
String msg = ""
- msoLogger.trace("setTaskVariables of ManualHandling ")
+ logger.trace("setTaskVariables of ManualHandling ")
String taskId = task.getId()
- msoLogger.debug("taskId is: " + taskId)
+ logger.debug("taskId is: " + taskId)
try {
execution.setVariable('taskId', taskId)
@@ -193,7 +197,7 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
String buildingBlockStep = execution.getVariable("workStep")
String validResponses = execution.getVariable("validResponses")
- msoLogger.debug("Before creating task")
+ logger.debug("Before creating task")
Map<String, String> taskVariables = new HashMap<String, String>()
taskVariables.put("type", type)
@@ -211,16 +215,16 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
taskService.setVariables(taskId, taskVariables)
- msoLogger.debug("successfully created task: "+ taskId)
+ logger.debug("successfully created task: "+ taskId)
} catch (BpmnError e) {
- msoLogger.debug("BPMN exception: " + e.errorMessage)
+ logger.debug("BPMN exception: " + e.errorMessage)
throw e;
} catch (Exception ex){
msg = "Exception in createManualTask " + ex.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit createManualTask of ManualHandling ")
+ logger.trace("Exit createManualTask of ManualHandling ")
}
public void completeTask (DelegateTask task) {
@@ -228,9 +232,9 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
DelegateExecution execution = task.getExecution()
String msg = ""
- msoLogger.trace("completeTask of ManualHandling ")
+ logger.trace("completeTask of ManualHandling ")
String taskId = task.getId()
- msoLogger.debug("taskId is: " + taskId)
+ logger.debug("taskId is: " + taskId)
try {
TaskService taskService = execution.getProcessEngineServices().getTaskService()
@@ -238,27 +242,27 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
Map<String, String> taskVariables = taskService.getVariables(taskId)
String responseValue = taskVariables.get("responseValue")
- msoLogger.debug("Received responseValue on completion: "+ responseValue)
+ logger.debug("Received responseValue on completion: "+ responseValue)
// Have to set the first letter of the response to upper case
String responseValueForRainyDay = responseValue.substring(0, 1).toUpperCase() + responseValue.substring(1)
- msoLogger.debug("ResponseValue to RainyDayHandler: "+ responseValueForRainyDay)
+ logger.debug("ResponseValue to RainyDayHandler: "+ responseValueForRainyDay)
execution.setVariable("responseValue", responseValueForRainyDay)
} catch (BpmnError e) {
- msoLogger.debug("BPMN exception: " + e.errorMessage)
+ logger.debug("BPMN exception: " + e.errorMessage)
throw e;
} catch (Exception ex){
msg = "Exception in createManualTask " + ex.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit completeTask of ManualHandling ")
+ logger.trace("Exit completeTask of ManualHandling ")
}
public void prepareRequestsDBStatusUpdate (DelegateExecution execution, String requestStatus){
def method = getClass().getSimpleName() + '.prepareRequestsDBStatusUpdate(' +'execution=' + execution.getId() +')'
- msoLogger.trace("prepareRequestsDBStatusUpdate of ManualHandling ")
+ logger.trace("prepareRequestsDBStatusUpdate of ManualHandling ")
try {
def requestId = execution.getVariable("msoRequestId")
String payload = """
@@ -267,29 +271,31 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
<soapenv:Body>
<req:updateInfraRequest>
<requestId>${MsoUtils.xmlEscape(requestId)}</requestId>
- <lastModifiedBy>ManualHandling</lastModifiedBy>
- <requestStatus>${MsoUtils.xmlEscape(requestStatus)}</requestStatus>
+ <lastModifiedBy>ManualHandling</lastModifiedBy>
+ <requestStatus>${MsoUtils.xmlEscape(requestStatus)}</requestStatus>
</req:updateInfraRequest>
</soapenv:Body>
</soapenv:Envelope>
"""
execution.setVariable("setUpdateDBstatusPayload", payload)
- msoLogger.debug("Outgoing Update Mso Request Payload is: " + payload)
- msoLogger.debug("setUpdateDBstatusPayload: " + payload)
+ logger.debug("Outgoing Update Mso Request Payload is: " + payload)
+ logger.debug("setUpdateDBstatusPayload: " + payload)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
}
- msoLogger.trace("Exit prepareRequestsDBStatusUpdate of ManualHandling ")
+ logger.trace("Exit prepareRequestsDBStatusUpdate of ManualHandling ")
}
public void createAOTSTicket (DelegateExecution execution) {
String msg = ""
- msoLogger.trace("createAOTSTicket of ManualHandling ")
+ logger.trace("createAOTSTicket of ManualHandling ")
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
// This method will not be throwing an exception, but rather log the error
@@ -298,44 +304,46 @@ public class ManualHandling extends AbstractServiceTaskProcessor {
setBasicDBAuthHeader(execution,isDebugLogEnabled)
// check for required input
String requestId = execution.getVariable("msoRequestId")
- msoLogger.debug("requestId is: " + requestId)
+ logger.debug("requestId is: " + requestId)
def currentActivity = execution.getVariable("currentActivity")
- msoLogger.debug("currentActivity is: " + currentActivity)
+ logger.debug("currentActivity is: " + currentActivity)
def workStep = execution.getVariable("workStep")
- msoLogger.debug("workStep is: " + workStep)
+ logger.debug("workStep is: " + workStep)
def failedActivity = execution.getVariable("failedActivity")
- msoLogger.debug("failedActivity is: " + failedActivity)
+ logger.debug("failedActivity is: " + failedActivity)
def errorCode = execution.getVariable("errorCode")
- msoLogger.debug("errorCode is: " + errorCode)
+ logger.debug("errorCode is: " + errorCode)
def errorText = execution.getVariable("errorText")
- msoLogger.debug("errorText is: " + errorText)
+ logger.debug("errorText is: " + errorText)
def vnfName = execution.getVariable("vnfName")
- msoLogger.debug("vnfName is: " + vnfName)
+ logger.debug("vnfName is: " + vnfName)
String rubyRequestId = UUID.randomUUID()
- msoLogger.debug("rubyRequestId: " + rubyRequestId)
+ logger.debug("rubyRequestId: " + rubyRequestId)
String sourceName = vnfName
- msoLogger.debug("sourceName: " + sourceName)
+ logger.debug("sourceName: " + sourceName)
String reason = "VID Workflow failed at " + failedActivity + " " + workStep + " call with error " + errorCode
- msoLogger.debug("reason: " + reason)
+ logger.debug("reason: " + reason)
String workflowId = requestId
- msoLogger.debug("workflowId: " + workflowId)
+ logger.debug("workflowId: " + workflowId)
String notification = "Request originated from VID | Workflow fallout on " + vnfName + " | Workflow step failure: " + workStep + " failed | VID workflow ID: " + workflowId
- msoLogger.debug("notification: " + notification)
+ logger.debug("notification: " + notification)
- msoLogger.debug("Creating AOTS Ticket request")
+ logger.debug("Creating AOTS Ticket request")
RubyClient rubyClient = new RubyClient()
rubyClient.rubyCreateTicketCheckRequest(rubyRequestId, sourceName, reason, workflowId, notification)
} catch (BpmnError e) {
msg = "BPMN error in createAOTSTicket " + ex.getMessage()
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
} catch (Exception ex){
msg = "Exception in createAOTSTicket " + ex.getMessage()
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
}
- msoLogger.trace("Exit createAOTSTicket of ManualHandling ")
+ logger.trace("Exit createAOTSTicket of ManualHandling ")
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
index 4f0b530a3b..ff1d2ecb19 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -28,6 +30,8 @@ import org.onap.so.bpmn.core.BPMNLogger
import org.onap.so.bpmn.core.xml.XmlTool
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import org.onap.so.utils.CryptoUtils
import org.slf4j.MDC
import org.w3c.dom.Element
@@ -36,16 +40,16 @@ import groovy.util.slurpersupport.NodeChild
import groovy.xml.XmlUtil
class MsoUtils {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, MsoUtils.class);
-
+ private static final Logger logger = LoggerFactory.getLogger( MsoUtils.class);
+
def initializeEndPoints(execution){
// use this placeholder to initialize end points, if called independently, this need to be set
- execution.setVariable("AAIEndPoint","http://localhost:28080/SoapUIMocks")
+ execution.setVariable("AAIEndPoint","http://localhost:28080/SoapUIMocks")
}
-
+
/**
* Returns the unescaped contents of element
- *
+ *
* @param xmlInput
* @param element
* @return
@@ -287,36 +291,38 @@ class MsoUtils {
return null
}
}
-
+
def log(logmode,logtxt,isDebugLogEnabled="false"){
if ("INFO"==logmode) {
- msoLogger.info(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, logtxt, "BPMN", MsoLogger.getServiceName());
+ logger.info(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, logtxt, "BPMN", MsoLogger.getServiceName());
} else if ("WARN"==logmode) {
// to see the warning text displayed in the log entry, the text must also be passed as arg0 (2nd argument) to invoke the correct MsoLogger warn() method
- msoLogger.warn (MessageEnum.BPMN_GENERAL_WARNING, logtxt, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logtxt);
+ logger.warn ("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), logtxt, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(), logtxt);
} else if ("ERROR"==logmode) {
// to see the error text displayed in the log entry, the text must also be passed as arg0 (2nd argument) to invoke the correct MsoLogger error() method
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, logtxt, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logtxt);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), logtxt, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(), logtxt);
} else {
BPMNLogger.debug(isDebugLogEnabled, logtxt);
}
}
-
+
def logContext(requestId, serviceInstanceId){
- msoLogger.setLogContext(requestId, serviceInstanceId);
+// msoLogger.setLogContext(requestId, serviceInstanceId);
}
def logMetrics(elapsedTime, logtxt){
- msoLogger.recordMetricEvent (elapsedTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- logtxt, "BPMN", MsoLogger.getServiceName(), null);
+// msoLogger.recordMetricEvent (elapsedTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+// logtxt, "BPMN", MsoLogger.getServiceName(), null);
}
-
+
def logAudit(logtxt){
long startTime = System.currentTimeMillis();
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logtxt);
+// msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logtxt);
}
// headers: header - name-value
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
index 5e949fd8d2..cac7a35282 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 Intel Corp. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -32,7 +34,8 @@ import org.onap.so.bpmn.core.domain.VnfResource
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
import org.onap.so.client.HttpClientFactory
-import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import org.onap.so.db.catalog.beans.CloudIdentity
import org.onap.so.db.catalog.beans.CloudSite
import org.onap.so.db.catalog.beans.HomingInstance
@@ -54,6 +57,7 @@ import javax.ws.rs.core.Response
* resources by calling OOF.
*/
class OofHoming extends AbstractServiceTaskProcessor {
+ private static final Logger logger = LoggerFactory.getLogger( OofHoming.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
@@ -67,29 +71,28 @@ class OofHoming extends AbstractServiceTaskProcessor {
* @param execution
*/
public void callOof(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
execution.setVariable("prefix", "HOME_")
- utils.log("DEBUG", "*** Started Homing Call OOF ***", isDebugEnabled)
+ logger.debug( "*** Started Homing Call OOF ***")
try {
execution.setVariable("rollbackData", null)
execution.setVariable("rolledBack", false)
String requestId = execution.getVariable("msoRequestId")
- utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled)
+ logger.debug( "Incoming Request Id is: " + requestId)
String serviceInstanceId = execution.getVariable("serviceInstanceId")
- utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled)
+ logger.debug( "Incoming Service Instance Id is: " + serviceInstanceId)
String serviceInstanceName = execution.getVariable("serviceInstanceName")
- utils.log("DEBUG", "Incoming Service Instance Name is: " + serviceInstanceName, isDebugEnabled)
+ logger.debug( "Incoming Service Instance Name is: " + serviceInstanceName)
ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- utils.log("DEBUG", "Incoming Service Decomposition is: " + serviceDecomposition, isDebugEnabled)
+ logger.debug( "Incoming Service Decomposition is: " + serviceDecomposition)
String subscriberInfo = execution.getVariable("subscriberInfo")
- utils.log("DEBUG", "Incoming Subscriber Information is: " + subscriberInfo, isDebugEnabled)
+ logger.debug( "Incoming Subscriber Information is: " + subscriberInfo)
Map customerLocation = execution.getVariable("customerLocation")
- utils.log("DEBUG", "Incoming Customer Location is: " + customerLocation.toString(), isDebugEnabled)
+ logger.debug( "Incoming Customer Location is: " + customerLocation.toString())
String cloudOwner = execution.getVariable("cloudOwner")
- utils.log("DEBUG", "Incoming cloudOwner is: " + cloudOwner, isDebugEnabled)
+ logger.debug( "Incoming cloudOwner is: " + cloudOwner)
String cloudRegionId = execution.getVariable("cloudRegionId")
- utils.log("DEBUG", "Incoming cloudRegionId is: " + cloudRegionId, isDebugEnabled)
+ logger.debug( "Incoming cloudRegionId is: " + cloudRegionId)
if (isBlank(requestId) ||
isBlank(serviceInstanceId) ||
@@ -119,18 +122,17 @@ class OofHoming extends AbstractServiceTaskProcessor {
String basicAuthValue = utils.encrypt(basicAuth, msokey)
if (basicAuthValue != null) {
- utils.log("DEBUG", "Obtained BasicAuth username and password for OOF Adapter: " + basicAuthValue,
- isDebugEnabled)
+ logger.debug( "Obtained BasicAuth username and password for OOF Adapter: " + basicAuthValue)
try {
authHeader = utils.getBasicAuth(basicAuthValue, msokey)
execution.setVariable("BasicAuthHeaderValue", authHeader)
} catch (Exception ex) {
- utils.log("DEBUG", "Unable to encode username and password string: " + ex, isDebugEnabled)
+ logger.debug( "Unable to encode username and password string: " + ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
"encode username and password string")
}
} else {
- utils.log("DEBUG", "Unable to obtain BasicAuth - BasicAuth value null", isDebugEnabled)
+ logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
"value null")
}
@@ -143,7 +145,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
timeout = "PT30M"
}
}
- utils.log("DEBUG", "Async Callback Timeout will be: " + timeout, isDebugEnabled)
+ logger.debug( "Async Callback Timeout will be: " + timeout)
execution.setVariable("timeout", timeout)
execution.setVariable("correlator", requestId)
@@ -153,10 +155,10 @@ class OofHoming extends AbstractServiceTaskProcessor {
String oofRequest = oofUtils.buildRequest(execution, requestId, serviceDecomposition,
subscriber, customerLocation)
execution.setVariable("oofRequest", oofRequest)
- utils.log("DEBUG", "OOF Request is: " + oofRequest, isDebugEnabled)
+ logger.debug( "OOF Request is: " + oofRequest)
String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
- utils.log("DEBUG", "Posting to OOF Url: " + urlString, isDebugEnabled)
+ logger.debug( "Posting to OOF Url: " + urlString)
URL url = new URL(urlString);
@@ -165,15 +167,15 @@ class OofHoming extends AbstractServiceTaskProcessor {
Response httpResponse = httpClient.post(oofRequest)
int responseCode = httpResponse.getStatus()
- logDebug("OOF sync response code is: " + responseCode, isDebugEnabled)
+ logDebug("OOF sync response code is: " + responseCode)
- utils.log("DEBUG", "*** Completed Homing Call OOF ***", isDebugEnabled)
+ logger.debug( "*** Completed Homing Call OOF ***")
}
} catch (BpmnError b) {
throw b
} catch (Exception e) {
- msoLogger.error(e);
+ logger.error(e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2500,
"Internal Error - Occured in Homing callOof: " + e.getMessage())
}
@@ -188,19 +190,19 @@ class OofHoming extends AbstractServiceTaskProcessor {
* @param execution
*/
public void processHomingSolution(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", "*** Started Homing Process Homing Solution ***", isDebugEnabled)
+
+ logger.debug( "*** Started Homing Process Homing Solution ***")
try {
String response = execution.getVariable("asyncCallbackResponse")
- utils.log("DEBUG", "OOF Async Callback Response is: " + response, isDebugEnabled)
+ logger.debug( "OOF Async Callback Response is: " + response)
utils.logAudit("OOF Async Callback Response is: " + response)
oofUtils.validateCallbackResponse(execution, response)
String placements = jsonUtil.getJsonValue(response, "solutions.placementSolutions")
- utils.log("DEBUG", "****** Solution Placements: " + placements + " *****", isDebugEnabled)
+ logger.debug( "****** Solution Placements: " + placements + " *****")
ServiceDecomposition decomposition = execution.getVariable("serviceDecomposition")
- utils.log("DEBUG", "Service Decomposition: " + decomposition, isDebugEnabled)
+ logger.debug( "Service Decomposition: " + decomposition)
List<Resource> resourceList = decomposition.getServiceResources()
JSONArray arr = new JSONArray(placements)
@@ -208,12 +210,12 @@ class OofHoming extends AbstractServiceTaskProcessor {
JSONArray arrSol = arr.getJSONArray(i)
for (int j = 0; j < arrSol.length(); j++) {
JSONObject placement = arrSol.getJSONObject(j)
- utils.log("DEBUG", "****** Placement Solution is: " + placement + " *****", "true")
+ logger.debug( "****** Placement Solution is: " + placement + " *****")
String jsonServiceResourceId = jsonUtil.getJsonValue( placement.toString(), "serviceResourceId")
- utils.log("DEBUG", "****** homing serviceResourceId is: " + jsonServiceResourceId + " *****", "true")
+ logger.debug( "****** homing serviceResourceId is: " + jsonServiceResourceId + " *****")
for (Resource resource : resourceList) {
String serviceResourceId = resource.getResourceId()
- utils.log("DEBUG", "****** decomp serviceResourceId is: " + serviceResourceId + " *****", "true")
+ logger.debug( "****** decomp serviceResourceId is: " + serviceResourceId + " *****")
if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)) {
JSONObject solution = placement.getJSONObject("solution")
String solutionType = solution.getString("identifierType")
@@ -223,26 +225,26 @@ class OofHoming extends AbstractServiceTaskProcessor {
} else {
inventoryType = "cloud"
}
- utils.log("DEBUG", "****** homing inventoryType is: " + inventoryType + " *****", "true")
+ logger.debug( "****** homing inventoryType is: " + inventoryType + " *****")
resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType))
JSONArray assignmentArr = placement.getJSONArray("assignmentInfo")
- utils.log("DEBUG", "****** assignmentInfo is: " + assignmentArr.toString() + " *****", "true")
+ logger.debug( "****** assignmentInfo is: " + assignmentArr.toString() + " *****")
Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution,
assignmentArr.toString(), "key", "value")
String oofDirectives = null
assignmentMap.each { key, value ->
- utils.log("DEBUG", "****** element: " + key + " *****", "true")
+ logger.debug( "****** element: " + key + " *****")
if (key == "oof_directives") {
oofDirectives = value
- utils.log("DEBUG", "****** homing oofDirectives: " + oofDirectives + " *****", "true")
+ logger.debug( "****** homing oofDirectives: " + oofDirectives + " *****")
}
}
String cloudOwner = assignmentMap.get("cloudOwner")
- utils.log("DEBUG", "****** homing cloudOwner: " + cloudOwner + " *****", "true")
+ logger.debug( "****** homing cloudOwner: " + cloudOwner + " *****")
String cloudRegionId = assignmentMap.get("locationId")
- utils.log("DEBUG", "****** homing cloudRegionId: " + cloudRegionId + " *****", "true")
+ logger.debug( "****** homing cloudRegionId: " + cloudRegionId + " *****")
resource.getHomingSolution().setCloudOwner(cloudOwner)
resource.getHomingSolution().setCloudRegionId(cloudRegionId)
@@ -252,7 +254,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
String orchestrator = execution.getVariable("orchestrator")
if ((orchestrator != null) && (orchestrator != "")) {
cloudSite.setOrchestrator(orchestrator)
- utils.log("DEBUG", "****** orchestrator: " + orchestrator + " *****", "true")
+ logger.debug( "****** orchestrator: " + orchestrator + " *****")
} else {
cloudSite.setOrchestrator("multicloud")
}
@@ -278,15 +280,15 @@ class OofHoming extends AbstractServiceTaskProcessor {
cloudIdentity.setIdentityUrl(msbHost + multicloudApiEndpoint
+ "/" + cloudOwner + "/" +
cloudRegionId + "/infra_workload")
- utils.log("DEBUG", "****** Cloud IdentityUrl: " + msbHost + multicloudApiEndpoint
+ logger.debug( "****** Cloud IdentityUrl: " + msbHost + multicloudApiEndpoint
+ "/" + cloudOwner + "/" +
cloudRegionId + "/infra_workload"
- + " *****", "true")
- utils.log("DEBUG", "****** CloudIdentity: " + cloudIdentity.toString()
- + " *****", "true")
+ + " *****")
+ logger.debug( "****** CloudIdentity: " + cloudIdentity.toString()
+ + " *****")
cloudSite.setIdentityService(cloudIdentity)
- utils.log("DEBUG", "****** CloudSite: " + cloudSite.toString()
- + " *****", "true")
+ logger.debug( "****** CloudSite: " + cloudSite.toString()
+ + " *****")
// Set cloudsite in catalog DB here
oofUtils.createCloudSite(cloudSite, execution)
@@ -294,7 +296,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
if (oofDirectives != null && oofDirectives != "") {
resource.getHomingSolution().setOofDirectives(oofDirectives)
execution.setVariable("oofDirectives", oofDirectives)
- utils.log("DEBUG", "***** OofDirectives set to: " + oofDirectives +
+ logger.debug( "***** OofDirectives set to: " + oofDirectives +
" *****", "true")
}
@@ -319,8 +321,8 @@ class OofHoming extends AbstractServiceTaskProcessor {
resource.getHomingSolution().setServiceInstanceId(solution.getJSONArray("identifiers")[0].toString())
}
} else {
- utils.log("DEBUG", "ProcessHomingSolution Exception: no matching serviceResourceIds returned in " +
- "homing solution", isDebugEnabled)
+ logger.debug( "ProcessHomingSolution Exception: no matching serviceResourceIds returned in " +
+ "homing solution")
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - " +
"Occurred in Homing ProcessHomingSolution: no matching serviceResourceIds returned")
@@ -351,13 +353,13 @@ class OofHoming extends AbstractServiceTaskProcessor {
execution.setVariable("serviceDecomposition", decomposition)
execution.setVariable("homingSolution", placements) //TODO - can be removed as output variable
- utils.log("DEBUG", "*** Completed Homing Process Homing Solution ***", isDebugEnabled)
+ logger.debug( "*** Completed Homing Process Homing Solution ***")
} catch (BpmnError b) {
- utils.log("DEBUG", "ProcessHomingSolution Error: " + b, isDebugEnabled)
+ logger.debug( "ProcessHomingSolution Error: " + b)
throw b
} catch (Exception e) {
- utils.log("DEBUG", "ProcessHomingSolution Exception: " + e, isDebugEnabled)
- msoLogger.error(e);
+ logger.debug( "ProcessHomingSolution Exception: " + e)
+ logger.error(e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in Homing ProcessHomingSolution")
}
}
@@ -369,14 +371,13 @@ class OofHoming extends AbstractServiceTaskProcessor {
* @param - execution
*/
public String logStart(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+
String requestId = execution.getVariable("testReqId")
if (isBlank(requestId)) {
requestId = execution.getVariable("msoRequestId")
}
execution.setVariable("DHVCS_requestId", requestId)
- utils.log("DEBUG", "***** STARTED Homing Subflow for request: " + requestId + " *****", "true")
- utils.log("DEBUG", "****** Homing Subflow Global Debug Enabled: " + isDebugEnabled + " *****", "true")
+ logger.debug( "***** STARTED Homing Subflow for request: " + requestId + " *****")
utils.logAudit("***** STARTED Homing Subflow for request: " + requestId + " *****")
}
@@ -404,18 +405,18 @@ class OofHoming extends AbstractServiceTaskProcessor {
'mso:workflow:message:endpoint was not passed in')
}
- utils.log("DEBUG", "passed in endpoint: " + endpoint + " *****", "true")
+ logger.debug( "passed in endpoint: " + endpoint + " *****")
while (endpoint.endsWith('/')) {
endpoint = endpoint.substring(0, endpoint.length() - 1)
}
- utils.log("DEBUG", "processed endpoint: " + endpoint + " *****", "true")
+ logger.debug( "processed endpoint: " + endpoint + " *****")
return endpoint +
'/' + UriUtils.encodePathSegment(messageType, 'UTF-8') +
'/' + UriUtils.encodePathSegment(correlator, 'UTF-8')
} catch (Exception ex) {
- utils.log("DEBUG", "createCallbackURL Exception: " + ex + " *****", "true")
+ logger.debug( "createCallbackURL Exception: " + ex + " *****")
}
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
index af33f38a64..b68e979b3c 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 Intel Corp. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -46,6 +48,8 @@ import org.springframework.http.client.BufferingClientHttpRequestFactory
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory
import org.springframework.web.client.RestTemplate
import org.springframework.web.util.UriComponentsBuilder
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response
@@ -54,6 +58,8 @@ import javax.xml.ws.http.HTTPException
import static org.onap.so.bpmn.common.scripts.GenericUtils.*
class OofUtils {
+ private static final Logger logger = LoggerFactory.getLogger( OofUtils.class);
+
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
@@ -86,40 +92,39 @@ class OofUtils {
ArrayList existingCandidates = null,
ArrayList excludedCandidates = null,
ArrayList requiredCandidates = null) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", "Started Building OOF Request", isDebugEnabled)
+ logger.debug( "Started Building OOF Request")
String callbackEndpoint = UrnPropertiesReader.getVariable("mso.oof.callbackEndpoint", execution)
- utils.log("DEBUG", "mso.oof.callbackEndpoint is: " + callbackEndpoint, isDebugEnabled)
+ logger.debug( "mso.oof.callbackEndpoint is: " + callbackEndpoint)
try {
def callbackUrl = utils.createHomingCallbackURL(callbackEndpoint, "oofResponse", requestId)
- utils.log("DEBUG", "callbackUrl is: " + callbackUrl, isDebugEnabled)
+ logger.debug( "callbackUrl is: " + callbackUrl)
def transactionId = requestId
- utils.log("DEBUG", "transactionId is: " + transactionId, isDebugEnabled)
+ logger.debug( "transactionId is: " + transactionId)
//ServiceInstance Info
ServiceInstance serviceInstance = decomposition.getServiceInstance()
def serviceInstanceId = ""
def serviceName = ""
serviceInstanceId = execution.getVariable("serviceInstanceId")
- utils.log("DEBUG", "serviceInstanceId is: " + serviceInstanceId, isDebugEnabled)
+ logger.debug( "serviceInstanceId is: " + serviceInstanceId)
serviceName = execution.getVariable("subscriptionServiceType")
- utils.log("DEBUG", "serviceName is: " + serviceName, isDebugEnabled)
+ logger.debug( "serviceName is: " + serviceName)
if (serviceInstanceId == null || serviceInstanceId == "null") {
- utils.log("DEBUG", "Unable to obtain Service Instance Id", isDebugEnabled)
+ logger.debug( "Unable to obtain Service Instance Id")
exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - Unable to " +
"obtain Service Instance Id, execution.getVariable(\"serviceInstanceId\") is null")
}
if (serviceName == null || serviceName == "null") {
- utils.log("DEBUG", "Unable to obtain Service Name", isDebugEnabled)
+ logger.debug( "Unable to obtain Service Name")
exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - Unable to " +
"obtain Service Name, execution.getVariable(\"subscriptionServiceType\") is null")
}
//Model Info
ModelInfo model = decomposition.getModelInfo()
- utils.log("DEBUG", "ModelInfo: " + model.toString(), isDebugEnabled)
+ logger.debug( "ModelInfo: " + model.toString())
String modelType = model.getModelType()
String modelInvariantId = model.getModelInvariantUuid()
String modelVersionId = model.getModelUuid()
@@ -153,12 +158,10 @@ class OofUtils {
List<VnfResource> vnfResourceList = decomposition.getVnfResources()
if (allottedResourceList == null || allottedResourceList.isEmpty()) {
- utils.log("DEBUG", "Allotted Resources List is empty - will try to get service VNFs instead.",
- isDebugEnabled)
+ logger.debug( "Allotted Resources List is empty - will try to get service VNFs instead.")
} else {
for (AllottedResource resource : allottedResourceList) {
- utils.log("DEBUG", "Allotted Resource: " + resource.toString(),
- isDebugEnabled)
+ logger.debug( "Allotted Resource: " + resource.toString())
def serviceResourceId = resource.getResourceId()
def toscaNodeType = resource.getToscaNodeType()
def resourceModuleName = toscaNodeType.substring(toscaNodeType.lastIndexOf(".") + 1)
@@ -195,13 +198,11 @@ class OofUtils {
}
if (vnfResourceList == null || vnfResourceList.isEmpty()) {
- utils.log("DEBUG", "VNF Resources List is empty",
- isDebugEnabled)
+ logger.debug( "VNF Resources List is empty")
} else {
for (VnfResource vnfResource : vnfResourceList) {
- utils.log("DEBUG", "VNF Resource: " + vnfResource.toString(),
- isDebugEnabled)
+ logger.debug( "VNF Resource: " + vnfResource.toString())
ModelInfo vnfResourceModelInfo = vnfResource.getModelInfo()
def toscaNodeType = vnfResource.getToscaNodeType()
def resourceModuleName = toscaNodeType.substring(toscaNodeType.lastIndexOf(".") + 1)
@@ -239,7 +240,7 @@ class OofUtils {
String licenseDemands = ""
sb = new StringBuilder()
if (vnfResourceList.isEmpty() || vnfResourceList == null) {
- utils.log("DEBUG", "Vnf Resources List is Empty", isDebugEnabled)
+ logger.debug( "Vnf Resources List is Empty")
} else {
for (VnfResource vnfResource : vnfResourceList) {
ModelInfo vnfResourceModelInfo = vnfResource.getModelInfo()
@@ -322,10 +323,10 @@ class OofUtils {
"}"
- utils.log("DEBUG", "Completed Building OOF Request", isDebugEnabled)
+ logger.debug( "Completed Building OOF Request")
return request
} catch (Exception ex) {
- utils.log("DEBUG", "buildRequest Exception: " + ex, isDebugEnabled)
+ logger.debug( "buildRequest Exception: " + ex)
}
}
@@ -339,7 +340,6 @@ class OofUtils {
* @param response - the async callback response from oof
*/
Void validateCallbackResponse(DelegateExecution execution, String response) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
String placements = ""
if (isBlank(response)) {
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "OOF Async Callback Response is Empty")
@@ -349,12 +349,12 @@ class OofUtils {
if (isBlank(placements) || placements.equalsIgnoreCase("[]")) {
String statusMessage = jsonUtil.getJsonValue(response, "statusMessage")
if (isBlank(statusMessage)) {
- utils.log("DEBUG", "Error Occurred in Homing: OOF Async Callback Response does " +
- "not contain placement solution.", isDebugEnabled)
+ logger.debug( "Error Occurred in Homing: OOF Async Callback Response does " +
+ "not contain placement solution.")
exceptionUtil.buildAndThrowWorkflowException(execution, 400,
"OOF Async Callback Response does not contain placement solution.")
} else {
- utils.log("DEBUG", "Error Occurred in Homing: " + statusMessage, isDebugEnabled)
+ logger.debug( "Error Occurred in Homing: " + statusMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 400, statusMessage)
}
} else {
@@ -374,11 +374,11 @@ class OofUtils {
} else {
errorMessage = "OOF Async Callback Response contains a Request Error. Unable to determine the Request Error Exception."
}
- utils.log("DEBUG", "Error Occurred in Homing: " + errorMessage, isDebugEnabled)
+ logger.debug( "Error Occurred in Homing: " + errorMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 400, errorMessage)
} else {
- utils.log("DEBUG", "Error Occurred in Homing: Received an Unknown Async Callback Response from OOF.", isDebugEnabled)
+ logger.debug( "Error Occurred in Homing: Received an Unknown Async Callback Response from OOF.")
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Received an Unknown Async Callback Response from OOF.")
}
}
@@ -518,15 +518,15 @@ class OofUtils {
Response response = client.post(request.getBody().toString())
int responseCode = response.getStatus()
- logDebug("CatalogDB response code is: " + responseCode, isDebugEnabled)
+ logDebug("CatalogDB response code is: " + responseCode)
String syncResponse = response.readEntity(String.class)
- logDebug("CatalogDB response is: " + syncResponse, isDebugEnabled)
+ logDebug("CatalogDB response is: " + syncResponse)
if(responseCode != 202){
exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from CatalogDB.")
}
}
-
+
/**
* This method creates a HomingInstance in catalog database.
*
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
index 15f00ac25f..259808feb6 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -37,11 +39,13 @@ import org.onap.so.client.graphinventory.entities.uri.Depth
import org.springframework.web.util.UriUtils
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
public class PrepareUpdateAAIVfModule extends VfModuleBase {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, PrepareUpdateAAIVfModule.class);
+ private static final Logger logger = LoggerFactory.getLogger( PrepareUpdateAAIVfModule.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -76,12 +80,12 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
def method = getClass().getSimpleName() + '.preProcessRequest(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def xml = execution.getVariable('PrepareUpdateAAIVfModuleRequest')
- msoLogger.debug('Received request xml:\n' + xml)
- msoLogger.debug("PrepareUpdateAAIVfModule Request : " + xml)
+ logger.debug('Received request xml:\n' + xml)
+ logger.debug("PrepareUpdateAAIVfModule Request : " + xml)
initProcessVariables(execution)
@@ -94,11 +98,11 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
def orchestrationStatus = getRequiredNodeText(execution, xml,'orchestration-status')
execution.setVariable('PUAAIVfMod_orchestrationStatus', orchestrationStatus)
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(e)
+ logger.error(e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
}
}
@@ -113,7 +117,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
def method = getClass().getSimpleName() + '.getGenericVnf(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def vnfId = execution.getVariable('PUAAIVfMod_vnfId')
@@ -129,16 +133,16 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
execution.setVariable('PUAAIVfMod_getVnfResponseCode', 200)
} catch (Exception ex) {
- msoLogger.error(ex);
- msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.error(ex);
+ logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
execution.setVariable('PUAAIVfMod_getVnfResponseCode', 500)
execution.setVariable('PUAAIVfMod_getVnfResponse', 'AAI GET Failed:' + ex.getMessage())
}
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(e)
+ logger.error(e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getGenericVnf(): ' + e.getMessage())
}
}
@@ -155,7 +159,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
def method = getClass().getSimpleName() + '.validateVfModule(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
GenericVnf genericVnf = execution.getVariable('PUAAIVfMod_getVnfResponse')
@@ -190,11 +194,11 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
}
}
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(e)
+ logger.error(e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in validateVfModule(): ' + e.getMessage())
}
}
@@ -208,7 +212,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
def method = getClass().getSimpleName() + '.updateVfModule(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def vnfId = execution.getVariable('PUAAIVfMod_vnfId')
@@ -228,20 +232,20 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
// backward compatibilty, the heat-stack-id is an output
execution.setVariable('PUAAIVfMod_outVfModule', vfModule)
def vnfName = execution.getVariable('PUAAIVfMod_vnfName')
- msoLogger.debug('Output PUAAIVfMod_vnfName set to ' + vnfName)
+ logger.debug('Output PUAAIVfMod_vnfName set to ' + vnfName)
// TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead
execution.setVariable('WorkflowResponse', vfModule)
def heatStackId = vfModule.getHeatStackId()
execution.setVariable('PUAAIVfMod_heatStackId', heatStackId)
- msoLogger.debug('Output PUAAIVfMod_heatStackId set to \'' + heatStackId + '\'')
+ logger.debug('Output PUAAIVfMod_heatStackId set to \'' + heatStackId + '\'')
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', 500)
throw e;
} catch (Exception e) {
- msoLogger.error(e)
+ logger.error(e)
execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', 500)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in updateVfModule(): ' + e.getMessage())
}
@@ -256,15 +260,15 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
def method = getClass().getSimpleName() + '.handleVnfNotFound(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
- msoLogger.error('Error occurred attempting to query AAI, Response Code ' + execution.getVariable('PUAAIVfMod_getVnfResponseCode'));
+ logger.error('Error occurred attempting to query AAI, Response Code ' + execution.getVariable('PUAAIVfMod_getVnfResponseCode'));
String processKey = getProcessKey(execution);
WorkflowException exception = new WorkflowException(processKey, 5000,
execution.getVariable('PUAAIVfMod_getVnfResponse'))
execution.setVariable('WorkflowException', exception)
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
}
/**
@@ -276,17 +280,17 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
def method = getClass().getSimpleName() + '.handleVfModuleValidationError(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
def String errorMsg = 'VF Module validation error: ' + execution.getVariable('PUAAIVfMod_vfModuleValidationError')
- msoLogger.error(errorMsg);
- msoLogger.debug("PrepareUpdateAAIVfModule: Error Message : " + errorMsg)
+ logger.error(errorMsg);
+ logger.debug("PrepareUpdateAAIVfModule: Error Message : " + errorMsg)
String processKey = getProcessKey(execution);
WorkflowException exception = new WorkflowException(processKey, 5000, errorMsg)
execution.setVariable('WorkflowException', exception)
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
}
/**
@@ -298,14 +302,14 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
def method = getClass().getSimpleName() + '.handleUpdateVfModuleFailure(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
- msoLogger.error('Error occurred attempting to update VF Module in AAI, Response Code ' + execution.getVariable('PUAAIVfMod_updateVfModuleResponseCode'));
+ logger.error('Error occurred attempting to update VF Module in AAI, Response Code ' + execution.getVariable('PUAAIVfMod_updateVfModuleResponseCode'));
String processKey = getProcessKey(execution);
WorkflowException exception = new WorkflowException(processKey, 5000,
execution.getVariable('PUAAIVfMod_updateVfModuleResponse'))
execution.setVariable('WorkflowException', exception)
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RainyDayHandler.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RainyDayHandler.groovy
index 0d66b8f51b..9f26cead49 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RainyDayHandler.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RainyDayHandler.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -32,7 +34,8 @@ import org.onap.so.client.policy.PolicyClientImpl
import org.onap.so.client.policy.entities.DictionaryData
import org.onap.so.client.policy.entities.PolicyDecision
import org.onap.so.client.policy.entities.Treatments
-import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
/**
@@ -58,7 +61,7 @@ import org.onap.so.logger.MsoLogger
*
*/
public class RainyDayHandler extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, RainyDayHandler.class);
+ private static final Logger logger = LoggerFactory.getLogger( RainyDayHandler.class);
String Prefix="RDH_"
@@ -68,44 +71,44 @@ public class RainyDayHandler extends AbstractServiceTaskProcessor {
public void preProcessRequest (DelegateExecution execution) {
String msg = ""
- msoLogger.trace("preProcessRequest of RainyDayHandler ")
+ logger.trace("preProcessRequest of RainyDayHandler ")
try {
execution.setVariable("prefix", Prefix)
// check for required input
String requestId = execution.getVariable("msoRequestId")
- msoLogger.debug("msoRequestId is: " + requestId)
+ logger.debug("msoRequestId is: " + requestId)
def serviceType = execution.getVariable("serviceType")
- msoLogger.debug("serviceType is: " + serviceType)
+ logger.debug("serviceType is: " + serviceType)
def vnfType = execution.getVariable("vnfType")
- msoLogger.debug("vnftype is: " + vnfType)
+ logger.debug("vnftype is: " + vnfType)
def currentActivity = execution.getVariable("currentActivity")
- msoLogger.debug("currentActivity is: " + currentActivity)
+ logger.debug("currentActivity is: " + currentActivity)
def workStep = execution.getVariable("workStep")
- msoLogger.debug("workStep is: " + workStep)
+ logger.debug("workStep is: " + workStep)
def failedActivity = execution.getVariable("failedActivity")
- msoLogger.debug("failedActivity is: " + failedActivity)
+ logger.debug("failedActivity is: " + failedActivity)
def errorCode = execution.getVariable("errorCode")
- msoLogger.debug("errorCode is: " + errorCode)
+ logger.debug("errorCode is: " + errorCode)
def errorText = execution.getVariable("errorText")
- msoLogger.debug("errorText is: " + errorText)
+ logger.debug("errorText is: " + errorText)
String defaultPolicyDisposition = (String) UrnPropertiesReader.getVariable("policy.default.disposition",execution)
- msoLogger.debug("defaultPolicyDisposition is: " + defaultPolicyDisposition)
+ logger.debug("defaultPolicyDisposition is: " + defaultPolicyDisposition)
execution.setVariable('defaultPolicyDisposition', defaultPolicyDisposition)
} catch (BpmnError e) {
throw e;
} catch (Exception ex){
msg = "Exception in preProcessRequest " + ex.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit preProcessRequest of RainyDayHandler ")
+ logger.trace("Exit preProcessRequest of RainyDayHandler ")
}
public void queryPolicy (DelegateExecution execution) {
String msg = ""
- msoLogger.trace("queryPolicy of RainyDayHandler ")
+ logger.trace("queryPolicy of RainyDayHandler ")
try {
@@ -113,14 +116,14 @@ public class RainyDayHandler extends AbstractServiceTaskProcessor {
String serviceType = execution.getVariable("serviceType")
String vnfType = execution.getVariable("vnfType")
- msoLogger.debug("serviceType: " + serviceType)
- msoLogger.debug("vnfType: " + vnfType)
+ logger.debug("serviceType: " + serviceType)
+ logger.debug("vnfType: " + vnfType)
def errorCode = execution.getVariable("errorCode")
def bbId = execution.getVariable("currentActivity")
def workStep = execution.getVariable("workStep")
- msoLogger.debug("Before querying policy")
+ logger.debug("Before querying policy")
String decision = 'DENY'
String disposition = "Abort"
@@ -128,9 +131,9 @@ public class RainyDayHandler extends AbstractServiceTaskProcessor {
String defaultPolicyDisposition = (String) execution.getVariable('defaultPolicyDisposition')
if (defaultPolicyDisposition != null && !defaultPolicyDisposition.isEmpty()) {
- msoLogger.debug("Setting disposition to the configured default instead of querying Policy: " + defaultPolicyDisposition)
+ logger.debug("Setting disposition to the configured default instead of querying Policy: " + defaultPolicyDisposition)
disposition = defaultPolicyDisposition
- msoLogger.debug("Setting default allowed treatments: " + defaultAllowedTreatments)
+ logger.debug("Setting default allowed treatments: " + defaultAllowedTreatments)
execution.setVariable("validResponses", defaultAllowedTreatments)
}
else {
@@ -139,28 +142,28 @@ public class RainyDayHandler extends AbstractServiceTaskProcessor {
try {
PolicyClient policyClient = new PolicyClientImpl()
- msoLogger.debug("Created policy client")
+ logger.debug("Created policy client")
decisionObject = policyClient.getDecision(serviceType, vnfType, bbId, workStep, errorCode)
- msoLogger.debug("Obtained decision object")
+ logger.debug("Obtained decision object")
DictionaryData dictClient = policyClient.getAllowedTreatments(bbId, workStep)
Treatments treatments = dictClient.getTreatments()
String validResponses = treatments.getString()
if (validResponses != null) {
validResponses = validResponses.toLowerCase()
}
- msoLogger.debug("Obtained validResponses: " + validResponses)
+ logger.debug("Obtained validResponses: " + validResponses)
execution.setVariable("validResponses", validResponses)
} catch(Exception e) {
msg = "Exception in queryPolicy " + e.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
}
if (decisionObject != null) {
decision = decisionObject.getDecision()
disposition = decisionObject.getDetails()
- msoLogger.debug("Obtained disposition from policy engine: " + disposition)
+ logger.debug("Obtained disposition from policy engine: " + disposition)
}
else {
disposition = "Abort"
@@ -171,17 +174,17 @@ public class RainyDayHandler extends AbstractServiceTaskProcessor {
}
execution.setVariable("handlingCode", disposition)
- msoLogger.debug("Disposition: "+ disposition)
+ logger.debug("Disposition: "+ disposition)
} catch (BpmnError e) {
- msoLogger.debug("BPMN exception: " + e.errorMessage)
+ logger.debug("BPMN exception: " + e.errorMessage)
throw e;
} catch (Exception ex){
msg = "Exception in queryPolicy " + ex.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
//exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit queryPolicy of RainyDayHandler ")
+ logger.trace("Exit queryPolicy of RainyDayHandler ")
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy
index 717d0df1ba..6094e457f1 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -29,12 +31,14 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
class ReceiveWorkflowMessage extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ReceiveWorkflowMessage.class);
+ private static final Logger logger = LoggerFactory.getLogger( ReceiveWorkflowMessage.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -48,7 +52,7 @@ public void preProcessRequest (DelegateExecution execution) {
def method = getClass().getSimpleName() + '.preProcessRequest(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
def prefix="RCVWFMSG_"
execution.setVariable("prefix", prefix)
@@ -58,42 +62,46 @@ public void preProcessRequest (DelegateExecution execution) {
// Confirm that timeout value has been provided in 'RCVWFMSG_timeout'.
def timeout = execution.getVariable('RCVWFMSG_timeout')
- msoLogger.debug('Timeout value is \'' + timeout + '\'')
+ logger.debug('Timeout value is \'' + timeout + '\'')
if ((timeout == null) || (timeout.isEmpty())) {
String msg = getProcessKey(execution) + ': Missing or empty input variable \'RCVWFMSG_timeout\''
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
// Confirm that message type has been provided in 'RCVWFMSG_messageType'
def messageType = execution.getVariable('RCVWFMSG_messageType')
- msoLogger.debug('Message type is \'' + messageType + '\'')
+ logger.debug('Message type is \'' + messageType + '\'')
if ((messageType == null) || (messageType.isEmpty())) {
String msg = getProcessKey(execution) + ': Missing or empty input variable \'RCVWFMSG_messageType\''
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
// Confirm that correlator value has been provided in 'RCVWFMSG_correlator'
def correlator = execution.getVariable('RCVWFMSG_correlator')
- msoLogger.debug('Correlator value is \'' + correlator + '\'')
+ logger.debug('Correlator value is \'' + correlator + '\'')
if ((correlator == null) || (correlator.isEmpty())) {
String msg = getProcessKey(execution) + ': Missing or empty input variable \'RCVWFMSG_correlator\''
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
execution.setVariable(messageType + '_CORRELATOR', correlator)
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e
} catch (Exception e) {
String msg = 'Caught exception in ' + method + ": " + e
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
}
@@ -107,7 +115,7 @@ public void preProcessRequest (DelegateExecution execution) {
def method = getClass().getSimpleName() + '.processReceivedMessage(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
String messageType = null;
String receivedMessage = null;
@@ -115,18 +123,18 @@ public void preProcessRequest (DelegateExecution execution) {
try {
messageType = execution.getVariable('RCVWFMSG_messageType')
receivedMessage = execution.getVariable(messageType + '_MESSAGE')
- msoLogger.debug(getProcessKey(execution) + ": received message:\n" + receivedMessage)
+ logger.debug(getProcessKey(execution) + ": received message:\n" + receivedMessage)
// The received message is made available to the calling flow in WorkflowResponse
execution.setVariable("WorkflowResponse", receivedMessage)
setSuccessIndicator(execution, true)
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (Exception e) {
receivedMessage = receivedMessage == null || String.valueOf(receivedMessage).isEmpty() ? "NONE" : receivedMessage
String msg = "Error processing received workflow message: " + receivedMessage
- msoLogger.debug(getProcessKey(execution) + ': ' + msg)
+ logger.debug(getProcessKey(execution) + ': ' + msg)
exceptionUtil.buildWorkflowException(execution, 7020, msg)
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy
index a430cdb715..5444c6a44b 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -27,13 +29,15 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import static org.apache.commons.lang3.StringUtils.*
// SDNC Adapter Request/Response processing
public class SDNCAdapter extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCAdapter.class);
+ private static final Logger logger = LoggerFactory.getLogger( SDNCAdapter.class);
def Prefix="SDNCA_"
@@ -46,8 +50,8 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
public void preProcessRequest (DelegateExecution execution) {
try{
- msoLogger.trace("Begin PreProcess SDNCAdapterRequestScript ")
- msoLogger.debug("Incoming sdncAdapterWorkflowRequest:\n" + execution.getVariable("sdncAdapterWorkflowRequest"))
+ logger.trace("Begin PreProcess SDNCAdapterRequestScript ")
+ logger.debug("Incoming sdncAdapterWorkflowRequest:\n" + execution.getVariable("sdncAdapterWorkflowRequest"))
// Initialize some variables used throughout the flow
execution.setVariable("prefix", Prefix)
@@ -69,7 +73,9 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution))
execution.setVariable("BasicAuthHeaderValue",encodedString)
} catch (IOException ex) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Unable to encode username password string", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Unable to encode username password string", "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue());
}
// TODO Use variables instead of passing xml request - Huh?
@@ -87,27 +93,27 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
if((useQualifiedHostName!=null) && (useQualifiedHostName.equals("true"))){
callbackUrlToUse = msoUtil.getQualifiedHostNameForCallback(callbackUrlToUse)
}
- msoLogger.debug("Callback URL to use:\n" + callbackUrlToUse)
+ logger.debug("Callback URL to use:\n" + callbackUrlToUse)
requestHeader = requestHeader.replace(origCallbackUrl, callbackUrlToUse)
// Get parameters from request header
def sdnca_svcInstanceId = utils.getNodeText(requestHeader, "SvcInstanceId") // optional
- msoLogger.debug("SvcInstanceId: " + sdnca_svcInstanceId)
+ logger.debug("SvcInstanceId: " + sdnca_svcInstanceId)
def sdnca_msoAction = utils.getNodeText(requestHeader, "MsoAction") // optional
- msoLogger.debug("MsoAction: " + sdnca_msoAction)
+ logger.debug("MsoAction: " + sdnca_msoAction)
def sdnca_svcAction = utils.getNodeText(requestHeader, "SvcAction")
- msoLogger.debug("SvcAction: " + sdnca_svcAction)
+ logger.debug("SvcAction: " + sdnca_svcAction)
def sdnca_svcOperation = utils.getNodeText(requestHeader, "SvcOperation")
- msoLogger.debug("SvcOperation: " + sdnca_svcOperation)
+ logger.debug("SvcOperation: " + sdnca_svcOperation)
def sdncRequestData = utils.getChildNodes(sdncwfreq, "SDNCRequestData")
sdncRequestData = sdncRequestData.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")
sdncRequestData = sdncRequestData.replaceAll('tag0:', '').replaceAll(':tag0', '')
- msoLogger.debug("SDNCRequestData:\n" + sdncRequestData)
+ logger.debug("SDNCRequestData:\n" + sdncRequestData)
def sdnca_serviceType = ""
if (utils.nodeExists(sdncwfreq, "service-type")) {
sdnca_serviceType = utils.getNodeText(sdncwfreq, "service-type")
}
- msoLogger.debug("service-type: " + sdnca_serviceType)
+ logger.debug("service-type: " + sdnca_serviceType)
def serviceConfigActivate = false
def source = ''
if ((sdnca_svcAction == 'activate') && (sdnca_svcOperation == 'service-configuration-operation') && (sdnca_serviceType == 'uCPE-VMS')) {
@@ -117,9 +123,9 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
}
}
execution.setVariable("serviceConfigActivate", serviceConfigActivate)
- msoLogger.debug("serviceConfigActivate: " + serviceConfigActivate)
+ logger.debug("serviceConfigActivate: " + serviceConfigActivate)
execution.setVariable("source", source)
- msoLogger.debug("source: " + source)
+ logger.debug("source: " + source)
//calling process should pass a generated uuid if sending multiple sdnc requests
def sdncRequestId = utils.getNodeText(requestHeader, "RequestId")
@@ -155,22 +161,22 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
${sdncRequestData}
</sdncadaptersc:RequestData></aetgt:SDNCAdapterRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>"""
- msoLogger.debug("Outgoing SDNCAdapterRequest:\n" + sdncAdapterRequest)
+ logger.debug("Outgoing SDNCAdapterRequest:\n" + sdncAdapterRequest)
execution.setVariable("sdncAdapterRequest", sdncAdapterRequest)
- msoLogger.debug(UrnPropertiesReader.getVariable("mso.adapters.sdnc.endpoint", execution))
+ logger.debug(UrnPropertiesReader.getVariable("mso.adapters.sdnc.endpoint", execution))
}catch(Exception e){
- msoLogger.debug('Internal Error occured during PreProcess Method: ', e)
+ logger.debug('Internal Error occured during PreProcess Method: ', e)
exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'Internal Error occured during PreProcess Method') // TODO: what message and error code?
}
- msoLogger.trace("End pre Process SDNCRequestScript ")
+ logger.trace("End pre Process SDNCRequestScript ")
}
public void postProcessResponse (DelegateExecution execution) {
try{
- msoLogger.trace("Begin POSTProcess SDNCAdapter ")
- msoLogger.trace("Incoming sdncAdapterCallbackRequest:\n" + execution.getVariable("sdncAdapterCallbackRequest"))
+ logger.trace("Begin POSTProcess SDNCAdapter ")
+ logger.trace("Incoming sdncAdapterCallbackRequest:\n" + execution.getVariable("sdncAdapterCallbackRequest"))
// Check the sdnccallback request and get the responsecode
def sdnccallbackreq = execution.getVariable("sdncAdapterCallbackRequest")
@@ -185,7 +191,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
callbackRequestData = callbackRequestData.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")
- msoLogger.trace("EnhancedCallbackRequestData:\n" + callbackRequestData)
+ logger.trace("EnhancedCallbackRequestData:\n" + callbackRequestData)
execution.setVariable("enhancedCallbackRequestData", callbackRequestData)
String sdncAdapterWorkflowResponse ="""
@@ -210,25 +216,25 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
}
}
execution.setVariable("continueListening", continueListening)
- msoLogger.debug("Continue Listening: " + continueListening)
+ logger.debug("Continue Listening: " + continueListening)
execution.setVariable("asynchronousResponseTimeout", false)
}else{
// Timed out waiting for asynchronous message, build error response
exceptionUtil.buildWorkflowException(execution, 500, "SDNC Callback Timeout Error")
execution.setVariable("asynchronousResponseTimeout", true)
- msoLogger.debug("Timed out waiting for asynchronous message")
+ logger.debug("Timed out waiting for asynchronous message")
}
}catch(Exception e){
- msoLogger.debug('Internal Error occured during PostProcess Method: ' + e)
+ logger.debug('Internal Error occured during PostProcess Method: ' + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'Internal Error occured during PostProcess Method') // TODO: what message and error code?
}
- msoLogger.trace("End POSTProcess SDNCAdapter ")
+ logger.trace("End POSTProcess SDNCAdapter ")
}
public void callbackResponsecheck(DelegateExecution execution){
def sdnccallbackreq=execution.getVariable("sdncAdapterCallbackRequest")
- msoLogger.debug("sdncAdapterCallbackRequest :" + sdnccallbackreq)
+ logger.debug("sdncAdapterCallbackRequest :" + sdnccallbackreq)
if (sdnccallbackreq==null){
execution.setVariable("callbackResponseReceived",false);
}else{
@@ -238,14 +244,14 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
public void resetCallbackRequest(DelegateExecution execution) {
- msoLogger.trace("Begin Reset Callback Info SDNCAdapter ")
+ logger.trace("Begin Reset Callback Info SDNCAdapter ")
// Clear sdncAdapterCallbackRequest variable
execution.removeVariable("sdncAdapterCallbackRequest")
// Determine and set SDNC Timeout Value
def enhancedCallbackRequestData = execution.getVariable("enhancedCallbackRequestData")
- msoLogger.debug("sdncAdapter - enhancedCallbackRequestData :" + enhancedCallbackRequestData)
+ logger.debug("sdncAdapter - enhancedCallbackRequestData :" + enhancedCallbackRequestData)
def interim = false
if (enhancedCallbackRequestData != null) {
if (utils.nodeExists(enhancedCallbackRequestData, "ack-final-indicator")) {
@@ -264,15 +270,15 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
timeoutValue = "PT" + utils.getNodeText(sdncAdapterWorkflowRequest, "SDNCTimeOutValueInMinutes") + "M"
}
execution.setVariable("sdncTimeoutValue", timeoutValue)
- msoLogger.debug("Setting SDNC Timeout Value to " + timeoutValue)
+ logger.debug("Setting SDNC Timeout Value to " + timeoutValue)
- msoLogger.trace("End Reset Callback Info SDNCAdapter ")
+ logger.trace("End Reset Callback Info SDNCAdapter ")
}
public void prepareDBMessage(DelegateExecution execution) {
- msoLogger.trace("Begin Prepare DB Message SDNCAdapter ")
+ logger.trace("Begin Prepare DB Message SDNCAdapter ")
// Create DB Message
def dbRequestId = execution.getVariable("mso-request-id")
@@ -289,9 +295,9 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
"""
execution.setVariable("dbUpdateInterimStageCompletion", dbUpdateInterimStageCompletion)
- msoLogger.debug("sdncAdapter - dbUpdateInterimStageCompletion :" + dbUpdateInterimStageCompletion)
- msoLogger.debug("DB UpdateInterimStageCompletion:\n" + dbUpdateInterimStageCompletion)
- msoLogger.trace("End Prepare DB Message SDNCAdapter ")
+ logger.debug("sdncAdapter - dbUpdateInterimStageCompletion :" + dbUpdateInterimStageCompletion)
+ logger.debug("DB UpdateInterimStageCompletion:\n" + dbUpdateInterimStageCompletion)
+ logger.trace("End Prepare DB Message SDNCAdapter ")
}
public String generateCurrentTimeInUtc(){
@@ -303,11 +309,11 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
public void toggleSuccessIndicator(DelegateExecution execution){
execution.setVariable("SDNCA_SuccessIndicator", true)
- msoLogger.debug("Setting SDNCA Success Indicator to True")
+ logger.debug("Setting SDNCA Success Indicator to True")
}
public void assignError(DelegateExecution execution){
- msoLogger.trace("Started Assign Error ")
+ logger.trace("Started Assign Error ")
WorkflowException wf = execution.getVariable("WorkflowException")
if(wf == null){
exceptionUtil.buildWorkflowException(execution, 5000, "SDNCAdapter Encountered an Internal Error") // TODO: Not sure what message and error code we want here.....
@@ -315,17 +321,17 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
execution.setVariable("WorkflowException", wf)
}
- msoLogger.debug("Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"))
- msoLogger.trace("End Assign Error ")
+ logger.debug("Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"))
+ logger.trace("End Assign Error ")
}
public void setTimeout(DelegateExecution execution){
- msoLogger.trace("Started SetTimeout ")
- msoLogger.debug("Timer expired, telling correlation service to stop listening")
+ logger.trace("Started SetTimeout ")
+ logger.debug("Timer expired, telling correlation service to stop listening")
execution.setVariable("asynchronousResponseTimeout", true)
- msoLogger.debug("Timed out branch sleeping for one second to give success branch a chance to complete if running")
+ logger.debug("Timed out branch sleeping for one second to give success branch a chance to complete if running")
Thread.sleep(1000)
- msoLogger.trace("End SetTimeout ")
+ logger.trace("End SetTimeout ")
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
index 9f1570ee15..1f39a5eac9 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -42,13 +44,15 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import org.onap.so.utils.TargetEntity
class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCAdapterRestV1.class);
+ private static final Logger logger = LoggerFactory.getLogger( SDNCAdapterRestV1.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -61,7 +65,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.preProcessRequest(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
def prefix="SDNCREST_"
execution.setVariable("prefix", prefix)
@@ -73,7 +77,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
String request = validateRequest(execution, "mso-request-id")
String requestType = jsonUtil.getJsonRootProperty(request)
execution.setVariable(prefix + 'requestType', requestType)
- msoLogger.debug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType)
// Determine the SDNCAdapter endpoint
@@ -81,8 +85,9 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
if (sdncAdapterEndpoint == null || sdncAdapterEndpoint.isEmpty()) {
String msg = getProcessKey(execution) + ': mso:adapters:sdnc:rest:endpoint URN mapping is not defined'
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -101,13 +106,14 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
if (sdncRequestId == null || sdncRequestId.isEmpty()) {
String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
execution.setVariable('SDNCAResponse_CORRELATOR', sdncRequestId)
- msoLogger.debug(getProcessKey(execution) + ': SDNCAResponse_CORRELATOR = ' + sdncRequestId)
+ logger.debug(getProcessKey(execution) + ': SDNCAResponse_CORRELATOR = ' + sdncRequestId)
// Get the bpNotificationUrl from the request (just to make sure it's there)
@@ -115,8 +121,9 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
if (bpNotificationUrl == null || bpNotificationUrl.isEmpty()) {
String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -131,8 +138,9 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
} else {
String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -145,15 +153,19 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
String basicAuthValue = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution)
if (basicAuthValue == null || basicAuthValue.isEmpty()) {
- msoLogger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined")
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined")
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
} else {
try {
def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution))
execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString)
} catch (IOException ex) {
- msoLogger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter")
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter")
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter",
+ "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
}
}
@@ -165,7 +177,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
// in addition to null/empty, also need to verify that the timer value is a valid duration "P[n]T[n]H|M|S"
String timerRegex = "PT[0-9]+[HMS]";
if (timeout == null || timeout.isEmpty() || !timeout.matches(timerRegex)) {
- msoLogger.debug(getProcessKey(execution) + ': preProcessRequest(): null/empty/invalid bpTimeout value. Using "mso.adapters.sdnc.timeout"')
+ logger.debug(getProcessKey(execution) + ': preProcessRequest(): null/empty/invalid bpTimeout value. Using "mso.adapters.sdnc.timeout"')
timeout = UrnPropertiesReader.getVariable("mso.adapters.sdnc.timeout", execution)
}
@@ -177,13 +189,14 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
}
execution.setVariable(prefix + 'timeout', timeout)
- msoLogger.debug(getProcessKey(execution) + ': ' + prefix + 'timeout = ' + timeout)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'timeout = ' + timeout)
} catch (BpmnError e) {
throw e
} catch (Exception e) {
String msg = 'Caught exception in ' + method + ": " + e
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
}
@@ -195,17 +208,17 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.sendRequestToSDNCAdapter(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
String prefix = execution.getVariable('prefix')
try {
String sdncAdapterMethod = execution.getVariable(prefix + 'sdncAdapterMethod')
- msoLogger.debug("SDNC Method is: " + sdncAdapterMethod)
+ logger.debug("SDNC Method is: " + sdncAdapterMethod)
String sdncAdapterUrl = execution.getVariable(prefix + 'sdncAdapterUrl')
- msoLogger.debug("SDNC Url is: " + sdncAdapterUrl)
+ logger.debug("SDNC Url is: " + sdncAdapterUrl)
String sdncAdapterRequest = execution.getVariable(prefix + 'sdncAdapterRequest')
- msoLogger.debug("SDNC Rest Request is: " + sdncAdapterRequest)
+ logger.debug("SDNC Rest Request is: " + sdncAdapterRequest)
URL url = new URL(sdncAdapterUrl);
@@ -229,8 +242,9 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
response = httpClient.delete(sdncAdapterRequest)
} else {
String msg = 'Unsupported HTTP method "' + sdncAdapterMethod + '" in ' + method + ": " + e
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -242,8 +256,9 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
throw e
} catch (Exception e) {
String msg = 'Caught exception in ' + method + ": " + e
- msoLogger.debug(msg, e)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg, e)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
}
@@ -255,14 +270,14 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.processCallback(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
String prefix = execution.getVariable('prefix')
String callback = execution.getVariable('SDNCAResponse_MESSAGE')
String requestId = execution.getVariable("mso-request-id");
String serviceInstanceId = execution.getVariable("mso-service-instance-id")
utils.logContext(requestId, serviceInstanceId)
- msoLogger.debug("Incoming SDNC Rest Callback is: " + callback)
+ logger.debug("Incoming SDNC Rest Callback is: " + callback)
try {
int callbackNumber = 1
@@ -290,7 +305,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
} catch (Exception e) {
callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback
String msg = "Received error from SDNCAdapter: " + callback
- msoLogger.debug(getProcessKey(execution) + ': ' + msg)
+ logger.debug(getProcessKey(execution) + ': ' + msg)
exceptionUtil.buildWorkflowException(execution, 5300, msg)
}
}
@@ -333,7 +348,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.getLastCallback(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
String prefix = execution.getVariable('prefix')
@@ -355,8 +370,9 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
return callback
} catch (Exception e) {
String msg = 'Caught exception in ' + method + ": " + e
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
}
@@ -368,7 +384,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.setTimeoutValue(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
String prefix = execution.getVariable('prefix')
@@ -380,8 +396,9 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
}
} catch (Exception e) {
String msg = 'Caught exception in ' + method + ": " + e
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy
index 1a20497bbc..64f54dbd66 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -37,6 +39,8 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
@@ -45,7 +49,7 @@ import org.onap.so.logger.MsoLogger
* any non-final response received from SDNC.
*/
class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCAdapterRestV2.class);
+ private static final Logger logger = LoggerFactory.getLogger( SDNCAdapterRestV2.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -58,7 +62,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
def method = getClass().getSimpleName() + '.preProcessRequest(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
def prefix="SDNCREST_"
execution.setVariable("prefix", prefix)
@@ -70,8 +74,8 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
String request = validateRequest(execution, "mso-request-id")
String requestType = jsonUtil.getJsonRootProperty(request)
execution.setVariable(prefix + 'requestType', requestType)
- msoLogger.debug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType)
- msoLogger.debug('SDNCAdapterRestV2, request: ' + request)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType)
+ logger.debug('SDNCAdapterRestV2, request: ' + request)
// Determine the SDNCAdapter endpoint
@@ -79,8 +83,9 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
if (sdncAdapterEndpoint == null || sdncAdapterEndpoint.isEmpty()) {
String msg = getProcessKey(execution) + ': mso:adapters:sdnc:rest:endpoint URN mapping is not defined'
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -99,13 +104,14 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
if (sdncRequestId == null || sdncRequestId.isEmpty()) {
String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
execution.setVariable('SDNCAResponse_CORRELATOR', sdncRequestId)
- msoLogger.debug(getProcessKey(execution) + ': SDNCAResponse_CORRELATOR = ' + sdncRequestId)
+ logger.debug(getProcessKey(execution) + ': SDNCAResponse_CORRELATOR = ' + sdncRequestId)
// Get the bpNotificationUrl from the request (just to make sure it's there)
@@ -113,8 +119,9 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
if (bpNotificationUrl == null || bpNotificationUrl.isEmpty()) {
String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -123,32 +130,37 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
} else {
String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
execution.setVariable(prefix + 'sdncAdapterMethod', sdncAdapterMethod)
- msoLogger.debug(getProcessKey(execution) + ': ' + prefix + 'sdncAdapterMethod = ' + sdncAdapterMethod)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'sdncAdapterMethod = ' + sdncAdapterMethod)
execution.setVariable(prefix + 'sdncAdapterUrl', sdncAdapterUrl)
- msoLogger.debug(getProcessKey(execution) + ': ' + prefix + 'sdncAdapterUrl = ' + sdncAdapterUrl)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'sdncAdapterUrl = ' + sdncAdapterUrl)
execution.setVariable(prefix + 'sdncAdapterRequest', sdncAdapterRequest)
- msoLogger.debug(getProcessKey(execution) + ': ' + prefix + 'sdncAdapterRequest = \n' + sdncAdapterRequest)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'sdncAdapterRequest = \n' + sdncAdapterRequest)
// Get the Basic Auth credentials for the SDNCAdapter (yes... we ARE using the PO adapters credentials)
String basicAuthValue = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution)
if (basicAuthValue == null || basicAuthValue.isEmpty()) {
- msoLogger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined")
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined")
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
} else {
try {
def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution))
execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString)
} catch (IOException ex) {
- msoLogger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter")
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter")
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter",
+ "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
}
}
@@ -160,25 +172,26 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
// in addition to null/empty, also need to verify that the timer value is a valid duration "P[n]T[n]H|M|S"
String timerRegex = "PT[0-9]+[HMS]";
if (timeout == null || timeout.isEmpty() || !timeout.matches(timerRegex)) {
- msoLogger.debug(getProcessKey(execution) + ': preProcessRequest(): null/empty/invalid bpTimeout value. Using "mso.adapters.sdnc.timeout"')
+ logger.debug(getProcessKey(execution) + ': preProcessRequest(): null/empty/invalid bpTimeout value. Using "mso.adapters.sdnc.timeout"')
timeout = UrnPropertiesReader.getVariable("mso.adapters.sdnc.timeout", execution)
}
// the timeout could still be null at this point if the config parm is missing/undefined
// forced to log (so OPs can fix the config) and temporarily use a hard coded value of 10 seconds
if (timeout == null) {
- msoLogger.warnSimple('preProcessRequest()', 'property "mso.adapters.sdnc.timeout" is missing/undefined. Using "PT10S"')
+ logger.warn("Service Name: {} Error: {}", 'preProcessRequest()', 'property "mso.adapters.sdnc.timeout" is missing/undefined. Using "PT10S"')
timeout = "PT10S"
}
execution.setVariable(prefix + 'timeout', timeout)
- msoLogger.debug(getProcessKey(execution) + ': ' + prefix + 'timeout = ' + timeout)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'timeout = ' + timeout)
} catch (BpmnError e) {
throw e
} catch (Exception e) {
String msg = 'Caught exception in ' + method + ": " + e
- msoLogger.debug(msg)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
}
@@ -190,14 +203,14 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
def method = getClass().getSimpleName() + '.processCallback(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
String prefix = execution.getVariable('prefix')
String callback = execution.getVariable('SDNCAResponse_MESSAGE')
- msoLogger.debug("Incoming SDNC Rest Callback is: " + callback)
+ logger.debug("Incoming SDNC Rest Callback is: " + callback)
try {
- msoLogger.debug(getProcessKey(execution) + ": received callback:\n" + callback)
+ logger.debug(getProcessKey(execution) + ": received callback:\n" + callback)
int callbackNumber = 1
while (execution.getVariable(prefix + 'callback' + callbackNumber) != null) {
@@ -236,7 +249,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
} catch (Exception e) {
callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback
String msg = "Received error from SDNCAdapter: " + callback
- msoLogger.debug(getProcessKey(execution) + ': ' + msg)
+ logger.debug(getProcessKey(execution) + ': ' + msg)
exceptionUtil.buildWorkflowException(execution, 5300, msg)
}
}
@@ -250,14 +263,14 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
def method = getClass().getSimpleName() + '.prepareInterimNotification(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
String prefix = execution.getVariable('prefix')
- msoLogger.debug("Preparing Interim Notification")
+ logger.debug("Preparing Interim Notification")
try {
def interimNotification = execution.getVariable(prefix + "interimNotification")
- msoLogger.debug("Preparing Interim Notification:\n" + JsonUtils.prettyJson(interimNotification))
+ logger.debug("Preparing Interim Notification:\n" + JsonUtils.prettyJson(interimNotification))
for (int i = 0; ; i++) {
def variable = JsonUtils.getJsonParamValue(interimNotification, 'variableList', 'variable', i)
@@ -270,13 +283,13 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
if ((variableName != null) && !variableName.isEmpty()) {
def variableValue = JsonUtils.getJsonValue(variable, "value")
execution.setVariable(variableName, variableValue)
- msoLogger.debug("Setting "+ variableName + "=" + variableValue)
+ logger.debug("Setting "+ variableName + "=" + variableValue)
}
}
} catch (Exception e) {
String msg = "Error preparing interim notification"
- msoLogger.debug(getProcessKey(execution) + ': ' + msg)
+ logger.debug(getProcessKey(execution) + ': ' + msg)
exceptionUtil.buildWorkflowException(execution, 5300, msg)
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy
index bed857dda8..b5ea12b85a 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -29,6 +31,8 @@ import org.springframework.web.util.UriUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
@@ -38,7 +42,7 @@ import org.onap.so.logger.MsoLogger
*
*/
class SDNCAdapterUtils {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCAdapterUtils.class);
+ private static final Logger logger = LoggerFactory.getLogger( SDNCAdapterUtils.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -259,7 +263,9 @@ class SDNCAdapterUtils {
def callbackUrl = (String)UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback',execution)
if (callbackUrl == null || callbackUrl.trim() == "") {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'mso:workflow:sdncadapter:callback URN is not set', "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'mso:workflow:sdncadapter:callback URN is not set', "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue());
workflowException(execution, 'Internal Error', 9999) // TODO: what message and error code?
}
@@ -373,7 +379,7 @@ class SDNCAdapterUtils {
', additionalData=' + (additionalData == null ? "no" : "yes") +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
MsoUtils utils = taskProcessor.utils
try {
def prefix = execution.getVariable('prefix')
@@ -395,7 +401,9 @@ class SDNCAdapterUtils {
def callbackUrl = (String)UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback',execution)
if (callbackUrl == null || callbackUrl.trim() == "") {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'mso:workflow:sdncadapter:callback URN is not set', "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'mso:workflow:sdncadapter:callback URN is not set', "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request")
}
@@ -460,13 +468,15 @@ class SDNCAdapterUtils {
content = utils.removeXmlPreamble(utils.formatXML(content))
execution.setVariable(resultVar, content)
- msoLogger.debug(resultVar + ' = ' + System.lineSeparator() + content)
+ logger.debug(resultVar + ' = ' + System.lineSeparator() + content)
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error")
}
}
@@ -783,17 +793,17 @@ class SDNCAdapterUtils {
* @param workflowException the WorkflowException Object returned from sdnc call
*/
public void validateSDNCResponse(DelegateExecution execution, String response, WorkflowException workflowException, boolean successIndicator){
- msoLogger.debug("SDNC Response is: " + response)
- msoLogger.debug("SuccessIndicator is: " + successIndicator)
+ logger.debug("SDNC Response is: " + response)
+ logger.debug("SuccessIndicator is: " + successIndicator)
try {
def prefix = execution.getVariable('prefix')
execution.setVariable(prefix+'sdncResponseSuccess', false)
- msoLogger.debug("Response" + ' = ' + (response == null ? "" : System.lineSeparator()) + response)
+ logger.debug("Response" + ' = ' + (response == null ? "" : System.lineSeparator()) + response)
if (successIndicator){
if (response == null || response.trim().equals("")) {
- msoLogger.debug(response + ' is empty');
+ logger.debug(response + ' is empty');
exceptionUtil.buildAndThrowWorkflowException(execution, 500, "SDNCAdapter Workflow Response is Empty")
}else{
@@ -801,7 +811,7 @@ class SDNCAdapterUtils {
def String sdncAdapterWorkflowResponse = taskProcessor.utils.getNodeXml(response, 'response-data', false)
def String decodedXml = sdncAdapterWorkflowResponse.replace('<?xml version="1.0" encoding="UTF-8"?>', "")
decodedXml = taskProcessor.utils.getNodeXml(response, 'RequestData')
- msoLogger.debug("decodedXml:\n" + decodedXml)
+ logger.debug("decodedXml:\n" + decodedXml)
int requestDataResponseCode = 200
def String requestDataResponseMessage = ''
@@ -813,33 +823,33 @@ class SDNCAdapterUtils {
requestDataResponseMessage = taskProcessor.utils.getNodeText(sdncAdapterWorkflowResponse, "ResponseMessage")
}
}catch(Exception e){
- msoLogger.debug('Error caught while decoding resposne ' + e.getMessage())
+ logger.debug('Error caught while decoding resposne ' + e.getMessage())
}
if(taskProcessor.utils.nodeExists(decodedXml, "response-code")) {
- msoLogger.debug("response-code node Exist ")
+ logger.debug("response-code node Exist ")
String code = taskProcessor.utils.getNodeText(decodedXml, "response-code")
if(code.isEmpty() || code.equals("")){
// if response-code is blank then Success
- msoLogger.debug("response-code node is empty")
+ logger.debug("response-code node is empty")
requestDataResponseCode = 0
}else{
requestDataResponseCode = code.toInteger()
- msoLogger.debug("response-code is: " + requestDataResponseCode)
+ logger.debug("response-code is: " + requestDataResponseCode)
}
}else if(taskProcessor.utils.nodeExists(sdncAdapterWorkflowResponse, "ResponseCode")){
- msoLogger.debug("ResponseCode node Exist ")
+ logger.debug("ResponseCode node Exist ")
String code = taskProcessor.utils.getNodeText(sdncAdapterWorkflowResponse, "ResponseCode")
if(code.isEmpty() || code.equals("")){
// if ResponseCode blank then Success
- msoLogger.debug("ResponseCode node is empty")
+ logger.debug("ResponseCode node is empty")
requestDataResponseCode = 0
}else{
requestDataResponseCode = code.toInteger()
- msoLogger.debug("ResponseCode is: " + requestDataResponseCode)
+ logger.debug("ResponseCode is: " + requestDataResponseCode)
}
}else{
- msoLogger.debug("A Response Code DOES NOT Exist.")
+ logger.debug("A Response Code DOES NOT Exist.")
// if a response code does not exist then Success
requestDataResponseCode = 0
}
@@ -849,8 +859,8 @@ class SDNCAdapterUtils {
// if a response code is 0 or 2XX then Success
if ((requestDataResponseCode >= 200 && requestDataResponseCode <= 299) || requestDataResponseCode == 0) {
execution.setVariable(prefix+'sdncResponseSuccess', true)
- msoLogger.debug("Setting sdncResponseSuccess to True ")
- msoLogger.debug("Exited ValidateSDNCResponse Method")
+ logger.debug("Setting sdncResponseSuccess to True ")
+ logger.debug("Exited ValidateSDNCResponse Method")
}else{
ExceptionUtil exceptionUtil = new ExceptionUtil()
String convertedCode = exceptionUtil.MapSDNCResponseCodeToErrorCode(requestDataResponseCode.toString())
@@ -863,12 +873,12 @@ class SDNCAdapterUtils {
requestDataResponseCode = 500
}
- msoLogger.debug("SDNC callback response-code: " + requestDataResponseCode)
- msoLogger.debug("SDNC callback response-message: " + requestDataResponseMessage)
+ logger.debug("SDNC callback response-code: " + requestDataResponseCode)
+ logger.debug("SDNC callback response-message: " + requestDataResponseMessage)
}
}else {
- msoLogger.debug('SDNCAdapter Subflow did NOT complete Successfully. SuccessIndicator is False. ')
+ logger.debug('SDNCAdapter Subflow did NOT complete Successfully. SuccessIndicator is False. ')
if(workflowException != null){
exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
}else{
@@ -880,7 +890,7 @@ class SDNCAdapterUtils {
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.debug('END of Validate SDNC Response')
+ logger.debug('END of Validate SDNC Response')
exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error- Unable to validate SDNC Response ');
}
}
@@ -897,20 +907,20 @@ class SDNCAdapterUtils {
'execution=' + execution.getId() +
', response=' + response +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
def prefix = execution.getVariable('prefix')
TrinityExceptionUtil trinityExceptionUtil = new TrinityExceptionUtil()
try {
execution.setVariable(prefix+'sdncResponseSuccess', false)
- msoLogger.debug("sdncAdapter Success Indicator is: " + success)
+ logger.debug("sdncAdapter Success Indicator is: " + success)
if (success) {
// we need to look inside the request data for error
def String callbackRequestData = taskProcessor.utils.getNodeXml(response, 'RequestData', false)
def String decodedXml = callbackRequestData
- msoLogger.debug("decodedXml:\n" + decodedXml)
+ logger.debug("decodedXml:\n" + decodedXml)
def requestDataResponseCode = '200'
def requestDataResponseMessage = ''
@@ -929,29 +939,29 @@ class SDNCAdapterUtils {
requestDataResponseMessage = taskProcessor.utils.getNodeText(response, "ResponseMessage")
}
- msoLogger.debug("SDNC callback response-code: " + requestDataResponseCode)
- msoLogger.debug("SDNC callback response-message: " + requestDataResponseMessage)
+ logger.debug("SDNC callback response-code: " + requestDataResponseCode)
+ logger.debug("SDNC callback response-message: " + requestDataResponseMessage)
// Get the AAI Status to determine if rollback is needed on ASSIGN
def aai_status = ''
if (taskProcessor.utils.nodeExists(decodedXml, "aai-status")) {
aai_status = ((String) taskProcessor.utils.getNodeText(decodedXml, "aai-status"))
- msoLogger.debug("SDNC sent AAI STATUS code: " + aai_status)
+ logger.debug("SDNC sent AAI STATUS code: " + aai_status)
}
if (aai_status != null && !aai_status.equals("")) {
execution.setVariable(prefix+"AaiStatus",aai_status)
- msoLogger.debug("Set variable " + prefix + "AaiStatus: " + execution.getVariable(prefix+"AaiStatus"))
+ logger.debug("Set variable " + prefix + "AaiStatus: " + execution.getVariable(prefix+"AaiStatus"))
}
// Get the result string to determine if rollback is needed on ASSIGN in Add Bonding flow only
def sdncResult = ''
if (taskProcessor.utils.nodeExists(decodedXml, "result")) {
sdncResult = ((String) taskProcessor.utils.getNodeText(decodedXml, "result"))
- msoLogger.debug("SDNC sent result: " + sdncResult)
+ logger.debug("SDNC sent result: " + sdncResult)
}
if (sdncResult != null && !sdncResult.equals("")) {
execution.setVariable(prefix+"SdncResult",sdncResult)
- msoLogger.debug("Set variable " + prefix + "SdncResult: " + execution.getVariable(prefix+"SdncResult"))
+ logger.debug("Set variable " + prefix + "SdncResult: " + execution.getVariable(prefix+"SdncResult"))
}
try{
@@ -960,7 +970,7 @@ class SDNCAdapterUtils {
intDataResponseCode = 400
}
- msoLogger.debug("intDataResponseCode " + intDataResponseCode )
+ logger.debug("intDataResponseCode " + intDataResponseCode )
// if response-code is not Success (200, 201, etc) we need to throw an exception
if ((intDataResponseCode < 200 || intDataResponseCode > 299) && intDataResponseCode != 0) {
@@ -971,25 +981,30 @@ class SDNCAdapterUtils {
}
}else {
- msoLogger.warn(MessageEnum.BPMN_GENERAL_WARNING, 'sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ', "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, 'sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ');
+ logger.warn("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING,
+ 'sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ',
+ "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError,
+ 'sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ')
execution.setVariable("L3HLAB_rollback", true)
def msg = trinityExceptionUtil.intDataResponseCode(response, execution)
exceptionUtil.buildAndThrowWorkflowException(execution, intDataResponseCode, msg)
}
if (response == null || response.trim().equals("")) {
- msoLogger.warn(MessageEnum.BPMN_GENERAL_WARNING, 'sdncAdapter workflow response is empty', "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, 'sdncAdapter workflow response is empty');;
+ logger.warn("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING,
+ 'sdncAdapter workflow response is empty', "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError, 'sdncAdapter workflow response is empty')
execution.setVariable("L3HLAB_rollback", true)
def msg = trinityExceptionUtil.buildException("Exception occurred while validating SDNC response " , execution)
exceptionUtil.buildAndThrowWorkflowException(execution, intResponseCode, msg)
}
execution.setVariable(prefix+'sdncResponseSuccess', true)
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
execution.setVariable(prefix+"ResponseCode",400)
execution.setVariable("L3HLAB_rollback", true)
def msg = trinityExceptionUtil.buildException("Exception occurred while validating SDNC response: " + e.getMessage(), execution)
@@ -1024,4 +1039,4 @@ class SDNCAdapterUtils {
return ecompModelInformation
}
-} \ No newline at end of file
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy
index 9556ae7d6a..8c2da2c112 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -46,8 +48,8 @@ import static org.onap.so.bpmn.common.scripts.GenericUtils.*;
import java.net.URL
import javax.ws.rs.core.Response
-import org.onap.so.logger.MessageEnum
-import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
/**
@@ -61,7 +63,7 @@ import org.onap.so.logger.MsoLogger
*/
class SniroHomingV1 extends AbstractServiceTaskProcessor{
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SniroHomingV1.class);
+ private static final Logger logger = LoggerFactory.getLogger( SniroHomingV1.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
SniroUtils sniroUtils = new SniroUtils(this)
@@ -77,19 +79,19 @@ class SniroHomingV1 extends AbstractServiceTaskProcessor{
*/
public void callSniro(DelegateExecution execution){
execution.setVariable("prefix","HOME_")
- msoLogger.trace("Started Sniro Homing Call Sniro ")
+ logger.trace("Started Sniro Homing Call Sniro ")
try{
execution.setVariable("rollbackData", null)
execution.setVariable("rolledBack", false)
String requestId = execution.getVariable("msoRequestId")
- msoLogger.debug("Incoming Request Id is: " + requestId)
+ logger.debug("Incoming Request Id is: " + requestId)
String serviceInstanceId = execution.getVariable("serviceInstanceId")
- msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
+ logger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- msoLogger.debug("Incoming Service Decomposition is: " + serviceDecomposition)
+ logger.debug("Incoming Service Decomposition is: " + serviceDecomposition)
String subscriberInfo = execution.getVariable("subscriberInfo")
- msoLogger.debug("Incoming Subscriber Information is: " + subscriberInfo)
+ logger.debug("Incoming Subscriber Information is: " + subscriberInfo)
if(isBlank(requestId) || isBlank(serviceInstanceId) || isBlank(serviceDecomposition.toString()) || isBlank(subscriberInfo)){
exceptionUtil.buildAndThrowWorkflowException(execution, 4000, "A required input variable is missing or null")
@@ -117,7 +119,7 @@ class SniroHomingV1 extends AbstractServiceTaskProcessor{
timeout = "PT30M";
}
}
- msoLogger.debug("Async Callback Timeout will be: " + timeout)
+ logger.debug("Async Callback Timeout will be: " + timeout)
execution.setVariable("timeout", timeout);
execution.setVariable("correlator", requestId);
@@ -126,12 +128,12 @@ class SniroHomingV1 extends AbstractServiceTaskProcessor{
//Build Request & Call Sniro
String sniroRequest = sniroUtils.buildRequest(execution, requestId, serviceDecomposition, subscriber, homingParameters)
execution.setVariable("sniroRequest", sniroRequest)
- msoLogger.debug("SNIRO Request is: " + sniroRequest)
+ logger.debug("SNIRO Request is: " + sniroRequest)
String endpoint = UrnPropertiesReader.getVariable("sniro.manager.uri.v1", execution)
String host = UrnPropertiesReader.getVariable("sniro.manager.host", execution)
String urlString = host + endpoint
- msoLogger.debug("Sniro Url is: " + urlString)
+ logger.debug("Sniro Url is: " + urlString)
URL url = new URL(urlString);
HttpClient httpClient = new HttpClientFactory().newJsonClient(url, TargetEntity.SNIRO)
@@ -140,21 +142,21 @@ class SniroHomingV1 extends AbstractServiceTaskProcessor{
int responseCode = httpResponse.getStatus()
- msoLogger.debug("Sniro sync response code is: " + responseCode)
+ logger.debug("Sniro sync response code is: " + responseCode)
if(httpResponse.hasEntity()){
- msoLogger.debug("Sniro sync response is: " + httpResponse.readEntity(String.class))
+ logger.debug("Sniro sync response is: " + httpResponse.readEntity(String.class))
}
if(responseCode != 202){
exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from Sniro.")
}
- msoLogger.trace("Completed Sniro Homing Call Sniro")
+ logger.trace("Completed Sniro Homing Call Sniro")
}
}catch(BpmnError b){
throw b
}catch(Exception e){
- msoLogger.debug("Error encountered within Homing CallSniro method: " + e)
+ logger.debug("Error encountered within Homing CallSniro method: " + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing CallSniro: " + e.getMessage())
}
}
@@ -170,10 +172,10 @@ class SniroHomingV1 extends AbstractServiceTaskProcessor{
* @author cb645j
*/
public void processHomingSolution(DelegateExecution execution){
- msoLogger.trace("Started Sniro Homing Process Homing Solution")
+ logger.trace("Started Sniro Homing Process Homing Solution")
try{
String response = execution.getVariable("asyncCallbackResponse")
- msoLogger.debug("Sniro Async Callback Response is: " + response)
+ logger.debug("Sniro Async Callback Response is: " + response)
sniroUtils.validateCallbackResponse(execution, response)
@@ -233,11 +235,11 @@ class SniroHomingV1 extends AbstractServiceTaskProcessor{
}
execution.setVariable("serviceDecomposition", decomposition)
- msoLogger.trace("Completed Sniro Homing Process Homing Solution")
+ logger.trace("Completed Sniro Homing Process Homing Solution")
}catch(BpmnError b){
throw b
}catch(Exception e){
- msoLogger.debug("Error encountered within Homing ProcessHomingSolution method: " + e)
+ logger.debug("Error encountered within Homing ProcessHomingSolution method: " + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Sniro Homing Process Solution")
}
}
@@ -255,9 +257,9 @@ class SniroHomingV1 extends AbstractServiceTaskProcessor{
requestId = execution.getVariable("msoRequestId")
}
execution.setVariable("DHVCS_requestId", requestId)
- msoLogger.trace("STARTED Homing Subflow for request: " + requestId + " ")
- msoLogger.debug("****** Homing Subflow Global Debug Enabled: " + execution.getVariable("isDebugLogEnabled") + " *****")
- msoLogger.trace("STARTED Homing Subflow for request: " + requestId + " ")
+ logger.trace("STARTED Homing Subflow for request: " + requestId + " ")
+ logger.debug("****** Homing Subflow Global Debug Enabled: " + execution.getVariable("isDebugLogEnabled") + " *****")
+ logger.trace("STARTED Homing Subflow for request: " + requestId + " ")
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroUtils.groovy
index 5ff49fbae8..2343d5451c 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroUtils.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -34,13 +36,13 @@ import static org.onap.so.bpmn.common.scripts.GenericUtils.*
import java.time.Duration
-import org.onap.so.logger.MessageEnum
-import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
class SniroUtils{
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SniroUtils.class);
+ private static final Logger logger = LoggerFactory.getLogger( SniroUtils.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -70,14 +72,14 @@ class SniroUtils{
* @author cb645j
*/
public String buildRequest(DelegateExecution execution, String requestId, ServiceDecomposition decomposition, Subscriber subscriber, String homingParams){
- msoLogger.debug("Started Building Sniro Request")
+ logger.debug("Started Building Sniro Request")
def callbackUrl = utils.createWorkflowMessageAdapterCallbackURL(execution, "SNIROResponse", requestId)
def transactionId = requestId
//ServiceInstance Info
ServiceInstance serviceInstance = decomposition.getServiceInstance()
def serviceInstanceId
if(serviceInstance == null){
- msoLogger.debug("Unable to obtain Service Instance Id, ServiceInstance Object is null" )
+ logger.debug("Unable to obtain Service Instance Id, ServiceInstance Object is null" )
exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - Unable to obtain Service Instance Id, ServiceInstance Object is null")
}else{
serviceInstanceId = serviceInstance.getInstanceId()
@@ -142,7 +144,7 @@ class SniroUtils{
}
if(resourceList.isEmpty() || resourceList == null){
- msoLogger.debug("Resources List is Empty")
+ logger.debug("Resources List is Empty")
}else{
for(Resource resource:resourceList){
ModelInfo resourceModelInfo = resource.getModelInfo()
@@ -197,7 +199,7 @@ class SniroUtils{
String licenseDemands = ""
sb = new StringBuilder()
if(vnfResourceList.isEmpty() || vnfResourceList == null){
- msoLogger.debug("Vnf Resources List is Empty")
+ logger.debug("Vnf Resources List is Empty")
}else{
for(VnfResource vnfResource:vnfResourceList){
ModelInfo vnfResourceModelInfo = vnfResource.getModelInfo()
@@ -291,7 +293,7 @@ class SniroUtils{
}
}"""
- msoLogger.debug("Completed Building Sniro Request")
+ logger.debug("Completed Building Sniro Request")
return request
}
@@ -321,7 +323,7 @@ class SniroUtils{
licenses = jsonUtil.getJsonValue(response, "solutionInfo.licenseInfo")
}
if((isBlank(placements) || placements.equalsIgnoreCase("[]")) && (isBlank(licenses) || licenses.equalsIgnoreCase("[]"))){
- msoLogger.debug("Sniro Async Response does not contain: licenses or placements")
+ logger.debug("Sniro Async Response does not contain: licenses or placements")
}else{
return
}
@@ -336,20 +338,20 @@ class SniroUtils{
}else{
errorMessage = "Sniro Async Response contains an error: not provided"
}
- msoLogger.debug("Sniro Async Response contains an error: " + errorMessage)
+ logger.debug("Sniro Async Response contains an error: " + errorMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 400, errorMessage)
}else{
- msoLogger.debug("Sniro Async Response contains an error: not provided")
+ logger.debug("Sniro Async Response contains an error: not provided")
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Sniro Async Response contains an error: not provided")
}
}
}catch(BpmnError b){
throw b
}catch(Exception e){
- msoLogger.debug("Error encountered within Homing validateCallbackResponse method: " + e)
+ logger.debug("Error encountered within Homing validateCallbackResponse method: " + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Sniro Homing Validate Async Response")
}
}
-} \ No newline at end of file
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy
index 3cf1edb8ca..ebce0c6753 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -24,15 +26,17 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
import org.apache.commons.lang3.*
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
class TrinityExceptionUtil {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, TrinityExceptionUtil.class);
+ private static final Logger logger = LoggerFactory.getLogger( TrinityExceptionUtil.class);
+
+
+
-
-
-
public static enum Error {
SVC_GENERAL_SERVICE_ERROR("SVC0001","Internal Error"),
SVC_BAD_PARAMETER("SVC0002", "Invalid input value for message part %1"),
@@ -64,8 +68,8 @@ class TrinityExceptionUtil {
}
-
-
+
+
String mapAdapterExecptionToCommonException(String response, DelegateExecution execution)
{
def utils=new MsoUtils()
@@ -73,26 +77,26 @@ class TrinityExceptionUtil {
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
+
-
def errorCode
-
+
try {
- errorCode = MapCategoryToErrorCode(utils.getNodeText(response, "category"))
+ errorCode = MapCategoryToErrorCode(utils.getNodeText(response, "category"))
execution.setVariable(prefix+"err",errorCode)
String message = buildException(response, execution)
- msoLogger.trace("End MapAdapterExecptionToWorkflowException ")
+ logger.trace("End MapAdapterExecptionToWorkflowException ")
return message
}catch (Exception ex) {
//Ignore the exception - cases include non xml payload
- msoLogger.debug("error mapping error, ignoring: " + ex)
- msoLogger.trace("End MapAdapterExecptionToWorkflowException ")
+ logger.debug("error mapping error, ignoring: " + ex)
+ logger.trace("End MapAdapterExecptionToWorkflowException ")
return buildException(response, execution)
- }
+ }
}
-
+
/**
* @param response
* @param execution
@@ -107,9 +111,9 @@ class TrinityExceptionUtil {
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
-
-
+ logger.trace('Entered ' + method)
+
+
try {
def errorCode = utils.getNodeText(response,"code")
def descr = utils.getNodeText(response, "description")
@@ -122,16 +126,16 @@ class TrinityExceptionUtil {
}
execution.setVariable(prefix+"err",mappedErr)
def message = buildException("Received error from AOTS: " + descr, execution)
- msoLogger.trace("End MapAOTSExecptionToCommonException ")
+ logger.trace("End MapAOTSExecptionToCommonException ")
return message
}catch (Exception ex) {
//Ignore the exception - cases include non xml payload
- msoLogger.debug("error mapping error, ignoring: " + ex)
- msoLogger.trace("End MapAOTSExecptionToCommonException ")
+ logger.debug("error mapping error, ignoring: " + ex)
+ logger.trace("End MapAOTSExecptionToCommonException ")
return buildException(response, execution)
}
}
-
+
String mapSDNCAdapterExceptionToErrorResponse(String sdncAdapterCallbackRequest, DelegateExecution execution) {
def utils=new MsoUtils()
def prefix=execution.getVariable("prefix")
@@ -139,15 +143,15 @@ class TrinityExceptionUtil {
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
-
+ logger.trace('Entered ' + method)
+
def sdncResponseCode
String responseCode = execution.getVariable(prefix+"ResponseCode")
- msoLogger.debug('responseCode to map: ' + responseCode)
+ logger.debug('responseCode to map: ' + responseCode)
def errorMessage
-
+
try {
-
+
if(utils.nodeExists(sdncAdapterCallbackRequest, "RequestData")) {
def reqDataXml = utils.getNodeXml(sdncAdapterCallbackRequest, "RequestData")
errorMessage = utils.getNodeText(reqDataXml, "response-message")
@@ -168,18 +172,18 @@ class TrinityExceptionUtil {
execution.setVariable(prefix+"err",mappedErr)
def message = buildException(modifiedErrorMessage, execution)
-
- msoLogger.trace("End MapSDNCAdapterException ")
+
+ logger.trace("End MapSDNCAdapterException ")
return message
}catch (Exception ex) {
//Ignore the exception - cases include non xml payload
- msoLogger.debug("error mapping sdnc error, ignoring: " + ex)
- msoLogger.trace("End MapSDNCAdapterException ")
+ logger.debug("error mapping sdnc error, ignoring: " + ex)
+ logger.trace("End MapSDNCAdapterException ")
return null
- }
-
+ }
+
}
-
+
/**
* @param response message from called component (ex: AAI)
* @param execution
@@ -193,11 +197,11 @@ class TrinityExceptionUtil {
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
def variables
def message
String errorCode = 'SVC0001'
- msoLogger.debug("response: " + response)
+ logger.debug("response: " + response)
//they use the same format we do, pass their error along
//TODO add Received error from A&AI at beg of text
try {
@@ -206,20 +210,20 @@ class TrinityExceptionUtil {
} catch (Exception ex) {
//Ignore the exception - cases include non xml payload
message = buildException("Received error from A&AI, unable to parse",execution)
- msoLogger.debug("error mapping error, ignoring: " + ex)
+ logger.debug("error mapping error, ignoring: " + ex)
}
-
- if(message != null) {
+
+ if(message != null) {
execution.setVariable(prefix+"ErrorResponse",message)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Fault", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, execution.getVariable(prefix+"ErrorResponse"));
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(),
+ execution.getVariable(prefix+"ErrorResponse"));
return message
} else {
-
return null
-
}
}
-
+
/**
* @param execution
* @return an error response conforming to the common API with default text msg
@@ -239,21 +243,21 @@ class TrinityExceptionUtil {
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
def prefix=execution.getVariable("prefix")
def responseCode = String.valueOf(execution.getVariable(prefix+"ResponseCode"))
def variables
- msoLogger.debug("response: " + response)
-
+ logger.debug("response: " + response)
+
try {
- msoLogger.debug("formatting error message" )
+ logger.debug("formatting error message" )
def msgVars = execution.getVariable(prefix+"errVariables")
def myErr = execution.getVariable(prefix+"err")
def messageTxt = execution.getVariable(prefix+"errTxt")
def messageId = null
-
+
if(myErr == null){
- msoLogger.debug("mapping response code: " + responseCode)
+ logger.debug("mapping response code: " + responseCode)
myErr = mapErrorCodetoError(responseCode, response)
if(myErr == null){
//not a service or policy error, just return error code
@@ -261,7 +265,7 @@ class TrinityExceptionUtil {
}
}
messageId = myErr.getMsgId()
-
+
if(messageTxt == null){
if(myErr!=null){
messageTxt = myErr.getMsgTxt()
@@ -293,35 +297,37 @@ class TrinityExceptionUtil {
<tns:messageId>${MsoUtils.xmlEscape(messageId)}</tns:messageId>
<tns:text>${MsoUtils.xmlEscape(messageTxt)}</tns:text>${msgVarsBuff}
</tns:serviceException>
-</tns:requestError>"""
+</tns:requestError>"""
}else{
message ="""<tns:requestError xmlns:tns="http://org.onap/so/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.onap/so/request/types/v1 MsoServiceInstanceTypesV1.xsd">
<tns:policyException>
<tns:messageId>${MsoUtils.xmlEscape(messageId)}</tns:messageId>
<tns:text>${MsoUtils.xmlEscape(messageTxt)}</tns:text>${msgVarsBuff}
</tns:policyException>
-</tns:requestError>"""
+</tns:requestError>"""
}
- msoLogger.debug("message " + message)
+ logger.debug("message " + message)
execution.setVariable(prefix+"ErrorResponse",message)
execution.setVariable(prefix+"err", myErr)
execution.setVariable(prefix+"errTxt", messageTxt)
execution.setVariable(prefix+"errVariables", msgVars)
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Fault", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, execution.getVariable(prefix+"ErrorResponse"));
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(),
+ execution.getVariable(prefix+"ErrorResponse"));
return message
}catch(Exception ex) {
- msoLogger.debug("error mapping error, return null: " + ex)
+ logger.debug("error mapping error, return null: " + ex)
return null
}
}
-
+
String parseError(DelegateExecution execution){
def utils=new MsoUtils()
def prefix=execution.getVariable("prefix")
def text = execution.getVariable(prefix+"errTxt")
def msgVars = execution.getVariable(prefix+"errVariables")
- msoLogger.debug('parsing message: ' + text)
+ logger.debug('parsing message: ' + text)
if(text == null){
return 'failed'
}
@@ -330,15 +336,15 @@ class TrinityExceptionUtil {
text = text.replaceFirst("%"+(i+1), msgVars[i])
}
}
- msoLogger.debug('parsed message is: ' + text)
+ logger.debug('parsed message is: ' + text)
return text
}
-
-
+
+
Error mapErrorCodetoError(responseCode, descr)
{
-
+
if(responseCode==null || responseCode=='0' || responseCode=='500' || responseCode =='408'){
return Error.SVC_NO_SERVER_RESOURCES
}else if(responseCode == '401' || responseCode == '405' || responseCode == '409' || responseCode == '503'){
@@ -373,10 +379,4 @@ class TrinityExceptionUtil {
else
return Error.SVC_GENERAL_SERVICE_ERROR
}
-
-
-
-
-
-
-} \ No newline at end of file
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy
index f96e3bea0e..867065696e 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -30,12 +32,14 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateAAIGenericVnf.class)
+ private static final Logger logger = LoggerFactory.getLogger( UpdateAAIGenericVnf.class);
private XmlParser xmlParser = new XmlParser()
@@ -69,12 +73,12 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.preProcessRequest(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def xml = execution.getVariable('UpdateAAIGenericVnfRequest')
- msoLogger.debug('Received request xml:\n' + xml)
- msoLogger.debug("UpdateAAIGenericVnf Request XML: " + xml)
+ logger.debug('Received request xml:\n' + xml)
+ logger.debug("UpdateAAIGenericVnf Request XML: " + xml)
initProcessVariables(execution)
def vnfId = getRequiredNodeText(execution, xml,'vnf-id')
@@ -99,17 +103,17 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
if (managementV6Address != null && !managementV6Address.isEmpty()) {
execution.setVariable('UAAIGenVnf_managementV6Address', managementV6Address)
}
-
+
def orchestrationStatus = getNodeTextForce(xml, 'orchestration-status')
if (orchestrationStatus != null && !orchestrationStatus.isEmpty()) {
execution.setVariable('UAAIGenVnf_orchestrationStatus', orchestrationStatus)
}
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e
} catch (Exception e) {
- msoLogger.error(e)
+ logger.error(e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
}
}
@@ -124,7 +128,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.getGenericVnf(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def vnfId = execution.getVariable('UAAIGenVnf_vnfId')
@@ -141,14 +145,14 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
execution.setVariable('UAAIGenVnf_getGenericVnfResponse', "Generic VNF not found for VNF ID: "+vnfId)
}
}catch (Exception ex) {
- msoLogger.error(ex.getMessage())
- msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.error(ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
execution.setVariable('UAAIGenVnf_getGenericVnfResponseCode', 500)
execution.setVariable('UAAIGenVnf_getGenericVnfResponse', 'AAI GET Failed:' + ex.getMessage())
}
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (Exception e) {
- msoLogger.error(e)
+ logger.error(e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getGenericVnf(): ' + e.getMessage())
}
}
@@ -162,14 +166,14 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.updateGenericVnf(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def vnfId = execution.getVariable('UAAIGenVnf_vnfId')
GenericVnf genericVnf = execution.getVariable('UAAIGenVnf_getGenericVnfResponse')
def origRequest = execution.getVariable('UpdateAAIGenericVnfRequest')
- msoLogger.debug("UpdateGenericVnf Request: " + origRequest)
+ logger.debug("UpdateGenericVnf Request: " + origRequest)
// Handle persona-model-id/persona-model-version
String newPersonaModelId = execution.getVariable('UAAIGenVnf_personaModelId')
@@ -178,7 +182,8 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
if (newPersonaModelId != null || newPersonaModelVersion != null) {
if (newPersonaModelId != genericVnf.getModelInvariantId()) {
def msg = 'Can\'t update Generic VNF ' + vnfId + ' since there is \'persona-model-id\' mismatch between the current and new values'
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "")
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue())
throw new Exception(msg)
}
@@ -216,27 +221,27 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
payload.setIpv4OamAddress(ipv4OamAddressEntry)
payload.setManagementV6Address(managementV6AddressEntry)
payload.setOrchestrationStatus(orchestrationStatusEntry)
-
+
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
try {
getAAIClient().update(uri,payload)
} catch (Exception ex) {
ex.printStackTrace()
- msoLogger.debug('Exception occurred while executing AAI PATCH:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI PATCH:' + ex.getMessage())
execution.setVariable('UAAIGenVnf_updateGenericVnfResponseCode', 500)
execution.setVariable('UAAIGenVnf_updateGenericVnfResponse', 'AAI PATCH Failed:' + ex.getMessage())
}
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (Exception e) {
- msoLogger.error(e)
+ logger.error(e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in updateGenericVnf(): ' + e.getMessage())
}
}
/**
* Sets up json attributes for PATCH request for Update
- *
+ *
* @param origRequest Incoming update request with Generic VNF element(s) to be updated.
* @param genericVnf Current Generic VNF retrieved from AAI.
* @param element Name of element to be inserted.
@@ -267,16 +272,16 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.handleAAIQueryFailure(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
- msoLogger.error( 'Error occurred attempting to query AAI, Response Code ' + execution.getVariable('UAAIGenVnf_getGenericVnfResponseCode'))
+ logger.error('Error occurred attempting to query AAI, Response Code ' + execution.getVariable('UAAIGenVnf_getGenericVnfResponseCode'))
String processKey = getProcessKey(execution)
WorkflowException exception = new WorkflowException(processKey, 5000,
execution.getVariable('UAAIGenVnf_getGenericVnfResponse'))
execution.setVariable('WorkflowException', exception)
- msoLogger.debug("Workflow Exception occurred when handling Quering AAI: " + exception.getErrorMessage())
- msoLogger.trace('Exited ' + method)
+ logger.debug("Workflow Exception occurred when handling Quering AAI: " + exception.getErrorMessage())
+ logger.trace('Exited ' + method)
}
/**
@@ -288,16 +293,16 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.handleUpdateGenericVnfFailure(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
- msoLogger.error('Error occurred attempting to update Generic VNF in AAI, Response Code ' + execution.getVariable('UAAIGenVnf_updateGenericVnfResponseCode'))
+ logger.error('Error occurred attempting to update Generic VNF in AAI, Response Code ' + execution.getVariable('UAAIGenVnf_updateGenericVnfResponseCode'))
String processKey = getProcessKey(execution)
WorkflowException exception = new WorkflowException(processKey, 5000,
execution.getVariable('UAAIGenVnf_updateGenericVnfResponse'))
execution.setVariable('WorkflowException', exception)
- msoLogger.debug("Workflow Exception occurred when Updating GenericVnf: " + exception.getErrorMessage())
- msoLogger.trace('Exited ' + method)
+ logger.debug("Workflow Exception occurred when Updating GenericVnf: " + exception.getErrorMessage())
+ logger.trace('Exited ' + method)
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy
index 3c4edd21ca..92a043e65a 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -29,10 +31,12 @@ import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateAAIVfModule.class);
+ private static final Logger logger = LoggerFactory.getLogger( UpdateAAIVfModule.class);
private XmlParser xmlParser = new XmlParser()
@@ -65,11 +69,11 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.preProcessRequest(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def xml = execution.getVariable('UpdateAAIVfModuleRequest')
- msoLogger.debug('Received request xml:\n' + xml)
+ logger.debug('Received request xml:\n' + xml)
initProcessVariables(execution)
def vnfId = getRequiredNodeText(execution, xml,'vnf-id')
@@ -78,11 +82,11 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
def vfModuleId = getRequiredNodeText(execution, xml,'vf-module-id')
execution.setVariable('UAAIVfMod_vfModuleId', vfModuleId)
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(e);
+ logger.error(e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
}
}
@@ -97,7 +101,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.getVfModule(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def vnfId = execution.getVariable('UAAIVfMod_vnfId')
@@ -113,14 +117,14 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
execution.setVariable('UAAIVfMod_getVfModuleResponse', "VF Module not found in AAI")
}
} catch (Exception ex) {
- msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
+ logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
execution.setVariable('UAAIVfMod_getVfModuleResponseCode', 500)
execution.setVariable('UAAIVfMod_getVfModuleResponse', 'AAI GET Failed:' + ex.getMessage())
}
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(e);
+ logger.error(e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getVfModule(): ' + e.getMessage())
}
}
@@ -134,7 +138,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.updateVfModule(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def vnfId = execution.getVariable('UAAIVfMod_vnfId')
@@ -142,7 +146,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('UAAIVfMod_getVfModuleResponse')
def origRequest = execution.getVariable('UpdateAAIVfModuleRequest')
- msoLogger.debug("UpdateAAIVfModule request: " + origRequest)
+ logger.debug("UpdateAAIVfModule request: " + origRequest)
// Handle persona-model-id/persona-model-version
def boolean doPersonaModelVersion = true
def String newPersonaModelId = utils.getNodeText(origRequest, 'persona-model-id')
@@ -161,11 +165,11 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
}
if (!newPersonaModelId.equals(currPersonaModelId)) {
def msg = 'Can\'t update VF Module ' + vfModuleId + ' since there is \'persona-model-id\' mismatch between the current and new values'
- msoLogger.error(msg)
+ logger.error(msg)
throw new Exception(msg)
}
}
-
+
// Construct payload
String orchestrationStatusEntry = updateVfModuleNode(origRequest , 'orchestration-status')
String heatStackIdEntry = updateVfModuleNode(origRequest, 'heat-stack-id')
@@ -187,7 +191,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', 200)
execution.setVariable('UAAIVfMod_updateVfModuleResponse', "Success")
}catch(NotFoundException ignored){
- msoLogger.debug("VF-Module not found!!")
+ logger.debug("VF-Module not found!!")
execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', 404)
execution.setVariable('UAAIVfMod_updateVfModuleResponse', ignored.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "vf-module " + vfModuleId + " not found for under vnf " + vnfId + " in A&AI!")
@@ -200,7 +204,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(e);
+ logger.error(e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in updateVfModule(): ' + e.getMessage())
}
}
@@ -210,7 +214,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
*
* @param origRequest Incoming update request with VF Module elements to be updated.
* @param element Name of element to be inserted.
- */
+ */
private String updateVfModuleNode(String origRequest, String elementName) {
if (!utils.nodeExists(origRequest, elementName)) {
@@ -236,14 +240,14 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.handleAAIQueryFailure(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
- msoLogger.error( 'Error occurred attempting to query AAI, Response Code ' + execution.getVariable('UAAIVfMod_getVfModuleResponseCode'));
+ logger.error('Error occurred attempting to query AAI, Response Code ' + execution.getVariable('UAAIVfMod_getVfModuleResponseCode'))
String processKey = getProcessKey(execution);
WorkflowException exception = new WorkflowException(processKey, 5000,
execution.getVariable('UAAIVfMod_getVfModuleResponse'))
execution.setVariable('WorkflowException', exception)
- msoLogger.debug("UpdateAAIVfModule query failure: " + exception.getErrorMessage())
- msoLogger.trace('Exited ' + method)
+ logger.debug("UpdateAAIVfModule query failure: " + exception.getErrorMessage())
+ logger.trace('Exited ' + method)
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModule.groovy
index b20cc38b8b..af0715cb11 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModule.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -20,16 +22,8 @@
package org.onap.so.bpmn.common.scripts;
-import org.apache.commons.lang3.*
-import org.onap.so.logger.MessageEnum
-import org.onap.so.logger.MsoLogger
-
-
public class VfModule implements Serializable {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VfModule.class);
-
-
/**
* Class representing a VF Module Node. Fields of this class include indicators
* as to whether the VF Module is the only VF Module in its containing Generic VNF
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy
index c1cd42e893..168ea1fdc9 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -30,16 +32,18 @@ import org.w3c.dom.NodeList
import org.xml.sax.InputSource
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VfModuleBase.class);
+ private static final Logger logger = LoggerFactory.getLogger( VfModuleBase.class);
+
-
protected XmlParser xmlParser = new XmlParser()
-
+
/**
* Get the XmlParser.
- *
+ *
* @return the XmlParser.
*/
protected XmlParser getXmlParser() {
@@ -105,11 +109,13 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
}
}
} catch (Exception e) {
- msoLogger.warn(MessageEnum.BPMN_GENERAL_WARNING, 'Exception transforming network params to vnfNetworks', "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, 'Exception is: \n' + e);
+ logger.warn("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(),
+ 'Exception transforming network params to vnfNetworks', "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), 'Exception is: \n' + e);
}
return vnfNetworks
}
-
+
/**
* Transform the parameter specifications from the incoming '*-params' root element to
* a corresponding list of 'entry's (typically used when invoking the VNF Rest Adpater).
@@ -142,7 +148,9 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
entries = entries + entry
}
} catch (Exception e) {
- msoLogger.warn(MessageEnum.BPMN_GENERAL_WARNING, 'Exception transforming params to entries', "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, 'Exception transforming params to entries', e);
+ logger.warn("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(),
+ 'Exception transforming params to entries', "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), 'Exception transforming params to entries' + e);
}
return entries
}
@@ -181,7 +189,9 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
}
}
} catch (Exception e) {
- msoLogger.warn(MessageEnum.BPMN_GENERAL_WARNING, 'Exception transforming params to entries', "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, 'Exception transforming params to entries', e);
+ logger.warn("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(),
+ 'Exception transforming params to entries', "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), 'Exception transforming params to entries' + e);
}
return entries
}
@@ -877,15 +887,15 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
<key>vf_module_name</key>
<value>${MsoUtils.xmlEscape(vfModuleName)}</value>
</entry>"""
-
- msoLogger.debug("vnfInfo: " + vnfInfo)
+
+ logger.debug("vnfInfo: " + vnfInfo)
InputSource source = new InputSource(new StringReader(data));
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setNamespaceAware(true)
DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
Document responseXml = docBuilder.parse(source)
-
-
+
+
// Availability Zones Data
String aZones = ""
StringBuilder sbAZone = new StringBuilder()
@@ -1235,9 +1245,9 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
${interfaceRoutePrefixes}
${vnfParams}
${sdncResponseParams}"""
-
+
return vfModuleParams
-
+
}
-
-} \ No newline at end of file
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy
index 40b0368eaa..259a7872a3 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -26,20 +28,20 @@ import groovy.json.JsonSlurper
import org.json.JSONObject
import org.json.XML
import org.onap.so.bpmn.core.xml.XmlTool
-import org.onap.so.logger.MsoLogger
-import org.onap.so.logger.MessageEnum
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
class VidUtils {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VidUtils.class);
-
+ private static final Logger logger = LoggerFactory.getLogger( VidUtils.class);
+
public MsoUtils utils = new MsoUtils()
private AbstractServiceTaskProcessor taskProcessor
public VidUtils(AbstractServiceTaskProcessor taskProcessor) {
this.taskProcessor = taskProcessor
}
-
+
/**
* Create a volume-request XML using a JSON string
* @param jsonReq - JSON request from VID
@@ -259,7 +261,7 @@ class VidUtils {
<source>VID</source>
<service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
</request-info>
- <network-inputs>
+ <network-inputs>
<network-id>${MsoUtils.xmlEscape(networkId)}</network-id>
<network-name>${MsoUtils.xmlEscape(instanceName)}</network-name>
<network-type>${MsoUtils.xmlEscape(modelName)}</network-type>
@@ -269,25 +271,25 @@ class VidUtils {
<service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
<backout-on-failure>${MsoUtils.xmlEscape(backoutOnFailure)}</backout-on-failure>
<sdncVersion>${MsoUtils.xmlEscape(sdncVersion)}</sdncVersion>
- </network-inputs>
+ </network-inputs>
<network-params>
${userParamsNode}
- </network-params>
+ </network-params>
</network-request>
"""
// return a pretty-print of the volume-request xml without the preamble
return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "")
-
+
} catch(Exception e) {
- msoLogger.debug("Error in Vid Utils",e.getCause())
+ logger.debug("{} {}", "Error in Vid Utils", e.getCause())
e.printStackTrace();
throw e
}
}
-
+
/**
- * Create a network-request XML using a map,
- * @param execution
+ * Create a network-request XML using a map,
+ * @param execution
* @return
*/
public String createXmlNetworkRequestInstance(execution) {
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
index 78af8768f9..50a0fe44a6 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -30,6 +32,8 @@ import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.client.HttpClient
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import org.onap.so.utils.TargetEntity
import java.util.UUID
@@ -37,7 +41,7 @@ import java.util.UUID
class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfAdapterRestV1.class);
+ private static final Logger logger = LoggerFactory.getLogger( VnfAdapterRestV1.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -47,7 +51,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.preProcessRequest(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
def prefix="VNFREST_"
execution.setVariable("prefix", prefix)
@@ -61,9 +65,9 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
Node root = new XmlParser().parseText(request)
String requestType = root.name()
execution.setVariable(prefix + 'requestType', requestType)
- msoLogger.debug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType)
- msoLogger.debug('VnfAdapterRestV1, request: ' + request)
+ logger.debug('VnfAdapterRestV1, request: ' + request)
// Get the messageId from the request
String messageId = getChildText(root, 'messageId')
@@ -74,12 +78,13 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (messageId == null || messageId.isEmpty()) {
String msg = getProcessKey(execution) + ': no messageId in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
execution.setVariable('VNFAResponse_CORRELATOR', messageId)
- msoLogger.debug(getProcessKey(execution) + ': VNFAResponse_CORRELATOR = ' + messageId)
+ logger.debug(getProcessKey(execution) + ': VNFAResponse_CORRELATOR = ' + messageId)
// Get the notificationUrl from the request
@@ -87,12 +92,13 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (notificationUrl == null || notificationUrl.isEmpty()) {
String msg = getProcessKey(execution) + ': no notificationUrl in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
execution.setVariable(prefix + 'notificationUrl', notificationUrl)
- msoLogger.debug(getProcessKey(execution) + ': ' + prefix + 'notificationUrl = ' + notificationUrl)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'notificationUrl = ' + notificationUrl)
// Determine the VnfAdapter endpoint
@@ -100,7 +106,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (vnfAdapterEndpoint == null || vnfAdapterEndpoint.isEmpty()) {
String msg = getProcessKey(execution) + ': mso:adapters:vnf:rest:endpoint URN mapping is not defined'
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -117,7 +124,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (vnfId == null || vnfId.isEmpty()) {
String msg = getProcessKey(execution) + ': no vnfId in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -129,7 +137,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (vnfId == null || vnfId.isEmpty()) {
String msg = getProcessKey(execution) + ': no vnfId in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -137,7 +146,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (vfModuleId == null || vfModuleId.isEmpty()) {
String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -150,7 +160,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (vnfId == null || vnfId.isEmpty()) {
String msg = getProcessKey(execution) + ': no vnfId in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -158,7 +169,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (vfModuleId == null || vfModuleId.isEmpty()) {
String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -171,7 +183,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (vfModuleRollbackNode == null) {
String msg = getProcessKey(execution) + ': no vfModuleRollback in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -179,7 +192,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (vnfId == null || vnfId.isEmpty()) {
String msg = getProcessKey(execution) + ': no vnfId in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -187,7 +201,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (vfModuleId == null || vfModuleId.isEmpty()) {
String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -207,7 +222,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (volumeGroupId == null || volumeGroupId.isEmpty()) {
String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -222,7 +238,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (volumeGroupId == null || volumeGroupId.isEmpty()) {
String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -237,7 +254,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if (volumeGroupId == null || volumeGroupId.isEmpty()) {
String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -249,39 +267,45 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
} else {
String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
execution.setVariable(prefix + 'vnfAdapterMethod', vnfAdapterMethod)
- msoLogger.debug(getProcessKey(execution) + ': ' + prefix + 'vnfAdapterMethod = ' + vnfAdapterMethod)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'vnfAdapterMethod = ' + vnfAdapterMethod)
execution.setVariable(prefix + 'vnfAdapterUrl', vnfAdapterUrl)
- msoLogger.debug(getProcessKey(execution) + ': ' + prefix + 'vnfAdapterUrl = ' + vnfAdapterUrl)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'vnfAdapterUrl = ' + vnfAdapterUrl)
execution.setVariable(prefix + 'vnfAdapterRequest', vnfAdapterRequest)
- msoLogger.debug(getProcessKey(execution) + ': ' + prefix + 'vnfAdapterRequest = \n' + vnfAdapterRequest)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'vnfAdapterRequest = \n' + vnfAdapterRequest)
// Get the Basic Auth credentials for the VnfAdapter
String basicAuthValue = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution)
if (basicAuthValue == null || basicAuthValue.isEmpty()) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
} else {
try {
def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution))
execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString)
} catch (IOException ex) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, getProcessKey(execution) + ": Unable to encode BasicAuth credentials for VnfAdapter", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ getProcessKey(execution) + ": Unable to encode BasicAuth credentials for VnfAdapter",
+ "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
}
}
} catch (BpmnError e) {
- msoLogger.debug(" Rethrowing MSOWorkflowException")
+ logger.debug(" Rethrowing MSOWorkflowException")
throw e
} catch (Exception e) {
String msg = 'Caught exception in ' + method + ": " + e
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
- msoLogger.debug(msg)
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
+ logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
}
@@ -302,7 +326,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.sendRequestToVnfAdapter(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
String prefix = execution.getVariable('prefix')
@@ -331,7 +355,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
response = httpClient.delete(vnfAdapterRequest)
} else {
String msg = 'Unsupported HTTP method "' + vnfAdapterMethod + '" in ' + method + ": " + e
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
@@ -343,7 +368,8 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
throw e
} catch (Exception e) {
String msg = 'Caught exception in ' + method + ": " + e
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
}
@@ -352,12 +378,12 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
def method = getClass().getSimpleName() + '.processCallback(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
String callback = execution.getVariable('VNFAResponse_MESSAGE')
try {
- msoLogger.debug(getProcessKey(execution) + ": received callback:\n" + callback)
+ logger.debug(getProcessKey(execution) + ": received callback:\n" + callback)
// The XML callback is available to the calling flow in any case,
// even if a WorkflowException is generated.
@@ -372,7 +398,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
vnfAdapterWorkflowException(execution, callback)
}
} catch (Exception e) {
- msoLogger.debug("Error encountered within VnfAdapterRest ProcessCallback method", e)
+ logger.debug("Error encountered within VnfAdapterRest ProcessCallback method", e)
exceptionUtil.buildAndThrowWorkflowException(execution, 7020, "Error encountered within VnfAdapterRest ProcessCallback method")
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy
index 8c979fca0b..f459b641eb 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -25,11 +27,13 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
class VnfAdapterUtils {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfAdapterUtils.class);
+ private static final Logger logger = LoggerFactory.getLogger( VnfAdapterUtils.class);
private AbstractServiceTaskProcessor taskProcessor
@@ -47,7 +51,7 @@ class VnfAdapterUtils {
', responseCodeVar=' + responseCodeVar +
', errorResponseVar=' + errorResponseVar +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered ' + method)
try {
def prefix = execution.getVariable('prefix')
@@ -62,27 +66,29 @@ class VnfAdapterUtils {
if (response.contains("WorkflowException")) {
execution.setVariable(prefix + "ErrorResponse", response)
//execution.setVariable(prefix + "ResponseCode", responseCode)
- msoLogger.debug(" Sub Vnf flow Error WorkflowException Response - " + "\n" + response)
+ logger.debug(" Sub Vnf flow Error WorkflowException Response - " + "\n" + response)
throw new BpmnError("MSOWorkflowException")
} else if (errorResponse != null && errorResponse instanceof WorkflowException) {
// Not sure the variables with the associated prefix are still used
execution.setVariable(prefix + "ErrorResponse", errorResponse.getErrorMessage())
execution.setVariable(prefix + "ResponseCode", errorResponse.getErrorCode())
- msoLogger.debug("Sub Vnf flow Error WorkflowException " + prefix + "ErrorResponse" + " - " + errorResponse.getErrorMessage())
+ logger.debug("Sub Vnf flow Error WorkflowException " + prefix + "ErrorResponse" + " - " + errorResponse.getErrorMessage())
// this is the important part to ensure we hit the Fallout Handler
throw new BpmnError("MSOWorkflowException")
} else if (errorResponse != null && errorResponse instanceof WorkflowException) {
// Not sure the variables with the associated prefix are still used
execution.setVariable(prefix + "ErrorResponse", errorResponse.getErrorMessage())
execution.setVariable(prefix + "ResponseCode", errorResponse.getErrorCode())
- msoLogger.debug("Sub Vnf flow Error WorkflowException " + prefix + "ErrorResponse" + " - " + errorResponse.getErrorMessage())
+ logger.debug("Sub Vnf flow Error WorkflowException " + prefix + "ErrorResponse" + " - " + errorResponse.getErrorMessage())
// this is the important part to ensure we hit the Fallout Handler
throw new BpmnError("MSOWorkflowException")
}
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),
+ MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, 'Internal Error- Unable to validate VNF Response ' + e.getMessage())
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy
index 75f5ec9161..d2b727b537 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy
@@ -25,6 +25,7 @@ import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.NetworkUtils
import org.onap.so.bpmn.common.scripts.VidUtils
import org.onap.so.bpmn.core.WorkflowException
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy
index 160eee2337..93a7115add 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -19,1338 +21,1251 @@
*/
package org.onap.so.bpmn.vcpe.scripts
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Rule
import org.junit.Test
-import org.junit.Ignore
import org.mockito.MockitoAnnotations
-import org.camunda.bpm.engine.delegate.BpmnError
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.bpmn.core.domain.HomingSolution
+import org.onap.so.bpmn.core.domain.*
import org.onap.so.bpmn.mock.FileUtil
-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.patch
-import static com.github.tomakehurst.wiremock.client.WireMock.put
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
-import static org.junit.Assert.*;
+import static org.junit.Assert.*
+import static org.mockito.ArgumentMatchers.any
+import static org.mockito.ArgumentMatchers.endsWith
import static org.mockito.Mockito.*
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
-import org.onap.so.bpmn.core.domain.ServiceDecomposition
-import org.onap.so.bpmn.core.domain.VnfResource
-import org.onap.so.bpmn.core.domain.AllottedResource
-import org.onap.so.bpmn.core.domain.ModelInfo
-import org.onap.so.bpmn.core.domain.HomingSolution
-import org.onap.so.bpmn.core.RollbackData
-import org.onap.so.bpmn.vcpe.scripts.MapGetter
-import org.onap.so.bpmn.vcpe.scripts.MapSetter
-
-import com.github.tomakehurst.wiremock.junit.WireMockRule
class CreateVcpeResCustServiceTest extends GroovyTestBase {
-
- private static String request
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(PORT)
-
- String Prefix = "CVRCS_"
- String RbType = "DCRENI_"
-
- @BeforeClass
- public static void setUpBeforeClass() {
- request = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/request.json")
- }
-
+
+ private static String request
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(PORT)
+
+ String Prefix = "CVRCS_"
+
+ @BeforeClass
+ public static void setUpBeforeClass() {
+ request = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/request.json")
+ }
+
@Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
- }
-
- public CreateVcpeResCustServiceTest() {
- super("CreateVcpeResCustService")
- }
-
-
- // ***** preProcessRequest *****
-
- @Test
- public void preProcessRequest() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
-
- initPreProcess(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.preProcessRequest(mex)
-
- verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("createVcpeServiceRequest", request)
- verify(mex).setVariable("msoRequestId", "mri")
- assertEquals("sii", map.get("serviceInstanceId"))
- verify(mex).setVariable("requestAction", "ra")
- verify(mex).setVariable("source", "VID")
- verify(mex).setVariable("globalSubscriberId", CUST)
- verify(mex).setVariable("globalCustomerId", CUST)
- verify(mex).setVariable("subscriptionServiceType", SVC)
- verify(mex).setVariable("disableRollback", "false")
- verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
- assertTrue(map.containsKey("subscriberInfo"))
-
- verify(mex).setVariable("brgWanMacAddress", "brgmac")
- verify(mex).setVariable("customerLocation", ["customerLatitude":"32.897480", "customerLongitude":"-97.040443", "customerName":"some_company"])
- verify(mex).setVariable("homingService", "sniro")
- assertTrue(map.containsKey("serviceInputParams"))
- assertTrue(map.containsKey(Prefix+"requestInfo"))
-
- def reqinfo = map.get(Prefix+"requestInfo")
- assertTrue(reqinfo.indexOf("<request-id>mri</") >= 0)
- assertTrue(reqinfo.indexOf("<source>VID</") >= 0)
-
- assertTrue(map.containsKey("vfModuleNames"))
- }
-
- @Test
- // @Ignore
- public void preProcessRequest_MissingAaiDistDelay() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcess(mex)
-
- when(mex.getVariable("aai.workflowAaiDistributionDelay")).thenReturn(null)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
- }
-
- @Test
- @Ignore // 1802 merge
- public void preProcessRequest_EmptyParts() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcess(mex)
-
- def req = request
- .replace('"source"', '"sourceXXX"')
- .replace('"BRG_WAN_MAC_Address"', '"BRG_WAN_MAC_AddressXXX"')
- .replace('"Customer_Location"', '"Customer_LocationXXX"')
-
- when(mex.getVariable("bpmnRequest")).thenReturn(req)
- when(mex.getVariable("serviceInstanceId")).thenReturn(null)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.preProcessRequest(mex)
-
- verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("createVcpeServiceRequest", req)
- verify(mex).setVariable("msoRequestId", "mri")
- assertNotNull(map.get("serviceInstanceId"))
- assertFalse(map.get("serviceInstanceId").isEmpty())
- verify(mex).setVariable("requestAction", "ra")
- verify(mex).setVariable("source", "VID")
- verify(mex).setVariable("globalSubscriberId", CUST)
- verify(mex).setVariable("globalCustomerId", CUST)
- verify(mex).setVariable("subscriptionServiceType", SVC)
- verify(mex).setVariable("disableRollback", "false")
- verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
- assertTrue(map.containsKey("subscriberInfo"))
-
- assertEquals("", map.get("brgWanMacAddress"))
- assertEquals("", map.get("customerLocation"))
- assertEquals("oof", map.get("homingService"))
- assertTrue(map.containsKey("serviceInputParams"))
- assertTrue(map.containsKey(Prefix+"requestInfo"))
-
- def reqinfo = map.get(Prefix+"requestInfo")
- println reqinfo
- assertTrue(reqinfo.indexOf("<request-id>mri</") >= 0)
- assertTrue(reqinfo.indexOf("<source>VID</") >= 0)
- }
-
- @Test
- // @Ignore
- public void preProcessRequest_MissingSubscriberId() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcess(mex)
-
- def req = request
- .replace('"globalSubscriberId"', '"globalSubscriberIdXXX"')
-
- when(mex.getVariable("bpmnRequest")).thenReturn(req)
- when(mex.getVariable("serviceInstanceId")).thenReturn(null)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
- }
-
- @Test
- @Ignore
- public void preProcessRequest_vimId() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcess(mex)
- UrnPropertiesReader
-
- def req = request
- .replace('"mdt1"', '"CloudOwner_CloudRegion1"')
-
- when(mex.getVariable("bpmnRequest")).thenReturn(req)
- when(mex.getVariable("aai.workflowAaiDistributionDelay")).thenReturn("PT5S")
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.preProcessRequest(mex)
-
- verify(mex).setVariable("cloudRegionId", "CloudRegion1")
- verify(mex).setVariable("cloudOwner", "CloudOwner")
- }
-
- @Test
- @Ignore
- public void preProcessRequest_noVimId() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcess(mex)
-
- def req = request
- .replace('"mdt1"', '"CloudRegion1_"')
-
- when(mex.getVariable("bpmnRequest")).thenReturn(req)
- when(mex.getVariable("aai.workflowAaiDistributionDelay")).thenReturn("PT5S")
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.preProcessRequest(mex)
-
- verify(mex).setVariable("cloudRegionId", "CloudRegion1_")
- verify(mex).setVariable("cloudOwner", "my-cloud-owner")
-
- }
-
-
- @Test
- // @Ignore
- public void preProcessRequest_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("bpmnRequest")).thenThrow(new BpmnError("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
- }
-
- @Test
- // @Ignore
- public void preProcessRequest_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("bpmnRequest")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
- }
-
- // ***** sendSyncResponse *****
-
- @Test
- // @Ignore
- public void sendSyncResponse() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initSendSyncResponse(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.sendSyncResponse(mex)
-
- verify(mex, times(2)).getVariable(DBGFLAG)
-
- verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
-
- assertEquals("202", map.get(processName+"ResponseCode"))
- assertEquals("Success", map.get(processName+"Status"))
-
- def resp = map.get(processName+"Response")
-
- assertTrue(resp.indexOf('"instanceId":"sii"') >= 0)
- assertTrue(resp.indexOf('"requestId":"mri"') >= 0)
- }
-
- @Test
- // @Ignore
- public void sendSyncResponse_Ex() {
- ExecutionEntity mex = setupMock()
- initSendSyncResponse(mex)
-
- when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.sendSyncResponse(mex) }))
- }
-
-
- // ***** prepareDecomposeService *****
-
- @Test
- // @Ignore
- public void prepareDecomposeService() {
- ExecutionEntity mex = setupMock()
- initPrepareDecomposeService(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.prepareDecomposeService(mex)
-
- verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("serviceModelInfo", "mi")
- }
-
- @Test
- // @Ignore
- public void prepareDecomposeService_Ex() {
- ExecutionEntity mex = setupMock()
- initPrepareDecomposeService(mex)
-
- when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareDecomposeService(mex) }))
- }
-
-
- // ***** prepareCreateServiceInstance *****
-
- @Test
- // @Ignore
- public void prepareCreateServiceInstance() {
- ExecutionEntity mex = setupMock()
- initPrepareCreateServiceInstance(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.prepareCreateServiceInstance(mex)
-
- verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("serviceInstanceName", "VCPE1")
- verify(mex).setVariable("serviceDecompositionString", "mydecomp")
- }
-
- @Test
- // @Ignore
- public void prepareCreateServiceInstance_Ex() {
- ExecutionEntity mex = setupMock()
- initPrepareCreateServiceInstance(mex)
-
- when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateServiceInstance(mex) }))
- }
-
-
- // ***** postProcessServiceInstanceCreate *****
-
- @Test
- // @Ignore
- public void postProcessServiceInstanceCreate() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPostProcessServiceInstanceCreate(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.postProcessServiceInstanceCreate(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- def reqinfo = map.get(Prefix+"setUpdateDbInstancePayload")
-
- assertTrue(reqinfo.indexOf("<requestId>mri</") >= 0)
- assertTrue(reqinfo.indexOf("<serviceInstanceId>sii</") >= 0)
- assertTrue(reqinfo.indexOf("<serviceInstanceName>sin</") >= 0)
- }
-
- @Test
- // @Ignore
- public void postProcessServiceInstanceCreate_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPostProcessServiceInstanceCreate(mex)
-
- doThrow(new BpmnError("expected exception")).when(mex).setVariable(endsWith("setUpdateDbInstancePayload"), any())
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) }))
- }
-
- @Test
- // @Ignore
- public void postProcessServiceInstanceCreate_Ex() {
- ExecutionEntity mex = setupMock()
- initPostProcessServiceInstanceCreate(mex)
-
- doThrow(new RuntimeException("expected exception")).when(mex).setVariable(endsWith("setUpdateDbInstancePayload"), any())
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) }))
- }
-
-
- // ***** processDecomposition *****
-
- @Test
- // @Ignore
- public void processDecomposition() {
- ExecutionEntity mex = setupMock()
- def svcdecomp = initProcessDecomposition(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.processDecomposition(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable("vnfList", svcdecomp.getVnfResources())
- verify(mex).setVariable("vnfListString", '[myvnf]')
- verify(mex).setVariable(Prefix+"VNFsCount", 1)
-
- verify(mex).setVariable("vnfModelInfo", "mymodel")
- verify(mex).setVariable("vnfModelInfoString", "mymodel")
- }
-
- @Test
- // @Ignore
- public void processDecomposition_EmptyNet_EmptyVnf() {
- ExecutionEntity mex = setupMock()
- def svcdecomp = initProcessDecomposition(mex)
-
- when(svcdecomp.getVnfResources()).thenReturn(new LinkedList<VnfResource>())
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.processDecomposition(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable("vnfList", svcdecomp.getVnfResources())
- verify(mex).setVariable("vnfListString", '[]')
- verify(mex).setVariable(Prefix+"VNFsCount", 0)
-
- verify(mex).setVariable("vnfModelInfo", "")
- verify(mex).setVariable("vnfModelInfoString", "")
- }
-
- @Test
- // @Ignore
- public void processDecomposition_Ex() {
- ExecutionEntity mex = setupMock()
- def svcdecomp = initProcessDecomposition(mex)
-
- when(svcdecomp.getVnfResources()).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processDecomposition(mex) }))
- }
-
-
- // ***** filterVnfs *****
-
- @Test
- // @Ignore
- public void filterVnfs() {
- ExecutionEntity mex = setupMock()
- def svcdecomp = initFilterVnfs(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.processDecomposition(mex)
-
- verify(mex).setVariable("vnfListString", '[myvnf3, myvnf5]')
- }
-
- @Test
- // @Ignore
- public void filterVnfs_Null() {
- ExecutionEntity mex = setupMock()
- def svcdecomp = initFilterVnfs(mex)
-
- when(svcdecomp.getVnfResources()).thenReturn(null)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.processDecomposition(mex)
-
- // nothing more to check, as long as it didn't throw an exception
- }
-
-
- // ***** prepareCreateAllottedResourceTXC *****
-
- @Test
- // @Ignore
- public void prepareCreateAllottedResourceTXC() {
- ExecutionEntity mex = setupMock()
- initPrepareCreateAllottedResourceTXC(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable("createTXCAR", true)
- verify(mex).setVariable("allottedResourceModelInfoTXC", "modelB")
- verify(mex).setVariable("allottedResourceRoleTXC", "TXCr")
- verify(mex).setVariable("allottedResourceTypeTXC", "Tunnel XConn")
- verify(mex).setVariable("parentServiceInstanceIdTXC", "homeB")
- }
-
- @Test
- // @Ignore
- public void prepareCreateAllottedResourceTXC_NullArList() {
- ExecutionEntity mex = setupMock()
- def svcdecomp = initPrepareCreateAllottedResourceTXC(mex)
-
- when(svcdecomp.getAllottedResources()).thenReturn(null)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex, never()).setVariable("createTXCAR", true)
- verify(mex, never()).setVariable("allottedResourceModelInfoTXC", "modelB")
- verify(mex, never()).setVariable("allottedResourceRoleTXC", "TXCr")
- verify(mex, never()).setVariable("allottedResourceTypeTXC", "Tunnel XConn")
- verify(mex, never()).setVariable("parentServiceInstanceIdTXC", "homeB")
- }
-
- @Test
- // @Ignore
- public void prepareCreateAllottedResourceTXC_Ex() {
- ExecutionEntity mex = setupMock()
- initPrepareCreateAllottedResourceTXC(mex)
-
- when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) }))
- }
-
-
- // ***** prepareCreateAllottedResourceBRG *****
-
- @Test
- // @Ignore
- public void prepareCreateAllottedResourceBRG() {
- ExecutionEntity mex = setupMock()
- initPrepareCreateAllottedResourceBRG(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable("createBRGAR", true)
- verify(mex).setVariable("allottedResourceModelInfoBRG", "modelB")
- verify(mex).setVariable("allottedResourceRoleBRG", "BRGr")
- verify(mex).setVariable("allottedResourceTypeBRG", "BRG")
- verify(mex).setVariable("parentServiceInstanceIdBRG", "homeB")
- }
-
- @Test
- // @Ignore
- public void prepareCreateAllottedResourceBRG_NullArList() {
- ExecutionEntity mex = setupMock()
- def svcdecomp = initPrepareCreateAllottedResourceBRG(mex)
-
- when(svcdecomp.getAllottedResources()).thenReturn(null)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex, never()).setVariable("createBRGAR", true)
- verify(mex, never()).setVariable("allottedResourceModelInfoBRG", "modelB")
- verify(mex, never()).setVariable("allottedResourceRoleBRG", "BRGr")
- verify(mex, never()).setVariable("allottedResourceTypeBRG", "BRG")
- verify(mex, never()).setVariable("parentServiceInstanceIdBRG", "homeB")
- }
-
- @Test
- // @Ignore
- public void prepareCreateAllottedResourceBRG_Ex() {
- ExecutionEntity mex = setupMock()
- initPrepareCreateAllottedResourceBRG(mex)
-
- when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) }))
- }
-
-
- // ***** prepareVnfAndModulesCreate *****
-
- @Test
- // @Ignore
- public void prepareVnfAndModulesCreate() {
- ExecutionEntity mex = setupMock()
- initPrepareVnfAndModulesCreate(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
- verify(mex).setVariable("lcpCloudRegionId", "mdt1")
- verify(mex).setVariable("cloudOwner", "my-cloud-owner")
- verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
- }
-
- @Test
- public void prepareVnfAndModulesCreate_noVimId() {
- ExecutionEntity mex = setupMock()
- initPrepareVnfAndModulesCreate(mex)
-
- def req = request
- .replace('"mdt1"', '"CloudRegion1_"')
-
- when(mex.getVariable("createVcpeServiceRequest")).thenReturn(req)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
-
- verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
- verify(mex).setVariable("cloudRegionId", "CloudRegion1_")
- verify(mex).setVariable("lcpCloudRegionId", "CloudRegion1_")
- verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
- }
-
- @Test
- public void prepareVnfAndModulesCreate_vimId() {
- ExecutionEntity mex = setupMock()
- initPrepareVnfAndModulesCreate(mex)
-
- def req = request
- .replace('"mdt1"', '"CloudOwner_CloudRegion1"')
-
- when(mex.getVariable("createVcpeServiceRequest")).thenReturn(req)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
-
- verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
- verify(mex).setVariable("cloudOwner", "CloudOwner")
- verify(mex).setVariable("cloudRegionId", "CloudRegion1")
- verify(mex).setVariable("lcpCloudRegionId", "CloudRegion1")
- verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
- }
-
- @Test
- // @Ignore
- public void prepareVnfAndModulesCreate_EmptyList() {
- ExecutionEntity mex = setupMock()
- initPrepareVnfAndModulesCreate(mex)
-
- when(mex.getVariable("vnfList")).thenReturn(new LinkedList<VnfResource>())
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
- verify(mex).setVariable("lcpCloudRegionId", "mdt1")
- verify(mex).setVariable("cloudOwner", "my-cloud-owner")
- verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
- }
-
- @Test
- // @Ignore
- public void prepareVnfAndModulesCreate_NullList() {
- ExecutionEntity mex = setupMock()
- initPrepareVnfAndModulesCreate(mex)
-
- when(mex.getVariable("vnfList")).thenReturn(null)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
- verify(mex).setVariable("lcpCloudRegionId", "mdt1")
- verify(mex).setVariable("cloudOwner", "my-cloud-owner")
- verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
- }
-
- @Test
- // @Ignore
- public void prepareVnfAndModulesCreate_Ex() {
- ExecutionEntity mex = setupMock()
- initPrepareVnfAndModulesCreate(mex)
-
- when(mex.getVariable("vnfList")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) }))
- }
-
-
- // ***** validateVnfCreate *****
-
- @Test
- // @Ignore
- public void validateVnfCreate() {
- ExecutionEntity mex = setupMock()
- initValidateVnfCreate(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.validateVnfCreate(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable(Prefix+"VnfsCreatedCount", 3)
- }
-
- @Test
- // @Ignore
- public void validateVnfCreate_Ex() {
- ExecutionEntity mex = setupMock()
- initValidateVnfCreate(mex)
-
- when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.validateVnfCreate(mex) }))
- }
-
-
- // ***** postProcessResponse *****
-
- @Test
- // @Ignore
- public void postProcessResponse() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPostProcessResponse(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.postProcessResponse(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable(Prefix+"Success", true)
-
- def reqinfo = map.get(Prefix+"CompleteMsoProcessRequest")
-
- assertTrue(reqinfo.indexOf("request-id>mri</") >= 0)
- assertTrue(reqinfo.indexOf("source>mysrc</") >= 0)
- assertTrue(reqinfo.indexOf("serviceInstanceId>sii</") >= 0)
- }
-
- @Test
- // @Ignore
- public void postProcessResponse_BpmnError() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPostProcessResponse(mex)
-
- when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessResponse(mex) }))
- }
-
- @Test
- // @Ignore
- public void postProcessResponse_Ex() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPostProcessResponse(mex)
-
- when(mex.getVariable("source")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessResponse(mex) }))
- }
-
-
- // ***** preProcessRollback *****
-
- @Test
- // @Ignore
- public void preProcessRollback() {
- ExecutionEntity mex = setupMock()
- def wfe = initPreProcessRollback(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.preProcessRollback(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable("prevWorkflowException", wfe)
- }
-
- @Test
- // @Ignore
- public void preProcessRollback_NullWfe() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def wfe = initPreProcessRollback(mex)
-
- when(mex.getVariable("WorkflowException")).thenReturn(null)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.preProcessRollback(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- assertFalse(map.containsKey("prevWorkflowException"))
- }
-
- @Test
- // @Ignore
- public void preProcessRollback_BpmnError() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def wfe = initPreProcessRollback(mex)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.preProcessRollback(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- assertFalse(map.containsKey("prevWorkflowException"))
- }
-
- @Test
- // @Ignore
- public void preProcessRollback_Ex() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def wfe = initPreProcessRollback(mex)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.preProcessRollback(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- assertFalse(map.containsKey("prevWorkflowException"))
- }
-
-
- // ***** postProcessRollback *****
-
- @Test
- // @Ignore
- public void postProcessRollback() {
- ExecutionEntity mex = setupMock()
- def wfe = initPostProcessRollback(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.postProcessRollback(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable("WorkflowException", wfe)
- }
-
- @Test
- // @Ignore
- public void postProcessRollback_NullWfe() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def wfe = initPostProcessRollback(mex)
-
- when(mex.getVariable("prevWorkflowException")).thenReturn(null)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.postProcessRollback(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- assertFalse(map.containsKey("WorkflowException"))
- }
-
- @Test
- // @Ignore
- public void postProcessRollback_BpmnError() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def wfe = initPostProcessRollback(mex)
-
- when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessRollback(mex) }))
- }
-
- @Test
- // @Ignore
- public void postProcessRollback_Ex() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def wfe = initPostProcessRollback(mex)
-
- when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.postProcessRollback(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- assertFalse(map.containsKey("WorkflowException"))
- }
-
-
- // ***** prepareFalloutRequest *****
-
- @Test
- // @Ignore
- public void prepareFalloutRequest() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPrepareFalloutRequest(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.prepareFalloutRequest(mex)
-
- verify(mex, times(2)).getVariable(DBGFLAG)
-
- def fo = map.get(Prefix+"falloutRequest")
-
- assertTrue(fo.indexOf("<hello>world</") >= 0)
- assertTrue(fo.indexOf("ErrorMessage>mymsg</") >= 0)
- assertTrue(fo.indexOf("ErrorCode>999</") >= 0)
- }
-
- @Test
- // @Ignore
- public void prepareFalloutRequest_Ex() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPrepareFalloutRequest(mex)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareFalloutRequest(mex) }))
- }
-
- // ***** sendSyncError *****
-
- @Test
- // @Ignore
- public void sendSyncError() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initSendSyncError(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.sendSyncError(mex)
-
- verify(mex, times(2)).getVariable(DBGFLAG)
-
- verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
-
- assertEquals("500", map.get(processName+"ResponseCode"))
- assertEquals("Fail", map.get(processName+"Status"))
-
- def resp = map.get(processName+"Response")
-
- assertTrue(resp.indexOf("ErrorMessage>mymsg</") >= 0)
-
- verify(mex).setVariable("WorkflowResponse", resp)
- }
-
- @Test
- // @Ignore
- public void sendSyncError_NotWfe() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initSendSyncError(mex)
-
- when(mex.getVariable("WorkflowException")).thenReturn("not a WFE")
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.sendSyncError(mex)
-
- verify(mex, times(2)).getVariable(DBGFLAG)
-
- verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
-
- assertEquals("500", map.get(processName+"ResponseCode"))
- assertEquals("Fail", map.get(processName+"Status"))
-
- def resp = map.get(processName+"Response")
-
- assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.</") >= 0)
-
- verify(mex).setVariable("WorkflowResponse", resp)
- }
-
- @Test
- // @Ignore
- public void sendSyncError_NullWfe() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initSendSyncError(mex)
-
- when(mex.getVariable("WorkflowException")).thenReturn(null)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.sendSyncError(mex)
-
- verify(mex, times(2)).getVariable(DBGFLAG)
-
- verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
-
- assertEquals("500", map.get(processName+"ResponseCode"))
- assertEquals("Fail", map.get(processName+"Status"))
-
- def resp = map.get(processName+"Response")
-
- assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.</") >= 0)
-
- verify(mex).setVariable("WorkflowResponse", resp)
- }
-
- @Test
- // @Ignore
- public void sendSyncError_Ex() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initSendSyncError(mex)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- CreateVcpeResCustService.sendSyncError(mex)
-
- assertFalse(map.containsKey(processName+"ResponseCode"))
- }
-
-
- // ***** processJavaException *****
-
- @Test
- // @Ignore
- public void processJavaException() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initProcessJavaException(mex)
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) }))
-
- verify(mex, times(2)).getVariable(DBGFLAG)
-
- verify(mex).setVariable("prefix", Prefix)
-
- def wfe = map.get("WorkflowException")
-
- assertEquals("Caught a Java Lang Exception", wfe.getErrorMessage())
- }
-
- @Test
- // @Ignore
- public void processJavaException_BpmnError() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initProcessJavaException(mex)
-
- when(mex.getVariables()).thenThrow(new BpmnError("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) }))
-
- assertFalse(map.containsKey("WorkflowException"))
- }
-
- @Test
- // @Ignore
- public void processJavaException_Ex() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initProcessJavaException(mex)
-
- when(mex.getVariables()).thenThrow(new RuntimeException("expected exception"))
-
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) }))
-
- def wfe = map.get("WorkflowException")
-
- assertEquals("Exception in processJavaException method", wfe.getErrorMessage())
- }
-
-
- private void initPreProcess(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("bpmnRequest")).thenReturn(request)
- when(mex.getVariable("aai.workflowAaiDistributionDelay")).thenReturn("PT5S")
- when(mex.getVariable("mso-request-id")).thenReturn("mri")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("requestAction")).thenReturn("ra")
- }
-
- private initSendSyncResponse(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("mso-request-id")).thenReturn("mri")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- }
-
- private void initPrepareDecomposeService(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("createVcpeServiceRequest")).thenReturn('{"requestDetails":{"modelInfo":"mi"}}')
- }
-
- private void initPrepareCreateServiceInstance(ExecutionEntity mex) {
- ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
- when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
-
- when(svcdecomp.toJsonStringNoRootName()).thenReturn("mydecomp")
- }
-
- private void initPostProcessServiceInstanceCreate(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("mso-request-id")).thenReturn("mri")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
- }
-
- private ServiceDecomposition initProcessDecomposition(ExecutionEntity mex) {
- List<VnfResource> vnflst = new LinkedList<>()
- vnflst.add(makeVnf("", ""))
- vnflst.add(makeVnf("2", "BRG"))
- vnflst.add(makeVnf("3", "BRG"))
-
- ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
- when(svcdecomp.getVnfResources()).thenReturn(vnflst)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
-
- return svcdecomp
- }
-
- private ServiceDecomposition initFilterVnfs(ExecutionEntity mex) {
- List<VnfResource> vnflst = new LinkedList<>()
- vnflst.add(makeVnf("", "BRG"))
- vnflst.add(makeVnf("2", "Tunnel XConn"))
- vnflst.add(makeVnf("3", ""))
- vnflst.add(makeVnf("4", "BRG"))
- vnflst.add(makeVnf("5", "other"))
-
- ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
- when(svcdecomp.getVnfResources()).thenReturn(vnflst)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
-
- return svcdecomp
- }
-
- private initAwaitAaiDistribution(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- }
-
- private ServiceDecomposition initPrepareCreateAllottedResourceTXC(ExecutionEntity mex) {
- ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
- List<AllottedResource> arlst = new LinkedList<>()
-
- arlst.add(makeArBRG("A"))
- arlst.add(makeArTXC("B"))
- arlst.add(makeArBRG("C"))
-
- when(svcdecomp.getAllottedResources()).thenReturn(arlst)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
- when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
- when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
-
- return svcdecomp
- }
-
- private ServiceDecomposition initPrepareCreateAllottedResourceBRG(ExecutionEntity mex) {
- ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
- List<AllottedResource> arlst = new LinkedList<>()
-
- arlst.add(makeArTXC("A"))
- arlst.add(makeArBRG("B"))
- arlst.add(makeArTXC("C"))
-
- when(svcdecomp.getAllottedResources()).thenReturn(arlst)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
- when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
- when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
-
- return svcdecomp
- }
-
- private AllottedResource makeArTXC(String id) {
- AllottedResource ar = mock(AllottedResource.class)
- ModelInfo mod = mock(ModelInfo.class)
- HomingSolution home = mock(HomingSolution.class)
-
- when(ar.toJsonStringNoRootName()).thenReturn("json"+id)
- when(ar.getAllottedResourceType()).thenReturn("Tunnel XConn")
- when(ar.getModelInfo()).thenReturn(mod)
- when(ar.getAllottedResourceRole()).thenReturn("TXCr")
- when(ar.getHomingSolution()).thenReturn(home)
-
- when(mod.toJsonStringNoRootName()).thenReturn("model"+id)
-
- when(home.getServiceInstanceId()).thenReturn("home"+id)
-
- return ar
- }
-
- private AllottedResource makeArBRG(String id) {
- AllottedResource ar = mock(AllottedResource.class)
- ModelInfo mod = mock(ModelInfo.class)
- HomingSolution home = mock(HomingSolution.class)
-
- when(ar.toJsonStringNoRootName()).thenReturn("json"+id)
- when(ar.getAllottedResourceType()).thenReturn("BRG")
- when(ar.getModelInfo()).thenReturn(mod)
- when(ar.getAllottedResourceRole()).thenReturn("BRGr")
- when(ar.getHomingSolution()).thenReturn(home)
-
- when(mod.toJsonStringNoRootName()).thenReturn("model"+id)
-
- when(home.getServiceInstanceId()).thenReturn("home"+id)
-
- return ar
- }
-
- private initPrepareVnfAndModulesCreate(ExecutionEntity mex) {
-
- List<VnfResource> vnflst = new LinkedList<>()
-
- vnflst.add(makeVnf("A", "BRG"))
- vnflst.add(makeVnf("B", ""))
- vnflst.add(makeVnf("C", ""))
- vnflst.add(makeVnf("D", "Tunnel XConn"))
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
- when(mex.getVariable("vnfList")).thenReturn(vnflst)
- when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenReturn(2)
- when(mex.getVariable("vnfModelInfo")).thenReturn("nomodel")
- when(mex.getVariable("sdncVersion")).thenReturn("myvers")
- }
-
- private VnfResource makeVnf(String id, String role) {
- ModelInfo mod = mock(ModelInfo.class)
- VnfResource vnf = mock(VnfResource.class)
-
- when(mod.toString()).thenReturn('{"modelInfo":"mymodel'+id+'"}')
-
- when(vnf.toString()).thenReturn("myvnf"+id)
- when(vnf.getModelInfo()).thenReturn(mod)
- when(vnf.getNfRole()).thenReturn(role)
-
- return vnf
- }
-
- private initValidateVnfCreate(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenReturn(2)
- }
-
- private initPostProcessResponse(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("source")).thenReturn("mysrc")
- when(mex.getVariable("mso-request-id")).thenReturn("mri")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- }
-
- private WorkflowException initPreProcessRollback(ExecutionEntity mex) {
- WorkflowException wfe = mock(WorkflowException.class)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("WorkflowException")).thenReturn(wfe)
-
- return wfe
- }
-
- private WorkflowException initPostProcessRollback(ExecutionEntity mex) {
- WorkflowException wfe = mock(WorkflowException.class)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prevWorkflowException")).thenReturn(wfe)
-
- return wfe
- }
-
- private initPrepareFalloutRequest(ExecutionEntity mex) {
- WorkflowException wfe = mock(WorkflowException.class)
-
- when(wfe.getErrorMessage()).thenReturn("mymsg")
- when(wfe.getErrorCode()).thenReturn(999)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("WorkflowException")).thenReturn(wfe)
- when(mex.getVariable(Prefix+"requestInfo")).thenReturn("<hello>world</hello>")
-
- return wfe
- }
-
- private initSendSyncError(ExecutionEntity mex) {
- WorkflowException wfe = mock(WorkflowException.class)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("mso-request-id")).thenReturn("mri")
- when(mex.getVariable("WorkflowException")).thenReturn(wfe)
-
- when(wfe.getErrorMessage()).thenReturn("mymsg")
- }
-
- private initProcessJavaException(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- }
-
+ public void init() {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ public CreateVcpeResCustServiceTest() {
+ super("CreateVcpeResCustService")
+ }
+
+ // ***** preProcessRequest *****
+
+ @Test
+ public void preProcessRequest() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+
+ initPreProcess(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.preProcessRequest(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("createVcpeServiceRequest", request)
+ verify(mex).setVariable("msoRequestId", "mri")
+ assertEquals("sii", map.get("serviceInstanceId"))
+ verify(mex).setVariable("requestAction", "ra")
+ verify(mex).setVariable("source", "VID")
+ verify(mex).setVariable("globalSubscriberId", CUST)
+ verify(mex).setVariable("globalCustomerId", CUST)
+ verify(mex).setVariable("subscriptionServiceType", SVC)
+ verify(mex).setVariable("disableRollback", "false")
+ verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
+ assertTrue(map.containsKey("subscriberInfo"))
+
+ verify(mex).setVariable("brgWanMacAddress", "brgmac")
+ verify(mex).setVariable("customerLocation", ["customerLatitude": "32.897480", "customerLongitude": "-97.040443", "customerName": "some_company"])
+ verify(mex).setVariable("homingService", "sniro")
+ assertTrue(map.containsKey("serviceInputParams"))
+ assertTrue(map.containsKey(Prefix + "requestInfo"))
+
+ def reqinfo = map.get(Prefix + "requestInfo")
+ assertTrue(reqinfo.indexOf("<request-id>mri</") >= 0)
+ assertTrue(reqinfo.indexOf("<source>VID</") >= 0)
+
+ assertTrue(map.containsKey("vfModuleNames"))
+ }
+
+ @Test
+ public void preProcessRequest_MissingAaiDistDelay() {
+ ExecutionEntity mex = setupMock()
+ setupMap(mex)
+ initPreProcess(mex)
+
+ when(mex.getVariable("aai.workflowAaiDistributionDelay")).thenReturn(null)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
+ }
+
+ @Test
+ public void preProcessRequest_EmptyParts() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcess(mex)
+
+ def req = request
+ .replace('"source"', '"sourceXXX"')
+ .replace('"BRG_WAN_MAC_Address"', '"BRG_WAN_MAC_AddressXXX"')
+ .replace('"Customer_Location"', '"Customer_LocationXXX"')
+
+ when(mex.getVariable("bpmnRequest")).thenReturn(req)
+ when(mex.getVariable("serviceInstanceId")).thenReturn(null)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.preProcessRequest(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("createVcpeServiceRequest", req)
+ verify(mex).setVariable("msoRequestId", "mri")
+ assertNotNull(map.get("serviceInstanceId"))
+ assertFalse(map.get("serviceInstanceId").isEmpty())
+ verify(mex).setVariable("requestAction", "ra")
+ verify(mex).setVariable("source", "VID")
+ verify(mex).setVariable("globalSubscriberId", CUST)
+ verify(mex).setVariable("globalCustomerId", CUST)
+ verify(mex).setVariable("subscriptionServiceType", SVC)
+ verify(mex).setVariable("disableRollback", "false")
+ verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
+ assertTrue(map.containsKey("subscriberInfo"))
+
+ assertEquals("", map.get("brgWanMacAddress"))
+ assertEquals("", map.get("customerLocation"))
+ assertEquals("sniro", map.get("homingService"))
+ assertTrue(map.containsKey("serviceInputParams"))
+ assertTrue(map.containsKey(Prefix + "requestInfo"))
+
+ def reqinfo = map.get(Prefix + "requestInfo")
+ println reqinfo
+ assertTrue(reqinfo.indexOf("<request-id>mri</") >= 0)
+ assertTrue(reqinfo.indexOf("<source>VID</") >= 0)
+ }
+
+ @Test
+ public void preProcessRequest_MissingSubscriberId() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcess(mex)
+
+ def req = request
+ .replace('"globalSubscriberId"', '"globalSubscriberIdXXX"')
+
+ when(mex.getVariable("bpmnRequest")).thenReturn(req)
+ when(mex.getVariable("serviceInstanceId")).thenReturn(null)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
+ }
+
+ @Test
+ public void preProcessRequest_vimId() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcess(mex)
+ UrnPropertiesReader
+
+ def req = request
+ .replace('"mdt1"', '"CloudOwner_CloudRegion1"')
+
+ when(mex.getVariable("bpmnRequest")).thenReturn(req)
+ when(mex.getVariable("aai.workflowAaiDistributionDelay")).thenReturn("PT5S")
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.preProcessRequest(mex)
+
+ verify(mex).setVariable("cloudRegionId", "CloudRegion1")
+ verify(mex).setVariable("cloudOwner", "CloudOwner")
+ }
+
+ @Test
+ public void preProcessRequest_noVimId() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcess(mex)
+
+ def req = request
+ .replace('"mdt1"', '"CloudRegion1_"')
+
+ when(mex.getVariable("bpmnRequest")).thenReturn(req)
+ when(mex.getVariable("aai.workflowAaiDistributionDelay")).thenReturn("PT5S")
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("cloudRegionId", "CloudRegion1_")
+ verify(mex).setVariable("cloudOwner", "CloudOwner")
+
+ }
+
+
+ @Test
+ public void preProcessRequest_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("bpmnRequest")).thenThrow(new BpmnError("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
+ }
+
+ @Test
+ public void preProcessRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("bpmnRequest")).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
+ }
+
+ // ***** sendSyncResponse *****
+
+ @Test
+ public void sendSyncResponse() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initSendSyncResponse(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.sendSyncResponse(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+
+ verify(mex).setVariable(processName + "WorkflowResponseSent", "true")
+
+ assertEquals("202", map.get(processName + "ResponseCode"))
+ assertEquals("Success", map.get(processName + "Status"))
+
+ def resp = map.get(processName + "Response")
+
+ assertTrue(resp.indexOf('"instanceId":"sii"') >= 0)
+ assertTrue(resp.indexOf('"requestId":"mri"') >= 0)
+ }
+
+ @Test
+ public void sendSyncResponse_Ex() {
+ ExecutionEntity mex = setupMock()
+ initSendSyncResponse(mex)
+
+ when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.sendSyncResponse(mex) }))
+ }
+
+ // ***** prepareDecomposeService *****
+
+ @Test
+ public void prepareDecomposeService() {
+ ExecutionEntity mex = setupMock()
+ initPrepareDecomposeService(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareDecomposeService(mex)
+
+ verify(mex).getVariable("createVcpeServiceRequest")
+ verify(mex).setVariable("serviceModelInfo", "mi")
+ }
+
+ @Test
+ public void prepareDecomposeService_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPrepareDecomposeService(mex)
+
+ when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.prepareDecomposeService(mex) }))
+ }
+
+ // ***** prepareCreateServiceInstance *****
+
+ @Test
+ public void prepareCreateServiceInstance() {
+ ExecutionEntity mex = setupMock()
+ ServiceDecomposition svcdecomp = initPrepareCreateServiceInstance(mex)
+ when(svcdecomp.toJsonStringNoRootName()).thenReturn("mydecomp")
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareCreateServiceInstance(mex)
+
+ verify(mex).getVariable("createVcpeServiceRequest")
+ verify(mex).setVariable("serviceInstanceName", "VCPE1")
+ verify(mex).setVariable("serviceDecompositionString", "mydecomp")
+ }
+
+ @Test
+ public void prepareCreateServiceInstance_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPrepareCreateServiceInstance(mex)
+
+ when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.prepareCreateServiceInstance(mex) }))
+ }
+
+ // ***** postProcessServiceInstanceCreate *****
+
+ @Test
+ public void postProcessServiceInstanceCreate() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPostProcessServiceInstanceCreate(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.postProcessServiceInstanceCreate(mex)
+
+ verify(mex).getVariable("mso-request-id")
+ verify(mex).getVariable("serviceInstanceId")
+ verify(mex).getVariable("serviceInstanceName")
+
+ def reqinfo = map.get(Prefix + "setUpdateDbInstancePayload")
+
+ assertTrue(reqinfo.indexOf("<requestId>mri</") >= 0)
+ assertTrue(reqinfo.indexOf("<serviceInstanceId>sii</") >= 0)
+ assertTrue(reqinfo.indexOf("<serviceInstanceName>sin</") >= 0)
+ }
+
+ @Test
+ public void postProcessServiceInstanceCreate_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPostProcessServiceInstanceCreate(mex)
+
+ doThrow(new BpmnError("expected exception")).when(mex).setVariable(endsWith("setUpdateDbInstancePayload"), any())
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) }))
+ }
+
+ @Test
+ public void postProcessServiceInstanceCreate_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPostProcessServiceInstanceCreate(mex)
+
+ doThrow(new RuntimeException("expected exception")).when(mex).setVariable(endsWith("setUpdateDbInstancePayload"), any())
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) }))
+ }
+
+ // ***** processDecomposition *****
+
+ @Test
+ public void processDecomposition() {
+ ExecutionEntity mex = setupMock()
+ def svcdecomp = initProcessDecomposition(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.processDecomposition(mex)
+
+ verify(mex).getVariable("serviceDecomposition")
+
+ verify(mex).setVariable("vnfList", svcdecomp.getVnfResources())
+ verify(mex).setVariable("vnfListString", '[myvnf]')
+ verify(mex).setVariable(Prefix + "VNFsCount", 1)
+
+ verify(mex).setVariable("vnfModelInfo", "mymodel")
+ verify(mex).setVariable("vnfModelInfoString", "mymodel")
+ }
+
+ @Test
+ public void processDecomposition_EmptyNet_EmptyVnf() {
+ ExecutionEntity mex = setupMock()
+ def svcdecomp = initProcessDecomposition(mex)
+
+ when(svcdecomp.getVnfResources()).thenReturn(new LinkedList<VnfResource>())
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.processDecomposition(mex)
+
+ verify(mex).getVariable("serviceDecomposition")
+
+ verify(mex).setVariable("vnfList", svcdecomp.getVnfResources())
+ verify(mex).setVariable("vnfListString", '[]')
+ verify(mex).setVariable(Prefix + "VNFsCount", 0)
+
+ verify(mex).setVariable("vnfModelInfo", "")
+ verify(mex).setVariable("vnfModelInfoString", "")
+ }
+
+ @Test
+ public void processDecomposition_Ex() {
+ ExecutionEntity mex = setupMock()
+ def svcdecomp = initProcessDecomposition(mex)
+
+ when(svcdecomp.getVnfResources()).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.processDecomposition(mex) }))
+ }
+
+ // ***** filterVnfs *****
+
+ @Test
+ public void filterVnfs() {
+ ExecutionEntity mex = setupMock()
+ initFilterVnfs(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.processDecomposition(mex)
+
+ verify(mex).setVariable("vnfListString", '[myvnf3, myvnf5]')
+ }
+
+ @Test
+ public void filterVnfs_Null() {
+ ExecutionEntity mex = setupMock()
+ def svcdecomp = initFilterVnfs(mex)
+
+ when(svcdecomp.getVnfResources()).thenReturn(null)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.processDecomposition(mex)
+
+ // nothing more to check, as long as it didn't throw an exception
+ }
+
+ // ***** prepareCreateAllottedResourceTXC *****
+
+ @Test
+ public void prepareCreateAllottedResourceTXC() {
+ ExecutionEntity mex = setupMock()
+ initPrepareCreateAllottedResourceTXC(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex)
+
+ verify(mex).getVariable("serviceDecomposition")
+
+ verify(mex).setVariable("createTXCAR", true)
+ verify(mex).setVariable("allottedResourceModelInfoTXC", "modelB")
+ verify(mex).setVariable("allottedResourceRoleTXC", "TXCr")
+ verify(mex).setVariable("allottedResourceTypeTXC", "Tunnel XConn")
+ verify(mex).setVariable("parentServiceInstanceIdTXC", "homeB")
+ }
+
+ @Test
+ public void prepareCreateAllottedResourceTXC_NullArList() {
+ ExecutionEntity mex = setupMock()
+ def svcdecomp = initPrepareCreateAllottedResourceTXC(mex)
+
+ when(svcdecomp.getAllottedResources()).thenReturn(null)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex)
+
+ verify(mex).getVariable("serviceDecomposition")
+
+ verify(mex, never()).setVariable("createTXCAR", true)
+ verify(mex, never()).setVariable("allottedResourceModelInfoTXC", "modelB")
+ verify(mex, never()).setVariable("allottedResourceRoleTXC", "TXCr")
+ verify(mex, never()).setVariable("allottedResourceTypeTXC", "Tunnel XConn")
+ verify(mex, never()).setVariable("parentServiceInstanceIdTXC", "homeB")
+ }
+
+ @Test
+ public void prepareCreateAllottedResourceTXC_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPrepareCreateAllottedResourceTXC(mex)
+
+ when(mex.getVariable("serviceDecomposition")).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) }))
+ }
+
+ // ***** prepareCreateAllottedResourceBRG *****
+
+ @Test
+ public void prepareCreateAllottedResourceBRG() {
+ ExecutionEntity mex = setupMock()
+ initPrepareCreateAllottedResourceBRG(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex)
+
+ verify(mex).getVariable("serviceDecomposition")
+
+ verify(mex).setVariable("createBRGAR", true)
+ verify(mex).setVariable("allottedResourceModelInfoBRG", "modelB")
+ verify(mex).setVariable("allottedResourceRoleBRG", "BRGr")
+ verify(mex).setVariable("allottedResourceTypeBRG", "BRG")
+ verify(mex).setVariable("parentServiceInstanceIdBRG", "homeB")
+ }
+
+ @Test
+ public void prepareCreateAllottedResourceBRG_NullArList() {
+ ExecutionEntity mex = setupMock()
+ def svcdecomp = initPrepareCreateAllottedResourceBRG(mex)
+
+ when(svcdecomp.getAllottedResources()).thenReturn(null)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex)
+
+ verify(mex).getVariable("serviceDecomposition")
+
+ verify(mex, never()).setVariable("createBRGAR", true)
+ verify(mex, never()).setVariable("allottedResourceModelInfoBRG", "modelB")
+ verify(mex, never()).setVariable("allottedResourceRoleBRG", "BRGr")
+ verify(mex, never()).setVariable("allottedResourceTypeBRG", "BRG")
+ verify(mex, never()).setVariable("parentServiceInstanceIdBRG", "homeB")
+ }
+
+ @Test
+ public void prepareCreateAllottedResourceBRG_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPrepareCreateAllottedResourceBRG(mex)
+
+ when(mex.getVariable("serviceDecomposition")).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) }))
+ }
+
+ // ***** prepareVnfAndModulesCreate *****
+
+ @Test
+ public void prepareVnfAndModulesCreate() {
+ ExecutionEntity mex = setupMock()
+ initPrepareVnfAndModulesCreate(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
+
+ verify(mex).getVariable("createVcpeServiceRequest")
+
+ verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
+ verify(mex).setVariable("lcpCloudRegionId", "mdt1")
+ verify(mex).setVariable("cloudOwner", "CloudOwner")
+ verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
+ }
+
+ @Test
+ public void prepareVnfAndModulesCreate_noVimId() {
+ ExecutionEntity mex = setupMock()
+ initPrepareVnfAndModulesCreate(mex)
+
+ def req = request
+ .replace('"mdt1"', '"CloudRegion1_"')
+
+ when(mex.getVariable("createVcpeServiceRequest")).thenReturn(req)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
+
+ verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
+ verify(mex).setVariable("cloudRegionId", "CloudRegion1_")
+ verify(mex).setVariable("lcpCloudRegionId", "CloudRegion1_")
+ verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
+ }
+
+ @Test
+ public void prepareVnfAndModulesCreate_vimId() {
+ ExecutionEntity mex = setupMock()
+ initPrepareVnfAndModulesCreate(mex)
+
+ def req = request
+ .replace('"mdt1"', '"CloudOwner_CloudRegion1"')
+
+ when(mex.getVariable("createVcpeServiceRequest")).thenReturn(req)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
+
+ verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
+ verify(mex).setVariable("cloudOwner", "CloudOwner")
+ verify(mex).setVariable("cloudRegionId", "CloudRegion1")
+ verify(mex).setVariable("lcpCloudRegionId", "CloudRegion1")
+ verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
+ }
+
+ @Test
+ public void prepareVnfAndModulesCreate_EmptyList() {
+ ExecutionEntity mex = setupMock()
+ initPrepareVnfAndModulesCreate(mex)
+
+ when(mex.getVariable("vnfList")).thenReturn(new LinkedList<VnfResource>())
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
+
+ verify(mex).getVariable("createVcpeServiceRequest")
+
+ verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
+ verify(mex).setVariable("lcpCloudRegionId", "mdt1")
+ verify(mex).setVariable("cloudOwner", "CloudOwner")
+ verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
+ }
+
+ @Test
+ public void prepareVnfAndModulesCreate_NullList() {
+ ExecutionEntity mex = setupMock()
+ initPrepareVnfAndModulesCreate(mex)
+
+ when(mex.getVariable("vnfList")).thenReturn(null)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
+
+ verify(mex).getVariable("createVcpeServiceRequest")
+
+ verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
+ verify(mex).setVariable("lcpCloudRegionId", "mdt1")
+ verify(mex).setVariable("cloudOwner", "CloudOwner")
+ verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
+ }
+
+ @Test
+ public void prepareVnfAndModulesCreate_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPrepareVnfAndModulesCreate(mex)
+
+ when(mex.getVariable("vnfList")).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) }))
+ }
+
+ // ***** validateVnfCreate *****
+
+ @Test
+ public void validateVnfCreate() {
+ ExecutionEntity mex = setupMock()
+ initValidateVnfCreate(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.validateVnfCreate(mex)
+
+ verify(mex).getVariable(Prefix + "VnfsCreatedCount")
+
+ verify(mex).setVariable(Prefix + "VnfsCreatedCount", 3)
+ }
+
+ @Test
+ public void validateVnfCreate_Ex() {
+ ExecutionEntity mex = setupMock()
+ initValidateVnfCreate(mex)
+
+ when(mex.getVariable(Prefix + "VnfsCreatedCount")).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.validateVnfCreate(mex) }))
+ }
+
+ // ***** postProcessResponse *****
+
+ @Test
+ public void postProcessResponse() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPostProcessResponse(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.postProcessResponse(mex)
+
+ verify(mex).getVariable("source")
+ verify(mex).getVariable("mso-request-id")
+ verify(mex).getVariable("serviceInstanceId")
+
+ verify(mex).setVariable(Prefix + "Success", true)
+
+ def reqinfo = map.get(Prefix + "CompleteMsoProcessRequest")
+
+ assertTrue(reqinfo.indexOf("request-id>mri</") >= 0)
+ assertTrue(reqinfo.indexOf("source>mysrc</") >= 0)
+ assertTrue(reqinfo.indexOf("serviceInstanceId>sii</") >= 0)
+ }
+
+ @Test
+ public void postProcessResponse_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ setupMap(mex)
+ initPostProcessResponse(mex)
+
+ when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.postProcessResponse(mex) }))
+ }
+
+ @Test
+ public void postProcessResponse_Ex() {
+ ExecutionEntity mex = setupMock()
+ setupMap(mex)
+ initPostProcessResponse(mex)
+
+ when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.postProcessResponse(mex) }))
+ }
+
+ // ***** preProcessRollback *****
+
+ @Test
+ public void preProcessRollback() {
+ ExecutionEntity mex = setupMock()
+ def wfe = initPreProcessRollback(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.preProcessRollback(mex)
+
+ verify(mex).getVariable("WorkflowException")
+
+ verify(mex).setVariable("prevWorkflowException", wfe)
+ }
+
+ @Test
+ public void preProcessRollback_NullWfe() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessRollback(mex)
+
+ when(mex.getVariable("WorkflowException")).thenReturn(null)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.preProcessRollback(mex)
+
+ verify(mex).getVariable("WorkflowException")
+
+ assertFalse(map.containsKey("prevWorkflowException"))
+ }
+
+ @Test
+ public void preProcessRollback_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessRollback(mex)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.preProcessRollback(mex)
+
+ verify(mex).getVariable("WorkflowException")
+
+ assertFalse(map.containsKey("prevWorkflowException"))
+ }
+
+ @Test
+ public void preProcessRollback_Ex() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessRollback(mex)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.preProcessRollback(mex)
+
+ verify(mex).getVariable("WorkflowException")
+
+ assertFalse(map.containsKey("prevWorkflowException"))
+ }
+
+ // ***** postProcessRollback *****
+
+ @Test
+ public void postProcessRollback() {
+ ExecutionEntity mex = setupMock()
+ def wfe = initPostProcessRollback(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.postProcessRollback(mex)
+
+ verify(mex).getVariable("prevWorkflowException")
+
+ verify(mex).setVariable("WorkflowException", wfe)
+ }
+
+ @Test
+ public void postProcessRollback_NullWfe() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPostProcessRollback(mex)
+
+ when(mex.getVariable("prevWorkflowException")).thenReturn(null)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.postProcessRollback(mex)
+
+ verify(mex).getVariable("prevWorkflowException")
+
+ assertFalse(map.containsKey("WorkflowException"))
+ }
+
+ @Test
+ public void postProcessRollback_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ setupMap(mex)
+ initPostProcessRollback(mex)
+
+ when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.postProcessRollback(mex) }))
+ }
+
+
+ @Test
+ public void postProcessRollback_Ex() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPostProcessRollback(mex)
+
+ when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.postProcessRollback(mex)
+
+ verify(mex).getVariable("prevWorkflowException")
+
+ assertFalse(map.containsKey("WorkflowException"))
+ }
+
+ // ***** prepareFalloutRequest *****
+
+ @Test
+ public void prepareFalloutRequest() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ WorkflowException wfe = initPrepareFalloutRequest(mex)
+ when(wfe.getErrorMessage()).thenReturn("mymsg")
+ when(wfe.getErrorCode()).thenReturn(999)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareFalloutRequest(mex)
+
+ verify(mex, times(4)).getVariable("WorkflowException")
+
+ def fo = map.get(Prefix + "falloutRequest")
+
+ assertTrue(fo.indexOf("<hello>world</") >= 0)
+ assertTrue(fo.indexOf("ErrorMessage>mymsg</") >= 0)
+ assertTrue(fo.indexOf("ErrorCode>999</") >= 0)
+ }
+
+ @Test
+ public void prepareFalloutRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ setupMap(mex)
+ initPrepareFalloutRequest(mex)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.prepareFalloutRequest(mex) }))
+ }
+
+ // ***** sendSyncError *****
+
+ @Test
+ public void sendSyncError() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initSendSyncError(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.sendSyncError(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+
+ verify(mex).setVariable(processName + "WorkflowResponseSent", "true")
+
+ assertEquals("500", map.get(processName + "ResponseCode"))
+ assertEquals("Fail", map.get(processName + "Status"))
+
+ def resp = map.get(processName + "Response")
+
+ assertTrue(resp.indexOf("ErrorMessage>mymsg</") >= 0)
+
+ verify(mex).setVariable("WorkflowResponse", resp)
+ }
+
+ @Test
+ public void sendSyncError_NotWfe() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initSendSyncError(mex)
+
+ when(mex.getVariable("WorkflowException")).thenReturn("not a WFE")
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.sendSyncError(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+
+ verify(mex).setVariable(processName + "WorkflowResponseSent", "true")
+
+ assertEquals("500", map.get(processName + "ResponseCode"))
+ assertEquals("Fail", map.get(processName + "Status"))
+
+ def resp = map.get(processName + "Response")
+
+ assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.</") >= 0)
+
+ verify(mex).setVariable("WorkflowResponse", resp)
+ }
+
+ @Test
+ public void sendSyncError_NullWfe() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initSendSyncError(mex)
+
+ when(mex.getVariable("WorkflowException")).thenReturn(null)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.sendSyncError(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+
+ verify(mex).setVariable(processName + "WorkflowResponseSent", "true")
+
+ assertEquals("500", map.get(processName + "ResponseCode"))
+ assertEquals("Fail", map.get(processName + "Status"))
+
+ def resp = map.get(processName + "Response")
+
+ assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.</") >= 0)
+
+ verify(mex).setVariable("WorkflowResponse", resp)
+ }
+
+ @Test
+ public void sendSyncError_Ex() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initSendSyncError(mex)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ CreateVcpeResCustService.sendSyncError(mex)
+
+ assertFalse(map.containsKey(processName + "ResponseCode"))
+ }
+
+ // ***** processJavaException *****
+
+ @Test
+ public void processJavaException() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initProcessJavaException(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.processJavaException(mex) }))
+
+ verify(mex).getVariable("testProcessKey")
+
+ verify(mex).setVariable("prefix", Prefix)
+
+ def wfe = map.get("WorkflowException")
+
+ assertEquals("Caught a Java Lang Exception", wfe.getErrorMessage())
+ }
+
+ @Test
+ public void processJavaException_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initProcessJavaException(mex)
+
+ when(mex.getVariables()).thenThrow(new BpmnError("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.processJavaException(mex) }))
+
+ assertFalse(map.containsKey("WorkflowException"))
+ }
+
+ @Test
+ public void processJavaException_Ex() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initProcessJavaException(mex)
+
+ when(mex.getVariables()).thenThrow(new RuntimeException("expected exception"))
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> CreateVcpeResCustService.processJavaException(mex) }))
+
+ def wfe = map.get("WorkflowException")
+
+ assertEquals("Exception in processJavaException method", wfe.getErrorMessage())
+ }
+
+
+ private void initPreProcess(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("bpmnRequest")).thenReturn(request)
+ when(mex.getVariable("aai.workflowAaiDistributionDelay")).thenReturn("PT5S")
+ when(mex.getVariable("mso-request-id")).thenReturn("mri")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("requestAction")).thenReturn("ra")
+ }
+
+ private initSendSyncResponse(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("mso-request-id")).thenReturn("mri")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ }
+
+ private void initPrepareDecomposeService(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("createVcpeServiceRequest")).thenReturn('{"requestDetails":{"modelInfo":"mi"}}')
+ }
+
+ private ServiceDecomposition initPrepareCreateServiceInstance(ExecutionEntity mex) {
+ ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
+ when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
+
+ return svcdecomp
+ }
+
+ private void initPostProcessServiceInstanceCreate(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("mso-request-id")).thenReturn("mri")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
+ }
+
+ private ServiceDecomposition initProcessDecomposition(ExecutionEntity mex) {
+ List<VnfResource> vnflst = new LinkedList<>()
+ vnflst.add(makeVnf("", ""))
+ vnflst.add(makeVnf("2", "BRG"))
+ vnflst.add(makeVnf("3", "BRG"))
+
+ ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
+ when(svcdecomp.getVnfResources()).thenReturn(vnflst)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
+
+ return svcdecomp
+ }
+
+ private ServiceDecomposition initFilterVnfs(ExecutionEntity mex) {
+ List<VnfResource> vnflst = new LinkedList<>()
+ vnflst.add(makeVnf("", "BRG"))
+ vnflst.add(makeVnf("2", "Tunnel XConn"))
+ vnflst.add(makeVnf("3", ""))
+ vnflst.add(makeVnf("4", "BRG"))
+ vnflst.add(makeVnf("5", "other"))
+
+ ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
+ when(svcdecomp.getVnfResources()).thenReturn(vnflst)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
+
+ return svcdecomp
+ }
+
+ private ServiceDecomposition initPrepareCreateAllottedResourceTXC(ExecutionEntity mex) {
+ ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
+ List<AllottedResource> arlst = new LinkedList<>()
+
+ arlst.add(makeArBRG("A"))
+ arlst.add(makeArTXC("B"))
+ arlst.add(makeArBRG("C"))
+
+ when(svcdecomp.getAllottedResources()).thenReturn(arlst)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
+ when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
+ when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
+
+ return svcdecomp
+ }
+
+ private ServiceDecomposition initPrepareCreateAllottedResourceBRG(ExecutionEntity mex) {
+ ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
+ List<AllottedResource> arlst = new LinkedList<>()
+
+ arlst.add(makeArTXC("A"))
+ arlst.add(makeArBRG("B"))
+ arlst.add(makeArTXC("C"))
+
+ when(svcdecomp.getAllottedResources()).thenReturn(arlst)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
+ when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
+ when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
+
+ return svcdecomp
+ }
+
+ private AllottedResource makeArTXC(String id) {
+ AllottedResource ar = mock(AllottedResource.class)
+ ModelInfo mod = mock(ModelInfo.class)
+ HomingSolution home = mock(HomingSolution.class)
+
+ when(ar.toJsonStringNoRootName()).thenReturn("json" + id)
+ when(ar.getAllottedResourceType()).thenReturn("Tunnel XConn")
+ when(ar.getModelInfo()).thenReturn(mod)
+ when(ar.getAllottedResourceRole()).thenReturn("TXCr")
+ when(ar.getHomingSolution()).thenReturn(home)
+
+ when(mod.toJsonStringNoRootName()).thenReturn("model" + id)
+
+ when(home.getServiceInstanceId()).thenReturn("home" + id)
+
+ return ar
+ }
+
+ private AllottedResource makeArBRG(String id) {
+ AllottedResource ar = mock(AllottedResource.class)
+ ModelInfo mod = mock(ModelInfo.class)
+ HomingSolution home = mock(HomingSolution.class)
+
+ when(ar.toJsonStringNoRootName()).thenReturn("json" + id)
+ when(ar.getAllottedResourceType()).thenReturn("BRG")
+ when(ar.getModelInfo()).thenReturn(mod)
+ when(ar.getAllottedResourceRole()).thenReturn("BRGr")
+ when(ar.getHomingSolution()).thenReturn(home)
+
+ when(mod.toJsonStringNoRootName()).thenReturn("model" + id)
+
+ when(home.getServiceInstanceId()).thenReturn("home" + id)
+
+ return ar
+ }
+
+ private initPrepareVnfAndModulesCreate(ExecutionEntity mex) {
+
+ List<VnfResource> vnflst = new LinkedList<>()
+
+ vnflst.add(makeVnf("A", "BRG"))
+ vnflst.add(makeVnf("B", ""))
+ vnflst.add(makeVnf("C", ""))
+ vnflst.add(makeVnf("D", "Tunnel XConn"))
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
+ when(mex.getVariable("vnfList")).thenReturn(vnflst)
+ when(mex.getVariable(Prefix + "VnfsCreatedCount")).thenReturn(2)
+ when(mex.getVariable("vnfModelInfo")).thenReturn("nomodel")
+ when(mex.getVariable("sdncVersion")).thenReturn("myvers")
+ }
+
+ private VnfResource makeVnf(String id, String role) {
+ ModelInfo mod = mock(ModelInfo.class)
+ VnfResource vnf = mock(VnfResource.class)
+
+ when(mod.toString()).thenReturn('{"modelInfo":"mymodel' + id + '"}')
+
+ when(vnf.toString()).thenReturn("myvnf" + id)
+ when(vnf.getModelInfo()).thenReturn(mod)
+ when(vnf.getNfRole()).thenReturn(role)
+
+ return vnf
+ }
+
+ private initValidateVnfCreate(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable(Prefix + "VnfsCreatedCount")).thenReturn(2)
+ }
+
+ private initPostProcessResponse(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("source")).thenReturn("mysrc")
+ when(mex.getVariable("mso-request-id")).thenReturn("mri")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ }
+
+ private WorkflowException initPreProcessRollback(ExecutionEntity mex) {
+ WorkflowException wfe = mock(WorkflowException.class)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("WorkflowException")).thenReturn(wfe)
+
+ return wfe
+ }
+
+ private WorkflowException initPostProcessRollback(ExecutionEntity mex) {
+ WorkflowException wfe = mock(WorkflowException.class)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prevWorkflowException")).thenReturn(wfe)
+
+ return wfe
+ }
+
+ private initPrepareFalloutRequest(ExecutionEntity mex) {
+ WorkflowException wfe = mock(WorkflowException.class)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("WorkflowException")).thenReturn(wfe)
+ when(mex.getVariable(Prefix + "requestInfo")).thenReturn("<hello>world</hello>")
+
+ return wfe
+ }
+
+ private initSendSyncError(ExecutionEntity mex) {
+ WorkflowException wfe = mock(WorkflowException.class)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("mso-request-id")).thenReturn("mri")
+ when(mex.getVariable("WorkflowException")).thenReturn(wfe)
+
+ when(wfe.getErrorMessage()).thenReturn("mymsg")
+ }
+
+ private initProcessJavaException(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy
index c2384b63a5..be8f2a2d2e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -19,756 +21,543 @@
*/
package org.onap.so.bpmn.vcpe.scripts
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Rule
import org.junit.Test
-import org.junit.Ignore
import org.mockito.MockitoAnnotations
-import org.camunda.bpm.engine.delegate.BpmnError
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
-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.patch
-import static com.github.tomakehurst.wiremock.client.WireMock.put
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
-import static org.junit.Assert.*;
+import static org.junit.Assert.*
import static org.mockito.Mockito.*
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
-import org.onap.so.bpmn.core.domain.ServiceDecomposition
-import org.onap.so.bpmn.core.domain.VnfResource
-import org.onap.so.bpmn.core.domain.AllottedResource
-import org.onap.so.bpmn.core.domain.ModelInfo
-import org.onap.so.bpmn.core.RollbackData
-import org.onap.so.bpmn.vcpe.scripts.MapGetter
-import org.onap.so.bpmn.vcpe.scripts.MapSetter
+class DeleteVcpeResCustServiceTest extends GroovyTestBase {
-import com.github.tomakehurst.wiremock.junit.WireMockRule
+ private static String request
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(PORT)
+
+ String Prefix = "DVRCS_"
+
+ @BeforeClass
+ public static void setUpBeforeClass() {
+ request = FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/request.json")
+ }
-class DeleteVcpeResCustServiceTest extends GroovyTestBase {
-
- private static String request
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(PORT)
-
- String Prefix = "DVRCS_"
- String RbType = "DCRENI_"
-
- @BeforeClass
- public static void setUpBeforeClass() {
- request = FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/request.json")
- }
-
@Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
- }
-
- public DeleteVcpeResCustServiceTest() {
- super("DeleteVcpeResCustService")
- }
-
-
- // ***** preProcessRequest *****
-
- @Test
-// @Ignore
- public void preProcessRequest() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcess(mex)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.preProcessRequest(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- assertEquals(Prefix, map.get("prefix"))
- assertEquals(request, map.get("DeleteVcpeResCustServiceRequest"))
- assertEquals("mri", map.get("msoRequestId"))
- assertEquals("ra", map.get("requestAction"))
- assertEquals("VID", map.get("source"))
- assertEquals(CUST, map.get("globalSubscriberId"))
- assertEquals(CUST, map.get("globalCustomerId"))
- assertEquals("false", map.get("disableRollback"))
- assertEquals("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", map.get("productFamilyId"))
- assertEquals(SVC, map.get("subscriptionServiceType"))
-
- assertEquals("mdt1", map.get("lcpCloudRegionId"))
- assertEquals("8b1df54faa3b49078e3416e21370a3ba", map.get("tenantId"))
- assertEquals("1707", map.get("sdncVersion"))
- assertEquals("service-instance", map.get("GENGS_type"))
- assertEquals("""{"tenantId":"8b1df54faa3b49078e3416e21370a3ba","lcpCloudRegionId":"mdt1"}""", map.get("cloudConfiguration"))
- assertTrue(map.containsKey(Prefix+"requestInfo"))
-
- def reqinfo = map.get(Prefix+"requestInfo")
- assertTrue(reqinfo.indexOf("<request-id>mri</") >= 0)
- assertTrue(reqinfo.indexOf("<source>VID</") >= 0)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_EmptyParts() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcess(mex)
-
- def req = request
- .replace('"source"', '"sourceXXX"')
-
- when(mex.getVariable("bpmnRequest")).thenReturn(req)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.preProcessRequest(mex)
-
- verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("DeleteVcpeResCustServiceRequest", req)
- verify(mex).setVariable("msoRequestId", "mri")
- verify(mex).setVariable("requestAction", "ra")
- verify(mex).setVariable("source", "VID")
- verify(mex).setVariable("globalSubscriberId", CUST)
- verify(mex).setVariable("globalCustomerId", CUST)
- verify(mex).setVariable("disableRollback", "false")
- verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
- verify(mex).setVariable("subscriptionServiceType", SVC)
-
- verify(mex).setVariable("lcpCloudRegionId", "mdt1")
- verify(mex).setVariable("cloudOwner", "my-cloud-owner")
- verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
- assertEquals("""{"tenantId":"8b1df54faa3b49078e3416e21370a3ba","lcpCloudRegionId":"mdt1"}""", map.get("cloudConfiguration"))
- verify(mex).setVariable("sdncVersion", "1707")
- verify(mex).setVariable("GENGS_type", "service-instance")
- assertTrue(map.containsKey(Prefix+"requestInfo"))
-
- def reqinfo = map.get(Prefix+"requestInfo")
- println reqinfo
- assertTrue(reqinfo.indexOf("<request-id>mri</") >= 0)
- assertTrue(reqinfo.indexOf("<source>VID</") >= 0)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_MissingServiceInstanceId() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("serviceInstanceId")).thenReturn(null)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.preProcessRequest(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("bpmnRequest")).thenThrow(new BpmnError("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.preProcessRequest(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("bpmnRequest")).thenThrow(new RuntimeException("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.preProcessRequest(mex) }))
- }
-
- private void initPreProcess(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("bpmnRequest")).thenReturn(request)
- when(mex.getVariable("mso-request-id")).thenReturn("mri")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("requestAction")).thenReturn("ra")
- }
-
- // ***** sendSyncResponse *****
-
- @Test
-// @Ignore
- public void sendSyncResponse() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initSendSyncResponse(mex)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.sendSyncResponse(mex)
-
- verify(mex, times(2)).getVariable(DBGFLAG)
-
- verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
-
- assertEquals("202", map.get(processName+"ResponseCode"))
- assertEquals("Success", map.get(processName+"Status"))
-
- def resp = map.get(processName+"Response")
-
- assertTrue(resp.indexOf('"instanceId":"sii"') >= 0)
- assertTrue(resp.indexOf('"requestId":"mri"') >= 0)
- }
-
- @Test
-// @Ignore
- public void sendSyncResponse_Ex() {
- ExecutionEntity mex = setupMock()
- initSendSyncResponse(mex)
-
- when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.sendSyncResponse(mex) }))
- }
-
- private initSendSyncResponse(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("mso-request-id")).thenReturn("mri")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- }
-
- // ***** prepareServiceDelete *****
-
- @Test
-// @Ignore
- public void prepareServiceDelete() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPrepareServiceDelete(mex)
-
- myMockGetAr("/aai/v11/anytxc", 200, "arGetTXCById.xml");
- myMockGetAr("/aai/v11/anybrg", 200, "arGetBRGById.xml");
- myMockGetAr("/aai/v11/other", 200, "arGetOtherById.xml");
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.prepareServiceDelete(mex)
-
- verify(mex).setVariable(Prefix+"TunnelXConn", true)
- assertEquals("ar-txcA", map.get("TXC_allottedResourceId"))
-
- verify(mex).setVariable(Prefix+"BRG", true)
- assertEquals("ar-brgB", map.get("BRG_allottedResourceId"))
-
- verify(mex).setVariable(Prefix+"vnfsCount", 2)
- assertNotNull(map.get(Prefix+"relatedVnfIdList"))
- assertEquals("[vnfX, vnfY]", map.get(Prefix+"relatedVnfIdList").toString())
-
- verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true")
- }
-
- @Test
-// @Ignore
- public void prepareServiceDelete_NotFound() {
- ExecutionEntity mex = setupMock()
- initPrepareServiceDelete(mex)
-
- when(mex.getVariable("GENGS_FoundIndicator")).thenReturn(false)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareServiceDelete(mex) }))
-
- verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true")
- }
-
- @Test
-// @Ignore
- public void prepareServiceDelete_Empty() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPrepareServiceDelete(mex)
-
- when(mex.getVariable("GENGS_service")).thenReturn("<empty></empty>")
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.prepareServiceDelete(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable(Prefix+"TunnelXConn", false)
- assertNull(map.get("TXC_allottedResourceId"))
-
- verify(mex).setVariable(Prefix+"BRG", false)
- assertNull(map.get("BRG_allottedResourceId"))
-
- assertEquals(0, map.get(Prefix+"vnfsCount"))
- assertFalse(map.containsKey(Prefix+"relatedVnfIdList"))
-
- verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true")
- }
-
- @Test
-// @Ignore
- public void prepareServiceDelete_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPrepareServiceDelete(mex)
-
- when(mex.getVariable("GENGS_FoundIndicator")).thenThrow(new BpmnError("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareServiceDelete(mex) }))
-
- verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true")
- }
-
- @Test
-// @Ignore
- public void prepareServiceDelete_Ex() {
- ExecutionEntity mex = setupMock()
- initPrepareServiceDelete(mex)
-
- when(mex.getVariable("GENGS_FoundIndicator")).thenThrow(new RuntimeException("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareServiceDelete(mex) }))
-
- verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
- }
-
- private initPrepareServiceDelete(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("GENGS_FoundIndicator")).thenReturn(true)
- when(mex.getVariable("mso-request-id")).thenReturn("mri")
- when(mex.getVariable("DeleteVcpeResCustServiceRequest")).thenReturn(request)
- when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx)
- when(mex.getVariable("GENGS_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/serviceToDelete.xml"))
- }
-
- // ***** getAaiAr *****
-
- @Test
-// @Ignore
- public void getAaiAr() {
- myMockGetAr("/myurl/ar1", 200, "arGetBRGById.xml");
-
- ExecutionEntity mex = setupMock()
- initGetAaiAr(mex)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- def (type, id) = DeleteVcpeResCustService.getAaiAr(mex, "/myurl/ar1")
-
- assertEquals("BRG", type)
- assertEquals("ar-brgB", id)
- }
-
- @Test
-// @Ignore
- public void getAaiAr_401() {
- myMockGetAr("/myurl/ar1", 401, "arGetBRGById.xml");
-
- ExecutionEntity mex = setupMock()
- initGetAaiAr(mex)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- def (type, id) = DeleteVcpeResCustService.getAaiAr(mex, "/myurl/ar1")
-
- assertEquals(null, type)
- assertEquals(null, id)
- }
-
- @Test
-// @Ignore
- public void getAaiAr_EmptyResponse() {
- myMockGetAr("/myurl/ar1", 200, "empty.txt");
-
- ExecutionEntity mex = setupMock()
- initGetAaiAr(mex)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- def (type, id) = DeleteVcpeResCustService.getAaiAr(mex, "/myurl/ar1")
-
- assertEquals(null, type)
- assertEquals(null, id)
- }
-
- private void initGetAaiAr(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx)
- }
-
- // ***** prepareVnfAndModulesDelete *****
-
- @Test
-// @Ignore
- public void prepareVnfAndModulesDelete() {
- ExecutionEntity mex = setupMock()
- initPrepareVnfAndModulesDelete(mex)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable("vnfId", "vnfB")
- }
-
- @Test
-// @Ignore
- public void prepareVnfAndModulesDelete_Empty() {
- ExecutionEntity mex = setupMock()
- initPrepareVnfAndModulesDelete(mex)
-
- when(mex.getVariable(Prefix+"relatedVnfIdList")).thenReturn(new LinkedList())
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable("vnfId", "")
- }
-
- @Test
-// @Ignore
- public void prepareVnfAndModulesDelete_Ex() {
- ExecutionEntity mex = setupMock()
- initPrepareVnfAndModulesDelete(mex)
-
- when(mex.getVariable(Prefix+"relatedVnfIdList")).thenThrow(new RuntimeException("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex) }))
- }
-
- private initPrepareVnfAndModulesDelete(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable(Prefix+"relatedVnfIdList")).thenReturn(Arrays.asList("vnfA", "vnfB", "vnfC"))
- when(mex.getVariable(Prefix+"vnfsDeletedCount")).thenReturn(1)
- }
-
- // ***** validateVnfDelete *****
-
- @Test
-// @Ignore
- public void validateVnfDelete() {
- ExecutionEntity mex = setupMock()
- initValidateVnfDelete(mex)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.validateVnfDelete(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- verify(mex).setVariable(Prefix+"vnfsDeletedCount", 3)
- }
-
- @Test
-// @Ignore
- public void validateVnfDelete_Ex() {
- ExecutionEntity mex = setupMock()
- initValidateVnfDelete(mex)
-
- when(mex.getVariable(Prefix+"vnfsDeletedCount")).thenThrow(new RuntimeException("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.validateVnfDelete(mex) }))
- }
-
- private initValidateVnfDelete(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable(Prefix+"vnfsDeletedCount")).thenReturn(2)
- }
-
- // ***** postProcessResponse *****
-
- @Test
-// @Ignore
- public void postProcessResponse() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPostProcessResponse(mex)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.postProcessResponse(mex)
-
- verify(mex).getVariable(DBGFLAG)
-
- assertEquals(true, map.get(Prefix+"Success"))
-
- def req = map.get(Prefix+"CompleteMsoProcessRequest")
-
- assertTrue(req.indexOf("<request-id>mri</") >= 0)
- assertTrue(req.indexOf("<source>mysrc</") >= 0)
- }
-
- @Test
-// @Ignore
- public void postProcessResponse_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPostProcessResponse(mex)
-
- when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.postProcessResponse(mex) }))
- }
-
- @Test
-// @Ignore
- public void postProcessResponse_Ex() {
- ExecutionEntity mex = setupMock()
- initPostProcessResponse(mex)
-
- when(mex.getVariable("source")).thenThrow(new RuntimeException("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.postProcessResponse(mex) }))
- }
-
- private initPostProcessResponse(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("source")).thenReturn("mysrc")
- when(mex.getVariable("msoRequestId")).thenReturn("mri")
- }
-
-
- // ***** prepareFalloutRequest *****
-
- @Test
-// @Ignore
- public void prepareFalloutRequest() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPrepareFalloutRequest(mex)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.prepareFalloutRequest(mex)
-
- verify(mex, times(2)).getVariable(DBGFLAG)
-
- def fo = map.get(Prefix+"falloutRequest")
-
- assertTrue(fo.indexOf("<hello>world</") >= 0)
- assertTrue(fo.indexOf("ErrorMessage>mymsg</") >= 0)
- assertTrue(fo.indexOf("ErrorCode>999</") >= 0)
- }
-
- @Test
-// @Ignore
- public void prepareFalloutRequest_Ex() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPrepareFalloutRequest(mex)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.prepareFalloutRequest(mex) }))
- }
-
- private initPrepareFalloutRequest(ExecutionEntity mex) {
- WorkflowException wfe = mock(WorkflowException.class)
-
- when(wfe.getErrorMessage()).thenReturn("mymsg")
- when(wfe.getErrorCode()).thenReturn(999)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("WorkflowException")).thenReturn(wfe)
- when(mex.getVariable(Prefix+"requestInfo")).thenReturn("<hello>world</hello>")
-
- return wfe
- }
-
- // ***** sendSyncError *****
-
- @Test
-// @Ignore
- public void sendSyncError() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initSendSyncError(mex)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.sendSyncError(mex)
-
- verify(mex, times(2)).getVariable(DBGFLAG)
-
- verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
-
- assertEquals("500", map.get(processName+"ResponseCode"))
- assertEquals("Fail", map.get(processName+"Status"))
-
- def resp = map.get(processName+"Response")
-
- assertTrue(resp.indexOf("ErrorMessage>mymsg</") >= 0)
-
- verify(mex).setVariable("WorkflowResponse", resp)
- }
-
- @Test
-// @Ignore
- public void sendSyncError_NotWfe() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initSendSyncError(mex)
-
- when(mex.getVariable("WorkflowException")).thenReturn("not a WFE")
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.sendSyncError(mex)
-
- verify(mex, times(2)).getVariable(DBGFLAG)
-
- verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
-
- assertEquals("500", map.get(processName+"ResponseCode"))
- assertEquals("Fail", map.get(processName+"Status"))
-
- def resp = map.get(processName+"Response")
-
- assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.</") >= 0)
-
- verify(mex).setVariable("WorkflowResponse", resp)
- }
-
- @Test
-// @Ignore
- public void sendSyncError_NullWfe() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initSendSyncError(mex)
-
- when(mex.getVariable("WorkflowException")).thenReturn(null)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.sendSyncError(mex)
-
- verify(mex, times(2)).getVariable(DBGFLAG)
-
- verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
-
- assertEquals("500", map.get(processName+"ResponseCode"))
- assertEquals("Fail", map.get(processName+"Status"))
-
- def resp = map.get(processName+"Response")
-
- assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.</") >= 0)
-
- verify(mex).setVariable("WorkflowResponse", resp)
- }
-
- @Test
-// @Ignore
- public void sendSyncError_Ex() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initSendSyncError(mex)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- DeleteVcpeResCustService.sendSyncError(mex)
-
- assertFalse(map.containsKey(processName+"ResponseCode"))
- }
-
- private initSendSyncError(ExecutionEntity mex) {
- WorkflowException wfe = mock(WorkflowException.class)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("mso-request-id")).thenReturn("mri")
- when(mex.getVariable("WorkflowException")).thenReturn(wfe)
-
- when(wfe.getErrorMessage()).thenReturn("mymsg")
- }
-
-
- // ***** processJavaException *****
-
- @Test
-// @Ignore
- public void processJavaException() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initProcessJavaException(mex)
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.processJavaException(mex) }))
-
- verify(mex, times(2)).getVariable(DBGFLAG)
-
- verify(mex).setVariable("prefix", Prefix)
-
- def wfe = map.get("WorkflowException")
-
- assertEquals("Caught a Java Lang Exception", wfe.getErrorMessage())
- }
-
- @Test
-// @Ignore
- public void processJavaException_BpmnError() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initProcessJavaException(mex)
-
- when(mex.getVariables()).thenThrow(new BpmnError("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.processJavaException(mex) }))
-
- assertFalse(map.containsKey("WorkflowException"))
- }
-
- @Test
-// @Ignore
- public void processJavaException_Ex() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initProcessJavaException(mex)
-
- when(mex.getVariables()).thenThrow(new RuntimeException("expected exception"))
-
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
-
- assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.processJavaException(mex) }))
-
- def wfe = map.get("WorkflowException")
-
- assertEquals("Exception in processJavaException method", wfe.getErrorMessage())
- }
-
- private initProcessJavaException(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- }
-
- private void myMockGetAr(String url, int status, String fileResp) {
- stubFor(get(urlMatching(url))
- .willReturn(aResponse()
- .withStatus(status)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VCPE/DeleteVcpeResCustService/" + fileResp)));
- }
-}
+ public void init() {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ public DeleteVcpeResCustServiceTest() {
+ super("DeleteVcpeResCustService")
+ }
+
+ // ***** preProcessRequest *****
+
+ @Test
+ public void preProcessRequest() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcess(mex)
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+ DeleteVcpeResCustService.preProcessRequest(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+
+ assertEquals(Prefix, map.get("prefix"))
+ assertEquals(request, map.get("DeleteVcpeResCustServiceRequest"))
+ assertEquals("mri", map.get("msoRequestId"))
+ assertEquals("ra", map.get("requestAction"))
+ assertEquals("VID", map.get("source"))
+ assertEquals(CUST, map.get("globalSubscriberId"))
+ assertEquals(CUST, map.get("globalCustomerId"))
+ assertEquals("false", map.get("disableRollback"))
+ assertEquals("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", map.get("productFamilyId"))
+ assertEquals(SVC, map.get("subscriptionServiceType"))
+
+ assertEquals("mdt1", map.get("lcpCloudRegionId"))
+ assertEquals("8b1df54faa3b49078e3416e21370a3ba", map.get("tenantId"))
+ assertEquals("1707", map.get("sdncVersion"))
+ assertEquals(
+ """{"cloudOwner":"CloudOwner","tenantId":"8b1df54faa3b49078e3416e21370a3ba","lcpCloudRegionId":"mdt1"}""",
+ map.get("cloudConfiguration")
+ )
+ assertTrue(map.containsKey(Prefix + "requestInfo"))
+
+ def reqinfo = map.get(Prefix + "requestInfo")
+ assertTrue(reqinfo.indexOf("<request-id>mri</") >= 0)
+ assertTrue(reqinfo.indexOf("<source>VID</") >= 0)
+ }
+
+ @Test
+ public void preProcessRequest_EmptyParts() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcess(mex)
+
+ def req = request
+ .replace('"source"', '"sourceXXX"')
+
+ when(mex.getVariable("bpmnRequest")).thenReturn(req)
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+ DeleteVcpeResCustService.preProcessRequest(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("DeleteVcpeResCustServiceRequest", req)
+ verify(mex).setVariable("msoRequestId", "mri")
+ verify(mex).setVariable("requestAction", "ra")
+ verify(mex).setVariable("source", "VID")
+ verify(mex).setVariable("globalSubscriberId", CUST)
+ verify(mex).setVariable("globalCustomerId", CUST)
+ verify(mex).setVariable("disableRollback", "false")
+ verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
+ verify(mex).setVariable("subscriptionServiceType", SVC)
+
+ verify(mex).setVariable("lcpCloudRegionId", "mdt1")
+ verify(mex).setVariable("cloudOwner", "CloudOwner")
+ verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
+ assertEquals(
+ """{"cloudOwner":"CloudOwner","tenantId":"8b1df54faa3b49078e3416e21370a3ba","lcpCloudRegionId":"mdt1"}""",
+ map.get("cloudConfiguration")
+ )
+ verify(mex).setVariable("sdncVersion", "1707")
+ assertTrue(map.containsKey(Prefix + "requestInfo"))
+
+ def reqinfo = map.get(Prefix + "requestInfo")
+ println reqinfo
+ assertTrue(reqinfo.indexOf("<request-id>mri</") >= 0)
+ assertTrue(reqinfo.indexOf("<source>VID</") >= 0)
+ }
+
+ @Test
+ public void preProcessRequest_MissingServiceInstanceId() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("serviceInstanceId")).thenReturn(null)
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.preProcessRequest(mex) }))
+ }
+
+ @Test
+ public void preProcessRequest_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("bpmnRequest")).thenThrow(new BpmnError("expected exception"))
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.preProcessRequest(mex) }))
+ }
+
+ @Test
+ public void preProcessRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("bpmnRequest")).thenThrow(new RuntimeException("expected exception"))
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.preProcessRequest(mex) }))
+ }
+
+ private void initPreProcess(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("bpmnRequest")).thenReturn(request)
+ when(mex.getVariable("mso-request-id")).thenReturn("mri")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("requestAction")).thenReturn("ra")
+ }
+
+ // ***** sendSyncResponse *****
+
+ @Test
+ public void sendSyncResponse() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initSendSyncResponse(mex)
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+ DeleteVcpeResCustService.sendSyncResponse(mex)
+
+ verify(mex, times(2)).getVariable(DBGFLAG)
+
+ verify(mex).setVariable(processName + "WorkflowResponseSent", "true")
+
+ assertEquals("202", map.get(processName + "ResponseCode"))
+ assertEquals("Success", map.get(processName + "Status"))
+
+ def resp = map.get(processName + "Response")
+
+ assertTrue(resp.indexOf('"instanceId":"sii"') >= 0)
+ assertTrue(resp.indexOf('"requestId":"mri"') >= 0)
+ }
+
+ @Test
+ public void sendSyncResponse_Ex() {
+ ExecutionEntity mex = setupMock()
+ initSendSyncResponse(mex)
+
+ when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.sendSyncResponse(mex) }))
+ }
+
+ private initSendSyncResponse(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("mso-request-id")).thenReturn("mri")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ }
+
+ // ***** prepareVnfAndModulesDelete *****
+
+ @Test
+ public void prepareVnfAndModulesDelete() {
+ ExecutionEntity mex = setupMock()
+ initPrepareVnfAndModulesDelete(mex)
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+ DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+
+ verify(mex).setVariable("vnfId", "vnfB")
+ }
+
+ @Test
+ public void prepareVnfAndModulesDelete_Empty() {
+ ExecutionEntity mex = setupMock()
+ initPrepareVnfAndModulesDelete(mex)
+
+ when(mex.getVariable(Prefix + "relatedVnfIdList")).thenReturn(new LinkedList())
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+ DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+
+ verify(mex).setVariable("vnfId", "")
+ }
+
+ @Test
+ public void prepareVnfAndModulesDelete_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPrepareVnfAndModulesDelete(mex)
+
+ when(mex.getVariable(Prefix + "relatedVnfIdList")).thenThrow(new RuntimeException("expected exception"))
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex) }))
+ }
+
+ private initPrepareVnfAndModulesDelete(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable(Prefix + "relatedVnfIdList")).thenReturn(Arrays.asList("vnfA", "vnfB", "vnfC"))
+ when(mex.getVariable(Prefix + "vnfsDeletedCount")).thenReturn(1)
+ }
+
+ // ***** validateVnfDelete *****
+
+ @Test
+ public void validateVnfDelete() {
+ ExecutionEntity mex = setupMock()
+ initValidateVnfDelete(mex)
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+ DeleteVcpeResCustService.validateVnfDelete(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+
+ verify(mex).setVariable(Prefix + "vnfsDeletedCount", 3)
+ }
+
+ @Test
+ public void validateVnfDelete_Ex() {
+ ExecutionEntity mex = setupMock()
+ initValidateVnfDelete(mex)
+
+ when(mex.getVariable(Prefix + "vnfsDeletedCount")).thenThrow(new RuntimeException("expected exception"))
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.validateVnfDelete(mex) }))
+ }
+
+ private initValidateVnfDelete(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable(Prefix + "vnfsDeletedCount")).thenReturn(2)
+ }
+
+ // ***** postProcessResponse *****
+
+ @Test
+ public void postProcessResponse() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPostProcessResponse(mex)
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+ DeleteVcpeResCustService.postProcessResponse(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+
+ verify(mex).setVariable(Prefix + "Success", true)
+
+ def req = map.get(Prefix + "CompleteMsoProcessRequest")
+
+ assertTrue(req.indexOf("<request-id>mri</") >= 0)
+ assertTrue(req.indexOf("<source>mysrc</") >= 0)
+ }
+
+ @Test
+ public void postProcessResponse_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPostProcessResponse(mex)
+
+ when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception"))
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.postProcessResponse(mex) }))
+ }
+
+ @Test
+ public void postProcessResponse_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPostProcessResponse(mex)
+
+ when(mex.getVariable("source")).thenThrow(new RuntimeException("expected exception"))
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.postProcessResponse(mex) }))
+ }
+
+ private initPostProcessResponse(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("source")).thenReturn("mysrc")
+ when(mex.getVariable("msoRequestId")).thenReturn("mri")
+ }
+
+ // ***** prepareFalloutRequest *****
+
+ @Test
+ public void prepareFalloutRequest() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ WorkflowException wfe = initPrepareFalloutRequest(mex)
+ when(wfe.getErrorMessage()).thenReturn("mymsg")
+ when(wfe.getErrorCode()).thenReturn(999)
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+ DeleteVcpeResCustService.prepareFalloutRequest(mex)
+
+ verify(mex).getVariable(DBGFLAG)
+ verify(mex, times(4)).getVariable("WorkflowException")
+ verify(mex).getVariable(Prefix + "requestInfo")
+
+ def fo = map.get(Prefix + "falloutRequest")
+
+ assertTrue(fo.indexOf("<hello>world</") >= 0)
+ assertTrue(fo.indexOf("ErrorMessage>mymsg</") >= 0)
+ assertTrue(fo.indexOf("ErrorCode>999</") >= 0)
+ }
+
+ @Test
+ public void prepareFalloutRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ setupMap(mex)
+ initPrepareFalloutRequest(mex)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareFalloutRequest(mex) }))
+ }
+
+ private initPrepareFalloutRequest(ExecutionEntity mex) {
+ WorkflowException wfe = mock(WorkflowException.class)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("WorkflowException")).thenReturn(wfe)
+ when(mex.getVariable(Prefix + "requestInfo")).thenReturn("<hello>world</hello>")
+
+ return wfe
+ }
+
+ // ***** sendSyncError *****
+
+ @Test
+ public void sendSyncError() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initSendSyncError(mex)
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+ DeleteVcpeResCustService.sendSyncError(mex)
+
+ verify(mex, times(2)).getVariable(DBGFLAG)
+
+ verify(mex).setVariable(processName + "WorkflowResponseSent", "true")
+
+ assertEquals("500", map.get(processName + "ResponseCode"))
+ assertEquals("Fail", map.get(processName + "Status"))
+
+ def resp = map.get(processName + "Response")
+
+ assertTrue(resp.indexOf("ErrorMessage>mymsg</") >= 0)
+
+ verify(mex).setVariable("WorkflowResponse", resp)
+ }
+
+ @Test
+ public void sendSyncError_NotWfe() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initSendSyncError(mex)
+
+ when(mex.getVariable("WorkflowException")).thenReturn("not a WFE")
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+ DeleteVcpeResCustService.sendSyncError(mex)
+
+ verify(mex, times(2)).getVariable(DBGFLAG)
+ verify(mex, times(2)).getProcessEngineServices()
+ verify(mex, times(2)).getProcessDefinitionId()
+
+ verify(mex).setVariable(processName + "WorkflowResponseSent", "true")
+
+ assertEquals("500", map.get(processName + "ResponseCode"))
+ assertEquals("Fail", map.get(processName + "Status"))
+
+ def resp = map.get(processName + "Response")
+
+ assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.</") >= 0)
+
+ verify(mex).setVariable("WorkflowResponse", resp)
+ }
+
+ @Test
+ public void sendSyncError_NullWfe() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initSendSyncError(mex)
+
+ when(mex.getVariable("WorkflowException")).thenReturn(null)
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+ DeleteVcpeResCustService.sendSyncError(mex)
+
+ verify(mex, times(2)).getVariable(DBGFLAG)
+
+ verify(mex).setVariable(processName + "WorkflowResponseSent", "true")
+
+ assertEquals("500", map.get(processName + "ResponseCode"))
+ assertEquals("Fail", map.get(processName + "Status"))
+
+ def resp = map.get(processName + "Response")
+
+ assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.</") >= 0)
+
+ verify(mex).setVariable("WorkflowResponse", resp)
+ }
+
+ @Test
+ public void sendSyncError_Ex() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initSendSyncError(mex)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ DeleteVcpeResCustService.sendSyncError(mex)
+
+ assertFalse(map.containsKey(processName + "ResponseCode"))
+ }
+
+ private initSendSyncError(ExecutionEntity mex) {
+ WorkflowException wfe = mock(WorkflowException.class)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("mso-request-id")).thenReturn("mri")
+ when(mex.getVariable("WorkflowException")).thenReturn(wfe)
+
+ when(wfe.getErrorMessage()).thenReturn("mymsg")
+ }
+
+ // ***** processJavaException *****
+
+ @Test
+ public void processJavaException() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initProcessJavaException(mex)
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.processJavaException(mex) }))
+
+ verify(mex).getVariable(DBGFLAG)
+
+ verify(mex).setVariable("prefix", Prefix)
+
+ def wfe = map.get("WorkflowException")
+
+ assertEquals("Caught a Java Lang Exception", wfe.getErrorMessage())
+ }
+
+ @Test
+ public void processJavaException_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initProcessJavaException(mex)
+
+ when(mex.getVariables()).thenThrow(new BpmnError("expected exception"))
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.processJavaException(mex) }))
+
+ assertFalse(map.containsKey("WorkflowException"))
+ }
+
+ @Test
+ public void processJavaException_Ex() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initProcessJavaException(mex)
+
+ when(mex.getVariables()).thenThrow(new RuntimeException("expected exception"))
+
+ DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
+
+ assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.processJavaException(mex) }))
+
+ def wfe = map.get("WorkflowException")
+
+ assertEquals("Exception in processJavaException method", wfe.getErrorMessage())
+ }
+
+ private initProcessJavaException(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy
index 7982e4dd4b..41a862e00e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -20,635 +22,577 @@
package org.onap.so.bpmn.vcpe.scripts
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.junit.Before
-import org.junit.BeforeClass
-import org.junit.Rule
-import org.junit.Test
-import org.junit.Ignore
+import org.junit.*
import org.mockito.MockitoAnnotations
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.bpmn.core.RollbackData
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.stubFor
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue
import static org.mockito.Mockito.*
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource
+import static org.onap.so.bpmn.mock.StubResponseAAI.*
-import org.onap.so.bpmn.core.RollbackData
+class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase {
-import com.github.tomakehurst.wiremock.junit.WireMockRule
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(PORT)
+
+ String Prefix = "DCARBRGRB_"
+ String RbType = "DCARBRG_"
+
+ @BeforeClass
+ public static void setUpBeforeClass() {
+ GroovyTestBase.setUpBeforeClass()
+ }
-class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase {
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(PORT)
-
- String Prefix = "DCARBRGRB_"
- String RbType = "DCARBRG_"
-
- @BeforeClass
- public static void setUpBeforeClass() {
- super.setUpBeforeClass()
- }
-
@Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
- }
-
- public DoCreateAllottedResourceBRGRollbackTest() {
- super("DoCreateAllottedResourceBRGRollback")
- }
-
-
- // ***** preProcessRequest *****
-
- @Test
-// @Ignore
- public void preProcessRequest() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
-
- ////verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("serviceInstanceId", "sii")
- verify(mex).setVariable("parentServiceInstanceId", "psii")
- verify(mex).setVariable("allottedResourceId", "myid")
- verify(mex).setVariable("rollbackAAI", true)
- verify(mex).setVariable("aaiARPath", "mypath")
- verify(mex).setVariable("rollbackSDNC", true)
- verify(mex).setVariable("deactivateSdnc", "myactivate")
- verify(mex).setVariable("deleteSdnc", "mycreate")
- verify(mex).setVariable("unassignSdnc", "true")
- verify(mex).setVariable("sdncDeactivateRequest", "activatereq")
- verify(mex).setVariable("sdncDeleteRequest", "createreq")
- verify(mex).setVariable("sdncUnassignRequest", "assignreq")
-
- verify(mex, never()).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_RollbackDisabled() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("disableRollback")).thenReturn("true")
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
-
- ////verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("serviceInstanceId", "sii")
- verify(mex).setVariable("parentServiceInstanceId", "psii")
- verify(mex).setVariable("allottedResourceId", "myid")
- verify(mex).setVariable("rollbackAAI", true)
- verify(mex).setVariable("aaiARPath", "mypath")
- verify(mex).setVariable("rollbackSDNC", true)
- verify(mex).setVariable("deactivateSdnc", "myactivate")
- verify(mex).setVariable("deleteSdnc", "mycreate")
- verify(mex).setVariable("unassignSdnc", "true")
- verify(mex).setVariable("sdncDeactivateRequest", "activatereq")
- verify(mex).setVariable("sdncDeleteRequest", "createreq")
- verify(mex).setVariable("sdncUnassignRequest", "assignreq")
-
- verify(mex).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_NoAAI() {
- ExecutionEntity mex = setupMock()
- def data = initPreProcess(mex)
-
- when(mex.getVariable("rollbackAAI")).thenReturn(false)
- data.put(RbType, "rollbackAAI", "false")
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("serviceInstanceId", "sii")
- verify(mex).setVariable("parentServiceInstanceId", "psii")
- verify(mex).setVariable("allottedResourceId", "myid")
- verify(mex, never()).setVariable("rollbackAAI", true)
- verify(mex, never()).setVariable("aaiARPath", "mypath")
- verify(mex).setVariable("rollbackSDNC", true)
- verify(mex).setVariable("deactivateSdnc", "myactivate")
- verify(mex).setVariable("deleteSdnc", "mycreate")
- verify(mex).setVariable("unassignSdnc", "true")
- verify(mex).setVariable("sdncDeactivateRequest", "activatereq")
- verify(mex).setVariable("sdncDeleteRequest", "createreq")
- verify(mex).setVariable("sdncUnassignRequest", "assignreq")
-
- verify(mex, never()).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_NoAssign() {
- ExecutionEntity mex = setupMock()
- def data = initPreProcess(mex)
-
- when(mex.getVariable("rollbackSDNC")).thenReturn(false)
- data.put(RbType, "rollbackSDNCassign", "false")
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("serviceInstanceId", "sii")
- verify(mex).setVariable("parentServiceInstanceId", "psii")
- verify(mex).setVariable("allottedResourceId", "myid")
- verify(mex).setVariable("rollbackAAI", true)
- verify(mex).setVariable("aaiARPath", "mypath")
- verify(mex, never()).setVariable("rollbackSDNC", true)
- verify(mex, never()).setVariable("deactivateSdnc", "myactivate")
- verify(mex, never()).setVariable("deleteSdnc", "mycreate")
- verify(mex, never()).setVariable("unassignSdnc", "true")
- verify(mex, never()).setVariable("sdncDeactivateRequest", "activatereq")
- verify(mex, never()).setVariable("sdncDeleteRequest", "createreq")
- verify(mex, never()).setVariable("sdncUnassignRequest", "assignreq")
-
- verify(mex, never()).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_NoAAI_NoAssign() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("rollbackAAI")).thenReturn(false)
- when(mex.getVariable("rollbackSDNC")).thenReturn(false)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
-
- verify(mex).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_NoRbStructure() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("rollbackData")).thenReturn(new RollbackData())
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
-
- verify(mex).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_NullRb() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("rollbackData")).thenReturn(null)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
-
- verify(mex).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) }))
- }
-
- @Test
- @Ignore
- public void updateAaiAROrchStatus() {
- ExecutionEntity mex = setupMock()
- initUpdateAaiAROrchStatus(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success")
- }
-
- @Test
-// @Ignore
- public void updateAaiAROrchStatus_EmptyResponse() {
- ExecutionEntity mex = setupMock()
- initUpdateAaiAROrchStatus(mex)
-
- wireMockRule
- .stubFor(get(urlMatching("/aai/v[0-9]+/.*"))
- .willReturn(aResponse()
- .withStatus(200)))
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") }))
- }
-
- @Test
-// @Ignore
- public void updateAaiAROrchStatus_NoArPath() {
- ExecutionEntity mex = setupMock()
- initUpdateAaiAROrchStatus(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
-
- when(mex.getVariable("aaiARPath")).thenReturn(null)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") }))
- }
-
-
- // ***** validateSDNCResp *****
-
- @Test
-// @Ignore
- public void validateSDNCResp() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
-
- DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create")
-
- verify(mex).getVariable("WorkflowException")
- verify(mex).getVariable("SDNCA_SuccessIndicator")
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Unsuccessful() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_BpmnError404() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("404", "expected exception"))
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
-
- DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create")
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_BpmnError() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Ex() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
- @Ignore
- public void deleteAaiAR() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex)
- }
-
- @Test
-// @Ignore
- public void deleteAaiAR_NoArPath() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- when(mex.getVariable("aaiARPath")).thenReturn("")
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) }))
- }
-
- @Test
-// @Ignore
- public void deleteAaiAR_BpmnError() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) }))
- }
-
- @Test
-// @Ignore
- public void deleteAaiAR_Ex() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) }))
- }
-
- @Test
-// @Ignore
- public void postProcessRequest() {
- ExecutionEntity mex = setupMock()
- initPostProcessRequest(mex)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.postProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("rollbackData", null)
- verify(mex).setVariable("rolledBack", true)
- }
-
- @Test
-// @Ignore
- public void postProcessRequest_RolledBack() {
- ExecutionEntity mex = setupMock()
- initPostProcessRequest(mex)
-
- when(mex.getVariable("skipRollback")).thenReturn(true)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.postProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("rollbackData", null)
- verify(mex, never()).setVariable("rolledBack", true)
- }
-
- @Test
-// @Ignore
- public void postProcessRequest_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPostProcessRequest(mex)
-
- when(mex.getVariable("skipRollback")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.postProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("rollbackData", null)
- verify(mex, never()).setVariable("rolledBack", true)
- }
-
- @Test
-// @Ignore
- public void postProcessRequest_Ex() {
- ExecutionEntity mex = setupMock()
- initPostProcessRequest(mex)
-
- when(mex.getVariable("skipRollback")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.postProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("rollbackData", null)
- verify(mex, never()).setVariable("rolledBack", true)
- }
-
- @Test
-// @Ignore
- public void processRollbackException() {
- ExecutionEntity mex = setupMock()
- initProcessRollbackException(mex)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.processRollbackException(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("rollbackData", null)
- verify(mex).setVariable("rolledBack", false)
- verify(mex).setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback")
- verify(mex).setVariable("WorkflowException", null)
- }
-
- @Test
-// @Ignore
- public void processRollbackException_BpmnError() {
- ExecutionEntity mex = setupMock()
- initProcessRollbackException(mex)
-
- doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.processRollbackException(mex)
- }
-
- @Test
-// @Ignore
- public void processRollbackException_Ex() {
- ExecutionEntity mex = setupMock()
- initProcessRollbackException(mex)
-
- doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.processRollbackException(mex)
- }
-
- @Test
-// @Ignore
- public void processRollbackJavaException() {
- ExecutionEntity mex = setupMock()
- initProcessRollbackException(mex)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("rollbackData", null)
- verify(mex).setVariable("rolledBack", false)
- verify(mex).setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback")
- verify(mex, never()).setVariable("WorkflowException", null)
- }
-
- @Test
-// @Ignore
- public void processRollbackJavaException_BpmnError() {
- ExecutionEntity mex = setupMock()
- initProcessRollbackException(mex)
-
- doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex)
- }
-
- @Test
-// @Ignore
- public void processRollbackJavaException_Ex() {
- ExecutionEntity mex = setupMock()
- initProcessRollbackException(mex)
-
- doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null)
-
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex)
- }
-
- private RollbackData initPreProcess(ExecutionEntity mex) {
- def data = new RollbackData()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("rollbackData")).thenReturn(data)
- when(mex.getVariable("rollbackAAI")).thenReturn(true)
- when(mex.getVariable("rollbackSDNC")).thenReturn(true)
- when(mex.getVariable("disableRollback")).thenReturn("false")
-
- data.put("SERVICEINSTANCE", "allottedResourceId", "myid")
-
- data.put(RbType, "serviceInstanceId", "sii")
- data.put(RbType, "parentServiceInstanceId", "psii")
-
- data.put(RbType, "rollbackAAI", "true")
- data.put(RbType, "aaiARPath", "mypath")
-
- data.put(RbType, "rollbackSDNCassign", "true")
- data.put(RbType, "rollbackSDNCactivate", "myactivate")
- data.put(RbType, "rollbackSDNCcreate", "mycreate")
- data.put(RbType, "sdncActivateRollbackReq", "activatereq")
- data.put(RbType, "sdncCreateRollbackReq", "createreq")
- data.put(RbType, "sdncAssignRollbackReq", "assignreq")
-
- return data
- }
-
- private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
- when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- }
-
- private initValidateSDNCResp(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prefix")).thenReturn(Prefix)
- when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
- }
-
- private String initValidateSDNCResp_Resp() {
- return "<response-data>&lt;response-code&gt;200&lt;/response-code&gt;</response-data>"
- }
-
- private initDeleteAaiAR(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARResourceVersion")).thenReturn(VERS)
- when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
- when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- }
-
- private initPostProcessRequest(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("skipRollback")).thenReturn(false)
- }
-
- private initProcessRollbackException(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- }
-
- private initProcessRollbackJavaException(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- }
-
+ public void init() {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ public DoCreateAllottedResourceBRGRollbackTest() {
+ super("DoCreateAllottedResourceBRGRollback")
+ }
+
+ // ***** preProcessRequest *****
+
+ @Test
+ public void preProcessRequest() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("serviceInstanceId", "sii")
+ verify(mex).setVariable("parentServiceInstanceId", "psii")
+ verify(mex).setVariable("allottedResourceId", "myid")
+ verify(mex).setVariable("rollbackAAI", true)
+ verify(mex).setVariable("aaiARPath", "mypath")
+ verify(mex).setVariable("rollbackSDNC", true)
+ verify(mex).setVariable("deactivateSdnc", "myactivate")
+ verify(mex).setVariable("deleteSdnc", "mycreate")
+ verify(mex).setVariable("unassignSdnc", "true")
+ verify(mex).setVariable("sdncDeactivateRequest", "activatereq")
+ verify(mex).setVariable("sdncDeleteRequest", "createreq")
+ verify(mex).setVariable("sdncUnassignRequest", "assignreq")
+
+ verify(mex, never()).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_RollbackDisabled() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("disableRollback")).thenReturn("true")
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("serviceInstanceId", "sii")
+ verify(mex).setVariable("parentServiceInstanceId", "psii")
+ verify(mex).setVariable("allottedResourceId", "myid")
+ verify(mex).setVariable("rollbackAAI", true)
+ verify(mex).setVariable("aaiARPath", "mypath")
+ verify(mex).setVariable("rollbackSDNC", true)
+ verify(mex).setVariable("deactivateSdnc", "myactivate")
+ verify(mex).setVariable("deleteSdnc", "mycreate")
+ verify(mex).setVariable("unassignSdnc", "true")
+ verify(mex).setVariable("sdncDeactivateRequest", "activatereq")
+ verify(mex).setVariable("sdncDeleteRequest", "createreq")
+ verify(mex).setVariable("sdncUnassignRequest", "assignreq")
+
+ verify(mex).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_NoAAI() {
+ ExecutionEntity mex = setupMock()
+ def data = initPreProcess(mex)
+
+ when(mex.getVariable("rollbackAAI")).thenReturn(false)
+ data.put(RbType, "rollbackAAI", "false")
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("serviceInstanceId", "sii")
+ verify(mex).setVariable("parentServiceInstanceId", "psii")
+ verify(mex).setVariable("allottedResourceId", "myid")
+ verify(mex, never()).setVariable("rollbackAAI", true)
+ verify(mex, never()).setVariable("aaiARPath", "mypath")
+ verify(mex).setVariable("rollbackSDNC", true)
+ verify(mex).setVariable("deactivateSdnc", "myactivate")
+ verify(mex).setVariable("deleteSdnc", "mycreate")
+ verify(mex).setVariable("unassignSdnc", "true")
+ verify(mex).setVariable("sdncDeactivateRequest", "activatereq")
+ verify(mex).setVariable("sdncDeleteRequest", "createreq")
+ verify(mex).setVariable("sdncUnassignRequest", "assignreq")
+
+ verify(mex, never()).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_NoAssign() {
+ ExecutionEntity mex = setupMock()
+ def data = initPreProcess(mex)
+
+ when(mex.getVariable("rollbackSDNC")).thenReturn(false)
+ data.put(RbType, "rollbackSDNCassign", "false")
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("serviceInstanceId", "sii")
+ verify(mex).setVariable("parentServiceInstanceId", "psii")
+ verify(mex).setVariable("allottedResourceId", "myid")
+ verify(mex).setVariable("rollbackAAI", true)
+ verify(mex).setVariable("aaiARPath", "mypath")
+ verify(mex, never()).setVariable("rollbackSDNC", true)
+ verify(mex, never()).setVariable("deactivateSdnc", "myactivate")
+ verify(mex, never()).setVariable("deleteSdnc", "mycreate")
+ verify(mex, never()).setVariable("unassignSdnc", "true")
+ verify(mex, never()).setVariable("sdncDeactivateRequest", "activatereq")
+ verify(mex, never()).setVariable("sdncDeleteRequest", "createreq")
+ verify(mex, never()).setVariable("sdncUnassignRequest", "assignreq")
+
+ verify(mex, never()).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_NoAAI_NoAssign() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("rollbackAAI")).thenReturn(false)
+ when(mex.getVariable("rollbackSDNC")).thenReturn(false)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_NoRbStructure() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("rollbackData")).thenReturn(new RollbackData())
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_NullRb() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("rollbackData")).thenReturn(null)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) }))
+ }
+
+ @Test
+ public void preProcessRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) }))
+ }
+
+ @Test
+ @Ignore
+ public void updateAaiAROrchStatus() {
+ ExecutionEntity mex = setupMock()
+ initUpdateAaiAROrchStatus(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
+ MockPatchAllottedResource(CUST, SVC, INST, ARID)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success")
+ }
+
+ @Test
+ public void updateAaiAROrchStatus_EmptyResponse() {
+ ExecutionEntity mex = setupMock()
+ initUpdateAaiAROrchStatus(mex)
+
+ wireMockRule
+ .stubFor(get(urlMatching("/aai/v[0-9]+/.*"))
+ .willReturn(aResponse()
+ .withStatus(200)))
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") }))
+ }
+
+ @Test
+ public void updateAaiAROrchStatus_NoArPath() {
+ ExecutionEntity mex = setupMock()
+ initUpdateAaiAROrchStatus(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
+ MockPatchAllottedResource(CUST, SVC, INST, ARID)
+
+ when(mex.getVariable("aaiARPath")).thenReturn(null)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") }))
+ }
+
+ // ***** validateSDNCResp *****
+
+ @Test
+ public void validateSDNCResp() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+
+ DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create")
+
+ verify(mex).getVariable("WorkflowException")
+ verify(mex).getVariable("SDNCA_SuccessIndicator")
+ }
+
+ @Test
+ public void validateSDNCResp_Unsuccessful() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(false)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ public void validateSDNCResp_BpmnError404() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("404", "expected exception"))
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+
+ DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create")
+ }
+
+ @Test
+ public void validateSDNCResp_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ public void validateSDNCResp_Ex() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ @Ignore
+ public void deleteAaiAR() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex)
+ }
+
+ @Test
+ public void deleteAaiAR_NoArPath() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ when(mex.getVariable("aaiARPath")).thenReturn("")
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) }))
+ }
+
+ @Test
+ public void deleteAaiAR_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) }))
+ }
+
+ @Test
+ public void deleteAaiAR_Ex() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) }))
+ }
+
+ @Test
+ public void postProcessRequest() {
+ ExecutionEntity mex = setupMock()
+ initPostProcessRequest(mex)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.postProcessRequest(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+ verify(mex).setVariable("rolledBack", true)
+ }
+
+ @Test
+ public void postProcessRequest_RolledBack() {
+ ExecutionEntity mex = setupMock()
+ initPostProcessRequest(mex)
+
+ when(mex.getVariable("skipRollback")).thenReturn(true)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.postProcessRequest(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+ verify(mex, never()).setVariable("rolledBack", true)
+ }
+
+ @Test
+ public void postProcessRequest_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPostProcessRequest(mex)
+
+ when(mex.getVariable("skipRollback")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.postProcessRequest(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+ verify(mex, never()).setVariable("rolledBack", true)
+ }
+
+ @Test
+ public void postProcessRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPostProcessRequest(mex)
+
+ when(mex.getVariable("skipRollback")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.postProcessRequest(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+ verify(mex, never()).setVariable("rolledBack", true)
+ }
+
+ @Test
+ public void processRollbackException() {
+ ExecutionEntity mex = setupMock()
+ initProcessRollbackException(mex)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.processRollbackException(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+ verify(mex).setVariable("rolledBack", false)
+ verify(mex).setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback")
+ verify(mex).setVariable("WorkflowException", null)
+ }
+
+ @Test
+ public void processRollbackException_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initProcessRollbackException(mex)
+
+ doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.processRollbackException(mex)
+ }
+
+ @Test
+ public void processRollbackException_Ex() {
+ ExecutionEntity mex = setupMock()
+ initProcessRollbackException(mex)
+
+ doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.processRollbackException(mex)
+ }
+
+ @Test
+ public void processRollbackJavaException() {
+ ExecutionEntity mex = setupMock()
+ initProcessRollbackException(mex)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+ verify(mex).setVariable("rolledBack", false)
+ verify(mex).setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback")
+ verify(mex, never()).setVariable("WorkflowException", null)
+ }
+
+ @Test
+ public void processRollbackJavaException_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initProcessRollbackException(mex)
+
+ doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex)
+ }
+
+ @Test
+ public void processRollbackJavaException_Ex() {
+ ExecutionEntity mex = setupMock()
+ initProcessRollbackException(mex)
+
+ doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null)
+
+ DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
+ DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex)
+ }
+
+ private RollbackData initPreProcess(ExecutionEntity mex) {
+ def data = new RollbackData()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("rollbackData")).thenReturn(data)
+ when(mex.getVariable("rollbackAAI")).thenReturn(true)
+ when(mex.getVariable("rollbackSDNC")).thenReturn(true)
+ when(mex.getVariable("disableRollback")).thenReturn("false")
+
+ data.put("SERVICEINSTANCE", "allottedResourceId", "myid")
+
+ data.put(RbType, "serviceInstanceId", "sii")
+ data.put(RbType, "parentServiceInstanceId", "psii")
+
+ data.put(RbType, "rollbackAAI", "true")
+ data.put(RbType, "aaiARPath", "mypath")
+
+ data.put(RbType, "rollbackSDNCassign", "true")
+ data.put(RbType, "rollbackSDNCactivate", "myactivate")
+ data.put(RbType, "rollbackSDNCcreate", "mycreate")
+ data.put(RbType, "sdncActivateRollbackReq", "activatereq")
+ data.put(RbType, "sdncCreateRollbackReq", "createreq")
+ data.put(RbType, "sdncAssignRollbackReq", "assignreq")
+
+ return data
+ }
+
+ private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/" + ARID)
+ when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
+ }
+
+ private initValidateSDNCResp(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prefix")).thenReturn(Prefix)
+ when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
+ }
+
+ private String initValidateSDNCResp_Resp() {
+ return "<response-data>&lt;response-code&gt;200&lt;/response-code&gt;</response-data>"
+ }
+
+ private initDeleteAaiAR(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("aaiARResourceVersion")).thenReturn(VERS)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/" + ARID)
+ when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
+ }
+
+ private initPostProcessRequest(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("skipRollback")).thenReturn(false)
+ }
+
+ private initProcessRollbackException(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ }
+
+ private initProcessRollbackJavaException(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy
index f5e48a02e4..f094ef25fa 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -20,15 +22,12 @@
package org.onap.so.bpmn.vcpe.scripts
-
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.junit.Before
-import org.junit.BeforeClass
-import org.junit.Rule
-import org.junit.Test
-import org.junit.Ignore
+import org.junit.*
import org.mockito.MockitoAnnotations
-import org.camunda.bpm.engine.delegate.BpmnError
+import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
@@ -41,945 +40,882 @@ import javax.ws.rs.core.UriBuilder
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
import static com.github.tomakehurst.wiremock.client.WireMock.put
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
-import static org.junit.Assert.*;
+import static org.junit.Assert.*
import static org.mockito.Mockito.*
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
-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.StubResponseAAI.MockPutAllottedResource_500
+import static org.onap.so.bpmn.mock.StubResponseAAI.*
-import org.onap.so.bpmn.core.RollbackData
+class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
-import com.github.tomakehurst.wiremock.junit.WireMockRule
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(PORT)
-class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(PORT)
+ String Prefix = "DCARBRG_"
- String Prefix = "DCARBRG_"
+ @BeforeClass
+ public static void setUpBeforeClass() {
+ aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint")
+ }
- @BeforeClass
- public static void setUpBeforeClass() {
- aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint")
- }
-
@Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
- }
-
- public DoCreateAllottedResourceBRGTest() {
- super("DoCreateAllottedResourceBRG")
- }
-
-
- // ***** preProcessRequest *****
-
- @Test
-// @Ignore
- public void preProcessRequest() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.preProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
-
- assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback"))
- assertTrue(checkMissingPreProcessRequest("mso.workflow.sdnc.replication.delay"))
- assertTrue(checkMissingPreProcessRequest("serviceInstanceId"))
- assertTrue(checkMissingPreProcessRequest("parentServiceInstanceId"))
- assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo"))
- assertTrue(checkMissingPreProcessRequest("vni"))
- assertTrue(checkMissingPreProcessRequest("vgmuxBearerIP"))
- assertTrue(checkMissingPreProcessRequest("brgWanMacAddress"))
- assertTrue(checkMissingPreProcessRequest("allottedResourceRole"))
- assertTrue(checkMissingPreProcessRequest("allottedResourceType"))
- }
-
-
- // ***** getAaiAR *****
-
- @Test
- @Ignore
- public void getAaiAR() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
-
- ExecutionEntity mex = setupMock()
- initGetAaiAR(mex)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.getAaiAR(mex)
-
- verify(mex).setVariable("foundActiveAR", true)
- }
-
- @Test
-// @Ignore
- public void getAaiAR_Duplicate() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
-
- ExecutionEntity mex = setupMock()
- initGetAaiAR(mex)
-
- // fail if duplicate
- when(mex.getVariable("failExists")).thenReturn("true")
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) }))
- }
-
- @Test
-// @Ignore
- public void getAaiAR_NotActive() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
-
- ExecutionEntity mex = setupMock()
- initGetAaiAR(mex)
-
- // not active
- when(mex.getVariable("aaiAROrchStatus")).thenReturn("not-active")
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) }))
- }
-
- @Test
- @Ignore
- public void getAaiAR_NoStatus() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
-
- ExecutionEntity mex = setupMock()
- initGetAaiAR(mex)
-
- when(mex.getVariable("aaiAROrchStatus")).thenReturn(null)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.getAaiAR(mex)
-
- verify(mex, never()).setVariable("foundActiveAR", true)
- }
-
-
- // ***** createAaiAR *****
-
- @Test
- public void createAaiAR() {
- ExecutionEntity mockExecution = setupMock()
- AAIResourcesClient client = mock(AAIResourcesClient.class)
- when(mockExecution.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE,UriBuilder.fromPath( "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST).build()))
- when(mockExecution.getVariable("CSI_resourceLink")).thenReturn("/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST)
- when(mockExecution.getVariable("allottedResourceModelInfo")).thenReturn("{\n" +
- " \"modelInvariantUuid\":\"modelInvariantUuid\",\n" +
- " \"modelUuid\" : \"modelUuid\"\n" +
- "}")
- DoCreateAllottedResourceBRG doCreateAllottedResourceBRG = spy(DoCreateAllottedResourceBRG.class)
- when(doCreateAllottedResourceBRG.getAAIClient()).thenReturn(client)
- doCreateAllottedResourceBRG.createAaiAR(mockExecution)
- }
-
- @Test
- @Ignore
- public void createAaiAR_NoArid_NoModelUuids() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initCreateAaiAr(mex)
-
- // no allottedResourceId - will be generated
-
- when(mex.getVariable("allottedResourceId")).thenReturn(null)
-
- wireMockRule
- .stubFor(put(urlMatching("/aai/.*/allotted-resource/.*"))
- .willReturn(aResponse()
- .withStatus(200)))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.createAaiAR(mex)
-
- def arid = map.get("allottedResourceId")
- assertNotNull(arid)
- assertFalse(arid.isEmpty())
-
- def data = map.get("rollbackData")
- assertNotNull(data)
- assertTrue(data instanceof RollbackData)
-
- assertEquals(arid, data.get(Prefix, "allottedResourceId"))
- }
-
- @Test
- public void createAaiAR_MissingPsiLink() {
- ExecutionEntity mex = setupMock()
- initCreateAaiAr(mex)
-
- when(mex.getVariable("PSI_resourceLink")).thenReturn(null)
-
- MockPutAllottedResource(CUST, SVC, INST, ARID)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) }))
- }
-
- @Test
- public void createAaiAR_HttpFailed() {
- ExecutionEntity mex = setupMock()
- initCreateAaiAr(mex)
-
- MockPutAllottedResource_500(CUST, SVC, INST, ARID)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) }))
- }
-
- @Test
- public void createAaiAR_BpmnError() {
- ExecutionEntity mex = setupMock()
- initCreateAaiAr(mex)
-
- when(mex.getVariable("aai.endpoint")).thenThrow(new BpmnError("expected exception"))
-
- MockPutAllottedResource(CUST, SVC, INST, ARID)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) }))
- }
-
- @Test
- public void createAaiAR_Ex() {
- ExecutionEntity mex = setupMock()
- initCreateAaiAr(mex)
-
- when(mex.getVariable("aai.endpoint")).thenThrow(new RuntimeException("expected exception"))
-
- MockPutAllottedResource(CUST, SVC, INST, ARID)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) }))
- }
-
-
- // ***** buildSDNCRequest *****
-
- @Test
-// @Ignore
- public void buildSDNCRequest() {
- ExecutionEntity mex = setupMock()
- initBuildSDNCRequest(mex)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq")
-
- assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
- assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
- assertTrue(result.indexOf("<service-instance-id>sii</") >= 0)
- assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
- assertTrue(result.indexOf("<subscription-service-type>sst</") >= 0)
- assertTrue(result.indexOf("<global-customer-id>gci</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
- assertTrue(result.indexOf("<request-id>mri</") >= 0)
- assertTrue(result.indexOf("<brg-wan-mac-address>bwma</") >= 0)
- assertTrue(result.indexOf("<vni>myvni</") >= 0)
- assertTrue(result.indexOf("<vgmux-bearer-ip>vbi</") >= 0)
- assertTrue(result.indexOf("<model-invariant-uuid>miu</") >= 0)
- assertTrue(result.indexOf("<model-uuid>mu</") >= 0)
- assertTrue(result.indexOf("<model-customization-uuid>mcu</") >= 0)
- assertTrue(result.indexOf("<model-version>mv</") >= 0)
- assertTrue(result.indexOf("<model-name>mn</") >= 0)
- }
-
- @Test
-// @Ignore
- public void buildSDNCRequest_EmptyModelInfo() {
- ExecutionEntity mex = setupMock()
- initBuildSDNCRequest(mex)
-
- when(mex.getVariable("allottedResourceModelInfo")).thenReturn("{}")
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq")
-
- assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
- assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
- assertTrue(result.indexOf("<service-instance-id>sii</") >= 0)
- assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
- assertTrue(result.indexOf("<subscription-service-type>sst</") >= 0)
- assertTrue(result.indexOf("<global-customer-id>gci</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
- assertTrue(result.indexOf("<request-id>mri</") >= 0)
- assertTrue(result.indexOf("<brg-wan-mac-address>bwma</") >= 0)
- assertTrue(result.indexOf("<vni>myvni</") >= 0)
- assertTrue(result.indexOf("<vgmux-bearer-ip>vbi</") >= 0)
- assertTrue(result.indexOf("<model-invariant-uuid/>") >= 0)
- assertTrue(result.indexOf("<model-uuid/>") >= 0)
- assertTrue(result.indexOf("<model-customization-uuid/>") >= 0)
- assertTrue(result.indexOf("<model-version/>") >= 0)
- assertTrue(result.indexOf("<model-name/>") >= 0)
- }
-
- @Test
-// @Ignore
- public void buildSDNCRequest_Ex() {
- ExecutionEntity mex = setupMock()
- initBuildSDNCRequest(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") }))
- }
-
-
- // ***** preProcessSDNCAssign *****
-
- @Test
-// @Ignore
- public void preProcessSDNCAssign() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def data = initPreProcessSDNC(mex)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex)
-
- def req = map.get("sdncAssignRequest")
- assertNotNull(req)
-
- assertEquals(data, map.get("rollbackData"))
-
- def rbreq = data.get(Prefix, "sdncAssignRollbackReq")
-
- assertTrue(req.indexOf("<sdncadapter:SvcAction>assign</") >= 0)
- assertTrue(req.indexOf("<request-action>CreateBRGInstance</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
-
- assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>unassign</") >= 0)
- assertTrue(rbreq.indexOf("<request-action>DeleteBRGInstance</") >= 0)
- assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCAssign_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCAssign_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) }))
- }
-
-
- // ***** preProcessSDNCCreate *****
-
- @Test
-// @Ignore
- public void preProcessSDNCCreate() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def data = initPreProcessSDNC(mex)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex)
-
- def req = map.get("sdncCreateRequest")
- assertNotNull(req)
-
- assertEquals(data, map.get("rollbackData"))
-
- def rbreq = data.get(Prefix, "sdncCreateRollbackReq")
-
- assertTrue(req.indexOf("<sdncadapter:SvcAction>create</") >= 0)
- assertTrue(req.indexOf("<request-action>CreateBRGInstance</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
-
- assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>delete</") >= 0)
- assertTrue(rbreq.indexOf("<request-action>DeleteBRGInstance</") >= 0)
- assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
-
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCCreate_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCCreate_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) }))
- }
-
-
- // ***** preProcessSDNCActivate *****
-
- @Test
-// @Ignore
- public void preProcessSDNCActivate() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def data = initPreProcessSDNC(mex)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex)
-
- def req = map.get("sdncActivateRequest")
- assertNotNull(req)
-
- assertEquals(data, map.get("rollbackData"))
-
- def rbreq = data.get(Prefix, "sdncActivateRollbackReq")
-
- assertTrue(req.indexOf("<sdncadapter:SvcAction>activate</") >= 0)
- assertTrue(req.indexOf("<request-action>CreateBRGInstance</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
-
- assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>deactivate</") >= 0)
- assertTrue(rbreq.indexOf("<request-action>DeleteBRGInstance</") >= 0)
- assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
-
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCActivate_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCActivate_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) }))
- }
-
-
- // ***** validateSDNCResp *****
-
- @Test
-// @Ignore
- public void validateSDNCResp() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def data = initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create")
-
- verify(mex).getVariable("WorkflowException")
- verify(mex).getVariable("SDNCA_SuccessIndicator")
- verify(mex).getVariable("rollbackData")
-
- assertEquals(data, map.get("rollbackData"))
-
- assertEquals("true", data.get(Prefix, "rollback" + "SDNCcreate"))
-
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Get() {
- ExecutionEntity mex = setupMock()
- def data = initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "get")
-
- verify(mex).getVariable("WorkflowException")
- verify(mex).getVariable("SDNCA_SuccessIndicator")
-
- verify(mex, never()).getVariable("rollbackData")
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Unsuccessful() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- // unsuccessful
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_BpmnError() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Ex() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
- }
-
-
- // ***** preProcessSDNCGet *****
-
- @Test
-// @Ignore
- public void preProcessSDNCGet_FoundAR() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcessSDNCGet(mex)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.preProcessSDNCGet(mex)
-
- String req = map.get("sdncGetRequest")
-
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
- assertTrue(req.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:SvcOperation>arlink</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:CallbackUrl>myurl</") >= 0)
-
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCGet_NotFoundAR() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcessSDNCGet(mex)
-
- when(mex.getVariable("foundActiveAR")).thenReturn(false)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.preProcessSDNCGet(mex)
-
- String req = map.get("sdncGetRequest")
-
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
- assertTrue(req.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:SvcOperation>assignlink</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:CallbackUrl>myurl</") >= 0)
-
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCGet_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNCGet(mex)
-
- when(mex.getVariable("foundActiveAR")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) }))
- }
-
-
- // ***** updateAaiAROrchStatus *****
-
- @Test
- @Ignore
- public void updateAaiAROrchStatus() {
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
-
- ExecutionEntity mex = setupMock()
- initUpdateAaiAROrchStatus(mex)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.updateAaiAROrchStatus(mex, "success")
- }
-
-
- // ***** generateOutputs *****
-
- @Test
-// @Ignore
- public void generateOutputs() {
- ExecutionEntity mex = setupMock()
- def brgtop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml")
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("enhancedCallbackRequestData")).thenReturn(brgtop)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.generateOutputs(mex)
-
- verify(mex).setVariable("allotedResourceName", "namefromrequest")
-
- }
-
- @Test
-// @Ignore
- public void generateOutputs_BadXml() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("enhancedCallbackRequestData")).thenReturn("invalid xml")
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.generateOutputs(mex)
-
- verify(mex, never()).setVariable(anyString(), anyString())
-
- }
-
- @Test
-// @Ignore
- public void generateOutputs_BpmnError() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- DoCreateAllottedResourceBRG.generateOutputs(mex)
- verify(mex, never()).setVariable(anyString(), anyString())
-
- }
-
- @Test
-// @Ignore
- public void generateOutputs_Ex() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- DoCreateAllottedResourceBRG.generateOutputs(mex)
- verify(mex, never()).setVariable(anyString(), anyString())
-
- }
-
-
- // ***** preProcessRollback *****
-
- @Test
-// @Ignore
- public void preProcessRollback() {
- ExecutionEntity mex = setupMock()
- WorkflowException wfe = mock(WorkflowException.class)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("WorkflowException")).thenReturn(wfe)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.preProcessRollback(mex)
-
- verify(mex).setVariable("prevWorkflowException", wfe)
-
- }
-
- @Test
-// @Ignore
- public void preProcessRollback_NotWFE() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("WorkflowException")).thenReturn("I'm not a WFE")
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.preProcessRollback(mex)
-
-// verify(mex, never()).setVariable("prevWorkflowException", any())
-
- }
-
- @Test
-// @Ignore
- public void preProcessRollback_BpmnError() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- DoCreateAllottedResourceBRG.preProcessRollback(mex)
-
- }
-
- @Test
-// @Ignore
- public void preProcessRollback_Ex() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- DoCreateAllottedResourceBRG.preProcessRollback(mex)
-
- }
-
-
- // ***** postProcessRollback *****
-
- @Test
-// @Ignore
- public void postProcessRollback() {
- ExecutionEntity mex = setupMock()
- WorkflowException wfe = mock(WorkflowException.class)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prevWorkflowException")).thenReturn(wfe)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.postProcessRollback(mex)
-
- verify(mex).setVariable("WorkflowException", wfe)
- verify(mex).setVariable("rollbackData", null)
-
- }
-
- @Test
-// @Ignore
- public void postProcessRollback_NotWFE() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prevWorkflowException")).thenReturn("I'm not a WFE")
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.postProcessRollback(mex)
-
-// verify(mex, never()).setVariable("WorkflowException", any())
- verify(mex).setVariable("rollbackData", null)
-
- }
-
- @Test
-// @Ignore
- public void postProcessRollback_BpmnError() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.postProcessRollback(mex) }))
- verify(mex, never()).setVariable("rollbackData", null)
-
- }
-
- @Test
-// @Ignore
- public void postProcessRollback_Ex() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- DoCreateAllottedResourceBRG.postProcessRollback(mex)
- verify(mex, never()).setVariable("rollbackData", null)
-
- }
-
- private boolean checkMissingPreProcessRequest(String fieldnm) {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
-
- when(mex.getVariable(fieldnm)).thenReturn("")
-
- return doBpmnError( { _ -> DoCreateAllottedResourceBRG.preProcessRequest(mex) })
- }
-
- private void initPreProcess(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn")
- when(mex.getVariable("mso.workflow.sdnc.replication.delay")).thenReturn("sdncdelay")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
- when(mex.getVariable("allottedResourceModelInfo")).thenReturn("armi")
- when(mex.getVariable("vni")).thenReturn("myvni")
- when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi")
- when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma")
- when(mex.getVariable("allottedResourceRole")).thenReturn("arr")
- when(mex.getVariable("allottedResourceType")).thenReturn("art")
- }
-
- private void initGetAaiAR(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("allottedResourceType")).thenReturn("BRGt")
- when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr")
- when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml"))
- when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
- }
-
- private initCreateAaiAr(ExecutionEntity mex) {
- when(mex.getVariable("disableRollback")).thenReturn(45)
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
- when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace"))
- when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath( "/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST).build()))
- when(mex.getVariable("allottedResourceType")).thenReturn("BRGt")
- when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr")
- when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mycsi")
- when(mex.getVariable("allottedResourceModelInfo")).thenReturn("""
- {
- "modelInvariantUuid":"modelinvuuid",
- "modelUuid":"modeluuid",
- "modelCustomizationUuid":"modelcustuuid"
- }
- """)
- }
-
- private initBuildSDNCRequest(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("allottedResourceId")).thenReturn("ari")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
- when(mex.getVariable("subscriptionServiceType")).thenReturn("sst")
- when(mex.getVariable("globalCustomerId")).thenReturn("gci")
- when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu")
- when(mex.getVariable("msoRequestId")).thenReturn("mri")
- when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma")
- when(mex.getVariable("vni")).thenReturn("myvni")
- when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi")
- when(mex.getVariable("allottedResourceModelInfo")).thenReturn("""
- {
- "modelInvariantUuid":"miu",
- "modelUuid":"mu",
- "modelCustomizationUuid":"mcu",
- "modelVersion":"mv",
- "modelName":"mn"
- }
- """)
- }
-
- private RollbackData initPreProcessSDNC(ExecutionEntity mex) {
- def data = new RollbackData()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("rollbackData")).thenReturn(data)
-
- return data
- }
-
- private initPreProcessSDNCGet(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl")
- when(mex.getVariable("foundActiveAR")).thenReturn(true)
- when(mex.getVariable("aaiARGetResponse")).thenReturn("<selflink>arlink</selflink>")
- when(mex.getVariable("sdncAssignResponse")).thenReturn("<response-data>&lt;object-path&gt;assignlink&lt;/object-path&gt;</response-data>")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl")
- }
-
- private RollbackData initValidateSDNCResp(ExecutionEntity mex) {
- def data = new RollbackData()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prefix")).thenReturn(Prefix)
- when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
- when(mex.getVariable("rollbackData")).thenReturn(data)
-
- return data
- }
-
- private String initValidateSDNCResp_Resp() {
- return "<response-data>&lt;response-code&gt;200&lt;/response-code&gt;</response-data>"
- }
-
- private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
- }
-
+ public void init() {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ public DoCreateAllottedResourceBRGTest() {
+ super("DoCreateAllottedResourceBRG")
+ }
+
+ // ***** preProcessRequest *****
+
+ @Test
+ public void preProcessRequest() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+
+ assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback"))
+ assertTrue(checkMissingPreProcessRequest("mso.workflow.sdnc.replication.delay"))
+ assertTrue(checkMissingPreProcessRequest("serviceInstanceId"))
+ assertTrue(checkMissingPreProcessRequest("parentServiceInstanceId"))
+ assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo"))
+ assertTrue(checkMissingPreProcessRequest("vni"))
+ assertTrue(checkMissingPreProcessRequest("vgmuxBearerIP"))
+ assertTrue(checkMissingPreProcessRequest("brgWanMacAddress"))
+ assertTrue(checkMissingPreProcessRequest("allottedResourceRole"))
+ assertTrue(checkMissingPreProcessRequest("allottedResourceType"))
+ }
+
+ // ***** getAaiAR *****
+
+ @Test
+ @Ignore
+ public void getAaiAR() {
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
+
+ ExecutionEntity mex = setupMock()
+ initGetAaiAR(mex)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.getAaiAR(mex)
+
+ verify(mex).setVariable("foundActiveAR", true)
+ }
+
+ @Test
+ public void getAaiAR_Duplicate() {
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
+
+ ExecutionEntity mex = setupMock()
+ initGetAaiAR(mex)
+
+ // fail if duplicate
+ when(mex.getVariable("failExists")).thenReturn("true")
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) }))
+ }
+
+ @Test
+ public void getAaiAR_NotActive() {
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
+
+ ExecutionEntity mex = setupMock()
+ initGetAaiAR(mex)
+
+ // not active
+ when(mex.getVariable("aaiAROrchStatus")).thenReturn("not-active")
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) }))
+ }
+
+ @Test
+ @Ignore
+ public void getAaiAR_NoStatus() {
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
+
+ ExecutionEntity mex = setupMock()
+ initGetAaiAR(mex)
+
+ when(mex.getVariable("aaiAROrchStatus")).thenReturn(null)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.getAaiAR(mex)
+
+ verify(mex, never()).setVariable("foundActiveAR", true)
+ }
+
+ // ***** createAaiAR *****
+
+ @Test
+ public void createAaiAR() {
+ ExecutionEntity mockExecution = setupMock()
+ AAIResourcesClient client = mock(AAIResourcesClient.class)
+ when(mockExecution.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath("/aai/v9/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST).build()))
+ when(mockExecution.getVariable("CSI_resourceLink")).thenReturn("/aai/v9/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST)
+ when(mockExecution.getVariable("allottedResourceModelInfo")).thenReturn("{\n" +
+ " \"modelInvariantUuid\":\"modelInvariantUuid\",\n" +
+ " \"modelUuid\" : \"modelUuid\"\n" +
+ "}")
+ DoCreateAllottedResourceBRG doCreateAllottedResourceBRG = spy(DoCreateAllottedResourceBRG.class)
+ when(doCreateAllottedResourceBRG.getAAIClient()).thenReturn(client)
+ doCreateAllottedResourceBRG.createAaiAR(mockExecution)
+ }
+
+ @Test
+ @Ignore
+ public void createAaiAR_NoArid_NoModelUuids() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initCreateAaiAr(mex)
+
+ // no allottedResourceId - will be generated
+
+ when(mex.getVariable("allottedResourceId")).thenReturn(null)
+
+ wireMockRule
+ .stubFor(put(urlMatching("/aai/.*/allotted-resource/.*"))
+ .willReturn(aResponse()
+ .withStatus(200)))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.createAaiAR(mex)
+
+ def arid = map.get("allottedResourceId")
+ assertNotNull(arid)
+ assertFalse(arid.isEmpty())
+
+ def data = map.get("rollbackData")
+ assertNotNull(data)
+ assertTrue(data instanceof RollbackData)
+
+ assertEquals(arid, data.get(Prefix, "allottedResourceId"))
+ }
+
+ @Test
+ public void createAaiAR_MissingPsiLink() {
+ ExecutionEntity mex = setupMock()
+ initCreateAaiAr(mex)
+
+ when(mex.getVariable("PSI_resourceLink")).thenReturn(null)
+
+ MockPutAllottedResource(CUST, SVC, INST, ARID)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) }))
+ }
+
+ @Test
+ public void createAaiAR_HttpFailed() {
+ ExecutionEntity mex = setupMock()
+ initCreateAaiAr(mex)
+
+ MockPutAllottedResource_500(CUST, SVC, INST, ARID)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) }))
+ }
+
+ @Test
+ public void createAaiAR_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initCreateAaiAr(mex)
+
+ when(mex.getVariable("aai.endpoint")).thenThrow(new BpmnError("expected exception"))
+
+ MockPutAllottedResource(CUST, SVC, INST, ARID)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) }))
+ }
+
+ @Test
+ public void createAaiAR_Ex() {
+ ExecutionEntity mex = setupMock()
+ initCreateAaiAr(mex)
+
+ when(mex.getVariable("aai.endpoint")).thenThrow(new RuntimeException("expected exception"))
+
+ MockPutAllottedResource(CUST, SVC, INST, ARID)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) }))
+ }
+
+ // ***** buildSDNCRequest *****
+
+ @Test
+ public void buildSDNCRequest() {
+ ExecutionEntity mex = setupMock()
+ initBuildSDNCRequest(mex)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq")
+
+ assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
+ assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
+ assertTrue(result.indexOf("<service-instance-id>sii</") >= 0)
+ assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
+ assertTrue(result.indexOf("<subscription-service-type>sst</") >= 0)
+ assertTrue(result.indexOf("<global-customer-id>gci</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
+ assertTrue(result.indexOf("<request-id>mri</") >= 0)
+ assertTrue(result.indexOf("<brg-wan-mac-address>bwma</") >= 0)
+ assertTrue(result.indexOf("<vni>myvni</") >= 0)
+ assertTrue(result.indexOf("<vgmux-bearer-ip>vbi</") >= 0)
+ assertTrue(result.indexOf("<model-invariant-uuid>miu</") >= 0)
+ assertTrue(result.indexOf("<model-uuid>mu</") >= 0)
+ assertTrue(result.indexOf("<model-customization-uuid>mcu</") >= 0)
+ assertTrue(result.indexOf("<model-version>mv</") >= 0)
+ assertTrue(result.indexOf("<model-name>mn</") >= 0)
+ }
+
+ @Test
+ public void buildSDNCRequest_EmptyModelInfo() {
+ ExecutionEntity mex = setupMock()
+ initBuildSDNCRequest(mex)
+
+ when(mex.getVariable("allottedResourceModelInfo")).thenReturn("{}")
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq")
+
+ assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
+ assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
+ assertTrue(result.indexOf("<service-instance-id>sii</") >= 0)
+ assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
+ assertTrue(result.indexOf("<subscription-service-type>sst</") >= 0)
+ assertTrue(result.indexOf("<global-customer-id>gci</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
+ assertTrue(result.indexOf("<request-id>mri</") >= 0)
+ assertTrue(result.indexOf("<brg-wan-mac-address>bwma</") >= 0)
+ assertTrue(result.indexOf("<vni>myvni</") >= 0)
+ assertTrue(result.indexOf("<vgmux-bearer-ip>vbi</") >= 0)
+ assertTrue(result.indexOf("<model-invariant-uuid/>") >= 0)
+ assertTrue(result.indexOf("<model-uuid/>") >= 0)
+ assertTrue(result.indexOf("<model-customization-uuid/>") >= 0)
+ assertTrue(result.indexOf("<model-version/>") >= 0)
+ assertTrue(result.indexOf("<model-name/>") >= 0)
+ }
+
+ @Test
+ public void buildSDNCRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ initBuildSDNCRequest(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") }))
+ }
+
+ // ***** preProcessSDNCAssign *****
+
+ @Test
+ public void preProcessSDNCAssign() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ def data = initPreProcessSDNC(mex)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex)
+
+ def req = map.get("sdncAssignRequest")
+ assertNotNull(req)
+
+ assertEquals(data, map.get("rollbackData"))
+
+ def rbreq = data.get(Prefix, "sdncAssignRollbackReq")
+
+ assertTrue(req.indexOf("<sdncadapter:SvcAction>assign</") >= 0)
+ assertTrue(req.indexOf("<request-action>CreateBRGInstance</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+
+ assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>unassign</") >= 0)
+ assertTrue(rbreq.indexOf("<request-action>DeleteBRGInstance</") >= 0)
+ assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
+ }
+
+ @Test
+ public void preProcessSDNCAssign_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) }))
+ }
+
+ @Test
+ public void preProcessSDNCAssign_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) }))
+ }
+
+ // ***** preProcessSDNCCreate *****
+
+ @Test
+ public void preProcessSDNCCreate() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ def data = initPreProcessSDNC(mex)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex)
+
+ def req = map.get("sdncCreateRequest")
+ assertNotNull(req)
+
+ assertEquals(data, map.get("rollbackData"))
+
+ def rbreq = data.get(Prefix, "sdncCreateRollbackReq")
+
+ assertTrue(req.indexOf("<sdncadapter:SvcAction>create</") >= 0)
+ assertTrue(req.indexOf("<request-action>CreateBRGInstance</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+
+ assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>delete</") >= 0)
+ assertTrue(rbreq.indexOf("<request-action>DeleteBRGInstance</") >= 0)
+ assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
+
+ }
+
+ @Test
+ public void preProcessSDNCCreate_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) }))
+ }
+
+ @Test
+ public void preProcessSDNCCreate_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) }))
+ }
+
+ // ***** preProcessSDNCActivate *****
+
+ @Test
+ public void preProcessSDNCActivate() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ def data = initPreProcessSDNC(mex)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex)
+
+ def req = map.get("sdncActivateRequest")
+ assertNotNull(req)
+
+ assertEquals(data, map.get("rollbackData"))
+
+ def rbreq = data.get(Prefix, "sdncActivateRollbackReq")
+
+ assertTrue(req.indexOf("<sdncadapter:SvcAction>activate</") >= 0)
+ assertTrue(req.indexOf("<request-action>CreateBRGInstance</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+
+ assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>deactivate</") >= 0)
+ assertTrue(rbreq.indexOf("<request-action>DeleteBRGInstance</") >= 0)
+ assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
+
+ }
+
+ @Test
+ public void preProcessSDNCActivate_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) }))
+ }
+
+ @Test
+ public void preProcessSDNCActivate_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) }))
+ }
+
+ // ***** validateSDNCResp *****
+
+ @Test
+ public void validateSDNCResp() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ def data = initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create")
+
+ verify(mex).getVariable("WorkflowException")
+ verify(mex).getVariable("SDNCA_SuccessIndicator")
+ verify(mex).getVariable("rollbackData")
+
+ assertEquals(data, map.get("rollbackData"))
+
+ assertEquals("true", data.get(Prefix, "rollback" + "SDNCcreate"))
+
+ }
+
+ @Test
+ public void validateSDNCResp_Get() {
+ ExecutionEntity mex = setupMock()
+ def data = initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "get")
+
+ verify(mex).getVariable("WorkflowException")
+ verify(mex).getVariable("SDNCA_SuccessIndicator")
+
+ verify(mex, never()).getVariable("rollbackData")
+ }
+
+ @Test
+ public void validateSDNCResp_Unsuccessful() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ // unsuccessful
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(false)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ public void validateSDNCResp_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ public void validateSDNCResp_Ex() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ // ***** preProcessSDNCGet *****
+
+ @Test
+ public void preProcessSDNCGet_FoundAR() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessSDNCGet(mex)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.preProcessSDNCGet(mex)
+
+ String req = map.get("sdncGetRequest")
+
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:SvcOperation>arlink</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:CallbackUrl>myurl</") >= 0)
+
+ }
+
+ @Test
+ public void preProcessSDNCGet_NotFoundAR() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessSDNCGet(mex)
+
+ when(mex.getVariable("foundActiveAR")).thenReturn(false)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.preProcessSDNCGet(mex)
+
+ String req = map.get("sdncGetRequest")
+
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:SvcOperation>assignlink</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:CallbackUrl>myurl</") >= 0)
+
+ }
+
+ @Test
+ public void preProcessSDNCGet_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNCGet(mex)
+
+ when(mex.getVariable("foundActiveAR")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) }))
+ }
+
+ // ***** updateAaiAROrchStatus *****
+
+ @Test
+ @Ignore
+ public void updateAaiAROrchStatus() {
+ MockPatchAllottedResource(CUST, SVC, INST, ARID)
+
+ ExecutionEntity mex = setupMock()
+ initUpdateAaiAROrchStatus(mex)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.updateAaiAROrchStatus(mex, "success")
+ }
+
+ // ***** generateOutputs *****
+
+ @Test
+ public void generateOutputs() {
+ ExecutionEntity mex = setupMock()
+ def brgtop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml")
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("enhancedCallbackRequestData")).thenReturn(brgtop)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.generateOutputs(mex)
+
+ verify(mex).setVariable("allotedResourceName", "namefromrequest")
+
+ }
+
+ @Test
+ public void generateOutputs_BadXml() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("enhancedCallbackRequestData")).thenReturn("invalid xml")
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.generateOutputs(mex)
+
+ verify(mex, never()).setVariable(anyString(), anyString())
+
+ }
+
+ @Test
+ public void generateOutputs_BpmnError() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ DoCreateAllottedResourceBRG.generateOutputs(mex)
+ verify(mex, never()).setVariable(anyString(), anyString())
+
+ }
+
+ @Test
+ public void generateOutputs_Ex() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ DoCreateAllottedResourceBRG.generateOutputs(mex)
+ verify(mex, never()).setVariable(anyString(), anyString())
+
+ }
+
+ // ***** preProcessRollback *****
+
+ @Test
+ public void preProcessRollback() {
+ ExecutionEntity mex = setupMock()
+ WorkflowException wfe = mock(WorkflowException.class)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("WorkflowException")).thenReturn(wfe)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.preProcessRollback(mex)
+
+ verify(mex).setVariable("prevWorkflowException", wfe)
+ }
+
+ @Test
+ public void preProcessRollback_NotWFE() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("WorkflowException")).thenReturn("I'm not a WFE")
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.preProcessRollback(mex)
+ }
+
+ @Test
+ public void preProcessRollback_BpmnError() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ DoCreateAllottedResourceBRG.preProcessRollback(mex)
+ }
+
+ @Test
+ public void preProcessRollback_Ex() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ DoCreateAllottedResourceBRG.preProcessRollback(mex)
+
+ }
+
+ // ***** postProcessRollback *****
+
+ @Test
+ public void postProcessRollback() {
+ ExecutionEntity mex = setupMock()
+ WorkflowException wfe = mock(WorkflowException.class)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prevWorkflowException")).thenReturn(wfe)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.postProcessRollback(mex)
+
+ verify(mex).setVariable("WorkflowException", wfe)
+ verify(mex).setVariable("rollbackData", null)
+
+ }
+
+ @Test
+ public void postProcessRollback_NotWFE() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prevWorkflowException")).thenReturn("I'm not a WFE")
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+ DoCreateAllottedResourceBRG.postProcessRollback(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+
+ }
+
+ @Test
+ public void postProcessRollback_BpmnError() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.postProcessRollback(mex) }))
+ verify(mex, never()).setVariable("rollbackData", null)
+
+ }
+
+ @Test
+ public void postProcessRollback_Ex() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ DoCreateAllottedResourceBRG.postProcessRollback(mex)
+ verify(mex, never()).setVariable("rollbackData", null)
+
+ }
+
+ private boolean checkMissingPreProcessRequest(String fieldnm) {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
+
+ when(mex.getVariable(fieldnm)).thenReturn("")
+
+ return doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessRequest(mex) })
+ }
+
+ private void initPreProcess(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn")
+ when(mex.getVariable("mso.workflow.sdnc.replication.delay")).thenReturn("sdncdelay")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
+ when(mex.getVariable("allottedResourceModelInfo")).thenReturn("armi")
+ when(mex.getVariable("vni")).thenReturn("myvni")
+ when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi")
+ when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma")
+ when(mex.getVariable("allottedResourceRole")).thenReturn("arr")
+ when(mex.getVariable("allottedResourceType")).thenReturn("art")
+ }
+
+ private void initGetAaiAR(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("allottedResourceType")).thenReturn("BRGt")
+ when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr")
+ when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml"))
+ when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
+ when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
+ }
+
+ private initCreateAaiAr(ExecutionEntity mex) {
+ when(mex.getVariable("disableRollback")).thenReturn(45)
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
+ when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
+ when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace"))
+ when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST).build()))
+ when(mex.getVariable("allottedResourceType")).thenReturn("BRGt")
+ when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr")
+ when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx + "/aai/v9/mycsi")
+ when(mex.getVariable("allottedResourceModelInfo")).thenReturn("""
+ {
+ "modelInvariantUuid":"modelinvuuid",
+ "modelUuid":"modeluuid",
+ "modelCustomizationUuid":"modelcustuuid"
+ }
+ """)
+ }
+
+ private initBuildSDNCRequest(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("allottedResourceId")).thenReturn("ari")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
+ when(mex.getVariable("subscriptionServiceType")).thenReturn("sst")
+ when(mex.getVariable("globalCustomerId")).thenReturn("gci")
+ when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu")
+ when(mex.getVariable("msoRequestId")).thenReturn("mri")
+ when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma")
+ when(mex.getVariable("vni")).thenReturn("myvni")
+ when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi")
+ when(mex.getVariable("allottedResourceModelInfo")).thenReturn("""
+ {
+ "modelInvariantUuid":"miu",
+ "modelUuid":"mu",
+ "modelCustomizationUuid":"mcu",
+ "modelVersion":"mv",
+ "modelName":"mn"
+ }
+ """)
+ }
+
+ private RollbackData initPreProcessSDNC(ExecutionEntity mex) {
+ def data = new RollbackData()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("rollbackData")).thenReturn(data)
+
+ return data
+ }
+
+ private initPreProcessSDNCGet(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl")
+ when(mex.getVariable("foundActiveAR")).thenReturn(true)
+ when(mex.getVariable("aaiARGetResponse")).thenReturn("<selflink>arlink</selflink>")
+ when(mex.getVariable("sdncAssignResponse")).thenReturn("<response-data>&lt;object-path&gt;assignlink&lt;/object-path&gt;</response-data>")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl")
+ }
+
+ private RollbackData initValidateSDNCResp(ExecutionEntity mex) {
+ def data = new RollbackData()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prefix")).thenReturn(Prefix)
+ when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
+ when(mex.getVariable("rollbackData")).thenReturn(data)
+
+ return data
+ }
+
+ private String initValidateSDNCResp_Resp() {
+ return "<response-data>&lt;response-code&gt;200&lt;/response-code&gt;</response-data>"
+ }
+
+ private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/" + ARID)
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy
index 50ce46e4a3..a877ce42e7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -20,635 +22,573 @@
package org.onap.so.bpmn.vcpe.scripts
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.junit.Before
-import org.junit.BeforeClass
-import org.junit.Rule
-import org.junit.Test
-import org.junit.Ignore
+import org.junit.*
import org.mockito.MockitoAnnotations
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.bpmn.core.RollbackData
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.stubFor
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue
import static org.mockito.Mockito.*
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource
+import static org.onap.so.bpmn.mock.StubResponseAAI.*
-import org.onap.so.bpmn.core.RollbackData
+class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase {
-import com.github.tomakehurst.wiremock.junit.WireMockRule
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(PORT)
+
+ String Prefix = "DCARTXCRB_"
+ String RbType = "DCARTXC_"
+
+ @BeforeClass
+ public static void setUpBeforeClass() {
+ GroovyTestBase.setUpBeforeClass()
+ }
-class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase {
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(PORT)
-
- String Prefix = "DCARTXCRB_"
- String RbType = "DCARTXC_"
-
- @BeforeClass
- public static void setUpBeforeClass() {
- super.setUpBeforeClass()
- }
-
@Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
- }
-
- public DoCreateAllottedResourceTXCRollbackTest() {
- super("DoCreateAllottedResourceTXCRollback")
- }
-
-
- // ***** preProcessRequest *****
-
- @Test
-// @Ignore
- public void preProcessRequest() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("serviceInstanceId", "sii")
- verify(mex).setVariable("parentServiceInstanceId", "psii")
- verify(mex).setVariable("allottedResourceId", "myid")
- verify(mex).setVariable("rollbackAAI", true)
- verify(mex).setVariable("aaiARPath", "mypath")
- verify(mex).setVariable("rollbackSDNC", true)
- verify(mex).setVariable("deactivateSdnc", "myactivate")
- verify(mex).setVariable("deleteSdnc", "mycreate")
- verify(mex).setVariable("unassignSdnc", "true")
- verify(mex).setVariable("sdncDeactivateRequest", "activatereq")
- verify(mex).setVariable("sdncDeleteRequest", "createreq")
- verify(mex).setVariable("sdncUnassignRequest", "assignreq")
-
- verify(mex, never()).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_RollbackDisabled() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("disableRollback")).thenReturn("true")
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("serviceInstanceId", "sii")
- verify(mex).setVariable("parentServiceInstanceId", "psii")
- verify(mex).setVariable("allottedResourceId", "myid")
- verify(mex).setVariable("rollbackAAI", true)
- verify(mex).setVariable("aaiARPath", "mypath")
- verify(mex).setVariable("rollbackSDNC", true)
- verify(mex).setVariable("deactivateSdnc", "myactivate")
- verify(mex).setVariable("deleteSdnc", "mycreate")
- verify(mex).setVariable("unassignSdnc", "true")
- verify(mex).setVariable("sdncDeactivateRequest", "activatereq")
- verify(mex).setVariable("sdncDeleteRequest", "createreq")
- verify(mex).setVariable("sdncUnassignRequest", "assignreq")
-
- verify(mex).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_NoAAI() {
- ExecutionEntity mex = setupMock()
- def data = initPreProcess(mex)
-
- when(mex.getVariable("rollbackAAI")).thenReturn(false)
- data.put(RbType, "rollbackAAI", "false")
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("serviceInstanceId", "sii")
- verify(mex).setVariable("parentServiceInstanceId", "psii")
- verify(mex).setVariable("allottedResourceId", "myid")
- verify(mex, never()).setVariable("rollbackAAI", true)
- verify(mex, never()).setVariable("aaiARPath", "mypath")
- verify(mex).setVariable("rollbackSDNC", true)
- verify(mex).setVariable("deactivateSdnc", "myactivate")
- verify(mex).setVariable("deleteSdnc", "mycreate")
- verify(mex).setVariable("unassignSdnc", "true")
- verify(mex).setVariable("sdncDeactivateRequest", "activatereq")
- verify(mex).setVariable("sdncDeleteRequest", "createreq")
- verify(mex).setVariable("sdncUnassignRequest", "assignreq")
-
- verify(mex, never()).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_NoAssign() {
- ExecutionEntity mex = setupMock()
- def data = initPreProcess(mex)
-
- when(mex.getVariable("rollbackSDNC")).thenReturn(false)
- data.put(RbType, "rollbackSDNCassign", "false")
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("serviceInstanceId", "sii")
- verify(mex).setVariable("parentServiceInstanceId", "psii")
- verify(mex).setVariable("allottedResourceId", "myid")
- verify(mex).setVariable("rollbackAAI", true)
- verify(mex).setVariable("aaiARPath", "mypath")
- verify(mex, never()).setVariable("rollbackSDNC", true)
- verify(mex, never()).setVariable("deactivateSdnc", "myactivate")
- verify(mex, never()).setVariable("deleteSdnc", "mycreate")
- verify(mex, never()).setVariable("unassignSdnc", "true")
- verify(mex, never()).setVariable("sdncDeactivateRequest", "activatereq")
- verify(mex, never()).setVariable("sdncDeleteRequest", "createreq")
- verify(mex, never()).setVariable("sdncUnassignRequest", "assignreq")
-
- verify(mex, never()).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_NoAAI_NoAssign() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("rollbackAAI")).thenReturn(false)
- when(mex.getVariable("rollbackSDNC")).thenReturn(false)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
-
- verify(mex).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_NoRbStructure() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("rollbackData")).thenReturn(new RollbackData())
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
-
- verify(mex).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_NullRb() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("rollbackData")).thenReturn(null)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
-
- verify(mex).setVariable("skipRollback", true)
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) }))
- }
-
- @Test
- @Ignore
- public void updateAaiAROrchStatus() {
- ExecutionEntity mex = setupMock()
- initUpdateAaiAROrchStatus(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success")
- }
-
- @Test
-// @Ignore
- public void updateAaiAROrchStatus_EmptyResponse() {
- ExecutionEntity mex = setupMock()
- initUpdateAaiAROrchStatus(mex)
-
- wireMockRule
- .stubFor(get(urlMatching("/aai/v[0-9]+/.*"))
- .willReturn(aResponse()
- .withStatus(200)))
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") }))
- }
-
- @Test
-// @Ignore
- public void updateAaiAROrchStatus_NoArPath() {
- ExecutionEntity mex = setupMock()
- initUpdateAaiAROrchStatus(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
-
- when(mex.getVariable("aaiARPath")).thenReturn(null)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") }))
- }
-
-
- // ***** validateSDNCResp *****
-
- @Test
-// @Ignore
- public void validateSDNCResp() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
-
- DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create")
-
- verify(mex).getVariable("WorkflowException")
- verify(mex).getVariable("SDNCA_SuccessIndicator")
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Unsuccessful() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_BpmnError404() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("404", "expected exception"))
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
-
- DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create")
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_BpmnError() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Ex() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
- @Ignore
- public void deleteAaiAR() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex)
- }
-
- @Test
-// @Ignore
- public void deleteAaiAR_NoArPath() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- when(mex.getVariable("aaiARPath")).thenReturn("")
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) }))
- }
-
- @Test
-// @Ignore
- public void deleteAaiAR_BpmnError() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) }))
- }
-
- @Test
-// @Ignore
- public void deleteAaiAR_Ex() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) }))
- }
-
- @Test
-// @Ignore
- public void postProcessRequest() {
- ExecutionEntity mex = setupMock()
- initPostProcessRequest(mex)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.postProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("rollbackData", null)
- verify(mex).setVariable("rolledBack", true)
- }
-
- @Test
-// @Ignore
- public void postProcessRequest_RolledBack() {
- ExecutionEntity mex = setupMock()
- initPostProcessRequest(mex)
-
- when(mex.getVariable("skipRollback")).thenReturn(true)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.postProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("rollbackData", null)
- verify(mex, never()).setVariable("rolledBack", true)
- }
-
- @Test
-// @Ignore
- public void postProcessRequest_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPostProcessRequest(mex)
-
- when(mex.getVariable("skipRollback")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.postProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("rollbackData", null)
- verify(mex, never()).setVariable("rolledBack", true)
- }
-
- @Test
-// @Ignore
- public void postProcessRequest_Ex() {
- ExecutionEntity mex = setupMock()
- initPostProcessRequest(mex)
-
- when(mex.getVariable("skipRollback")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.postProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("rollbackData", null)
- verify(mex, never()).setVariable("rolledBack", true)
- }
-
- @Test
-// @Ignore
- public void processRollbackException() {
- ExecutionEntity mex = setupMock()
- initProcessRollbackException(mex)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.processRollbackException(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("rollbackData", null)
- verify(mex).setVariable("rolledBack", false)
- verify(mex).setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback")
- verify(mex).setVariable("WorkflowException", null)
- }
-
- @Test
-// @Ignore
- public void processRollbackException_BpmnError() {
- ExecutionEntity mex = setupMock()
- initProcessRollbackException(mex)
-
- doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.processRollbackException(mex)
- }
-
- @Test
-// @Ignore
- public void processRollbackException_Ex() {
- ExecutionEntity mex = setupMock()
- initProcessRollbackException(mex)
-
- doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.processRollbackException(mex)
- }
-
- @Test
-// @Ignore
- public void processRollbackJavaException() {
- ExecutionEntity mex = setupMock()
- initProcessRollbackException(mex)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("rollbackData", null)
- verify(mex).setVariable("rolledBack", false)
- verify(mex).setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback")
- verify(mex, never()).setVariable("WorkflowException", null)
- }
-
- @Test
-// @Ignore
- public void processRollbackJavaException_BpmnError() {
- ExecutionEntity mex = setupMock()
- initProcessRollbackException(mex)
-
- doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex)
- }
-
- @Test
-// @Ignore
- public void processRollbackJavaException_Ex() {
- ExecutionEntity mex = setupMock()
- initProcessRollbackException(mex)
-
- doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null)
-
- DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
- DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex)
- }
-
- private RollbackData initPreProcess(ExecutionEntity mex) {
- def data = new RollbackData()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("rollbackData")).thenReturn(data)
- when(mex.getVariable("rollbackAAI")).thenReturn(true)
- when(mex.getVariable("rollbackSDNC")).thenReturn(true)
- when(mex.getVariable("disableRollback")).thenReturn("false")
-
- data.put("SERVICEINSTANCE", "allottedResourceId", "myid")
-
- data.put(RbType, "serviceInstanceId", "sii")
- data.put(RbType, "parentServiceInstanceId", "psii")
-
- data.put(RbType, "rollbackAAI", "true")
- data.put(RbType, "aaiARPath", "mypath")
-
- data.put(RbType, "rollbackSDNCassign", "true")
- data.put(RbType, "rollbackSDNCactivate", "myactivate")
- data.put(RbType, "rollbackSDNCcreate", "mycreate")
- data.put(RbType, "sdncActivateRollbackReq", "activatereq")
- data.put(RbType, "sdncCreateRollbackReq", "createreq")
- data.put(RbType, "sdncAssignRollbackReq", "assignreq")
-
- return data
- }
-
- private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
- when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- }
-
- private initValidateSDNCResp(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prefix")).thenReturn(Prefix)
- when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
- }
-
- private String initValidateSDNCResp_Resp() {
- return "<response-data>&lt;response-code&gt;200&lt;/response-code&gt;</response-data>"
- }
-
- private initDeleteAaiAR(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARResourceVersion")).thenReturn(VERS)
- when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
- when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- }
-
- private initPostProcessRequest(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("skipRollback")).thenReturn(false)
- }
-
- private initProcessRollbackException(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- }
-
- private initProcessRollbackJavaException(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- }
-
+ public void init() {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ public DoCreateAllottedResourceTXCRollbackTest() {
+ super("DoCreateAllottedResourceTXCRollback")
+ }
+
+ // ***** preProcessRequest *****
+
+ @Test
+ public void preProcessRequest() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("serviceInstanceId", "sii")
+ verify(mex).setVariable("parentServiceInstanceId", "psii")
+ verify(mex).setVariable("allottedResourceId", "myid")
+ verify(mex).setVariable("rollbackAAI", true)
+ verify(mex).setVariable("aaiARPath", "mypath")
+ verify(mex).setVariable("rollbackSDNC", true)
+ verify(mex).setVariable("deactivateSdnc", "myactivate")
+ verify(mex).setVariable("deleteSdnc", "mycreate")
+ verify(mex).setVariable("unassignSdnc", "true")
+ verify(mex).setVariable("sdncDeactivateRequest", "activatereq")
+ verify(mex).setVariable("sdncDeleteRequest", "createreq")
+ verify(mex).setVariable("sdncUnassignRequest", "assignreq")
+
+ verify(mex, never()).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_RollbackDisabled() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("disableRollback")).thenReturn("true")
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("serviceInstanceId", "sii")
+ verify(mex).setVariable("parentServiceInstanceId", "psii")
+ verify(mex).setVariable("allottedResourceId", "myid")
+ verify(mex).setVariable("rollbackAAI", true)
+ verify(mex).setVariable("aaiARPath", "mypath")
+ verify(mex).setVariable("rollbackSDNC", true)
+ verify(mex).setVariable("deactivateSdnc", "myactivate")
+ verify(mex).setVariable("deleteSdnc", "mycreate")
+ verify(mex).setVariable("unassignSdnc", "true")
+ verify(mex).setVariable("sdncDeactivateRequest", "activatereq")
+ verify(mex).setVariable("sdncDeleteRequest", "createreq")
+ verify(mex).setVariable("sdncUnassignRequest", "assignreq")
+
+ verify(mex).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_NoAAI() {
+ ExecutionEntity mex = setupMock()
+ def data = initPreProcess(mex)
+
+ when(mex.getVariable("rollbackAAI")).thenReturn(false)
+ data.put(RbType, "rollbackAAI", "false")
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("serviceInstanceId", "sii")
+ verify(mex).setVariable("parentServiceInstanceId", "psii")
+ verify(mex).setVariable("allottedResourceId", "myid")
+ verify(mex, never()).setVariable("rollbackAAI", true)
+ verify(mex, never()).setVariable("aaiARPath", "mypath")
+ verify(mex).setVariable("rollbackSDNC", true)
+ verify(mex).setVariable("deactivateSdnc", "myactivate")
+ verify(mex).setVariable("deleteSdnc", "mycreate")
+ verify(mex).setVariable("unassignSdnc", "true")
+ verify(mex).setVariable("sdncDeactivateRequest", "activatereq")
+ verify(mex).setVariable("sdncDeleteRequest", "createreq")
+ verify(mex).setVariable("sdncUnassignRequest", "assignreq")
+
+ verify(mex, never()).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_NoAssign() {
+ ExecutionEntity mex = setupMock()
+ def data = initPreProcess(mex)
+
+ when(mex.getVariable("rollbackSDNC")).thenReturn(false)
+ data.put(RbType, "rollbackSDNCassign", "false")
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("serviceInstanceId", "sii")
+ verify(mex).setVariable("parentServiceInstanceId", "psii")
+ verify(mex).setVariable("allottedResourceId", "myid")
+ verify(mex).setVariable("rollbackAAI", true)
+ verify(mex).setVariable("aaiARPath", "mypath")
+ verify(mex, never()).setVariable("rollbackSDNC", true)
+ verify(mex, never()).setVariable("deactivateSdnc", "myactivate")
+ verify(mex, never()).setVariable("deleteSdnc", "mycreate")
+ verify(mex, never()).setVariable("unassignSdnc", "true")
+ verify(mex, never()).setVariable("sdncDeactivateRequest", "activatereq")
+ verify(mex, never()).setVariable("sdncDeleteRequest", "createreq")
+ verify(mex, never()).setVariable("sdncUnassignRequest", "assignreq")
+
+ verify(mex, never()).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_NoAAI_NoAssign() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("rollbackAAI")).thenReturn(false)
+ when(mex.getVariable("rollbackSDNC")).thenReturn(false)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_NoRbStructure() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("rollbackData")).thenReturn(new RollbackData())
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_NullRb() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("rollbackData")).thenReturn(null)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.preProcessRequest(mex)
+
+ verify(mex).setVariable("skipRollback", true)
+ }
+
+ @Test
+ public void preProcessRequest_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) }))
+ }
+
+ @Test
+ public void preProcessRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) }))
+ }
+
+ @Test
+ @Ignore
+ public void updateAaiAROrchStatus() {
+ ExecutionEntity mex = setupMock()
+ initUpdateAaiAROrchStatus(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
+ MockPatchAllottedResource(CUST, SVC, INST, ARID)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success")
+ }
+
+ @Test
+ public void updateAaiAROrchStatus_EmptyResponse() {
+ ExecutionEntity mex = setupMock()
+ initUpdateAaiAROrchStatus(mex)
+
+ wireMockRule
+ .stubFor(get(urlMatching("/aai/v[0-9]+/.*"))
+ .willReturn(aResponse()
+ .withStatus(200)))
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") }))
+ }
+
+ @Test
+ public void updateAaiAROrchStatus_NoArPath() {
+ ExecutionEntity mex = setupMock()
+ initUpdateAaiAROrchStatus(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
+ MockPatchAllottedResource(CUST, SVC, INST, ARID)
+
+ when(mex.getVariable("aaiARPath")).thenReturn(null)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") }))
+ }
+
+ // ***** validateSDNCResp *****
+
+ @Test
+ public void validateSDNCResp() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+
+ DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create")
+
+ verify(mex).getVariable("WorkflowException")
+ verify(mex).getVariable("SDNCA_SuccessIndicator")
+ }
+
+ @Test
+ public void validateSDNCResp_Unsuccessful() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(false)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ public void validateSDNCResp_BpmnError404() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("404", "expected exception"))
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+
+ DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create")
+ }
+
+ @Test
+ public void validateSDNCResp_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ public void validateSDNCResp_Ex() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ @Ignore
+ public void deleteAaiAR() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex)
+ }
+
+ @Test
+ public void deleteAaiAR_NoArPath() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ when(mex.getVariable("aaiARPath")).thenReturn("")
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) }))
+ }
+
+ @Test
+ public void deleteAaiAR_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) }))
+ }
+
+ @Test
+ public void deleteAaiAR_Ex() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) }))
+ }
+
+ @Test
+ public void postProcessRequest() {
+ ExecutionEntity mex = setupMock()
+ initPostProcessRequest(mex)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.postProcessRequest(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+ verify(mex).setVariable("rolledBack", true)
+ }
+
+ @Test
+ public void postProcessRequest_RolledBack() {
+ ExecutionEntity mex = setupMock()
+ initPostProcessRequest(mex)
+
+ when(mex.getVariable("skipRollback")).thenReturn(true)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.postProcessRequest(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+ verify(mex, never()).setVariable("rolledBack", true)
+ }
+
+ @Test
+ public void postProcessRequest_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPostProcessRequest(mex)
+
+ when(mex.getVariable("skipRollback")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.postProcessRequest(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+ verify(mex, never()).setVariable("rolledBack", true)
+ }
+
+ @Test
+ public void postProcessRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPostProcessRequest(mex)
+
+ when(mex.getVariable("skipRollback")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.postProcessRequest(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+ verify(mex, never()).setVariable("rolledBack", true)
+ }
+
+ @Test
+ public void processRollbackException() {
+ ExecutionEntity mex = setupMock()
+ initProcessRollbackException(mex)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.processRollbackException(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+ verify(mex).setVariable("rolledBack", false)
+ verify(mex).setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback")
+ verify(mex).setVariable("WorkflowException", null)
+ }
+
+ @Test
+ public void processRollbackException_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initProcessRollbackException(mex)
+
+ doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.processRollbackException(mex)
+ }
+
+ @Test
+ public void processRollbackException_Ex() {
+ ExecutionEntity mex = setupMock()
+ initProcessRollbackException(mex)
+
+ doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.processRollbackException(mex)
+ }
+
+ @Test
+ public void processRollbackJavaException() {
+ ExecutionEntity mex = setupMock()
+ initProcessRollbackException(mex)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex)
+
+ verify(mex).setVariable("rollbackData", null)
+ verify(mex).setVariable("rolledBack", false)
+ verify(mex).setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback")
+ verify(mex, never()).setVariable("WorkflowException", null)
+ }
+
+ @Test
+ public void processRollbackJavaException_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initProcessRollbackException(mex)
+
+ doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex)
+ }
+
+ @Test
+ public void processRollbackJavaException_Ex() {
+ ExecutionEntity mex = setupMock()
+ initProcessRollbackException(mex)
+
+ doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null)
+
+ DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback()
+ DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex)
+ }
+
+ private RollbackData initPreProcess(ExecutionEntity mex) {
+ def data = new RollbackData()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("rollbackData")).thenReturn(data)
+ when(mex.getVariable("rollbackAAI")).thenReturn(true)
+ when(mex.getVariable("rollbackSDNC")).thenReturn(true)
+ when(mex.getVariable("disableRollback")).thenReturn("false")
+
+ data.put("SERVICEINSTANCE", "allottedResourceId", "myid")
+
+ data.put(RbType, "serviceInstanceId", "sii")
+ data.put(RbType, "parentServiceInstanceId", "psii")
+
+ data.put(RbType, "rollbackAAI", "true")
+ data.put(RbType, "aaiARPath", "mypath")
+
+ data.put(RbType, "rollbackSDNCassign", "true")
+ data.put(RbType, "rollbackSDNCactivate", "myactivate")
+ data.put(RbType, "rollbackSDNCcreate", "mycreate")
+ data.put(RbType, "sdncActivateRollbackReq", "activatereq")
+ data.put(RbType, "sdncCreateRollbackReq", "createreq")
+ data.put(RbType, "sdncAssignRollbackReq", "assignreq")
+
+ return data
+ }
+
+ private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/" + ARID)
+ when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
+ }
+
+ private initValidateSDNCResp(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prefix")).thenReturn(Prefix)
+ when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
+ }
+
+ private String initValidateSDNCResp_Resp() {
+ return "<response-data>&lt;response-code&gt;200&lt;/response-code&gt;</response-data>"
+ }
+
+ private initDeleteAaiAR(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("aaiARResourceVersion")).thenReturn(VERS)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/" + ARID)
+ when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
+ }
+
+ private initPostProcessRequest(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("skipRollback")).thenReturn(false)
+ }
+
+ private initProcessRollbackException(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy
index b759ca1c20..b53e5fce21 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -20,15 +22,10 @@
package org.onap.so.bpmn.vcpe.scripts
-
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.junit.Before
-import org.junit.BeforeClass
-import org.junit.Rule
-import org.junit.Test
-import org.junit.Ignore
+import org.junit.*
import org.mockito.MockitoAnnotations
-import org.camunda.bpm.engine.delegate.BpmnError
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
@@ -38,7 +35,7 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory
import javax.ws.rs.core.UriBuilder
-import static org.junit.Assert.*;
+import static org.junit.Assert.*
import static org.mockito.Mockito.*
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource
@@ -50,860 +47,808 @@ import org.onap.so.bpmn.core.RollbackData
import com.github.tomakehurst.wiremock.junit.WireMockRule
class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(PORT)
- String Prefix = "DCARTXC_"
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(PORT)
+
+ String Prefix = "DCARTXC_"
+
+ @BeforeClass
+ public static void setUpBeforeClass() {
+ aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint")
+ }
- @BeforeClass
- public static void setUpBeforeClass() {
- aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint")
- }
-
@Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
- }
-
- public DoCreateAllottedResourceTXCTest() {
- super("DoCreateAllottedResourceTXC")
- }
-
-
- // ***** preProcessRequest *****
-
- @Test
-
- public void preProcessRequest() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.preProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
-
- assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback"))
- assertTrue(checkMissingPreProcessRequest("mso.workflow.sdnc.replication.delay"))
- assertTrue(checkMissingPreProcessRequest("serviceInstanceId"))
- assertTrue(checkMissingPreProcessRequest("parentServiceInstanceId"))
- assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo"))
- assertTrue(checkMissingPreProcessRequest("brgWanMacAddress"))
- assertTrue(checkMissingPreProcessRequest("allottedResourceRole"))
- assertTrue(checkMissingPreProcessRequest("allottedResourceType"))
- }
-
-
- // ***** getAaiAR *****
-
- @Test
- @Ignore
- public void getAaiAR() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
-
- ExecutionEntity mex = setupMock()
- initGetAaiAR(mex)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.getAaiAR(mex)
-
- verify(mex).setVariable("foundActiveAR", true)
- }
-
- @Test
-
- public void getAaiAR_Duplicate() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
-
- ExecutionEntity mex = setupMock()
- initGetAaiAR(mex)
-
- // fail if duplicate
- when(mex.getVariable("failExists")).thenReturn("true")
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXC.getAaiAR(mex) }))
- }
-
- @Test
-
- public void getAaiAR_NotActive() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
-
- ExecutionEntity mex = setupMock()
- initGetAaiAR(mex)
-
- // not active
- when(mex.getVariable("aaiAROrchStatus")).thenReturn("not-active")
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXC.getAaiAR(mex) }))
- }
-
- @Test
- @Ignore
- public void getAaiAR_NoStatus() {
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
-
- ExecutionEntity mex = setupMock()
- initGetAaiAR(mex)
-
- when(mex.getVariable("aaiAROrchStatus")).thenReturn(null)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.getAaiAR(mex)
-
- verify(mex, never()).setVariable("foundActiveAR", true)
- }
-
-
- // ***** createAaiAR *****
-
- @Test
- public void createAaiAR() {
- ExecutionEntity mex = setupMock()
- initCreateAaiAr(mex)
- when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath( "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST).build()))
- when(mex.getVariable("CSI_resourceLink")).thenReturn("/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST)
- when(mex.getVariable("allottedResourceModelInfo")).thenReturn("{\n" +
- " \"modelInvariantUuid\":\"modelInvariantUuid\",\n" +
- " \"modelUuid\" : \"modelUuid\"\n" +
- "}")
- AAIResourcesClient client = mock(AAIResourcesClient.class)
- DoCreateAllottedResourceTXC doCreateAllottedResourceTXC = spy(DoCreateAllottedResourceTXC.class)
- when(doCreateAllottedResourceTXC.getAAIClient()).thenReturn(client)
- doCreateAllottedResourceTXC.createAaiAR(mex)
- }
-
-
- @Test
- public void createAaiAR_MissingPsiLink() {
- ExecutionEntity mex = setupMock()
- initCreateAaiAr(mex)
-
- when(mex.getVariable("PSI_resourceLink")).thenReturn(null)
-
- MockPutAllottedResource(CUST, SVC, INST, ARID)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) }))
- }
-
- @Test
-
- public void createAaiAR_HttpFailed() {
- ExecutionEntity mex = setupMock()
- initCreateAaiAr(mex)
-
- MockPutAllottedResource_500(CUST, SVC, INST, ARID)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) }))
- }
-
- @Test
-
- public void createAaiAR_BpmnError() {
- ExecutionEntity mex = setupMock()
- initCreateAaiAr(mex)
-
- when(mex.getVariable("aai.endpoint")).thenThrow(new BpmnError("expected exception"))
-
- MockPutAllottedResource(CUST, SVC, INST, ARID)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) }))
- }
-
- @Test
-
- public void createAaiAR_Ex() {
- ExecutionEntity mex = setupMock()
- initCreateAaiAr(mex)
-
- when(mex.getVariable("aai.endpoint")).thenThrow(new RuntimeException("expected exception"))
-
- MockPutAllottedResource(CUST, SVC, INST, ARID)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) }))
- }
-
-
- // ***** buildSDNCRequest *****
-
- @Test
-
- public void buildSDNCRequest() {
- ExecutionEntity mex = setupMock()
- initBuildSDNCRequest(mex)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- String result = DoCreateAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq")
-
- assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
- assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
- assertTrue(result.indexOf("<service-instance-id>sii</") >= 0)
- assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
- assertTrue(result.indexOf("<subscription-service-type>sst</") >= 0)
- assertTrue(result.indexOf("<global-customer-id>gci</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
- assertTrue(result.indexOf("<request-id>mri</") >= 0)
- assertTrue(result.indexOf("<model-invariant-uuid/>") >= 0)
- assertTrue(result.indexOf("<model-uuid/>") >= 0)
- assertTrue(result.indexOf("<model-customization-uuid/>") >= 0)
- assertTrue(result.indexOf("<model-version/>") >= 0)
- assertTrue(result.indexOf("<model-name/>") >= 0)
- }
-
- @Test
-
- public void buildSDNCRequest_Ex() {
- ExecutionEntity mex = setupMock()
- initBuildSDNCRequest(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") }))
- }
-
-
- // ***** preProcessSDNCAssign *****
-
- @Test
-
- public void preProcessSDNCAssign() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def data = initPreProcessSDNC(mex)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex)
-
- def req = map.get("sdncAssignRequest")
- assertNotNull(req)
-
- assertEquals(data, map.get("rollbackData"))
-
- def rbreq = data.get(Prefix, "sdncAssignRollbackReq")
-
- assertTrue(req.indexOf("<sdncadapter:SvcAction>assign</") >= 0)
- assertTrue(req.indexOf("<request-action>CreateTunnelXConnInstance</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
-
- assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>unassign</") >= 0)
- assertTrue(rbreq.indexOf("<request-action>DeleteTunnelXConnInstance</") >= 0)
- assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
- }
-
- @Test
-
- public void preProcessSDNCAssign_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) }))
- }
-
- @Test
-
- public void preProcessSDNCAssign_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) }))
- }
-
-
- // ***** preProcessSDNCCreate *****
-
- @Test
-
- public void preProcessSDNCCreate() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def data = initPreProcessSDNC(mex)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex)
-
- def req = map.get("sdncCreateRequest")
- assertNotNull(req)
-
- assertEquals(data, map.get("rollbackData"))
-
- def rbreq = data.get(Prefix, "sdncCreateRollbackReq")
-
- assertTrue(req.indexOf("<sdncadapter:SvcAction>create</") >= 0)
- assertTrue(req.indexOf("<request-action>CreateTunnelXConnInstance</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
-
- assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>delete</") >= 0)
- assertTrue(rbreq.indexOf("<request-action>DeleteTunnelXConnInstance</") >= 0)
- assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
-
- }
-
- @Test
-
- public void preProcessSDNCCreate_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) }))
- }
-
- @Test
-
- public void preProcessSDNCCreate_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) }))
- }
-
-
- // ***** preProcessSDNCActivate *****
-
- @Test
-
- public void preProcessSDNCActivate() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def data = initPreProcessSDNC(mex)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex)
-
- def req = map.get("sdncActivateRequest")
- assertNotNull(req)
-
- assertEquals(data, map.get("rollbackData"))
-
- def rbreq = data.get(Prefix, "sdncActivateRollbackReq")
-
- assertTrue(req.indexOf("<sdncadapter:SvcAction>activate</") >= 0)
- assertTrue(req.indexOf("<request-action>CreateTunnelXConnInstance</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
-
- assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>deactivate</") >= 0)
- assertTrue(rbreq.indexOf("<request-action>DeleteTunnelXConnInstance</") >= 0)
- assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
-
- }
-
- @Test
-
- public void preProcessSDNCActivate_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) }))
- }
-
- @Test
-
- public void preProcessSDNCActivate_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) }))
- }
-
-
- // ***** validateSDNCResp *****
-
- @Test
-
- public void validateSDNCResp() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- def data = initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create")
-
- verify(mex).getVariable("WorkflowException")
- verify(mex).getVariable("SDNCA_SuccessIndicator")
- verify(mex).getVariable("rollbackData")
-
- assertEquals(data, map.get("rollbackData"))
-
- assertEquals("true", data.get(Prefix, "rollback" + "SDNCcreate"))
-
- }
-
- @Test
-
- public void validateSDNCResp_Get() {
- ExecutionEntity mex = setupMock()
- def data = initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "get")
-
- verify(mex).getVariable("WorkflowException")
- verify(mex).getVariable("SDNCA_SuccessIndicator")
-
- verify(mex, never()).getVariable("rollbackData")
- }
-
- @Test
-
- public void validateSDNCResp_Unsuccessful() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- // unsuccessful
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
-
- public void validateSDNCResp_BpmnError() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
-
- public void validateSDNCResp_Ex() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp()
-
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") }))
- }
-
-
- // ***** preProcessSDNCGet *****
-
- @Test
-
- public void preProcessSDNCGet_FoundAR() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcessSDNCGet(mex)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.preProcessSDNCGet(mex)
-
- String req = map.get("sdncGetRequest")
-
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
- assertTrue(req.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:SvcOperation>arlink</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:CallbackUrl>myurl</") >= 0)
-
- }
-
- @Test
-
- public void preProcessSDNCGet_NotFoundAR() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcessSDNCGet(mex)
-
- when(mex.getVariable("foundActiveAR")).thenReturn(false)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.preProcessSDNCGet(mex)
-
- String req = map.get("sdncGetRequest")
-
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
- assertTrue(req.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:SvcOperation>assignlink</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:CallbackUrl>myurl</") >= 0)
-
- }
-
- @Test
-
- public void preProcessSDNCGet_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNCGet(mex)
-
- when(mex.getVariable("foundActiveAR")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCGet(mex) }))
- }
-
-
- // ***** updateAaiAROrchStatus *****
-
- @Test
- @Ignore
- public void updateAaiAROrchStatus() {
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
-
- ExecutionEntity mex = setupMock()
- initUpdateAaiAROrchStatus(mex)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.updateAaiAROrchStatus(mex, "success")
- }
-
-
- // ***** generateOutputs *****
-
- @Test
-
- public void generateOutputs() {
- ExecutionEntity mex = setupMock()
- def txctop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml")
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("enhancedCallbackRequestData")).thenReturn(txctop)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.generateOutputs(mex)
-
- verify(mex).setVariable("allotedResourceName", "namefromrequest")
- verify(mex).setVariable("vni", "my-vni")
- verify(mex).setVariable("vgmuxBearerIP", "my-bearer-ip")
- verify(mex).setVariable("vgmuxLanIP", "my-lan-ip")
-
- }
-
- @Test
-
- public void generateOutputs_BadXml() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("enhancedCallbackRequestData")).thenReturn("invalid xml")
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.generateOutputs(mex)
-
- verify(mex, never()).setVariable(anyString(), anyString())
-
- }
-
- @Test
-
- public void generateOutputs_BpmnError() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- DoCreateAllottedResourceTXC.generateOutputs(mex)
- verify(mex, never()).setVariable(anyString(), anyString())
-
- }
-
- @Test
-
- public void generateOutputs_Ex() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- DoCreateAllottedResourceTXC.generateOutputs(mex)
- verify(mex, never()).setVariable(anyString(), anyString())
-
- }
-
-
- // ***** preProcessRollback *****
-
- @Test
-
- public void preProcessRollback() {
- ExecutionEntity mex = setupMock()
- WorkflowException wfe = mock(WorkflowException.class)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("WorkflowException")).thenReturn(wfe)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.preProcessRollback(mex)
-
- verify(mex).setVariable("prevWorkflowException", wfe)
-
- }
-
- @Test
-
- public void preProcessRollback_NotWFE() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("WorkflowException")).thenReturn("I'm not a WFE")
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.preProcessRollback(mex)
-
-// verify(mex, never()).setVariable("prevWorkflowException", any())
-
- }
-
- @Test
-
- public void preProcessRollback_BpmnError() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- DoCreateAllottedResourceTXC.preProcessRollback(mex)
-
- }
-
- @Test
-
- public void preProcessRollback_Ex() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- DoCreateAllottedResourceTXC.preProcessRollback(mex)
-
- }
-
-
- // ***** postProcessRollback *****
-
- @Test
-
- public void postProcessRollback() {
- ExecutionEntity mex = setupMock()
- WorkflowException wfe = mock(WorkflowException.class)
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prevWorkflowException")).thenReturn(wfe)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.postProcessRollback(mex)
-
- verify(mex).setVariable("WorkflowException", wfe)
- verify(mex).setVariable("rollbackData", null)
-
- }
-
- @Test
-
- public void postProcessRollback_NotWFE() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prevWorkflowException")).thenReturn("I'm not a WFE")
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.postProcessRollback(mex)
-
-// verify(mex, never()).setVariable("WorkflowException", any())
- verify(mex).setVariable("rollbackData", null)
-
- }
-
- @Test
-
- public void postProcessRollback_BpmnError() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.postProcessRollback(mex) }))
- verify(mex, never()).setVariable("rollbackData", null)
-
- }
-
- @Test
-
- public void postProcessRollback_Ex() {
- ExecutionEntity mex = setupMock()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- DoCreateAllottedResourceTXC.postProcessRollback(mex)
- verify(mex, never()).setVariable("rollbackData", null)
-
- }
-
- private boolean checkMissingPreProcessRequest(String fieldnm) {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
-
- when(mex.getVariable(fieldnm)).thenReturn("")
-
- return doBpmnError( { _ -> DoCreateAllottedResourceTXC.preProcessRequest(mex) })
- }
-
- private void initPreProcess(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn")
- when(mex.getVariable("mso.workflow.sdnc.replication.delay")).thenReturn("sdncdelay")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
- when(mex.getVariable("allottedResourceModelInfo")).thenReturn("armi")
- when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma")
- when(mex.getVariable("allottedResourceRole")).thenReturn("arr")
- when(mex.getVariable("allottedResourceType")).thenReturn("art")
- }
-
- private void initGetAaiAR(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("allottedResourceType")).thenReturn("TXCt")
- when(mex.getVariable("allottedResourceRole")).thenReturn("TXCr")
- when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml"))
- when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
- }
-
- private initCreateAaiAr(ExecutionEntity mex) {
- when(mex.getVariable("disableRollback")).thenReturn(45)
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
- when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace"))
- when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath( "/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST).build()))
- when(mex.getVariable("allottedResourceType")).thenReturn("TXCt")
- when(mex.getVariable("allottedResourceRole")).thenReturn("TXCr")
- when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mycsi")
- when(mex.getVariable("allottedResourceModelInfo")).thenReturn("""
- {
- "modelInvariantUuid":"modelinvuuid",
- "modelUuid":"modeluuid",
- "modelCustomizationUuid":"modelcustuuid"
- }
- """)
- }
-
- private initBuildSDNCRequest(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("allottedResourceId")).thenReturn("ari")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
- when(mex.getVariable("subscriptionServiceType")).thenReturn("sst")
- when(mex.getVariable("globalCustomerId")).thenReturn("gci")
- when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu")
- when(mex.getVariable("msoRequestId")).thenReturn("mri")
- }
-
- private RollbackData initPreProcessSDNC(ExecutionEntity mex) {
- def data = new RollbackData()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("rollbackData")).thenReturn(data)
-
- return data
- }
-
- private initPreProcessSDNCGet(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl")
- when(mex.getVariable("foundActiveAR")).thenReturn(true)
- when(mex.getVariable("aaiARGetResponse")).thenReturn("<selflink>arlink</selflink>")
- when(mex.getVariable("sdncAssignResponse")).thenReturn("<response-data>&lt;object-path&gt;assignlink&lt;/object-path&gt;</response-data>")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl")
- }
-
- private RollbackData initValidateSDNCResp(ExecutionEntity mex) {
- def data = new RollbackData()
-
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prefix")).thenReturn(Prefix)
- when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
- when(mex.getVariable("rollbackData")).thenReturn(data)
-
- return data
- }
-
- private String initValidateSDNCResp_Resp() {
- return "<response-data>&lt;response-code&gt;200&lt;/response-code&gt;</response-data>"
- }
-
- private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
- }
-
+ public void init() {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ public DoCreateAllottedResourceTXCTest() {
+ super("DoCreateAllottedResourceTXC")
+ }
+
+ // ***** preProcessRequest *****
+ @Test
+ public void preProcessRequest() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+
+ assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback"))
+ assertTrue(checkMissingPreProcessRequest("mso.workflow.sdnc.replication.delay"))
+ assertTrue(checkMissingPreProcessRequest("serviceInstanceId"))
+ assertTrue(checkMissingPreProcessRequest("parentServiceInstanceId"))
+ assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo"))
+ assertTrue(checkMissingPreProcessRequest("brgWanMacAddress"))
+ assertTrue(checkMissingPreProcessRequest("allottedResourceRole"))
+ assertTrue(checkMissingPreProcessRequest("allottedResourceType"))
+ }
+
+ // ***** getAaiAR *****
+
+ @Test
+ @Ignore
+ public void getAaiAR() {
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
+
+ ExecutionEntity mex = setupMock()
+ initGetAaiAR(mex)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.getAaiAR(mex)
+
+ verify(mex).setVariable("foundActiveAR", true)
+ }
+
+ @Test
+
+ public void getAaiAR_Duplicate() {
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
+
+ ExecutionEntity mex = setupMock()
+ initGetAaiAR(mex)
+
+ // fail if duplicate
+ when(mex.getVariable("failExists")).thenReturn("true")
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.getAaiAR(mex) }))
+ }
+
+ @Test
+ public void getAaiAR_NotActive() {
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
+
+ ExecutionEntity mex = setupMock()
+ initGetAaiAR(mex)
+
+ // not active
+ when(mex.getVariable("aaiAROrchStatus")).thenReturn("not-active")
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.getAaiAR(mex) }))
+ }
+
+ @Test
+ @Ignore
+ public void getAaiAR_NoStatus() {
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
+
+ ExecutionEntity mex = setupMock()
+ initGetAaiAR(mex)
+
+ when(mex.getVariable("aaiAROrchStatus")).thenReturn(null)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.getAaiAR(mex)
+
+ verify(mex, never()).setVariable("foundActiveAR", true)
+ }
+
+ // ***** createAaiAR *****
+
+ @Test
+ public void createAaiAR() {
+ ExecutionEntity mex = setupMock()
+ initCreateAaiAr(mex)
+ when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath("/aai/v9/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST).build()))
+ when(mex.getVariable("CSI_resourceLink")).thenReturn("/aai/v9/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST)
+ when(mex.getVariable("allottedResourceModelInfo")).thenReturn("{\n" +
+ " \"modelInvariantUuid\":\"modelInvariantUuid\",\n" +
+ " \"modelUuid\" : \"modelUuid\"\n" +
+ "}")
+ AAIResourcesClient client = mock(AAIResourcesClient.class)
+ DoCreateAllottedResourceTXC doCreateAllottedResourceTXC = spy(DoCreateAllottedResourceTXC.class)
+ when(doCreateAllottedResourceTXC.getAAIClient()).thenReturn(client)
+ doCreateAllottedResourceTXC.createAaiAR(mex)
+ }
+
+
+ @Test
+ public void createAaiAR_MissingPsiLink() {
+ ExecutionEntity mex = setupMock()
+ initCreateAaiAr(mex)
+
+ when(mex.getVariable("PSI_resourceLink")).thenReturn(null)
+
+ MockPutAllottedResource(CUST, SVC, INST, ARID)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) }))
+ }
+
+ @Test
+ public void createAaiAR_HttpFailed() {
+ ExecutionEntity mex = setupMock()
+ initCreateAaiAr(mex)
+
+ MockPutAllottedResource_500(CUST, SVC, INST, ARID)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) }))
+ }
+
+ @Test
+ public void createAaiAR_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initCreateAaiAr(mex)
+
+ when(mex.getVariable("aai.endpoint")).thenThrow(new BpmnError("expected exception"))
+
+ MockPutAllottedResource(CUST, SVC, INST, ARID)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) }))
+ }
+
+ @Test
+ public void createAaiAR_Ex() {
+ ExecutionEntity mex = setupMock()
+ initCreateAaiAr(mex)
+
+ when(mex.getVariable("aai.endpoint")).thenThrow(new RuntimeException("expected exception"))
+
+ MockPutAllottedResource(CUST, SVC, INST, ARID)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) }))
+ }
+
+ // ***** buildSDNCRequest *****
+
+ @Test
+ public void buildSDNCRequest() {
+ ExecutionEntity mex = setupMock()
+ initBuildSDNCRequest(mex)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ String result = DoCreateAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq")
+
+ assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
+ assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
+ assertTrue(result.indexOf("<service-instance-id>sii</") >= 0)
+ assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
+ assertTrue(result.indexOf("<subscription-service-type>sst</") >= 0)
+ assertTrue(result.indexOf("<global-customer-id>gci</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
+ assertTrue(result.indexOf("<request-id>mri</") >= 0)
+ assertTrue(result.indexOf("<model-invariant-uuid/>") >= 0)
+ assertTrue(result.indexOf("<model-uuid/>") >= 0)
+ assertTrue(result.indexOf("<model-customization-uuid/>") >= 0)
+ assertTrue(result.indexOf("<model-version/>") >= 0)
+ assertTrue(result.indexOf("<model-name/>") >= 0)
+ }
+
+ @Test
+ public void buildSDNCRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ initBuildSDNCRequest(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") }))
+ }
+
+ // ***** preProcessSDNCAssign *****
+
+ @Test
+ public void preProcessSDNCAssign() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ def data = initPreProcessSDNC(mex)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex)
+
+ def req = map.get("sdncAssignRequest")
+ assertNotNull(req)
+
+ assertEquals(data, map.get("rollbackData"))
+
+ def rbreq = data.get(Prefix, "sdncAssignRollbackReq")
+
+ assertTrue(req.indexOf("<sdncadapter:SvcAction>assign</") >= 0)
+ assertTrue(req.indexOf("<request-action>CreateTunnelXConnInstance</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+
+ assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>unassign</") >= 0)
+ assertTrue(rbreq.indexOf("<request-action>DeleteTunnelXConnInstance</") >= 0)
+ assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
+ }
+
+ @Test
+ public void preProcessSDNCAssign_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) }))
+ }
+
+ @Test
+ public void preProcessSDNCAssign_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) }))
+ }
+
+ // ***** preProcessSDNCCreate *****
+
+ @Test
+ public void preProcessSDNCCreate() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ def data = initPreProcessSDNC(mex)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex)
+
+ def req = map.get("sdncCreateRequest")
+ assertNotNull(req)
+
+ assertEquals(data, map.get("rollbackData"))
+
+ def rbreq = data.get(Prefix, "sdncCreateRollbackReq")
+
+ assertTrue(req.indexOf("<sdncadapter:SvcAction>create</") >= 0)
+ assertTrue(req.indexOf("<request-action>CreateTunnelXConnInstance</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+
+ assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>delete</") >= 0)
+ assertTrue(rbreq.indexOf("<request-action>DeleteTunnelXConnInstance</") >= 0)
+ assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
+
+ }
+
+ @Test
+ public void preProcessSDNCCreate_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) }))
+ }
+
+ @Test
+ public void preProcessSDNCCreate_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) }))
+ }
+
+ // ***** preProcessSDNCActivate *****
+
+ @Test
+ public void preProcessSDNCActivate() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ def data = initPreProcessSDNC(mex)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex)
+
+ def req = map.get("sdncActivateRequest")
+ assertNotNull(req)
+
+ assertEquals(data, map.get("rollbackData"))
+
+ def rbreq = data.get(Prefix, "sdncActivateRollbackReq")
+
+ assertTrue(req.indexOf("<sdncadapter:SvcAction>activate</") >= 0)
+ assertTrue(req.indexOf("<request-action>CreateTunnelXConnInstance</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+
+ assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>deactivate</") >= 0)
+ assertTrue(rbreq.indexOf("<request-action>DeleteTunnelXConnInstance</") >= 0)
+ assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
+
+ }
+
+ @Test
+ public void preProcessSDNCActivate_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) }))
+ }
+
+ @Test
+ public void preProcessSDNCActivate_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) }))
+ }
+
+ // ***** validateSDNCResp *****
+
+ @Test
+ public void validateSDNCResp() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ def data = initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create")
+
+ verify(mex).getVariable("WorkflowException")
+ verify(mex).getVariable("SDNCA_SuccessIndicator")
+ verify(mex).getVariable("rollbackData")
+
+ assertEquals(data, map.get("rollbackData"))
+
+ assertEquals("true", data.get(Prefix, "rollback" + "SDNCcreate"))
+
+ }
+
+ @Test
+ public void validateSDNCResp_Get() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "get")
+
+ verify(mex).getVariable("WorkflowException")
+ verify(mex).getVariable("SDNCA_SuccessIndicator")
+
+ verify(mex, never()).getVariable("rollbackData")
+ }
+
+ @Test
+ public void validateSDNCResp_Unsuccessful() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ // unsuccessful
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(false)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ public void validateSDNCResp_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ public void validateSDNCResp_Ex() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp()
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ // ***** preProcessSDNCGet *****
+
+ @Test
+ public void preProcessSDNCGet_FoundAR() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessSDNCGet(mex)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.preProcessSDNCGet(mex)
+
+ String req = map.get("sdncGetRequest")
+
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:SvcOperation>arlink</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:CallbackUrl>myurl</") >= 0)
+
+ }
+
+ @Test
+ public void preProcessSDNCGet_NotFoundAR() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessSDNCGet(mex)
+
+ when(mex.getVariable("foundActiveAR")).thenReturn(false)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.preProcessSDNCGet(mex)
+
+ String req = map.get("sdncGetRequest")
+
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:SvcOperation>assignlink</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:CallbackUrl>myurl</") >= 0)
+
+ }
+
+ @Test
+ public void preProcessSDNCGet_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNCGet(mex)
+
+ when(mex.getVariable("foundActiveAR")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCGet(mex) }))
+ }
+
+ // ***** updateAaiAROrchStatus *****
+
+ @Test
+ @Ignore
+ public void updateAaiAROrchStatus() {
+ MockPatchAllottedResource(CUST, SVC, INST, ARID)
+
+ ExecutionEntity mex = setupMock()
+ initUpdateAaiAROrchStatus(mex)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.updateAaiAROrchStatus(mex, "success")
+ }
+
+ // ***** generateOutputs *****
+
+ @Test
+ public void generateOutputs() {
+ ExecutionEntity mex = setupMock()
+ def txctop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml")
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("enhancedCallbackRequestData")).thenReturn(txctop)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.generateOutputs(mex)
+
+ verify(mex).setVariable("allotedResourceName", "namefromrequest")
+ verify(mex).setVariable("vni", "my-vni")
+ verify(mex).setVariable("vgmuxBearerIP", "my-bearer-ip")
+ verify(mex).setVariable("vgmuxLanIP", "my-lan-ip")
+
+ }
+
+ @Test
+ public void generateOutputs_BadXml() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("enhancedCallbackRequestData")).thenReturn("invalid xml")
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.generateOutputs(mex)
+
+ verify(mex, never()).setVariable(anyString(), anyString())
+
+ }
+
+ @Test
+ public void generateOutputs_BpmnError() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ DoCreateAllottedResourceTXC.generateOutputs(mex)
+ verify(mex, never()).setVariable(anyString(), anyString())
+
+ }
+
+ @Test
+ public void generateOutputs_Ex() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ DoCreateAllottedResourceTXC.generateOutputs(mex)
+ verify(mex, never()).setVariable(anyString(), anyString())
+
+ }
+
+ // ***** preProcessRollback *****
+
+ @Test
+ public void preProcessRollback() {
+ ExecutionEntity mex = setupMock()
+ WorkflowException wfe = mock(WorkflowException.class)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("WorkflowException")).thenReturn(wfe)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.preProcessRollback(mex)
+
+ verify(mex).setVariable("prevWorkflowException", wfe)
+
+ }
+
+ @Test
+ public void preProcessRollback_NotWFE() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("WorkflowException")).thenReturn("I'm not a WFE")
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.preProcessRollback(mex)
+
+ verify(mex, never()).setVariable(eq("prevWorkflowException"), any())
+
+ }
+
+ @Test
+ public void preProcessRollback_BpmnError() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ DoCreateAllottedResourceTXC.preProcessRollback(mex)
+
+ }
+
+ @Test
+ public void preProcessRollback_Ex() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ DoCreateAllottedResourceTXC.preProcessRollback(mex)
+
+ }
+
+ // ***** postProcessRollback *****
+
+ @Test
+ public void postProcessRollback() {
+ ExecutionEntity mex = setupMock()
+ WorkflowException wfe = mock(WorkflowException.class)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prevWorkflowException")).thenReturn(wfe)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.postProcessRollback(mex)
+
+ verify(mex).setVariable("WorkflowException", wfe)
+ verify(mex).setVariable("rollbackData", null)
+
+ }
+
+ @Test
+ public void postProcessRollback_NotWFE() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prevWorkflowException")).thenReturn("I'm not a WFE")
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+ DoCreateAllottedResourceTXC.postProcessRollback(mex)
+
+ verify(mex, never()).setVariable(eq("WorkflowException"), any())
+ verify(mex).setVariable("rollbackData", null)
+
+ }
+
+ @Test
+ public void postProcessRollback_BpmnError() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.postProcessRollback(mex) }))
+ verify(mex, never()).setVariable("rollbackData", null)
+
+ }
+
+ @Test
+ public void postProcessRollback_Ex() {
+ ExecutionEntity mex = setupMock()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ DoCreateAllottedResourceTXC.postProcessRollback(mex)
+ verify(mex, never()).setVariable("rollbackData", null)
+
+ }
+
+ private boolean checkMissingPreProcessRequest(String fieldnm) {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
+
+ when(mex.getVariable(fieldnm)).thenReturn("")
+
+ return doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessRequest(mex) })
+ }
+
+ private void initPreProcess(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn")
+ when(mex.getVariable("mso.workflow.sdnc.replication.delay")).thenReturn("sdncdelay")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
+ when(mex.getVariable("allottedResourceModelInfo")).thenReturn("armi")
+ when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma")
+ when(mex.getVariable("allottedResourceRole")).thenReturn("arr")
+ when(mex.getVariable("allottedResourceType")).thenReturn("art")
+ }
+
+ private void initGetAaiAR(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("allottedResourceType")).thenReturn("TXCt")
+ when(mex.getVariable("allottedResourceRole")).thenReturn("TXCr")
+ when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml"))
+ when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
+ when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
+ }
+
+ private initCreateAaiAr(ExecutionEntity mex) {
+ when(mex.getVariable("disableRollback")).thenReturn(45)
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
+ when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
+ when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace"))
+ when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST).build()))
+ when(mex.getVariable("allottedResourceType")).thenReturn("TXCt")
+ when(mex.getVariable("allottedResourceRole")).thenReturn("TXCr")
+ when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx + "/aai/v9/mycsi")
+ when(mex.getVariable("allottedResourceModelInfo")).thenReturn("""
+ {
+ "modelInvariantUuid":"modelinvuuid",
+ "modelUuid":"modeluuid",
+ "modelCustomizationUuid":"modelcustuuid"
+ }
+ """)
+ }
+
+ private initBuildSDNCRequest(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("allottedResourceId")).thenReturn("ari")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
+ when(mex.getVariable("subscriptionServiceType")).thenReturn("sst")
+ when(mex.getVariable("globalCustomerId")).thenReturn("gci")
+ when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu")
+ when(mex.getVariable("msoRequestId")).thenReturn("mri")
+ }
+
+ private RollbackData initPreProcessSDNC(ExecutionEntity mex) {
+ def data = new RollbackData()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("rollbackData")).thenReturn(data)
+
+ return data
+ }
+
+ private initPreProcessSDNCGet(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl")
+ when(mex.getVariable("foundActiveAR")).thenReturn(true)
+ when(mex.getVariable("aaiARGetResponse")).thenReturn("<selflink>arlink</selflink>")
+ when(mex.getVariable("sdncAssignResponse")).thenReturn("<response-data>&lt;object-path&gt;assignlink&lt;/object-path&gt;</response-data>")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl")
+ }
+
+ private RollbackData initValidateSDNCResp(ExecutionEntity mex) {
+ def data = new RollbackData()
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prefix")).thenReturn(Prefix)
+ when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
+ when(mex.getVariable("rollbackData")).thenReturn(data)
+
+ return data
+ }
+
+ private String initValidateSDNCResp_Resp() {
+ return "<response-data>&lt;response-code&gt;200&lt;/response-code&gt;</response-data>"
+ }
+
+ private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/" + ARID)
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy
index 0528529819..e77c1dd9ed 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -20,19 +22,15 @@
package org.onap.so.bpmn.vcpe.scripts
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.junit.Before
-import org.junit.BeforeClass
-import org.junit.Rule
-import org.junit.Test
-import org.junit.Ignore
+import org.junit.*
import org.mockito.MockitoAnnotations
-import org.camunda.bpm.engine.delegate.BpmnError
import org.mockito.Spy
import org.onap.so.bpmn.core.UrnPropertiesReader
-import org.onap.so.bpmn.mock.FileUtil
-import org.onap.so.client.aai.entities.uri.AAIResourceUri
-import static org.junit.Assert.*;
+
+import static org.junit.Assert.assertTrue
+import static org.mockito.ArgumentMatchers.eq
import static org.mockito.Mockito.*
import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
@@ -41,533 +39,497 @@ import com.github.tomakehurst.wiremock.junit.WireMockRule
class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(PORT)
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(PORT)
+
+ String Prefix = "DDARBRG_"
- String Prefix = "DDARBRG_"
+ @BeforeClass
+ public static void setUpBeforeClass() {
+ GroovyTestBase.setUpBeforeClass()
+ }
- @BeforeClass
- public static void setUpBeforeClass() {
- super.setUpBeforeClass()
- }
+ @Spy
+ DoDeleteAllottedResourceBRG doDeleteAllottedResourceBRG
- @Spy
- DoDeleteAllottedResourceBRG doDeleteAllottedResourceBRG
-
@Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
- super.init()
- when(doDeleteAllottedResourceBRG.getAllottedResourceUtils()).thenReturn(allottedResourceUtils_MOCK)
- }
-
- public DoDeleteAllottedResourceBRGTest() {
- super("DoDeleteAllottedResourceBRG")
- }
-
-
- // ***** preProcessRequest *****
-
- @Test
-// @Ignore
- public void preProcessRequest() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
- DoDeleteAllottedResourceBRG.preProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("sdncCallbackUrl", "sdncurn")
-
- assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback"))
- assertTrue(checkMissingPreProcessRequest("serviceInstanceId"))
- assertTrue(checkMissingPreProcessRequest("allottedResourceId"))
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("serviceInstanceId")).thenThrow(new BpmnError("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) }))
- }
-
-
- // ***** getAaiAR *****
-
- @Test
+ public void init() {
+ MockitoAnnotations.initMocks(this)
+ initAllottedResourceMock()
+ }
+
+ public DoDeleteAllottedResourceBRGTest() {
+ super("DoDeleteAllottedResourceBRG")
+ }
+
+ // ***** preProcessRequest *****
+
+ @Test
+ public void preProcessRequest() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+ DoDeleteAllottedResourceBRG.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("sdncCallbackUrl", "sdncurn")
+
+ assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback"))
+ assertTrue(checkMissingPreProcessRequest("serviceInstanceId"))
+ assertTrue(checkMissingPreProcessRequest("allottedResourceId"))
+ }
+
+ @Test
+ public void preProcessRequest_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("serviceInstanceId")).thenThrow(new BpmnError("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) }))
+ }
+
+ @Test
+ public void preProcessRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) }))
+ }
+
+ // ***** getAaiAR *****
+
+ @Test
+ public void getAaiAR() {
+ ExecutionEntity mex = setupMock()
+ initGetAaiAR(mex)
+ when(doDeleteAllottedResourceBRG.getAllottedResourceUtils()).thenReturn(allottedResourceUtils_MOCK)
+ doReturn(true).when(allottedResourceUtils_MOCK).ifExistsAR(eq(mex), eq(ARID))
+ doDeleteAllottedResourceBRG.getAaiAR(mex)
+ verify(mex).setVariable("parentServiceInstanceId", INST)
+ }
+
+ @Test
+ public void getAaiAR_EmptyResponse() {
+ ExecutionEntity mex = setupMock()
+ initGetAaiAR(mex)
+ doReturn(false).when(allottedResourceUtils_MOCK).ifExistsAR(eq(mex), eq(ARID))
+ assertTrue(doBpmnError({ _ -> doDeleteAllottedResourceBRG.getAaiAR(mex) }))
+ }
+
+ // ***** updateAaiAROrchStatus *****
+
+ @Test
@Ignore
- public void getAaiAR() {
- ExecutionEntity mex = setupMock()
- initGetAaiAR(mex)
- when(client_MOCK.exists(any(AAIResourceUri.class))).thenReturn(true)
- doDeleteAllottedResourceBRG.getAaiAR(mex)
- verify(mex).setVariable("parentServiceInstanceId", INST)
- }
-
- @Test
- public void getAaiAR_EmptyResponse() {
- ExecutionEntity mex = setupMock()
- initGetAaiAR(mex)
- when(client_MOCK.exists(any(AAIResourceUri.class))).thenReturn(false)
- assertTrue(doBpmnError( { _ -> doDeleteAllottedResourceBRG.getAaiAR(mex) }))
- }
-
-
- // ***** updateAaiAROrchStatus *****
-
- @Test
- @Ignore
- public void updateAaiAROrchStatus() {
- ExecutionEntity mex = setupMock()
- initUpdateAaiAROrchStatus(mex)
-
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
- DoDeleteAllottedResourceBRG.updateAaiAROrchStatus(mex, "success")
- }
-
-
- // ***** buildSDNCRequest *****
-
- @Test
-// @Ignore
- public void buildSDNCRequest() {
- ExecutionEntity mex = setupMock()
- initBuildSDNCRequest(mex)
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- String result = DoDeleteAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq")
-
- assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
- assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
- assertTrue(result.indexOf("<service-instance-id>sii</") >= 0)
- assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
- assertTrue(result.indexOf("<subscription-service-type>sst</") >= 0)
- assertTrue(result.indexOf("<global-customer-id>gci</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
- assertTrue(result.indexOf("<request-id>mri</") >= 0)
- assertTrue(result.indexOf("<model-invariant-uuid/>") >= 0)
- assertTrue(result.indexOf("<model-uuid/>") >= 0)
- assertTrue(result.indexOf("<model-customization-uuid/>") >= 0)
- assertTrue(result.indexOf("<model-version/>") >= 0)
- assertTrue(result.indexOf("<model-name/>") >= 0)
- }
-
- @Test
-// @Ignore
- public void buildSDNCRequest_Ex() {
- ExecutionEntity mex = setupMock()
- initBuildSDNCRequest(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") }))
- }
-
-
- // ***** preProcessSDNCUnassign *****
-
- @Test
-// @Ignore
- public void preProcessSDNCUnassign() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcessSDNC(mex)
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
- DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex)
-
- def req = map.get("sdncUnassignRequest")
-
- assertTrue(req.indexOf("<sdncadapter:SvcAction>unassign</") >= 0)
- assertTrue(req.indexOf("<request-action>DeleteBRGInstance</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCUnassign_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCUnassign_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) }))
- }
-
-
- // ***** preProcessSDNCDelete *****
-
- @Test
-// @Ignore
- public void preProcessSDNCDelete() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcessSDNC(mex)
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
- DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex)
-
- def req = map.get("sdncDeleteRequest")
-
- assertTrue(req.indexOf("<sdncadapter:SvcAction>delete</") >= 0)
- assertTrue(req.indexOf("<request-action>DeleteBRGInstance</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCDelete_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCDelete_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) }))
- }
-
-
- // ***** preProcessSDNCDeactivate *****
-
- @Test
-// @Ignore
- public void preProcessSDNCDeactivate() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcessSDNC(mex)
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
- DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex)
-
- def req = map.get("sdncDeactivateRequest")
-
- assertTrue(req.indexOf("<sdncadapter:SvcAction>deactivate</") >= 0)
- assertTrue(req.indexOf("<request-action>DeleteBRGInstance</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCDeactivate_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCDeactivate_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) }))
- }
-
-
- // ***** validateSDNCResp *****
-
- @Test
-// @Ignore
- public void validateSDNCResp() {
- ExecutionEntity mex = setupMock()
- def data = initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp(200)
-
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create")
-
- verify(mex).getVariable("WorkflowException")
- verify(mex).getVariable("SDNCA_SuccessIndicator")
- verify(mex).getVariable(Prefix+"sdncResponseSuccess")
-
- verify(mex, never()).getVariable(Prefix + "sdncRequestDataResponseCode")
- verify(mex, never()).setVariable("wasDeleted", false)
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Fail404_Deactivate_FailNotFound() {
- ExecutionEntity mex = setupMock()
- def data = initValidateSDNCResp(mex)
-
- def resp = initValidateSDNCResp_Resp(404)
- when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404")
- when(mex.getVariable("failNotFound")).thenReturn("true")
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")}))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Fail404_Deactivate() {
- ExecutionEntity mex = setupMock()
- def data = initValidateSDNCResp(mex)
-
- def resp = initValidateSDNCResp_Resp(404)
- when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404")
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")
-
- verify(mex).setVariable("ARNotFoundInSDNC", true)
- verify(mex).setVariable("wasDeleted", false)
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Fail404() {
- ExecutionEntity mex = setupMock()
- def data = initValidateSDNCResp(mex)
-
- def resp = initValidateSDNCResp_Resp(404)
- when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404")
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create")}))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Deactivate() {
- ExecutionEntity mex = setupMock()
- def data = initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp(200)
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")}))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_BpmnError() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp(200)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Ex() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp(200)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
- @Ignore
- public void deleteAaiAR() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
- DoDeleteAllottedResourceBRG.deleteAaiAR(mex)
- }
-
- @Test
-// @Ignore
- public void deleteAaiAR_NoArPath() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- when(mex.getVariable("aaiARPath")).thenReturn("")
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) }))
- }
-
- @Test
-// @Ignore
- public void deleteAaiAR_BpmnError() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) }))
- }
-
- @Test
-// @Ignore
- public void deleteAaiAR_Ex() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) }))
- }
-
- private boolean checkMissingPreProcessRequest(String fieldnm) {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- when(mex.getVariable(fieldnm)).thenReturn("")
-
- return doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) })
- }
-
- private void initPreProcess(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("allottedResourceId")).thenReturn("ari")
- }
-
- private void initGetAaiAR(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("allottedResourceType")).thenReturn("BRG")
- when(mex.getVariable("allottedResourceRole")).thenReturn("BRG")
- when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
- when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoDeleteAllottedResourceBRG/getAR.xml"))
- when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace"))
- when(mex.getVariable("mso.workflow.global.default.aai.version")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.version"))
- when(mex.getVariable("mso.workflow.default.aai.v8.nodes.query.uri")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.default.aai.v8.nodes-query.uri"))
- when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
- when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
- }
-
- private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
- }
-
- private initBuildSDNCRequest(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("allottedResourceId")).thenReturn("ari")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
- when(mex.getVariable("subscriptionServiceType")).thenReturn("sst")
- when(mex.getVariable("globalCustomerId")).thenReturn("gci")
- when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu")
- when(mex.getVariable("msoRequestId")).thenReturn("mri")
- }
-
- private initPreProcessSDNC(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- }
-
- private initValidateSDNCResp(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prefix")).thenReturn(Prefix)
- when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
- }
-
- private String initValidateSDNCResp_Resp(int code) {
- return "<response-data>&lt;response-code&gt;${code}&lt;/response-code&gt;</response-data>"
- }
-
- private initDeleteAaiAR(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
- when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers")
- when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- }
-
+ public void updateAaiAROrchStatus() {
+ ExecutionEntity mex = setupMock()
+ initUpdateAaiAROrchStatus(mex)
+
+ MockPatchAllottedResource(CUST, SVC, INST, ARID)
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+ DoDeleteAllottedResourceBRG.updateAaiAROrchStatus(mex, "success")
+ }
+
+ // ***** buildSDNCRequest *****
+
+ @Test
+ public void buildSDNCRequest() {
+ ExecutionEntity mex = setupMock()
+ initBuildSDNCRequest(mex)
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ String result = DoDeleteAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq")
+
+ assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
+ assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
+ assertTrue(result.indexOf("<service-instance-id>sii</") >= 0)
+ assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
+ assertTrue(result.indexOf("<subscription-service-type>sst</") >= 0)
+ assertTrue(result.indexOf("<global-customer-id>gci</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
+ assertTrue(result.indexOf("<request-id>mri</") >= 0)
+ assertTrue(result.indexOf("<model-invariant-uuid/>") >= 0)
+ assertTrue(result.indexOf("<model-uuid/>") >= 0)
+ assertTrue(result.indexOf("<model-customization-uuid/>") >= 0)
+ assertTrue(result.indexOf("<model-version/>") >= 0)
+ assertTrue(result.indexOf("<model-name/>") >= 0)
+ }
+
+ @Test
+ public void buildSDNCRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ initBuildSDNCRequest(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") }))
+ }
+
+ // ***** preProcessSDNCUnassign *****
+
+ @Test
+ public void preProcessSDNCUnassign() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessSDNC(mex)
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+ DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex)
+
+ def req = map.get("sdncUnassignRequest")
+
+ assertTrue(req.indexOf("<sdncadapter:SvcAction>unassign</") >= 0)
+ assertTrue(req.indexOf("<request-action>DeleteBRGInstance</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+ }
+
+ @Test
+ public void preProcessSDNCUnassign_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) }))
+ }
+
+ @Test
+ public void preProcessSDNCUnassign_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) }))
+ }
+
+ // ***** preProcessSDNCDelete *****
+
+ @Test
+ public void preProcessSDNCDelete() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessSDNC(mex)
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+ DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex)
+
+ def req = map.get("sdncDeleteRequest")
+
+ assertTrue(req.indexOf("<sdncadapter:SvcAction>delete</") >= 0)
+ assertTrue(req.indexOf("<request-action>DeleteBRGInstance</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+ }
+
+ @Test
+ public void preProcessSDNCDelete_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) }))
+ }
+
+ @Test
+ public void preProcessSDNCDelete_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) }))
+ }
+
+ // ***** preProcessSDNCDeactivate *****
+
+ @Test
+ public void preProcessSDNCDeactivate() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessSDNC(mex)
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+ DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex)
+
+ def req = map.get("sdncDeactivateRequest")
+
+ assertTrue(req.indexOf("<sdncadapter:SvcAction>deactivate</") >= 0)
+ assertTrue(req.indexOf("<request-action>DeleteBRGInstance</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+ }
+
+ @Test
+ public void preProcessSDNCDeactivate_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) }))
+ }
+
+ @Test
+ public void preProcessSDNCDeactivate_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) }))
+ }
+
+ // ***** validateSDNCResp *****
+
+ @Test
+ public void validateSDNCResp() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp(200)
+
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create")
+
+ verify(mex).getVariable("WorkflowException")
+ verify(mex).getVariable("SDNCA_SuccessIndicator")
+ verify(mex).getVariable(Prefix + "sdncResponseSuccess")
+
+ verify(mex, never()).getVariable(Prefix + "sdncRequestDataResponseCode")
+ verify(mex, never()).setVariable("wasDeleted", false)
+ }
+
+ @Test
+ public void validateSDNCResp_Fail404_Deactivate_FailNotFound() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+
+ def resp = initValidateSDNCResp_Resp(404)
+ when(mex.getVariable(Prefix + "sdncRequestDataResponseCode")).thenReturn("404")
+ when(mex.getVariable("failNotFound")).thenReturn("true")
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate") }))
+ }
+
+ @Test
+ public void validateSDNCResp_Fail404_Deactivate() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+
+ def resp = initValidateSDNCResp_Resp(404)
+ when(mex.getVariable(Prefix + "sdncRequestDataResponseCode")).thenReturn("404")
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")
+
+ verify(mex).setVariable("ARNotFoundInSDNC", true)
+ verify(mex).setVariable("wasDeleted", false)
+ }
+
+ @Test
+ public void validateSDNCResp_Fail404() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+
+ def resp = initValidateSDNCResp_Resp(404)
+ when(mex.getVariable(Prefix + "sdncRequestDataResponseCode")).thenReturn("404")
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ public void validateSDNCResp_Deactivate() {
+ ExecutionEntity mex = setupMock()
+ def data = initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp(200)
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate") }))
+ }
+
+ @Test
+ public void validateSDNCResp_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp(200)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ public void validateSDNCResp_Ex() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp(200)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ @Ignore
+ public void deleteAaiAR() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+ DoDeleteAllottedResourceBRG.deleteAaiAR(mex)
+ }
+
+ @Test
+ public void deleteAaiAR_NoArPath() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ when(mex.getVariable("aaiARPath")).thenReturn("")
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) }))
+ }
+
+ @Test
+ public void deleteAaiAR_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) }))
+ }
+
+ @Test
+ public void deleteAaiAR_Ex() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) }))
+ }
+
+ private boolean checkMissingPreProcessRequest(String fieldnm) {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
+
+ when(mex.getVariable(fieldnm)).thenReturn("")
+
+ return doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) })
+ }
+
+ private void initPreProcess(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("allottedResourceId")).thenReturn("ari")
+ }
+
+ private void initGetAaiAR(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("allottedResourceType")).thenReturn("BRG")
+ when(mex.getVariable("allottedResourceRole")).thenReturn("BRG")
+ when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
+ when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace"))
+ when(mex.getVariable("mso.workflow.global.default.aai.version")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.version"))
+ when(mex.getVariable("mso.workflow.default.aai.v8.nodes.query.uri")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.default.aai.v8.nodes-query.uri"))
+ when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/" + ARID)
+ when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
+ }
+
+ private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/" + ARID)
+ }
+
+ private initBuildSDNCRequest(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("allottedResourceId")).thenReturn("ari")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
+ when(mex.getVariable("subscriptionServiceType")).thenReturn("sst")
+ when(mex.getVariable("globalCustomerId")).thenReturn("gci")
+ when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu")
+ when(mex.getVariable("msoRequestId")).thenReturn("mri")
+ }
+
+ private initPreProcessSDNC(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ }
+
+ private initValidateSDNCResp(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prefix")).thenReturn(Prefix)
+ when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
+ }
+
+ private String initValidateSDNCResp_Resp(int code) {
+ return "<response-data>&lt;response-code&gt;${code}&lt;/response-code&gt;</response-data>"
+ }
+
+ private initDeleteAaiAR(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/" + ARID)
+ when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers")
+ when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy
index ad9b3d4f88..23115874a2 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -20,19 +22,15 @@
package org.onap.so.bpmn.vcpe.scripts
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.junit.Before
-import org.junit.BeforeClass
-import org.junit.Rule
-import org.junit.Test
-import org.junit.Ignore
+import org.junit.*
import org.mockito.MockitoAnnotations
-import org.camunda.bpm.engine.delegate.BpmnError
import org.mockito.Spy
import org.onap.so.bpmn.core.UrnPropertiesReader
-import org.onap.so.bpmn.mock.FileUtil
-import org.onap.so.client.aai.entities.uri.AAIResourceUri
-import static org.junit.Assert.*;
+
+import static org.junit.Assert.assertTrue
+import static org.mockito.ArgumentMatchers.eq
import static org.mockito.Mockito.*
import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
@@ -40,534 +38,498 @@ import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource
import com.github.tomakehurst.wiremock.junit.WireMockRule
class DoDeleteAllottedResourceTXCTest extends GroovyTestBase {
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(PORT)
- String Prefix = "DDARTXC_"
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(PORT)
+
+ String Prefix = "DDARTXC_"
@Spy
DoDeleteAllottedResourceTXC doDeleteAllottedResourceTXC
- @BeforeClass
- public static void setUpBeforeClass() {
- super.setUpBeforeClass()
- }
-
+ @BeforeClass
+ public static void setUpBeforeClass() {
+ GroovyTestBase.setUpBeforeClass()
+ }
+
@Before
- public void init()
- {
+ public void init() {
MockitoAnnotations.initMocks(this)
- super.init()
+ initAllottedResourceMock()
+ }
+
+ public DoDeleteAllottedResourceTXCTest() {
+ super("DoDeleteAllottedResourceTXC")
+ }
+
+ // ***** preProcessRequest *****
+
+ @Test
+ public void preProcessRequest() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+ DoDeleteAllottedResourceTXC.preProcessRequest(mex)
+
+ verify(mex).setVariable("prefix", Prefix)
+ verify(mex).setVariable("sdncCallbackUrl", "sdncurn")
+
+ assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback"))
+ assertTrue(checkMissingPreProcessRequest("serviceInstanceId"))
+ assertTrue(checkMissingPreProcessRequest("allottedResourceId"))
+ }
+
+ @Test
+ public void preProcessRequest_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("serviceInstanceId")).thenThrow(new BpmnError("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) }))
+ }
+
+ @Test
+ public void preProcessRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) }))
+ }
+
+ // ***** getAaiAR *****
+ @Test
+ public void getAaiAR() {
+
+ ExecutionEntity mex = setupMock()
+ initGetAaiAR(mex)
when(doDeleteAllottedResourceTXC.getAllottedResourceUtils()).thenReturn(allottedResourceUtils_MOCK)
- }
-
- public DoDeleteAllottedResourceTXCTest() {
- super("DoDeleteAllottedResourceTXC")
- }
-
-
- // ***** preProcessRequest *****
-
- @Test
-// @Ignore
- public void preProcessRequest() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
- DoDeleteAllottedResourceTXC.preProcessRequest(mex)
-
- //verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
- verify(mex).setVariable("sdncCallbackUrl", "sdncurn")
-
- assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback"))
- assertTrue(checkMissingPreProcessRequest("serviceInstanceId"))
- assertTrue(checkMissingPreProcessRequest("allottedResourceId"))
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("serviceInstanceId")).thenThrow(new BpmnError("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessRequest_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) }))
- }
-
-
- // ***** getAaiAR *****
- @Test
+ doReturn(true).when(allottedResourceUtils_MOCK).ifExistsAR(eq(mex), eq(ARID))
+ doDeleteAllottedResourceTXC.getAaiAR(mex)
+ verify(mex).setVariable("parentServiceInstanceId", INST)
+ }
+
+ @Test
+ public void getAaiAR_EmptyResponse() {
+ ExecutionEntity mex = setupMock()
+ initGetAaiAR(mex)
+ doReturn(false).when(allottedResourceUtils_MOCK).ifExistsAR(eq(mex), eq(ARID))
+ assertTrue(doBpmnError({ _ -> doDeleteAllottedResourceTXC.getAaiAR(mex) }))
+ }
+
+ // ***** updateAaiAROrchStatus *****
+
+ @Test
@Ignore
- public void getAaiAR() {
+ public void updateAaiAROrchStatus() {
+ ExecutionEntity mex = setupMock()
+ initUpdateAaiAROrchStatus(mex)
+
+ MockPatchAllottedResource(CUST, SVC, INST, ARID)
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+ DoDeleteAllottedResourceTXC.updateAaiAROrchStatus(mex, "success")
+ }
+
+ // ***** buildSDNCRequest *****
+
+ @Test
+ public void buildSDNCRequest() {
+ ExecutionEntity mex = setupMock()
+ initBuildSDNCRequest(mex)
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ String result = DoDeleteAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq")
+
+ assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
+ assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
+ assertTrue(result.indexOf("<service-instance-id>sii</") >= 0)
+ assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
+ assertTrue(result.indexOf("<subscription-service-type>sst</") >= 0)
+ assertTrue(result.indexOf("<global-customer-id>gci</") >= 0)
+ assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
+ assertTrue(result.indexOf("<request-id>mri</") >= 0)
+ assertTrue(result.indexOf("<model-invariant-uuid/>") >= 0)
+ assertTrue(result.indexOf("<model-uuid/>") >= 0)
+ assertTrue(result.indexOf("<model-customization-uuid/>") >= 0)
+ assertTrue(result.indexOf("<model-version/>") >= 0)
+ assertTrue(result.indexOf("<model-name/>") >= 0)
+ }
+
+ @Test
+ public void buildSDNCRequest_Ex() {
+ ExecutionEntity mex = setupMock()
+ initBuildSDNCRequest(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") }))
+ }
+
+ // ***** preProcessSDNCUnassign *****
+
+ @Test
+ public void preProcessSDNCUnassign() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessSDNC(mex)
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+ DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex)
+
+ def req = map.get("sdncUnassignRequest")
+
+ assertTrue(req.indexOf("<sdncadapter:SvcAction>unassign</") >= 0)
+ assertTrue(req.indexOf("<request-action>DeleteTunnelXConnInstance</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+ }
+
+ @Test
+ public void preProcessSDNCUnassign_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) }))
+ }
+
+ @Test
+ public void preProcessSDNCUnassign_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) }))
+ }
+
+ // ***** preProcessSDNCDelete *****
+
+ @Test
+ public void preProcessSDNCDelete() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessSDNC(mex)
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+ DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex)
+
+ def req = map.get("sdncDeleteRequest")
+
+ assertTrue(req.indexOf("<sdncadapter:SvcAction>delete</") >= 0)
+ assertTrue(req.indexOf("<request-action>DeleteTunnelXConnInstance</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+ }
+
+ @Test
+ public void preProcessSDNCDelete_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) }))
+ }
+
+ @Test
+ public void preProcessSDNCDelete_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) }))
+ }
+
+ // ***** preProcessSDNCDeactivate *****
+
+ @Test
+ public void preProcessSDNCDeactivate() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcessSDNC(mex)
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+ DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex)
+
+ def req = map.get("sdncDeactivateRequest")
+
+ assertTrue(req.indexOf("<sdncadapter:SvcAction>deactivate</") >= 0)
+ assertTrue(req.indexOf("<request-action>DeleteTunnelXConnInstance</") >= 0)
+ assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
+ }
+
+ @Test
+ public void preProcessSDNCDeactivate_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) }))
+ }
+
+ @Test
+ public void preProcessSDNCDeactivate_Ex() {
+ ExecutionEntity mex = setupMock()
+ initPreProcessSDNC(mex)
+
+ when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) }))
+ }
+
+ // ***** validateSDNCResp *****
+
+ @Test
+ public void validateSDNCResp() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp(200)
+
+ when(mex.getVariable(Prefix + "sdncResponseSuccess")).thenReturn(true)
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create")
+
+ verify(mex).getVariable("WorkflowException")
+ verify(mex).getVariable("SDNCA_SuccessIndicator")
+ verify(mex).getVariable(Prefix + "sdncResponseSuccess")
+
+ verify(mex, never()).getVariable(Prefix + "sdncRequestDataResponseCode")
+ verify(mex, never()).setVariable("wasDeleted", false)
+ }
+
+ @Test
+ public void validateSDNCResp_Fail404_Deactivate_FailNotFound() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+
+ def resp = initValidateSDNCResp_Resp(404)
+ when(mex.getVariable(Prefix + "sdncRequestDataResponseCode")).thenReturn("404")
+ when(mex.getVariable("failNotFound")).thenReturn("true")
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate") }))
+ }
+
+ @Test
+ public void validateSDNCResp_Fail404_Deactivate() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+
+ def resp = initValidateSDNCResp_Resp(404)
+ when(mex.getVariable(Prefix + "sdncRequestDataResponseCode")).thenReturn("404")
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate")
+
+ verify(mex).setVariable("ARNotFoundInSDNC", true)
+ verify(mex).setVariable("wasDeleted", false)
+ }
+
+ @Test
+ public void validateSDNCResp_Fail404() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+
+ def resp = initValidateSDNCResp_Resp(404)
+ when(mex.getVariable(Prefix + "sdncRequestDataResponseCode")).thenReturn("404")
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ public void validateSDNCResp_Deactivate() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp(200)
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate") }))
+ }
+
+ @Test
+ public void validateSDNCResp_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp(200)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ public void validateSDNCResp_Ex() {
+ ExecutionEntity mex = setupMock()
+ initValidateSDNCResp(mex)
+ def resp = initValidateSDNCResp_Resp(200)
+
+ when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") }))
+ }
+
+ @Test
+ @Ignore
+ public void deleteAaiAR() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+ DoDeleteAllottedResourceTXC.deleteAaiAR(mex)
+ }
+
+ @Test
+ public void deleteAaiAR_NoArPath() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ when(mex.getVariable("aaiARPath")).thenReturn("")
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) }))
+ }
+
+ @Test
+ public void deleteAaiAR_BpmnError() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) }))
+ }
+
+ @Test
+ public void deleteAaiAR_Ex() {
+ ExecutionEntity mex = setupMock()
+ initDeleteAaiAR(mex)
+
+ MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
+ MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
+
+ when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) }))
+ }
+
+ private boolean checkMissingPreProcessRequest(String fieldnm) {
+ ExecutionEntity mex = setupMock()
+ initPreProcess(mex)
+
+ DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
+
+ when(mex.getVariable(fieldnm)).thenReturn("")
+
+ return doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) })
+ }
+
+ private void initPreProcess(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("allottedResourceId")).thenReturn("ari")
+ }
+
+ private void initGetAaiAR(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("allottedResourceType")).thenReturn("TXC")
+ when(mex.getVariable("allottedResourceRole")).thenReturn("TXC")
+ when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
+ when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace"))
+ when(mex.getVariable("mso.workflow.global.default.aai.version")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.version"))
+ when(mex.getVariable("mso.workflow.default.aai.v8.nodes.query.uri")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.default.aai.v8.nodes-query.uri"))
+ when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/" + ARID)
+ when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
+ }
+
+ private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/" + ARID)
+ }
+
+ private initBuildSDNCRequest(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("allottedResourceId")).thenReturn("ari")
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
+ when(mex.getVariable("subscriptionServiceType")).thenReturn("sst")
+ when(mex.getVariable("globalCustomerId")).thenReturn("gci")
+ when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu")
+ when(mex.getVariable("msoRequestId")).thenReturn("mri")
+ }
+
+ private initPreProcessSDNC(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ }
+
+ private initValidateSDNCResp(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("prefix")).thenReturn(Prefix)
+ when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
+ }
+
+ private String initValidateSDNCResp_Resp(int code) {
+ return "<response-data>&lt;response-code&gt;${code}&lt;/response-code&gt;</response-data>"
+ }
+
+ private initDeleteAaiAR(ExecutionEntity mex) {
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST + "/allotted-resources/allotted-resource/" + ARID)
+ when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers")
+ when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
+ }
- ExecutionEntity mex = setupMock()
- initGetAaiAR(mex)
- when(client_MOCK.exists(any(AAIResourceUri.class))).thenReturn(true)
- doDeleteAllottedResourceTXC.getAaiAR(mex)
- verify(mex).setVariable("parentServiceInstanceId", INST)
- }
-
- @Test
- public void getAaiAR_EmptyResponse() {
- ExecutionEntity mex = setupMock()
- initGetAaiAR(mex)
- when(client_MOCK.exists(any(AAIResourceUri.class))).thenReturn(false)
- assertTrue(doBpmnError( { _ -> doDeleteAllottedResourceTXC.getAaiAR(mex) }))
- }
-
-
- // ***** updateAaiAROrchStatus *****
-
- @Test
- @Ignore
- public void updateAaiAROrchStatus() {
- ExecutionEntity mex = setupMock()
- initUpdateAaiAROrchStatus(mex)
-
- MockPatchAllottedResource(CUST, SVC, INST, ARID)
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
- DoDeleteAllottedResourceTXC.updateAaiAROrchStatus(mex, "success")
- }
-
-
- // ***** buildSDNCRequest *****
-
- @Test
-// @Ignore
- public void buildSDNCRequest() {
- ExecutionEntity mex = setupMock()
- initBuildSDNCRequest(mex)
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- String result = DoDeleteAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq")
-
- assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
- assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
- assertTrue(result.indexOf("<service-instance-id>sii</") >= 0)
- assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
- assertTrue(result.indexOf("<subscription-service-type>sst</") >= 0)
- assertTrue(result.indexOf("<global-customer-id>gci</") >= 0)
- assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
- assertTrue(result.indexOf("<request-id>mri</") >= 0)
- assertTrue(result.indexOf("<model-invariant-uuid/>") >= 0)
- assertTrue(result.indexOf("<model-uuid/>") >= 0)
- assertTrue(result.indexOf("<model-customization-uuid/>") >= 0)
- assertTrue(result.indexOf("<model-version/>") >= 0)
- assertTrue(result.indexOf("<model-name/>") >= 0)
- }
-
- @Test
-// @Ignore
- public void buildSDNCRequest_Ex() {
- ExecutionEntity mex = setupMock()
- initBuildSDNCRequest(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") }))
- }
-
-
- // ***** preProcessSDNCUnassign *****
-
- @Test
-// @Ignore
- public void preProcessSDNCUnassign() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcessSDNC(mex)
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
- DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex)
-
- def req = map.get("sdncUnassignRequest")
-
- assertTrue(req.indexOf("<sdncadapter:SvcAction>unassign</") >= 0)
- assertTrue(req.indexOf("<request-action>DeleteTunnelXConnInstance</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCUnassign_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCUnassign_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) }))
- }
-
-
- // ***** preProcessSDNCDelete *****
-
- @Test
-// @Ignore
- public void preProcessSDNCDelete() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcessSDNC(mex)
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
- DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex)
-
- def req = map.get("sdncDeleteRequest")
-
- assertTrue(req.indexOf("<sdncadapter:SvcAction>delete</") >= 0)
- assertTrue(req.indexOf("<request-action>DeleteTunnelXConnInstance</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCDelete_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCDelete_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) }))
- }
-
-
- // ***** preProcessSDNCDeactivate *****
-
- @Test
-// @Ignore
- public void preProcessSDNCDeactivate() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initPreProcessSDNC(mex)
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
- DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex)
-
- def req = map.get("sdncDeactivateRequest")
-
- assertTrue(req.indexOf("<sdncadapter:SvcAction>deactivate</") >= 0)
- assertTrue(req.indexOf("<request-action>DeleteTunnelXConnInstance</") >= 0)
- assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCDeactivate_BpmnError() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) }))
- }
-
- @Test
-// @Ignore
- public void preProcessSDNCDeactivate_Ex() {
- ExecutionEntity mex = setupMock()
- initPreProcessSDNC(mex)
-
- when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) }))
- }
-
-
- // ***** validateSDNCResp *****
-
- @Test
-// @Ignore
- public void validateSDNCResp() {
- ExecutionEntity mex = setupMock()
- def data = initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp(200)
-
- when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create")
-
- verify(mex).getVariable("WorkflowException")
- verify(mex).getVariable("SDNCA_SuccessIndicator")
- verify(mex).getVariable(Prefix+"sdncResponseSuccess")
-
- verify(mex, never()).getVariable(Prefix + "sdncRequestDataResponseCode")
- verify(mex, never()).setVariable("wasDeleted", false)
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Fail404_Deactivate_FailNotFound() {
- ExecutionEntity mex = setupMock()
- def data = initValidateSDNCResp(mex)
-
- def resp = initValidateSDNCResp_Resp(404)
- when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404")
- when(mex.getVariable("failNotFound")).thenReturn("true")
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate")}))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Fail404_Deactivate() {
- ExecutionEntity mex = setupMock()
- def data = initValidateSDNCResp(mex)
-
- def resp = initValidateSDNCResp_Resp(404)
- when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404")
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate")
-
- verify(mex).setVariable("ARNotFoundInSDNC", true)
- verify(mex).setVariable("wasDeleted", false)
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Fail404() {
- ExecutionEntity mex = setupMock()
- def data = initValidateSDNCResp(mex)
-
- def resp = initValidateSDNCResp_Resp(404)
- when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404")
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create")}))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Deactivate() {
- ExecutionEntity mex = setupMock()
- def data = initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp(200)
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate")}))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_BpmnError() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp(200)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
-// @Ignore
- public void validateSDNCResp_Ex() {
- ExecutionEntity mex = setupMock()
- initValidateSDNCResp(mex)
- def resp = initValidateSDNCResp_Resp(200)
-
- when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") }))
- }
-
- @Test
- @Ignore
- public void deleteAaiAR() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
- DoDeleteAllottedResourceTXC.deleteAaiAR(mex)
- }
-
- @Test
-// @Ignore
- public void deleteAaiAR_NoArPath() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- when(mex.getVariable("aaiARPath")).thenReturn("")
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) }))
- }
-
- @Test
-// @Ignore
- public void deleteAaiAR_BpmnError() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) }))
- }
-
- @Test
-// @Ignore
- public void deleteAaiAR_Ex() {
- ExecutionEntity mex = setupMock()
- initDeleteAaiAR(mex)
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
- MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
-
- when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) }))
- }
-
- private boolean checkMissingPreProcessRequest(String fieldnm) {
- ExecutionEntity mex = setupMock()
- initPreProcess(mex)
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- when(mex.getVariable(fieldnm)).thenReturn("")
-
- return doBpmnError( { _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) })
- }
-
- private void initPreProcess(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("allottedResourceId")).thenReturn("ari")
- }
-
- private void initGetAaiAR(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("allottedResourceType")).thenReturn("TXC")
- when(mex.getVariable("allottedResourceRole")).thenReturn("TXC")
- when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
- when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoDeleteAllottedResourceTXC/getAR.xml"))
- when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace"))
- when(mex.getVariable("mso.workflow.global.default.aai.version")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.version"))
- when(mex.getVariable("mso.workflow.default.aai.v8.nodes.query.uri")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.default.aai.v8.nodes-query.uri"))
- when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
- when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
- }
-
- private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
- }
-
- private initBuildSDNCRequest(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("allottedResourceId")).thenReturn("ari")
- when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
- when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
- when(mex.getVariable("subscriptionServiceType")).thenReturn("sst")
- when(mex.getVariable("globalCustomerId")).thenReturn("gci")
- when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu")
- when(mex.getVariable("msoRequestId")).thenReturn("mri")
- }
-
- private initPreProcessSDNC(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- }
-
- private initValidateSDNCResp(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("prefix")).thenReturn(Prefix)
- when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
- }
-
- private String initValidateSDNCResp_Resp(int code) {
- return "<response-data>&lt;response-code&gt;${code}&lt;/response-code&gt;</response-data>"
- }
-
- private initDeleteAaiAR(ExecutionEntity mex) {
- when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
- when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers")
- when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- }
-
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy
index 8ce3bdb6c3..1ff098b940 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -20,97 +22,94 @@
package org.onap.so.bpmn.vcpe.scripts
-
import org.camunda.bpm.engine.ProcessEngineServices
import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.camunda.bpm.engine.repository.ProcessDefinition
import org.junit.runner.RunWith
import org.mockito.Mock
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.mockito.runners.MockitoJUnitRunner
+import org.mockito.junit.MockitoJUnitRunner
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.AllottedResourceUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.client.aai.AAIResourcesClient
+
+import static org.mockito.ArgumentMatchers.any
import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
class GroovyTestBase {
-
- static final int PORT = 28090
- static final String LOCAL_URI = "http://localhost:" + PORT
-
- static final String CUST = "SDN-ETHERNET-INTERNET"
- static final String SVC = "123456789"
- static final String INST = "MIS%252F1604%252F0026%252FSW_INTERNET"
- static final String ARID = "arId-1"
- static final String VERS = "myvers"
-
- static final String DBGFLAG = "isDebugLogEnabled"
-
- static String aaiUriPfx
-
- String processName
+
+ static final int PORT = 28090
+ static final String LOCAL_URI = "http://localhost:" + PORT
+
+ static final String CUST = "SDN-ETHERNET-INTERNET"
+ static final String SVC = "123456789"
+ static final String INST = "MIS%252F1604%252F0026%252FSW_INTERNET"
+ static final String ARID = "arId-1"
+ static final String VERS = "myvers"
+
+ static final String DBGFLAG = "isDebugLogEnabled"
+
+ static String aaiUriPfx
+
+ String processName
AllottedResourceUtils allottedResourceUtils_MOCK
@Mock
AAIResourcesClient client_MOCK
- public static void setUpBeforeClass() {
- aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint")
- }
-
- public GroovyTestBase(String processName) {
- this.processName = processName
- }
-
- public boolean doBpmnError(def func) {
-
- try {
- func()
- return false;
-
- } catch(BpmnError e) {
- return true;
- }
- }
-
- public ExecutionEntity setupMock() {
-
- ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
- when(mockProcessDefinition.getKey()).thenReturn(processName)
- RepositoryService mockRepositoryService = mock(RepositoryService.class)
- when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
- when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(processName)
- when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
- ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
- when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
-
- ExecutionEntity mex = mock(ExecutionEntity.class)
-
- when(mex.getId()).thenReturn("100")
- when(mex.getProcessDefinitionId()).thenReturn(processName)
- when(mex.getProcessInstanceId()).thenReturn(processName)
- when(mex.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
- when(mex.getProcessEngineServices().getRepositoryService().getProcessDefinition(mex.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
-
- when(mex.getVariable("isAsyncProcess")).thenReturn("true")
- when(mex.getVariable(processName+"WorkflowResponseSent")).thenReturn("false")
-
- return mex
- }
-
- public Map<String,Object> setupMap(ExecutionEntity mex) {
- MapSetter mapset = new MapSetter();
- doAnswer(mapset).when(mex).setVariable(any(), any())
- return mapset.getMap();
- }
-
- void init(){
+ public static void setUpBeforeClass() {
+ aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint")
+ }
+
+ public GroovyTestBase(String processName) {
+ this.processName = processName
+ }
+
+ public boolean doBpmnError(def func) {
+
+ try {
+ func()
+ return false;
+
+ } catch (BpmnError e) {
+ return true;
+ }
+ }
+
+ public ExecutionEntity setupMock() {
+
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn(processName)
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(processName)
+ ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
+ when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
+
+ ExecutionEntity mex = mock(ExecutionEntity.class)
+
+ when(mex.getProcessDefinitionId()).thenReturn(processName)
+ when(mex.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mex.getProcessEngineServices().getRepositoryService().getProcessDefinition(mex.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+
+ when(mex.getVariable("isAsyncProcess")).thenReturn("true")
+ when(mex.getVariable(processName + "WorkflowResponseSent")).thenReturn("false")
+
+ return mex
+ }
+
+ public Map<String, Object> setupMap(ExecutionEntity mex) {
+ MapSetter mapset = new MapSetter();
+ doAnswer(mapset).when(mex).setVariable(any(), any())
+ return mapset.getMap();
+ }
+
+ void initAllottedResourceMock() {
allottedResourceUtils_MOCK = spy(new AllottedResourceUtils(mock(AbstractServiceTaskProcessor.class)))
- when(allottedResourceUtils_MOCK.getAAIClient()).thenReturn(client_MOCK)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy
index fa5dcec4bc..9b29c43a9c 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy
@@ -18,32 +18,29 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.vcpe.scripts;
+package org.onap.so.bpmn.vcpe.scripts
-import java.util.HashMap;
-import java.util.Map;
-
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
+import org.mockito.invocation.InvocationOnMock
+import org.mockito.stubbing.Answer
class MapGetter implements Answer<Object> {
- final Map<String,Object> map;
-
- public MapGetter() {
- map = new HashMap<>();
- }
-
- public MapGetter(Map<String,Object> map) {
- this.map = map;
- }
-
- public Map<String, Object> getMap() {
- return map;
- }
-
- @Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- return map.get(invocation.getArgumentAt(0, String.class));
- }
-
-}
+ final Map<String, Object> map;
+
+ public MapGetter() {
+ map = new HashMap<>();
+ }
+
+ public MapGetter(Map<String, Object> map) {
+ this.map = map;
+ }
+
+ public Map<String, Object> getMap() {
+ return map;
+ }
+
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ return map.get(invocation.getArgumentAt(0, String.class));
+ }
+
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy
index 7b50c616ea..06057cdd61 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -18,33 +20,30 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.vcpe.scripts;
-
-import java.util.HashMap;
-import java.util.Map;
+package org.onap.so.bpmn.vcpe.scripts
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
+import org.mockito.invocation.InvocationOnMock
+import org.mockito.stubbing.Answer
class MapSetter implements Answer<Void> {
- final Map<String,Object> map;
-
- public MapSetter() {
- map = new HashMap<>();
- }
-
- public MapSetter(Map<String,Object> map) {
- this.map = map;
- }
-
- public Map<String, Object> getMap() {
- return map;
- }
-
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- map.put(invocation.getArgumentAt(0, String.class), invocation.getArgumentAt(1, Object.class));
- return null;
- }
-
-}
+ final Map<String, Object> map;
+
+ public MapSetter() {
+ map = new HashMap<>();
+ }
+
+ public MapSetter(Map<String, Object> map) {
+ this.map = map;
+ }
+
+ public Map<String, Object> getMap() {
+ return map;
+ }
+
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ map.put((String) invocation.getArgument(0), invocation.getArgument(1))
+ return null
+ }
+
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTestsTestSuite.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTestsTestSuite.java
index 0c0f38c0f9..01f37ad655 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTestsTestSuite.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTestsTestSuite.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -27,8 +29,8 @@ import com.googlecode.junittoolbox.WildcardPatternSuite;
@RunWith(WildcardPatternSuite.class)
@SuiteClasses({"!**/service/*Test.class", "!**/subprocess/*Test.class", "!**/process/*Test.class",
- "!**/tasks/*Test.class", "!**/infrastructure/aai/*Test.class",
- "!**/scripts/*Test.class", "**/*Test.class"})
+ "!**/tasks/*Test.class", "!**/infrastructure/aai/*Test.class",
+ "!**/infrastructure/scripts/*Test.class", "**/*Test.class"})
public class AllTestsTestSuite {
// the class remains empty,
// used only as a holder for the above annotations
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json
index dc4669e8d9..7c60512c36 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json
@@ -23,6 +23,7 @@
},
"cloudConfiguration":
{
+ "cloudOwner":"CloudOwner",
"lcpCloudRegionId":"mdt1",
"tenantId":"8b1df54faa3b49078e3416e21370a3ba"
},
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
index fedbde251e..b086b8a7ff 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
@@ -163,7 +163,7 @@ public class GeneralTopologyObjectMapper {
vfModuleInformation.setFromPreload(requestContext.getRequestParameters().getUsePreload());
}
else {
- vfModuleInformation.setFromPreload(false);
+ vfModuleInformation.setFromPreload(true);
}
return vfModuleInformation;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java
index 3bb54278b6..630bccee9d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java
@@ -362,7 +362,7 @@ public class GeneralTopologyObjectMapperTest extends TestDataSetup {
assertNull(gcRequestInput.getOnapModelInformation());
assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
assertNotNull(gcRequestInput.getVfModuleId());
- assertFalse(gcRequestInput.getFromPreload());
+ assertTrue(gcRequestInput.getFromPreload());
}
@Test
@@ -386,7 +386,7 @@ public class GeneralTopologyObjectMapperTest extends TestDataSetup {
assertNull(gcRequestInput.getOnapModelInformation());
assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
assertNotNull(gcRequestInput.getVfModuleId());
- assertFalse(gcRequestInput.getFromPreload());
+ assertTrue(gcRequestInput.getFromPreload());
}
@Test
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json
index cecb4c1dc7..c28b0fa689 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json
@@ -22,7 +22,7 @@
},
"vf-module-information" : {
"vf-module-id" : "testVfModuleId",
- "from-preload": false
+ "from-preload": true
},
"vnf-information" : {
"vnf-id" : "testVnfId",
diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java
index 4c3597b2c1..710c820148 100644
--- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java
+++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java
@@ -21,18 +21,22 @@
package org.onap.so.serviceinstancebeans;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import org.apache.commons.lang3.builder.ToStringBuilder;
@JsonInclude(Include.NON_DEFAULT)
public class RequestStatus {
- protected String requestState;
+ @JsonProperty("requestState")
+ protected String requestState;
+ @JsonProperty("statusMessage")
protected String statusMessage;
+ @JsonProperty("percentProgress")
protected Integer percentProgress;
+ @JsonProperty("timestamp")
protected String timeStamp;
-
public String getRequestState() {
return requestState;
}
@@ -60,6 +64,6 @@ public class RequestStatus {
@Override
public String toString() {
return new ToStringBuilder(this).append("requestState", requestState).append("statusMessage", statusMessage)
- .append("percentProgress", percentProgress).append("timeStamp", timeStamp).toString();
+ .append("percentProgress", percentProgress).append("timestamp", timeStamp).toString();
}
}
diff --git a/common/src/test/java/org/onap/so/serviceinstancebeans/RequestStatusTest.java b/common/src/test/java/org/onap/so/serviceinstancebeans/RequestStatusTest.java
new file mode 100644
index 0000000000..fa4d2f772d
--- /dev/null
+++ b/common/src/test/java/org/onap/so/serviceinstancebeans/RequestStatusTest.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.serviceinstancebeans;
+
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.junit.Test;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class RequestStatusTest {
+
+ @Test
+ public void requestStatusDefaultValues() throws Exception {
+ RequestStatus requestStatus = new RequestStatus();
+ requestStatus.setRequestState("COMPLETE");
+ requestStatus.setStatusMessage("STATUS: COMPLETED");
+ requestStatus.setPercentProgress(100);
+ requestStatus.setTimeStamp("Fri, 08 Mar 2019 04:41:42 GMT");
+ String expectedResponse = "{\"requestState\":\"COMPLETE\",\"statusMessage\":\"STATUS: COMPLETED\",\"percentProgress\":100,\"timestamp\":\"Fri, 08 Mar 2019 04:41:42 GMT\"}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ String realResponse = mapper.writeValueAsString(requestStatus);
+
+ JSONAssert.assertEquals(expectedResponse, realResponse, false);
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java
index 7ef712e124..6fd765b76f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java
@@ -38,7 +38,7 @@ public class RequestStatus implements Serializable {
protected String statusMessage;
@JsonProperty("percentProgress")
protected String percentProgress;
- @JsonProperty("timeStamp")
+ @JsonProperty("timestamp")
protected String timeStamp;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java
index edb92ef68b..8e1a6f5d35 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java
@@ -73,6 +73,23 @@ public class RequestParametersValidation implements ValidationRule{
if(action == Action.createInstance || action == Action.updateInstance){
if(requestParameters.isUsePreload() == null){
if(reqVersion >= 4){
+ if (requestParameters.getALaCarte() == null || requestParameters.getALaCarte() == true) {
+ requestParameters.setUsePreload(true);
+ }
+ else {
+ requestParameters.setUsePreload(false);
+ }
+ }
+ else {
+ requestParameters.setUsePreload(true);
+ }
+ }
+ }
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.service.name())){
+ if(action == Action.createInstance){
+ if(requestParameters.isUsePreload() == null){
+ if(reqVersion >= 4){
if (requestParameters.getALaCarte() == null || requestParameters.getALaCarte() == false) {
requestParameters.setUsePreload(false);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java
index 2813ef7b70..8d456e3f68 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java
@@ -66,7 +66,7 @@ public class RequestParametersValidationTest extends BaseTest{
RequestParametersValidation validation = new RequestParametersValidation();
validation.validate(info);
- assertFalse(info.getReqParameters().getUsePreload());
+ assertTrue(info.getReqParameters().getUsePreload());
}
@Test
@@ -100,4 +100,68 @@ public class RequestParametersValidationTest extends BaseTest{
assertTrue(info.getReqParameters().getUsePreload());
}
+
+ @Test
+ public void testServiceWithFalseALaCarte() throws IOException, ValidationException {
+ String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleModelVersionId.json")));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
+ sir.getRequestDetails().getRequestParameters().setUsePreload(null);
+ ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance,
+ 6, false, sir.getRequestDetails().getRequestParameters());
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ info.setRequestScope("service");
+ RequestParametersValidation validation = new RequestParametersValidation();
+ validation.validate(info);
+
+ assertFalse(info.getReqParameters().getUsePreload());
+ }
+
+ @Test
+ public void testServiceWithNoALaCarte() throws IOException, ValidationException {
+ String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersNoALaCarte.json")));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
+ ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance,
+ 6, false, sir.getRequestDetails().getRequestParameters());
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ sir.getRequestDetails().getRequestParameters().setSubscriptionServiceType("subscriptionServiceType");
+ info.setRequestScope("service");
+ RequestParametersValidation validation = new RequestParametersValidation();
+ validation.validate(info);
+
+ assertFalse(info.getReqParameters().getUsePreload());
+ }
+
+ @Test
+ public void testServiceWithTrueALaCarte() throws IOException, ValidationException {
+ String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersIsALaCarte.json")));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
+ sir.getRequestDetails().getRequestParameters().setUsePreload(null);
+ ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance,
+ 6, true, sir.getRequestDetails().getRequestParameters());
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ info.setRequestScope("service");
+ RequestParametersValidation validation = new RequestParametersValidation();
+ validation.validate(info);
+
+ assertTrue(info.getReqParameters().getUsePreload());
+ }
+
+ @Test
+ public void testServiceWithReqVersionBelow4() throws IOException, ValidationException {
+ String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleModelVersionId.json")));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
+ sir.getRequestDetails().getRequestParameters().setUsePreload(null);
+ ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance,
+ 3, false, sir.getRequestDetails().getRequestParameters());
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ info.setRequestScope("service");
+ RequestParametersValidation validation = new RequestParametersValidation();
+ validation.validate(info);
+
+ assertTrue(info.getReqParameters().getUsePreload());
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json
index dde4392c38..3b2eca7ce2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json
@@ -29,7 +29,7 @@
"requestState": "COMPLETE",
"statusMessage": "STATUS: COMPLETED",
"percentProgress": 100,
- "timeStamp": "Fri, 01 Jul 2016 04:41:42 GMT"
+ "timestamp": "Fri, 01 Jul 2016 04:41:42 GMT"
}
}
},
@@ -63,7 +63,7 @@
"requestState": "COMPLETE",
"statusMessage": "STATUS: Vf Module has been deleted successfully. FLOW STATUS: Building blocks 1 of 3 completed. ROLLBACK STATUS: Rollback has been completed successfully.",
"percentProgress": 100,
- "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT"
+ "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT"
}
}
},
@@ -97,7 +97,7 @@
"requestState": "PENDING",
"statusMessage": "STATUS: Vf Module deletion pending.",
"percentProgress": 0,
- "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT"
+ "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT"
}
}
},
@@ -181,7 +181,7 @@
"requestState": "UNLOCKED",
"statusMessage": "STATUS: Vf Module deletion pending.",
"percentProgress": 0,
- "timeStamp": "Mon, 30 Jul 2018 06:09:01 GMT"
+ "timestamp": "Mon, 30 Jul 2018 06:09:01 GMT"
}
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json
index ecbf7a92a4..90089c0c7e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json
@@ -28,7 +28,7 @@
"requestState":"COMPLETE",
"statusMessage":"STATUS: Vf Module has been deleted successfully.",
"percentProgress":100,
- "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT"
+ "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT"
}
}
},
@@ -60,7 +60,7 @@
"requestState":"PENDING",
"statusMessage":"FLOW STATUS: Building blocks 1 of 3 completed. RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.",
"percentProgress":0,
- "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT"
+ "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT"
}
}
},
@@ -323,7 +323,7 @@
"requestState":"PENDING",
"statusMessage":"STATUS: Adding members. FLOW STATUS: Building blocks 1 of 3 completed. RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.",
"percentProgress":0,
- "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT"
+ "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT"
}
}
}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java
index 69d84b7679..c8ad5f1843 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java
@@ -56,7 +56,6 @@ public class WatchdogDistributionStatus implements Serializable {
@Column(name = "MODIFY_TIME")
@Temporal(TemporalType.TIMESTAMP)
private Date modifyTime;
- @Version
@Column(name = "LOCK_VERSION")
private int version;
diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml
index 11b7de62b7..49f6422f3f 100644
--- a/packages/docker/pom.xml
+++ b/packages/docker/pom.xml
@@ -80,6 +80,31 @@
</build>
</image>
<image>
+ <name>onap/so/vnfm-adapter</name>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFileDir>docker-files</dockerFileDir>
+ <dockerFile>Dockerfile.so-app</dockerFile>
+ <tags>
+ <tag>${project.version}</tag>
+ <tag>${project.version}-${maven.build.timestamp}</tag>
+ <tag>${project.docker.latesttag.version}</tag>
+ </tags>
+ <assembly>
+ <inline>
+ <dependencySets>
+ <dependencySet>
+ <includes>
+ <include>org.onap.so.adapters:mso-vnfm-etsi-adapter</include>
+ </includes>
+ <outputFileNameMapping>app.jar</outputFileNameMapping>
+ </dependencySet>
+ </dependencySets>
+ </inline>
+ </assembly>
+ </build>
+ </image>
+ <image>
<name>onap/so/catalog-db-adapter</name>
<build>
<cleanup>try</cleanup>
@@ -355,6 +380,11 @@
<dependencies>
<dependency>
<groupId>org.onap.so.adapters</groupId>
+ <artifactId>mso-vnfm-etsi-adapter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-catalog-db-adapter</artifactId>
<version>${project.version}</version>
</dependency>