aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN')
-rw-r--r--bpmn/MSOCommonBPMN/pom.xml1114
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/MSOCommonApplication.java59
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java18
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/ProcessEngineAwareService.java64
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java10
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java8
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java17
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java11
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/PreconditionFailedException.java (renamed from bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java)67
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapper.java98
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapperImpl.java39
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestProperties.java30
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestPropertiesLoader.java55
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java30
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DefaultDmaapPropertiesImpl.java38
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapClient.java68
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java117
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapProperties.java32
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java49
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java25
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Publisher.java26
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/DMaaPConsumerFailure.java34
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/ExceededMaximumPollingTime.java34
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java57
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/PropertiesBean.java131
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestConsumer.java60
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestPublisher.java56
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java268
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java53
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestProperties.java64
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java181
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/entities/PolicyServiceType.java48
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java101
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java (renamed from bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Body.java)4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java (renamed from bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Input.java)8
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java (renamed from bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/RequestHealthDiagnostic.java)4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java (renamed from bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/ResultInfo.java)4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java (renamed from bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNO.java)24
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java156
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java50
-rw-r--r--bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/applicationContext.xml8
-rw-r--r--bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-deployment-structure.xml38
-rw-r--r--bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-web.xml26
-rw-r--r--bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/web.xml81
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java3
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/FileUtil.java80
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResource.java205
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResourceApplication.java50
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterMockTransformer.java140
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterNetworkTopologyMockTransformer.java132
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java1069
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java102
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseNetworkAdapter.java113
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponsePolicy.java94
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSDNCAdapter.java146
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSNIRO.java69
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseVNFAdapter.java158
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterCreateMockTransformer.java148
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterDeleteMockTransformer.java143
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterQueryMockTransformer.java161
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterRollbackMockTransformer.java144
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterUpdateMockTransformer.java149
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/policy/PolicyDecisionTest.java70
67 files changed, 5316 insertions, 1338 deletions
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml
index e5becbf6cc..c0e657479f 100644
--- a/bpmn/MSOCommonBPMN/pom.xml
+++ b/bpmn/MSOCommonBPMN/pom.xml
@@ -1,604 +1,510 @@
-<?xml version="1.0"?>
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.openecomp.so</groupId>
- <artifactId>bpmn</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </parent>
- <artifactId>MSOCommonBPMN</artifactId>
- <name>MSOCommonBPMN</name>
- <packaging>war</packaging>
-
- <properties>
- <camunda.version>7.6.0</camunda.version>
- <spring.version>4.3.2.RELEASE</spring.version>
- <httpclient.version>3.1</httpclient.version>
- <jax.ws.rs>2.0.1</jax.ws.rs>
- <jackson.version>1.1.1</jackson.version>
- <maven.compiler.target>1.8</maven.compiler.target>
- <maven.compiler.source>1.8</maven.compiler.source>
- </properties>
-
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <executions>
- <execution>
- <id>test-compile</id>
- <phase>compile</phase>
- <goals>
- <goal>testCompile</goal>
- </goals>
- <configuration>
- <skip>false</skip>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <!-- Build MSOCommonBPMN-${version}.jar -->
- <id>default-jar</id>
- <phase>package</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- <configuration>
- <excludes>
- <exclude>org/openecomp/mso/bpmn/common/MSOCommonApplication.class</exclude>
- <!-- <exclude>META-INF/</exclude> -->
- </excludes>
- </configuration>
- </execution>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- <configuration>
- <forceCreation>true</forceCreation>
- <skip>false</skip>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>3.0.0</version>
- <executions>
- <execution>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <artifacts>
- <artifact>
- <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
- <type>jar</type>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.3</version>
- <configuration>
- <failOnMissingWebXml>false</failOnMissingWebXml>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-codegen-plugin</artifactId>
- <version>2.5.2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-eclipse-plugin</artifactId>
- <version>2.8</version>
- <configuration>
- <additionalProjectnatures>
- <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
- </additionalProjectnatures>
- <sourceIncludes>
- <sourceInclude>**/*.groovy</sourceInclude>
- </sourceIncludes>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>compile</id>
- <phase>compile</phase>
- <configuration>
- <tasks>
- <mkdir dir="${basedir}/src/main/groovy" />
- <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
- <classpath refid="maven.compile.classpath" />
- </taskdef>
- <mkdir dir="${project.build.outputDirectory}" />
- <groovyc destdir="${project.build.outputDirectory}"
- srcdir="${basedir}/src/main/groovy/" listfiles="true">
- <classpath refid="maven.compile.classpath" />
- </groovyc>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- <execution>
- <id>test-compile</id>
- <phase>test-compile</phase>
- <configuration>
- <tasks>
- <mkdir dir="${basedir}/src/test/groovy" />
- <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
- <classpath refid="maven.test.classpath" />
- </taskdef>
- <mkdir dir="${project.build.testOutputDirectory}" />
- <groovyc destdir="${project.build.testOutputDirectory}"
- srcdir="${basedir}/src/test/groovy/" listfiles="true">
- <classpath refid="maven.test.classpath" />
- </groovyc>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jaxb2-maven-plugin</artifactId>
- <version>2.3</version>
- <executions>
- <execution>
- <id>xjc</id>
- <goals>
- <goal>xjc</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <extension>true</extension>
- <arguments>
- <argument>-Xannotate</argument>
- <argument>-Xcommons-lang</argument>
- </arguments>
- <sources>
- <source>src/main/resources/xsd</source>
- </sources>
- <xjbSources>
- <xjbSource>src/main/resources/xjb</xjbSource>
- </xjbSources>
- <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>org.jvnet.jaxb2_commons</groupId>
- <artifactId>jaxb2-basics-annotate</artifactId>
- <version>0.6.4</version>
- </dependency>
- <dependency>
- <groupId>org.jvnet.jaxb2_commons</groupId>
- <artifactId>jaxb2-commons-lang</artifactId>
- <version>2.3</version>
- </dependency>
- <dependency>
- <groupId>com.sun.codemodel</groupId>
- <artifactId>codemodel</artifactId>
- <version>2.6</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <!--This plugin's configuration is used to store Eclipse m2e settings
- only. It has no influence on the Maven build itself. -->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>
- org.apache.maven.plugins
- </groupId>
- <artifactId>
- maven-antrun-plugin
- </artifactId>
- <versionRange>
- [1.3,)
- </versionRange>
- <goals>
- <goal>run</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore></ignore>
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
-
-
- </plugins>
- </pluginManagement>
- </build>
-
- <dependencies>
-
- <dependency>
- <!-- process engine, in compile scope to include it in the war file -->
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine</artifactId>
- <scope>compile</scope>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <!-- Using the `DefaultEjbProcessApplication` result in: `java.sql.SQLException:
- You cannot commit during a managed transaction!` -->
- <dependency>
- <!-- CDI integration, needs to be included in WAR, otherwise CDI can not
- work correctly -->
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine-cdi</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.camunda.bpm.extension</groupId>
- <artifactId>camunda-bpm-assert</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
-
- <!-- Spin dataformat support, in compile scope to include it in the war
- file -->
- <dependency>
- <groupId>org.camunda.spin</groupId>
- <artifactId>camunda-spin-dataformat-all</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine-plugin-spin</artifactId>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine-plugin-connect</artifactId>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <!-- Bootstrap for styling via Webjars project -->
- <groupId>org.webjars</groupId>
- <artifactId>bootstrap</artifactId>
- <version>2.3.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-client</artifactId>
- <version>3.0.19.Final</version>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <!-- Needed for InMemoryH2Test -->
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>com.fasterxml.uuid</groupId>
- <artifactId>java-uuid-generator</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.4</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.so</groupId>
- <artifactId>MSOCoreBPMN</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <!-- unit test utilities -->
- <groupId>org.openecomp.so</groupId>
- <artifactId>MSOCoreBPMN</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.openecomp.so</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>2.0</version>
- </dependency>
- <!-- for encoding the url the same way A&AI does -->
- <dependency>
- <groupId>org.openecomp.so</groupId>
- <artifactId>MSOMockServer</artifactId>
- <version>${project.version}</version>
- <classifier>classes</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.openecomp.so</groupId>
- <artifactId>MSORESTClient</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.0.1</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>${spring.version}</version>
- </dependency>
-
- <dependency>
- <groupId>com.github.tomakehurst</groupId>
- <artifactId>wiremock</artifactId>
- <version>1.56</version>
- <scope>test</scope>
- <classifier>standalone</classifier>
- <exclusions>
- <exclusion>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.skyscreamer</groupId>
- <artifactId>jsonassert</artifactId>
- </exclusion>
- <exclusion>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.jayway.jsonpath</groupId>
- <artifactId>json-path</artifactId>
- </exclusion>
- <exclusion>
- <groupId>net.sf.jopt-simple</groupId>
- <artifactId>jopt-simple</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine-spring</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>4.3.2.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- <version>2.8.7</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- <version>2.8.7</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.module</groupId>
- <artifactId>jackson-module-jaxb-annotations</artifactId>
- <version>2.4.0</version>
- </dependency>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>1.6.12</version>
- </dependency>
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>${httpclient.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.appc.client</groupId>
- <artifactId>client-kit</artifactId>
- <version>1.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.appc.client</groupId>
- <artifactId>client-lib</artifactId>
- <version>1.1.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aai.aai-common</groupId>
- <artifactId>aai-schema</artifactId>
- <version>1.1.0</version>
- </dependency>
-
-
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.8.7</version>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.10.19</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.6</version>
- </dependency>
- <dependency>
- <groupId>com.openpojo</groupId>
- <artifactId>openpojo</artifactId>
- <version>0.8.6</version>
- </dependency>
- <dependency>
- <groupId>com.jayway.jsonpath</groupId>
- <artifactId>json-path</artifactId>
- <version>2.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- </dependency>
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>${httpclient.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>${jax.ws.rs}</version>
- </dependency>
-
- <dependency>
- <groupId>org.openecomp.appc.client</groupId>
- <artifactId>client-kit</artifactId>
- <version>1.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.appc.client</groupId>
- <artifactId>client-lib</artifactId>
- <version>1.1.0</version>
- </dependency>
-
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.8.7</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- <version>2.8.7</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.module</groupId>
- <artifactId>jackson-module-jaxb-annotations</artifactId>
- <version>2.4.0</version>
- </dependency>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>1.6.12</version>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.10.19</version>
- </dependency>
- <dependency>
- <groupId>com.att.nsa</groupId>
- <artifactId>dmaapClient</artifactId>
- <version>0.2.12</version>
- </dependency>
- <dependency>
- <!-- Optional Plugin for Camunda BPM Workbench -->
- <groupId>org.camunda.bpm.workbench</groupId>
- <artifactId>camunda-workbench-dist-embeddable</artifactId>
- <version>1.0.0-alpha8</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jackson2-provider</artifactId>
- <version>3.0.11.Final</version>
- </dependency>
-
- </dependencies>
-</project>
+<?xml version="1.0"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>bpmn</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>MSOCommonBPMN</artifactId>
+ <name>MSOCommonBPMN</name>
+ <packaging>jar</packaging>
+
+ <properties>
+ <camunda.version>7.6.0</camunda.version>
+ <spring.version>4.3.2.RELEASE</spring.version>
+ <httpclient.version>3.1</httpclient.version>
+ <jax.ws.rs>2.0.1</jax.ws.rs>
+ <jackson.version>1.1.1</jackson.version>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>test-compile</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.0.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-codegen-plugin</artifactId>
+ <version>2.5.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.8</version>
+ <configuration>
+ <additionalProjectnatures>
+ <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
+ </additionalProjectnatures>
+ <sourceIncludes>
+ <sourceInclude>**/*.groovy</sourceInclude>
+ </sourceIncludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>compile</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${basedir}/src/main/groovy" />
+ <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
+ <classpath refid="maven.compile.classpath" />
+ </taskdef>
+ <mkdir dir="${project.build.outputDirectory}" />
+ <groovyc destdir="${project.build.outputDirectory}"
+ srcdir="${basedir}/src/main/groovy/" listfiles="true">
+ <classpath refid="maven.compile.classpath" />
+ </groovyc>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>test-compile</id>
+ <phase>test-compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${basedir}/src/test/groovy" />
+ <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
+ <classpath refid="maven.test.classpath" />
+ </taskdef>
+ <mkdir dir="${project.build.testOutputDirectory}" />
+ <groovyc destdir="${project.build.testOutputDirectory}"
+ srcdir="${basedir}/src/test/groovy/" listfiles="true">
+ <classpath refid="maven.test.classpath" />
+ </groovyc>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxb2-maven-plugin</artifactId>
+ <version>2.3</version>
+ <executions>
+ <execution>
+ <id>xjc</id>
+ <goals>
+ <goal>xjc</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <extension>true</extension>
+ <arguments>
+ <argument>-Xannotate</argument>
+ <argument>-Xcommons-lang</argument>
+ </arguments>
+ <sources>
+ <source>src/main/resources/xsd</source>
+ </sources>
+ <xjbSources>
+ <xjbSource>src/main/resources/xjb</xjbSource>
+ </xjbSources>
+ <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-basics-annotate</artifactId>
+ <version>0.6.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-commons-lang</artifactId>
+ <version>2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.codemodel</groupId>
+ <artifactId>codemodel</artifactId>
+ <version>2.6</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings
+ only. It has no influence on the Maven build itself. -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ org.apache.maven.plugins
+ </groupId>
+ <artifactId>
+ maven-antrun-plugin
+ </artifactId>
+ <versionRange>
+ [1.3,)
+ </versionRange>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.camunda.bpm</groupId>
+ <artifactId>camunda-engine</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.camunda.bpm</groupId>
+ <artifactId>camunda-engine-cdi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.camunda.bpm.extension</groupId>
+ <artifactId>camunda-bpm-assert</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.camunda.spin</groupId>
+ <artifactId>camunda-spin-dataformat-all</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.camunda.bpm</groupId>
+ <artifactId>camunda-engine-plugin-spin</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.camunda.bpm</groupId>
+ <artifactId>camunda-engine-plugin-connect</artifactId>
+ </dependency>
+ <dependency>
+ <!-- Bootstrap for styling via Webjars project -->
+ <groupId>org.webjars</groupId>
+ <artifactId>bootstrap</artifactId>
+ <version>2.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-client</artifactId>
+ <version>3.0.19.Final</version>
+ </dependency>
+ <dependency>
+ <!-- Needed for InMemoryH2Test -->
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.uuid</groupId>
+ <artifactId>java-uuid-generator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>MSOCoreBPMN</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <!-- unit test utilities -->
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>MSOCoreBPMN</artifactId>
+ <version>${project.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>MSORESTClient</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.github.tomakehurst</groupId>
+ <artifactId>wiremock</artifactId>
+ <version>1.56</version>
+ <scope>test</scope>
+ <classifier>standalone</classifier>
+ <exclusions>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.skyscreamer</groupId>
+ <artifactId>jsonassert</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.jayway.jsonpath</groupId>
+ <artifactId>json-path</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>net.sf.jopt-simple</groupId>
+ <artifactId>jopt-simple</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.camunda.bpm</groupId>
+ <artifactId>camunda-engine-spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>4.3.2.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>2.8.7</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>2.8.7</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.module</groupId>
+ <artifactId>jackson-module-jaxb-annotations</artifactId>
+ <version>2.4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>1.6.12</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>${httpclient.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc.client</groupId>
+ <artifactId>client-kit</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc.client</groupId>
+ <artifactId>client-lib</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.aai.aai-common</groupId>
+ <artifactId>aai-schema</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.8.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.10.19</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>com.openpojo</groupId>
+ <artifactId>openpojo</artifactId>
+ <version>0.8.6</version>
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.jsonpath</groupId>
+ <artifactId>json-path</artifactId>
+ <version>2.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>${httpclient.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>${jax.ws.rs}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc.client</groupId>
+ <artifactId>client-kit</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc.client</groupId>
+ <artifactId>client-lib</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.8.7</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>2.8.7</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.module</groupId>
+ <artifactId>jackson-module-jaxb-annotations</artifactId>
+ <version>2.4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>1.6.12</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.10.19</version>
+ </dependency>
+ <dependency>
+ <groupId>com.att.nsa</groupId>
+ <artifactId>dmaapClient</artifactId>
+ <version>0.2.12</version>
+ </dependency>
+ <dependency>
+ <!-- Optional Plugin for Camunda BPM Workbench -->
+ <groupId>org.camunda.bpm.workbench</groupId>
+ <artifactId>camunda-workbench-dist-embeddable</artifactId>
+ <version>1.0.0-alpha8</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jackson2-provider</artifactId>
+ <version>3.0.11.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>22.0</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/MSOCommonApplication.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/MSOCommonApplication.java
deleted file mode 100644
index 3e8fd6ee05..0000000000
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/MSOCommonApplication.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.openecomp.mso.bpmn.common;
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-
-
-import java.util.List;
-
-import org.camunda.bpm.application.PostDeploy;
-import org.camunda.bpm.application.PreUndeploy;
-import org.camunda.bpm.application.ProcessApplication;
-import org.camunda.bpm.application.ProcessApplicationInfo;
-import org.camunda.bpm.application.impl.ServletProcessApplication;
-import org.camunda.bpm.engine.ProcessEngine;
-
-import org.openecomp.mso.logger.MsoLogger;
-
-/**
- * @since Version 1.0
- *
- */
-@ProcessApplication(name="MSO Common Application", deploymentDescriptors={"../processes.xml"})
-public class MSOCommonApplication extends ServletProcessApplication {
-
- private MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
-
- @PostDeploy
- public void postDeploy(ProcessEngine processEngineInstance) {
- long startTime = System.currentTimeMillis();
-
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Post deployment complete...");
- }
-
- @PreUndeploy
- public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo, List<ProcessEngine> processEngines) {
- long startTime = System.currentTimeMillis();
-
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Pre Undeploy complete...");
-
- }
-
-}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java
index c0be8992ef..d65311dfe8 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java
@@ -26,8 +26,6 @@ import java.util.List;
import java.util.Map;
import org.camunda.bpm.engine.MismatchingMessageCorrelationException;
-import org.camunda.bpm.engine.ProcessEngineServices;
-import org.camunda.bpm.engine.ProcessEngines;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.runtime.Execution;
import org.camunda.bpm.engine.runtime.MessageCorrelationResult;
@@ -38,7 +36,7 @@ import org.openecomp.mso.logger.MsoLogger;
/**
* Abstract base class for callback services.
*/
-public abstract class AbstractCallbackService {
+public abstract class AbstractCallbackService extends ProcessEngineAwareService {
public static final long DEFAULT_TIMEOUT_SECONDS = 60;
public static final long FAST_POLL_DUR_SECONDS = 5;
public static final long FAST_POLL_INT_MS = 100;
@@ -46,8 +44,6 @@ public abstract class AbstractCallbackService {
private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
- protected volatile ProcessEngineServices pes4junit = null;
-
/**
* Parameterized callback handler.
*/
@@ -368,16 +364,4 @@ public abstract class AbstractCallbackService {
+ ":" + execution.getId() + "]";
}
}
-
- protected ProcessEngineServices getProcessEngineServices() {
- if (pes4junit == null) {
- return ProcessEngines.getProcessEngine("infrastructure");
- } else {
- return pes4junit;
- }
- }
-
- public void setProcessEngineServices4junit(ProcessEngineServices pes) {
- pes4junit = pes;
- }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/ProcessEngineAwareService.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/ProcessEngineAwareService.java
new file mode 100644
index 0000000000..dbb6674a64
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/ProcessEngineAwareService.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.bpmn.common.workflow.service;
+
+import java.util.Optional;
+
+import org.camunda.bpm.engine.ProcessEngineServices;
+import org.camunda.bpm.engine.ProcessEngines;
+
+/**
+ * Base class for services that must be process-engine aware. The only
+ * process engine currently supported is the "default" process engine.
+ */
+public class ProcessEngineAwareService {
+
+ private final String processEngineName = "default";
+ private volatile Optional<ProcessEngineServices> pes4junit = Optional.empty();
+
+ /**
+ * Gets the process engine name.
+ * @return the process engine name
+ */
+ public String getProcessEngineName() {
+ return processEngineName;
+ }
+
+ /**
+ * Gets process engine services.
+ * @return process engine services
+ */
+ public ProcessEngineServices getProcessEngineServices() {
+ return pes4junit.orElse(ProcessEngines.getProcessEngine(
+ getProcessEngineName()));
+ }
+
+ /**
+ * Allows a particular process engine to be specified, overriding the
+ * usual process engine lookup by name. Intended primarily for the
+ * unit test environment.
+ * @param pes process engine services
+ */
+ public void setProcessEngineServices4junit(ProcessEngineServices pes) {
+ pes4junit = Optional.ofNullable(pes);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java
index 2186e071f4..c5f0d02dff 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java
@@ -20,9 +20,6 @@
package org.openecomp.mso.bpmn.common.workflow.service;
-import java.util.HashMap;
-import java.util.Map;
-
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
@@ -30,16 +27,9 @@ import javax.jws.WebService;
import javax.ws.rs.core.Context;
import javax.xml.ws.WebServiceContext;
-import org.camunda.bpm.BpmPlatform;
-import org.camunda.bpm.engine.MismatchingMessageCorrelationException;
-import org.camunda.bpm.engine.ProcessEngineServices;
-import org.camunda.bpm.engine.RuntimeService;
-import org.camunda.bpm.engine.runtime.ExecutionQuery;
import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest;
import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterResponse;
import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCCallbackAdapterPortType;
-import org.openecomp.mso.bpmn.core.PropertyConfiguration;
-import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoLogger;
/**
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java
index 99909b68a0..608adcf756 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java
@@ -53,7 +53,7 @@ import org.slf4j.MDC;
* For asynchronous process - the activity may send a acknowledgement response and then proceed further on executing the process
*/
@Path("/async")
-public abstract class WorkflowAsyncResource {
+public class WorkflowAsyncResource extends ProcessEngineAwareService {
private static final WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance();
protected Optional<ProcessEngineServices> pes4junit = Optional.empty();
@@ -274,12 +274,6 @@ public abstract class WorkflowAsyncResource {
}
- protected abstract ProcessEngineServices getProcessEngineServices();
-
- public void setProcessEngineServices4junit(ProcessEngineServices pes) {
- pes4junit = Optional.ofNullable(pes);
- }
-
private static Map<String, Object> getInputVariables(VariableMapImpl variableMap) {
Map<String, Object> inputVariables = new HashMap<>();
@SuppressWarnings("unchecked")
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java
index 0521fb4df3..76ff221018 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java
@@ -39,7 +39,6 @@ import javax.ws.rs.core.UriInfo;
import org.camunda.bpm.engine.HistoryService;
import org.camunda.bpm.engine.ProcessEngineException;
import org.camunda.bpm.engine.ProcessEngineServices;
-import org.camunda.bpm.engine.ProcessEngines;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.history.HistoricVariableInstance;
import org.camunda.bpm.engine.runtime.ProcessInstance;
@@ -53,10 +52,8 @@ import org.openecomp.mso.logger.MsoLogger;
import org.slf4j.MDC;
@Path("/workflow")
-public class WorkflowResource {
+public class WorkflowResource extends ProcessEngineAwareService {
- private ProcessEngineServices pes4junit = null;
-
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
private static final String LOGMARKER = "[WRKFLOW-RESOURCE]";
@@ -615,16 +612,4 @@ public class WorkflowResource {
return response;
}
-
- private ProcessEngineServices getProcessEngineServices() {
- if (pes4junit == null) {
- return ProcessEngines.getProcessEngine("infrastructure");
- } else {
- return pes4junit;
- }
- }
-
- public void setProcessEngineServices4junit(ProcessEngineServices pes) {
- pes4junit = pes;
- }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java
index 4f99edd660..193b8fe903 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java
@@ -26,23 +26,12 @@ import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowMessageResource;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource;
-
-/**
- * @version 1.0
- * RESTeasy workflow application which wires synchronous and asynchronous response
- *
- */
@ApplicationPath("/")
public class WorkflowResourceApplication extends Application {
private Set<Object> singletons = new HashSet<Object>();
private Set<Class<?>> classes = new HashSet<Class<?>>();
public WorkflowResourceApplication() {
- singletons.add(new WorkflowResource());
- singletons.add(new WorkflowAsyncCommonResource());
- singletons.add(new WorkflowMessageResource());
}
@Override
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/PreconditionFailedException.java
index 4534b56efc..df28baac74 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/PreconditionFailedException.java
@@ -1,32 +1,35 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.common.workflow.service;
-
-import org.camunda.bpm.engine.ProcessEngineServices;
-import org.camunda.bpm.engine.ProcessEngines;
-
-
-public class WorkflowAsyncCommonResource extends WorkflowAsyncResource {
-
- protected ProcessEngineServices getProcessEngineServices() {
- return pes4junit.orElse(ProcessEngines.getProcessEngine("infrastructure"));
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+
+public class PreconditionFailedException extends WebApplicationException {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public PreconditionFailedException(String message) {
+ super(message, Response.Status.PRECONDITION_FAILED);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapper.java
new file mode 100644
index 0000000000..e0e3e936be
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapper.java
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Optional;
+
+import javax.annotation.Priority;
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.ForbiddenException;
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.NotAcceptableException;
+import javax.ws.rs.NotAllowedException;
+import javax.ws.rs.NotAuthorizedException;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.NotSupportedException;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientResponseContext;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+@Priority(value = 1)
+public abstract class ResponseExceptionMapper implements ClientResponseFilter {
+
+ @Override
+ public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
+ if (responseContext.getStatus() >= 300) {
+ String message = "empty message";
+ if (responseContext.hasEntity()) {
+ Optional<String> result = this.extractMessage(responseContext.getEntityStream());
+ if (result.isPresent()) {
+ message = result.get();
+ }
+ }
+ Response.Status status = Response.Status.fromStatusCode(responseContext.getStatus());
+ WebApplicationException webAppException;
+ switch (status) {
+ case BAD_REQUEST:
+ webAppException = new BadRequestException(message);
+ break;
+ case UNAUTHORIZED:
+ webAppException = new NotAuthorizedException(message);
+ break;
+ case FORBIDDEN:
+ webAppException = new ForbiddenException(message);
+ break;
+ case NOT_FOUND:
+ webAppException = new NotFoundException(message);
+ break;
+ case METHOD_NOT_ALLOWED:
+ webAppException = new NotAllowedException(message);
+ break;
+ case NOT_ACCEPTABLE:
+ webAppException = new NotAcceptableException(message);
+ break;
+ case PRECONDITION_FAILED:
+ webAppException = new PreconditionFailedException(message);
+ break;
+ case UNSUPPORTED_MEDIA_TYPE:
+ webAppException = new NotSupportedException(message);
+ break;
+ case INTERNAL_SERVER_ERROR:
+ webAppException = new InternalServerErrorException(message);
+ break;
+ case SERVICE_UNAVAILABLE:
+ webAppException = new WebApplicationException(message);
+ break;
+ default:
+ webAppException = new WebApplicationException(message);
+ }
+ throw webAppException;
+ }
+ }
+
+ public abstract Optional<String> extractMessage(InputStream stream) throws IOException;
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapperImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapperImpl.java
new file mode 100644
index 0000000000..0845a2fbcd
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapperImpl.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Optional;
+
+import org.apache.commons.io.IOUtils;
+
+public class ResponseExceptionMapperImpl extends ResponseExceptionMapper {
+
+ @Override
+ public Optional<String> extractMessage(InputStream stream) throws IOException {
+ final String input = IOUtils.toString(stream, "UTF-8");
+ IOUtils.closeQuietly(stream);
+ return Optional.of(input);
+ }
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestProperties.java
new file mode 100644
index 0000000000..ae8862de5e
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestProperties.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public interface RestProperties {
+
+ public URL getEndpoint() throws MalformedURLException;
+ public String getSystemName();
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestPropertiesLoader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestPropertiesLoader.java
new file mode 100644
index 0000000000..6d49d9800f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestPropertiesLoader.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client;
+
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+public class RestPropertiesLoader {
+
+ private final ServiceLoader<RestProperties> services;
+ private RestPropertiesLoader() {
+ services = ServiceLoader.load(RestProperties.class);
+ }
+
+ private static class Helper {
+ private static final RestPropertiesLoader INSTANCE = new RestPropertiesLoader();
+ }
+
+ public static RestPropertiesLoader getInstance() {
+ return Helper.INSTANCE;
+ }
+
+ public <T> T getImpl(Class<? extends RestProperties> clazz) {
+ T result = null;
+ Iterator<RestProperties> propertyImpls = services.iterator();
+ RestProperties item;
+ while (propertyImpls.hasNext()) {
+ item = propertyImpls.next();
+ if (clazz.isAssignableFrom(item.getClass())) {
+ result = (T)item;
+ break;
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java
index f1bafde997..0e00ae5da8 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java
@@ -22,33 +22,5 @@ package org.openecomp.mso.client.dmaap;
public interface Consumer {
- /**
- * Should this consumer continue to consume messages from the topic?
- * @return
- */
- public boolean continuePolling();
- /**
- * Process a message from a DMaaP topic
- *
- * @param message
- * @throws Exception
- */
- public void processMessage(String message) throws Exception;
- /**
- * Has the request been accepted by the receiving system?
- * Should the consumer move to processing messages?
- *
- * @param message
- * @return
- */
- public boolean isAccepted(String message);
- /**
- * The request id to filter messages on
- * @return
- */
- public String getRequestId();
- /**
- * Logic that defines when the consumer should stop processing messages
- */
- public void stopProcessingMessages();
+ public Iterable<String> fetch();
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DefaultDmaapPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DefaultDmaapPropertiesImpl.java
new file mode 100644
index 0000000000..9af1fd3f7e
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DefaultDmaapPropertiesImpl.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.dmaap;
+
+import java.util.Map;
+
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+
+public class DefaultDmaapPropertiesImpl implements DmaapProperties {
+
+ private final Map<String, String> properties;
+ public DefaultDmaapPropertiesImpl() {
+ this.properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+ }
+ @Override
+ public Map<String, String> getProperties() {
+ return this.properties;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapClient.java
new file mode 100644
index 0000000000..7862c9d41d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapClient.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.dmaap;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Map;
+import java.util.Properties;
+
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+public abstract class DmaapClient {
+
+ protected final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
+ protected final Map<String, String> msoProperties;
+ protected final Properties properties;
+ public DmaapClient(String filepath) throws FileNotFoundException, IOException {
+ Resource resource = new ClassPathResource(filepath);
+ DmaapProperties dmaapProperties = DmaapPropertiesLoader.getInstance().getImpl();
+ if (dmaapProperties == null) {
+ dmaapProperties = new DefaultDmaapPropertiesImpl();
+ }
+ this.msoProperties = dmaapProperties.getProperties();
+ this.properties = new Properties();
+ this.properties.load(resource.getInputStream());
+ this.properties.put("password", this.deobfuscatePassword(this.getPassword()));
+ this.properties.put("username", this.getUserName());
+ this.properties.put("topic", this.getTopic());
+ }
+ protected String deobfuscatePassword(String password) {
+
+ try {
+ return new String(Base64.getDecoder().decode(password.getBytes()));
+ } catch(IllegalArgumentException iae) {
+
+ return password;
+ }
+ }
+
+
+ public abstract String getUserName();
+ public abstract String getPassword();
+ public abstract String getTopic();
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java
index 2a618763ff..033951612d 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java
@@ -22,39 +22,110 @@ package org.openecomp.mso.client.dmaap;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
-import com.att.nsa.mr.client.MRClientFactory;
-import com.att.nsa.mr.client.MRConsumer;
+import org.openecomp.mso.client.dmaap.exceptions.DMaaPConsumerFailure;
+import org.openecomp.mso.client.dmaap.exceptions.ExceededMaximumPollingTime;
+import org.openecomp.mso.client.dmaap.rest.RestConsumer;
-public class DmaapConsumer {
+import com.google.common.base.Stopwatch;
- private final MRConsumer mrConsumer;
- public DmaapConsumer() {
- mrConsumer = null;
- }
- public DmaapConsumer (String filepath) throws FileNotFoundException, IOException {
-
- mrConsumer = MRClientFactory.createConsumer(filepath);
+public abstract class DmaapConsumer extends DmaapClient {
+
+ public DmaapConsumer() throws FileNotFoundException, IOException {
+ super("dmaap/default-consumer.properties");
}
-
- public MRConsumer getMRConsumer() {
- return mrConsumer;
+ public Consumer getConsumer() throws FileNotFoundException, IOException {
+ return new RestConsumer(this.properties);
}
- public boolean consume(Consumer consumer) throws Exception {
+ public boolean consume() throws Exception {
+
+ Consumer mrConsumer = this.getConsumer();
+ int iterations = 0;
boolean accepted = false;
- while (consumer.continuePolling()) {
- for (String message : this.getMRConsumer().fetch()) {
- if (!accepted && consumer.isAccepted(message)) {
- accepted = true;
- }
- if (accepted) {
- consumer.processMessage(message);
+ Stopwatch stopwatch = Stopwatch.createUnstarted();
+ try {
+ while (this.continuePolling()) {
+ if (stopwatch.elapsed(TimeUnit.MILLISECONDS) >= this.getMaximumElapsedTime()) {
+ final String message = "exceeded maximum retries on " + this.getRequestId() + " on " + this.getTopic();
+ auditLogger.error(message);
+ throw new ExceededMaximumPollingTime(message);
}
+ stopwatch.start();
+ Iterable<String> itr = mrConsumer.fetch();
+ stopwatch.stop();
+ for (String message : itr) {
+ if (!accepted && this.isAccepted(message)) {
+ auditLogger.info("accepted message found for " + this.getRequestId() + " on " + this.getTopic());
+ accepted = true;
+ }
+ if (accepted) {
+ if (this.isFailure(message)) {
+ this.stopProcessingMessages();
+ auditLogger.info("received dmaap message: " + message);
+ final String errorMsg = "failure received from dmaap topic " + this.getTopic();
+ auditLogger.error(errorMsg);
+ throw new DMaaPConsumerFailure(errorMsg);
+ } else {
+ auditLogger.info("received dmaap message: " + message);
+ this.processMessage(message);
+ }
+ }
+ }
+ iterations++;
+ }
+ return true;
+ } catch (Exception e ) {
+ throw e;
+ } finally {
+ if (stopwatch.isRunning()) {
+ stopwatch.stop();
}
}
-
- return true;
}
+ /**
+ * Should this consumer continue to consume messages from the topic?
+ * @return
+ */
+ public abstract boolean continuePolling();
+ /**
+ * Process a message from a DMaaP topic
+ *
+ * @param message
+ * @throws Exception
+ */
+ public abstract void processMessage(String message) throws Exception;
+ /**
+ * Has the request been accepted by the receiving system?
+ * Should the consumer move to processing messages?
+ *
+ * @param message
+ * @return
+ */
+ public abstract boolean isAccepted(String message);
+ /**
+ * has the request failed?
+ *
+ * @param message
+ * @return
+ */
+ public abstract boolean isFailure(String message);
+ /**
+ * The request id to filter messages on
+ * @return
+ */
+ public abstract String getRequestId();
+ /**
+ * Logic that defines when the consumer should stop processing messages
+ */
+ public abstract void stopProcessingMessages();
+
+ /**
+ * time in milliseconds
+ */
+ public int getMaximumElapsedTime() {
+ return 180000;
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapProperties.java
new file mode 100644
index 0000000000..7bdd7dfe40
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapProperties.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.dmaap;
+
+import java.util.Map;
+
+public interface DmaapProperties {
+
+ /**
+ * A map of strings which contains the properties for a dmaap client
+ * @return
+ */
+ public Map<String, String> getProperties();
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java
new file mode 100644
index 0000000000..a21dbe8477
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.dmaap;
+
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+public class DmaapPropertiesLoader {
+
+ private final ServiceLoader<DmaapProperties> services;
+ private DmaapPropertiesLoader() {
+ services = ServiceLoader.load(DmaapProperties.class);
+ }
+
+ private static class Helper {
+ private static final DmaapPropertiesLoader INSTANCE = new DmaapPropertiesLoader();
+ }
+
+ public static DmaapPropertiesLoader getInstance() {
+ return Helper.INSTANCE;
+ }
+
+ public DmaapProperties getImpl() {
+ Iterator<DmaapProperties> propertyImpls = services.iterator();
+ while (propertyImpls.hasNext()) {
+ return propertyImpls.next();
+ }
+
+ return null;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java
index 4d70a16b73..d2752c531b 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java
@@ -22,29 +22,30 @@ package org.openecomp.mso.client.dmaap;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-import com.att.nsa.mr.client.MRBatchingPublisher;
-import com.att.nsa.mr.client.MRClientFactory;
+import org.openecomp.mso.client.dmaap.rest.RestPublisher;
-public class DmaapPublisher {
+public abstract class DmaapPublisher extends DmaapClient {
- private final long seconds;
- private final MRBatchingPublisher publisher;
-
- public DmaapPublisher(String filepath) throws FileNotFoundException, IOException {
+ private long seconds;
+ private final Publisher publisher;
+ public DmaapPublisher() throws FileNotFoundException, IOException {
+ super("dmaap/default-consumer.properties");
+ this.publisher = new RestPublisher(properties);
this.seconds = 20;
- this.publisher = MRClientFactory.createBatchingPublisher(filepath);
+
}
- public DmaapPublisher(String filepath, long seconds) throws FileNotFoundException, IOException {
+ public DmaapPublisher(long seconds) throws FileNotFoundException, IOException {
+ this();
this.seconds = seconds;
- this.publisher = MRClientFactory.createBatchingPublisher(filepath);
}
public void send(String json) throws IOException, InterruptedException {
+ auditLogger.info("publishing message to dmaap topic " + this.getTopic() + ": " + json);
publisher.send(json);
- publisher.close(seconds, TimeUnit.SECONDS);
+ //publisher.close(seconds, TimeUnit.SECONDS);
}
+
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Publisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Publisher.java
new file mode 100644
index 0000000000..d89ee6e5c6
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Publisher.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.dmaap;
+
+public interface Publisher {
+
+ public void send(String json);
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/DMaaPConsumerFailure.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/DMaaPConsumerFailure.java
new file mode 100644
index 0000000000..29472b2180
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/DMaaPConsumerFailure.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.dmaap.exceptions;
+
+public class DMaaPConsumerFailure extends Exception {
+
+ private static final long serialVersionUID = 2499229901897110362L;
+
+ public DMaaPConsumerFailure() {
+ super();
+ }
+
+ public DMaaPConsumerFailure(String message) {
+ super(message);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/ExceededMaximumPollingTime.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/ExceededMaximumPollingTime.java
new file mode 100644
index 0000000000..c9d675067e
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/ExceededMaximumPollingTime.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.dmaap.exceptions;
+
+public class ExceededMaximumPollingTime extends RuntimeException {
+
+ private static final long serialVersionUID = 2331207691092906423L;
+
+ public ExceededMaximumPollingTime() {
+ super();
+ }
+
+ public ExceededMaximumPollingTime(String message) {
+ super(message);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java
new file mode 100644
index 0000000000..124e2c3a28
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.dmaap.rest;
+
+import java.net.URL;
+import java.util.Base64;
+import java.util.Map;
+import java.util.Optional;
+
+import javax.ws.rs.client.ClientResponseFilter;
+
+import org.openecomp.mso.client.ResponseExceptionMapperImpl;
+import org.openecomp.mso.client.policy.RestClient;
+
+public class DMaaPRestClient extends RestClient {
+
+ private final String username;
+ private final String password;
+ public DMaaPRestClient(URL url, String contentType, String username, String password) {
+ super(url, contentType);
+ this.username = username;
+ this.password = password;
+ }
+
+ @Override
+ protected void initializeHeaderMap(Map<String, String> headerMap) {
+ headerMap.put("Authorization", "Basic " + Base64.getEncoder().encodeToString(new String(username + ":" + password).getBytes()));
+ }
+
+ @Override
+ protected Optional<ClientResponseFilter> addResponseFilter() {
+ return Optional.of(new ResponseExceptionMapperImpl());
+ }
+
+ @Override
+ public RestClient addRequestId(String requestId) {
+ return null;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/PropertiesBean.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/PropertiesBean.java
new file mode 100644
index 0000000000..fb914a0c13
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/PropertiesBean.java
@@ -0,0 +1,131 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.dmaap.rest;
+
+import java.util.Properties;
+
+public class PropertiesBean {
+
+ private String username;
+ private String password;
+ private String environment;
+ private String partition;
+ private String contentType;
+ private String host;
+ private String topic;
+ private String timeout;
+
+
+ public PropertiesBean(Properties properties) {
+ this.withUsername(properties.getProperty("username"))
+ .withPassword(properties.getProperty("password"))
+ .withTopic(properties.getProperty("topic"))
+ .withEnvironment(properties.getProperty("environment"))
+ .withHost(properties.getProperty("host"))
+ .withTimeout(properties.getProperty("timeout", "20000"))
+ .withPartition(properties.getProperty("partition"))
+ .withContentType(properties.getProperty("contentType", "application/json"));
+ }
+ public String getUsername() {
+ return username;
+ }
+ public void setUsername(String username) {
+ this.username = username;
+ }
+ public PropertiesBean withUsername(String username) {
+ this.username = username;
+ return this;
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+ public PropertiesBean withPassword(String password) {
+ this.password = password;
+ return this;
+ }
+ public String getEnvironment() {
+ return environment;
+ }
+ public void setEnvironment(String environment) {
+ this.environment = environment;
+ }
+ public PropertiesBean withEnvironment(String environment) {
+ this.environment = environment;
+ return this;
+ }
+ public String getPartition() {
+ return partition;
+ }
+ public void setPartition(String partition) {
+ this.partition = partition;
+ }
+ public PropertiesBean withPartition(String partition) {
+ this.partition = partition;
+ return this;
+ }
+ public String getContentType() {
+ return contentType;
+ }
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+ public PropertiesBean withContentType(String contentType) {
+ this.contentType = contentType;
+ return this;
+ }
+ public String getHost() {
+ return host;
+ }
+ public void setHost(String host) {
+ this.host = host;
+ }
+ public PropertiesBean withHost(String host) {
+ this.host = host;
+ return this;
+ }
+ public String getTopic() {
+ return topic;
+ }
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+ public PropertiesBean withTopic(String topic) {
+ this.topic = topic;
+ return this;
+ }
+ public String getTimeout() {
+ return timeout;
+ }
+ public void setTimeout(String timeout) {
+ this.timeout = timeout;
+ }
+ public PropertiesBean withTimeout(String timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+
+
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestConsumer.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestConsumer.java
new file mode 100644
index 0000000000..ff199e2373
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestConsumer.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.dmaap.rest;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.UriBuilder;
+
+import org.openecomp.mso.client.dmaap.Consumer;
+import org.openecomp.mso.client.policy.RestClient;
+
+public class RestConsumer implements Consumer {
+
+ private final RestClient client;
+ public RestConsumer(Properties properties) {
+ PropertiesBean bean = new PropertiesBean(properties);
+ client = new DMaaPRestClient(this.createURL(bean), bean.getContentType(), bean.getUsername(), bean.getPassword());
+ }
+
+ private URL createURL(PropertiesBean properties) {
+ try {
+ return UriBuilder.fromUri("http://" + properties.getHost())
+ .path("events").path(properties.getTopic())
+ .path(properties.getPartition())
+ .path("consumer1")
+ .queryParam("timeout", properties.getTimeout()).build().toURL();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public Iterable<String> fetch() {
+
+ return client.get(new GenericType<List<String>>() {});
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestPublisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestPublisher.java
new file mode 100644
index 0000000000..e8e685932a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestPublisher.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.dmaap.rest;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriBuilderException;
+
+import org.openecomp.mso.client.dmaap.Publisher;
+import org.openecomp.mso.client.policy.RestClient;
+
+public class RestPublisher implements Publisher {
+
+ private final RestClient client;
+
+ public RestPublisher(Properties properties) {
+ PropertiesBean bean = new PropertiesBean(properties);
+ client = new DMaaPRestClient(this.createURL(bean), bean.getContentType(), bean.getUsername(), bean.getPassword());
+ }
+
+ private URL createURL(PropertiesBean properties) {
+ try {
+ return UriBuilder.fromUri("http://" + properties.getHost())
+ .path("events").path(properties.getTopic())
+ .queryParam("timeout", properties.getTimeout()).build().toURL();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public void send(String json) {
+ client.post(json);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java
index 665b9052eb..e02941944a 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java
@@ -1,130 +1,138 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.client.policy;
-
-import java.io.BufferedInputStream;
-
-import java.io.ByteArrayOutputStream;
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.logging.Logger;
-import javax.annotation.Priority;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.client.ClientRequestContext;
-import javax.ws.rs.client.ClientRequestFilter;
-import javax.ws.rs.client.ClientResponseContext;
-import javax.ws.rs.client.ClientResponseFilter;
-import javax.ws.rs.ext.WriterInterceptor;
-import javax.ws.rs.ext.WriterInterceptorContext;
-
-@Priority(Integer.MIN_VALUE)
-public class LoggingFilter implements ClientRequestFilter, ClientResponseFilter, WriterInterceptor {
-
- private static final Logger logger = Logger.getLogger(LoggingFilter.class.getName());
- private static final String ENTITY_STREAM_PROPERTY = "LoggingFilter.entityStream";
- private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
- private final int maxEntitySize = 1024 * 8;
-
- private void log(StringBuilder sb) {
- logger.info(sb.toString());
- }
-
- private InputStream logInboundEntity(final StringBuilder b, InputStream stream, final Charset charset)
- throws IOException {
- InputStream inputStream = stream;
- if (!inputStream.markSupported()) {
- inputStream = new BufferedInputStream(inputStream);
- }
- inputStream.mark(maxEntitySize + 1);
- final byte[] entity = new byte[maxEntitySize + 1];
- final int entitySize = inputStream.read(entity);
- b.append(new String(entity, 0, Math.min(entitySize, maxEntitySize), charset));
- if (entitySize > maxEntitySize) {
- b.append("...more...");
- }
- b.append('\n');
- inputStream.reset();
- return inputStream;
- }
-
- @Override
- public void filter(ClientRequestContext requestContext) throws IOException {
- if (requestContext.hasEntity()) {
- final OutputStream stream = new LoggingStream(requestContext.getEntityStream());
- requestContext.setEntityStream(stream);
- requestContext.setProperty(ENTITY_STREAM_PROPERTY, stream);
- }
- }
-
- @Override
- public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
- final StringBuilder sb = new StringBuilder();
- if (responseContext.hasEntity()) {
- responseContext.setEntityStream(logInboundEntity(sb, responseContext.getEntityStream(), DEFAULT_CHARSET));
- log(sb);
- }
-
- }
-
- @Override
- public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
- final LoggingStream stream = (LoggingStream) context.getProperty(ENTITY_STREAM_PROPERTY);
- context.proceed();
- if (stream != null) {
- log(stream.getStringBuilder(DEFAULT_CHARSET));
- }
- }
-
- private class LoggingStream extends FilterOutputStream {
-
- private final StringBuilder sb = new StringBuilder();
- private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- LoggingStream(OutputStream out) {
- super(out);
- }
-
- StringBuilder getStringBuilder(Charset charset) {
- // write entity to the builder
- final byte[] entity = baos.toByteArray();
-
- sb.append(new String(entity, 0, entity.length, charset));
- if (entity.length > maxEntitySize) {
- sb.append("...more...");
- }
- sb.append('\n');
-
- return sb;
- }
-
- @Override
- public void write(final int i) throws IOException {
- if (baos.size() <= maxEntitySize) {
- baos.write(i);
- }
- out.write(i);
- }
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.policy;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.logging.Logger;
+
+import javax.annotation.Priority;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseContext;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.ext.WriterInterceptor;
+import javax.ws.rs.ext.WriterInterceptorContext;
+
+@Priority(Integer.MIN_VALUE)
+public class LoggingFilter implements ClientRequestFilter, ClientResponseFilter, WriterInterceptor {
+
+ private static final Logger logger = Logger.getLogger(LoggingFilter.class.getName());
+ private static final String ENTITY_STREAM_PROPERTY = "LoggingFilter.entityStream";
+ private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
+ private final int maxEntitySize;
+
+ public LoggingFilter() {
+ maxEntitySize = 1024 * 1024;
+ }
+
+ public LoggingFilter(int maxPayloadSize) {
+ this.maxEntitySize = Integer.min(maxPayloadSize, 1024 * 1024);
+ }
+
+ private void log(StringBuilder sb) {
+ logger.info(sb.toString());
+ }
+
+ private InputStream logInboundEntity(final StringBuilder b, InputStream stream, final Charset charset)
+ throws IOException {
+ if (!stream.markSupported()) {
+ stream = new BufferedInputStream(stream);
+ }
+ stream.mark(maxEntitySize + 1);
+ final byte[] entity = new byte[maxEntitySize + 1];
+ final int entitySize = stream.read(entity);
+ if (entitySize != -1) {
+ b.append(new String(entity, 0, Math.min(entitySize, maxEntitySize), charset));
+ }
+ if (entitySize > maxEntitySize) {
+ b.append("...more...");
+ }
+ b.append('\n');
+ stream.reset();
+ return stream;
+ }
+
+ @Override
+ public void filter(ClientRequestContext requestContext) throws IOException {
+ if (requestContext.hasEntity()) {
+ final OutputStream stream = new LoggingStream(requestContext.getEntityStream());
+ requestContext.setEntityStream(stream);
+ requestContext.setProperty(ENTITY_STREAM_PROPERTY, stream);
+ }
+ }
+
+ @Override
+ public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
+ final StringBuilder sb = new StringBuilder();
+ if (responseContext.hasEntity()) {
+ responseContext.setEntityStream(logInboundEntity(sb, responseContext.getEntityStream(), DEFAULT_CHARSET));
+ log(sb);
+ }
+ }
+
+ @Override
+ public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
+ final LoggingStream stream = (LoggingStream) context.getProperty(ENTITY_STREAM_PROPERTY);
+ context.proceed();
+ if (stream != null) {
+ log(stream.getStringBuilder(DEFAULT_CHARSET));
+ }
+ }
+
+ private class LoggingStream extends FilterOutputStream {
+
+ private final StringBuilder sb = new StringBuilder();
+ private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ LoggingStream(OutputStream out) {
+ super(out);
+ }
+
+ StringBuilder getStringBuilder(Charset charset) {
+ // write entity to the builder
+ final byte[] entity = baos.toByteArray();
+
+ sb.append(new String(entity, 0, entity.length, charset));
+ if (entity.length > maxEntitySize) {
+ sb.append("...more...");
+ }
+ sb.append('\n');
+
+ return sb;
+ }
+
+ @Override
+ public void write(final int i) throws IOException {
+ if (baos.size() <= maxEntitySize) {
+ baos.write(i);
+ }
+ out.write(i);
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java
index 71ae56f55b..4ed2a887ef 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP - SO
+ * OPENECOMP - MSO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -20,50 +20,47 @@
package org.openecomp.mso.client.policy;
+import java.net.MalformedURLException;
import java.util.Map;
+import java.util.Optional;
import java.util.UUID;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.MediaType;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriBuilderException;
+import org.openecomp.mso.client.ResponseExceptionMapperImpl;
+import org.openecomp.mso.client.RestProperties;
+import org.openecomp.mso.client.policy.entities.PolicyServiceType;
import org.springframework.stereotype.Service;
@Service
public class PolicyRestClient extends RestClient {
- private static final String ENDPOINT_KEY = "policy.endpoint";
private static final String X_ECOMP_REQUESTID = String.valueOf(UUID.randomUUID());
-
- public PolicyRestClient() {
- super(ENDPOINT_KEY);
+ private final PolicyRestProperties properties;
+ public PolicyRestClient(PolicyRestProperties props, PolicyServiceType serviceType) {
+ super(props, Optional.of(UriBuilder.fromPath(serviceType.toString()).build()));
+ this.properties = props;
+ this.getClient();
}
@Override
protected void initializeHeaderMap(Map<String, String> headerMap) {
- headerMap.put("ClientAuth", properties.get("policy.client.auth"));
- headerMap.put("Authorization", properties.get("policy.auth"));
- headerMap.put("Environment", properties.get("policy.environment"));
- headerMap.put("X-ECOMP-RequestID", X_ECOMP_REQUESTID);
+ headerMap.put("ClientAuth", properties.getClientAuth());
+ headerMap.put("Authorization", properties.getAuth());
+ headerMap.put("Environment", properties.getEnvironment());
+ this.addRequestId(X_ECOMP_REQUESTID);
}
- public PolicyDecision getDecision(String serviceType, String vnfType, String bbID, String workStep,
- String errorCode) {
- DecisionAttributes decisionAttributes = new DecisionAttributes();
- decisionAttributes.setServiceType(serviceType);
- decisionAttributes.setVNFType(vnfType);
- decisionAttributes.setBBID(bbID);
- decisionAttributes.setWorkStep(workStep);
- decisionAttributes.setErrorCode(errorCode);
-
- return this.getDecision(decisionAttributes);
+ @Override
+ protected Optional<ClientResponseFilter> addResponseFilter() {
+ return Optional.of(new ResponseExceptionMapperImpl());
}
- private PolicyDecision getDecision(DecisionAttributes decisionAttributes) {
- PolicyDecisionRequest decisionRequest = new PolicyDecisionRequest();
- decisionRequest.setDecisionAttributes(decisionAttributes);
- decisionRequest.setEcompcomponentName(ECOMP_COMPONENT_NAME);
-
- return this.getBuilder().accept(MediaType.APPLICATION_JSON_TYPE)
- .post(Entity.entity(decisionRequest, MediaType.APPLICATION_JSON)).readEntity(PolicyDecision.class);
+ @Override
+ public RestClient addRequestId(String requestId) {
+ this.headerMap.put("X-ECOMP-RequestID", requestId);
+ return this;
}
} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestProperties.java
new file mode 100644
index 0000000000..d9336768fc
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestProperties.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.policy;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+import org.openecomp.mso.client.RestProperties;
+
+public class PolicyRestProperties implements RestProperties {
+
+
+ final Map<String, String> props;
+ public PolicyRestProperties() {
+ this.props = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+
+ }
+ @Override
+ public URL getEndpoint() {
+ try {
+ return new URL(props.getOrDefault("policy.endpoint", ""));
+ } catch (MalformedURLException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public String getSystemName() {
+ return "MSO";
+ }
+
+ public String getClientAuth() {
+ return props.get("policy.client.auth");
+ }
+
+ public String getAuth() {
+ return props.get("policy.auth");
+ }
+
+ public String getEnvironment() {
+ return props.get("policy.environment");
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java
index 81c072ff33..74b1c3f802 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java
@@ -20,51 +20,104 @@
package org.openecomp.mso.client.policy;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.logging.Logger;
+import java.util.Optional;
+import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.ext.ContextResolver;
-
-import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+import org.apache.log4j.Logger;
+import org.openecomp.mso.client.RestProperties;
import org.openecomp.mso.logger.MsoLogger;
import org.springframework.stereotype.Service;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
@Service
public abstract class RestClient {
protected static final String ECOMP_COMPONENT_NAME = "MSO";
-
+
+ private static final int MAX_PAYLOAD_SIZE = 1024 * 1024;
private WebTarget webTarget;
protected final Map<String, String> headerMap;
protected final MsoLogger msoLogger;
- protected Map<String, String> properties;
- protected String host;
+ protected URL host;
+ protected Optional<URI> path;
+ protected Logger logger;
+ protected String accept;
+ protected String contentType;
- protected RestClient(String endpointKey) {
- Logger logger = Logger.getLogger(getClass().getName());
+ protected RestClient(RestProperties props, Optional<URI> path) {
+ logger = Logger.getLogger(getClass().getName());
msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
-
- properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+
headerMap = new HashMap<>();
- initializeHeaderMap(headerMap);
+ try {
+ host = props.getEndpoint();
+ } catch (MalformedURLException e) {
+ logger.error("url not valid", e);
+ throw new RuntimeException(e);
+ }
+
+ this.path = path;
+ initializeClient(getClient());
+ }
- host = this.getHost(endpointKey);
+ protected RestClient(RestProperties props, Optional<URI> path, String accept, String contentType) {
+ this(props, path);
+ this.accept = accept;
+ this.contentType = contentType;
- webTarget = ClientBuilder.newClient().register(logger).register(new LoggingFilter())
- .register(new CommonObjectMapperProvider()).target(host);
}
- private String getHost(String key) {
- return properties.get(key);
+ protected RestClient(URL host, String contentType) {
+ headerMap = new HashMap<>();
+ logger = Logger.getLogger(getClass().getName());
+ msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
+ this.path = Optional.empty();
+ this.host = host;
+ this.contentType = contentType;
+ initializeClient(getClient());
+ }
+
+ /**
+ * Override method to return false to disable logging.
+ *
+ * @return true - to enable logging, false otherwise
+ */
+ protected boolean enableLogging() {
+ return true;
+ }
+
+ /**
+ * Override method to return custom value for max payload size.
+ *
+ * @return Default value for MAX_PAYLOAD_SIZE = 1024 * 1024
+ */
+ protected int getMaxPayloadSize()
+ {
+ return MAX_PAYLOAD_SIZE;
}
protected Builder getBuilder() {
+
Builder builder = webTarget.request();
+ initializeHeaderMap(headerMap);
for (Entry<String, String> entry : headerMap.entrySet()) {
builder.header(entry.getKey(), entry.getValue());
@@ -73,4 +126,100 @@ public abstract class RestClient {
}
protected abstract void initializeHeaderMap(Map<String, String> headerMap);
+
+ protected abstract Optional<ClientResponseFilter> addResponseFilter();
+
+ public abstract RestClient addRequestId(String requestId);
+
+ protected ContextResolver<ObjectMapper> getMapper() {
+ return new CommonObjectMapperProvider();
+ }
+
+ protected String getAccept() {
+ return accept;
+ }
+
+ protected String getContentType() {
+ return contentType;
+ }
+
+ protected String getMergeContentType() {
+ return "application/merge-patch+json";
+ }
+
+ protected Client getClient() {
+ return ClientBuilder.newBuilder().build();
+ }
+
+ protected void initializeClient(Client client) {
+ if (this.enableLogging()) {
+ client.register(logger).register(new LoggingFilter(this.getMaxPayloadSize()));
+ }
+ client.register(this.getMapper());
+ Optional<ClientResponseFilter> responseFilter = this.addResponseFilter();
+ if (responseFilter.isPresent()) {
+ client.register(responseFilter.get());
+ }
+ if (!path.isPresent()) {
+ webTarget = client.target(host.toString());
+ } else {
+ webTarget = client.target(UriBuilder.fromUri(host + path.get().toString()));
+ }
+ this.accept = MediaType.APPLICATION_JSON;
+ this.contentType = MediaType.APPLICATION_JSON;
+ }
+
+ public Response get() {
+ return this.getBuilder().accept(this.getAccept()).get();
+ }
+
+ public Response post(Object obj) {
+ return this.getBuilder().accept(this.getAccept()).post(Entity.entity(obj, this.getContentType()));
+ }
+
+ public Response patch(Object obj) {
+ return this.getBuilder().header("X-HTTP-Method-Override", "PATCH").accept(this.getAccept())
+ .post(Entity.entity(obj, this.getMergeContentType()));
+ }
+
+ public Response put(Object obj) {
+ return this.getBuilder().accept(this.getAccept()).put(Entity.entity(obj, this.getContentType()));
+ }
+
+ public Response delete() {
+ return this.getBuilder().accept(this.getAccept()).delete();
+ }
+
+ public Response delete(Object obj) {
+ return this.getBuilder().header("X-HTTP-Method-Override", "DELETE").accept(this.getAccept())
+ .put(Entity.entity(obj, this.getContentType()));
+ }
+
+ public <T> T get(Class<T> resultClass) {
+ return this.get().readEntity(resultClass);
+ }
+
+ public <T> T get(GenericType<T> resultClass) {
+ return this.get().readEntity(resultClass);
+ }
+
+ public <T> T post(Object obj, Class<T> resultClass) {
+ return this.post(obj).readEntity(resultClass);
+ }
+
+ public <T> T patch(Object obj, Class<T> resultClass) {
+ return this.patch(obj).readEntity(resultClass);
+ }
+
+ public <T> T put(Object obj, Class<T> resultClass) {
+ return this.put(obj).readEntity(resultClass);
+ }
+
+ public <T> T delete(Class<T> resultClass) {
+ return this.delete().readEntity(resultClass);
+ }
+
+ public <T> T delete(Object obj, Class<T> resultClass) {
+ return this.delete(obj).readEntity(resultClass);
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/entities/PolicyServiceType.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/entities/PolicyServiceType.java
new file mode 100644
index 0000000000..b5ab63ce35
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/entities/PolicyServiceType.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.policy.entities;
+
+public enum PolicyServiceType {
+ GET_CONFIG("getConfig"),
+ SEND_EVENT("sendEvent"),
+ PUSH_POLICY("pushPolicy"),
+ CREATE_POLICY("createPolicy"),
+ UPDATE_POLICY("updatePolicy"),
+ GET_DECISION("getDecision"),
+ GET_METRICS("getMetrics"),
+ DELETE_POLICY("deletePolicy"),
+ LIST_CONFIG("listConfig"),
+ CREATE_DICTIONARY_ITEM("createDictionaryItem"),
+ UPDATE_DICTIONARY_ITEM("updateDictionaryItem"),
+ GET_DICTIONARY_ITEMS("getDictionaryItems");
+
+ private final String name;
+
+ private PolicyServiceType(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java
index eb18e10bc3..c746c0d448 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java
@@ -32,6 +32,6 @@ public interface SDNOValidator {
* @throws IOException
* @throws Exception
*/
- public void healthDiagnostic(String vnfName, String uuid) throws IOException, Exception;
+ public void healthDiagnostic(String vnfId, String requestingUserId) throws IOException, Exception;
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java
index 92a00eee65..bdb4aa94ee 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java
@@ -30,7 +30,7 @@ import org.openecomp.mso.client.dmaap.DmaapPublisher;
import org.openecomp.mso.client.exceptions.SDNOException;
import org.openecomp.mso.jsonpath.JsonPathUtil;
-public class SDNOValidatorImpl implements SDNOValidator, Consumer {
+public class SDNOValidatorImpl implements SDNOValidator {
private final static String aafUserName = "something";
private final static String clientName = "MSO";
@@ -51,103 +51,4 @@ public class SDNOValidatorImpl implements SDNOValidator, Consumer {
//block and continue to poll waiting for response
}
- protected SDNO buildRequestDiagnostic(String vnfName, String uuid, String oamIp) {
-
- Input input = new Input();
- SDNO parentRequest = new SDNO();
- Body body = new Body();
- parentRequest.setBody(body);
- parentRequest.setNodeType("vPE");
- parentRequest.setOperation("health-diagnostic");
-
- body.setInput(input);
-
- RequestHealthDiagnostic request = new RequestHealthDiagnostic();
- request.setRequestClientName(clientName);
- request.setRequestNodeName(vnfName);
- request.setRequestNodeIp(oamIp); //generic-vnf oam ip
- request.setRequestUserId(aafUserName); //mech id?
- request.setRequestId(uuid); //something to identify this request by for polling
-
- input.setRequestHealthDiagnostic(request);
-
- return parentRequest;
- }
- protected void submitRequest(String json) throws FileNotFoundException, IOException, InterruptedException {
- DmaapPublisher publisher = new DmaapPublisher(this.producerFilePath);
- publisher.send(json);
- }
- protected boolean pollForResponse(DmaapConsumer consumer, String uuid) throws Exception {
- this.uuid = uuid;
- return consumer.consume(this);
- }
-
- @Override
- public boolean continuePolling() {
- return continuePolling;
- }
-
- @Override
- public void stopProcessingMessages() {
- continuePolling = false;
- }
- @Override
- public void processMessage(String message) throws Exception {
- if (isHealthDiagnostic(message, this.getRequestId())) {
- if (!healthDiagnosticSuccessful(message)) {
- Optional<String> statusMessage = this.getStatusMessage(message);
- if (statusMessage.isPresent()) {
- throw new SDNOException(statusMessage.get());
- } else {
- throw new SDNOException();
- }
- } else {
- stopProcessingMessages();
- }
- }
- }
-
- @Override
- public boolean isAccepted(String message) {
- if (isResultInfo(message)) {
- Optional<String> code = isAccepted(message, this.getRequestId());
- if (code.isPresent()) {
- if ("202".equals(code.get())) {
- return true;
- } else {
- //TODO check other statuses 400 and 500
- }
- } else {
- //TODO throw error
- }
- }
-
- return false;
- }
-
- @Override
- public String getRequestId() {
- return uuid;
- }
-
- protected Optional<String> isAccepted(String json, String uuid) {
- return JsonPathUtil.getInstance().locateResult(json, String.format("$.result-info[?(@.status=='ACCEPTED' && @.request-id=='%s')].code", uuid));
- }
-
- protected boolean isResultInfo(String json) {
- return JsonPathUtil.getInstance().pathExists(json, "$[?(@.result-info)]");
- }
-
- protected boolean isHealthDiagnostic(String json, String uuid) {
- return JsonPathUtil.getInstance().pathExists(json, String.format("$[?(@.result-info.request-id=='%s')].%s", uuid, healthDiagnosticPath));
- }
-
- protected boolean healthDiagnosticSuccessful(String json) {
- return JsonPathUtil.getInstance().pathExists(json, "$." + healthDiagnosticPath + "[?(@.response-status=='Success')]");
- }
-
- protected Optional<String> getStatusMessage(String json) {
- return JsonPathUtil.getInstance().locateResult(json, "$." + healthDiagnosticPath + ".response-details-json");
- }
-
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Body.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java
index 2db4dea069..cc8ce81dec 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Body.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.client.sdno;
+package org.openecomp.mso.client.sdno.beans;
import java.io.Serializable;
import java.util.HashMap;
@@ -41,7 +41,7 @@ public class Body implements Serializable
@JsonProperty("input")
private Input input;
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<>();
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 9101706044452851559L;
@JsonProperty("input")
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Input.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java
index 25eb2ed270..7b9bf6f2c7 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Input.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.client.sdno;
+package org.openecomp.mso.client.sdno.beans;
import java.io.Serializable;
import java.util.HashMap;
@@ -33,15 +33,17 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
- "request-healthdiagnostic"
+ "request-healthdiagnostic",
+ "request-hd-custom"
})
public class Input implements Serializable
{
@JsonProperty("request-healthdiagnostic")
private RequestHealthDiagnostic RequestHealthDiagnostic;
+
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<>();
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 7155546785389227528L;
@JsonProperty("request-healthdiagnostic")
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/RequestHealthDiagnostic.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java
index b1ed77b513..104dbb7ee6 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/RequestHealthDiagnostic.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.client.sdno;
+package org.openecomp.mso.client.sdno.beans;
import java.io.Serializable;
import java.util.HashMap;
@@ -59,7 +59,7 @@ public class RequestHealthDiagnostic implements Serializable
@JsonProperty("health-diagnostic-code")
private String healthDiagnosticCode;
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<>();
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 1166788526178388021L;
@JsonProperty("request-client-name")
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/ResultInfo.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java
index 0997b2df90..4d029cb8cb 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/ResultInfo.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.client.sdno;
+package org.openecomp.mso.client.sdno.beans;
import java.util.HashMap;
import java.util.Map;
@@ -51,7 +51,7 @@ private String requestId;
@JsonProperty("status")
private String status;
@JsonIgnore
-private Map<String, Object> additionalProperties = new HashMap<>();
+private Map<String, Object> additionalProperties = new HashMap<String, Object>();
@JsonProperty("client-name")
public String getClientName() {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNO.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java
index caa3ff58e9..4edd54ca09 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNO.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.client.sdno;
+package org.openecomp.mso.client.sdno.beans;
import java.io.Serializable;
import java.util.HashMap;
@@ -34,6 +34,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"operation",
+ "nodeLoc",
"nodeType",
"body"
})
@@ -42,12 +43,14 @@ public class SDNO implements Serializable
@JsonProperty("operation")
private String operation;
+ @JsonProperty("nodeLoc")
+ private String nodeLoc;
@JsonProperty("nodeType")
private String nodeType;
@JsonProperty("body")
private Body body;
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<>();
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = -5303297382564282650L;
@JsonProperty("operation")
@@ -59,8 +62,23 @@ public class SDNO implements Serializable
public void setOperation(String operation) {
this.operation = operation;
}
+
+ @JsonProperty("nodeLoc")
+ public String getNodeLoc() {
+ return nodeLoc;
+ }
+
+ @JsonProperty("nodeLoc")
+ public void setNodeLoc(String nodeLoc) {
+ this.nodeLoc = nodeLoc;
+ }
+
+ public SDNO withNodeLoc(String nodeLoc) {
+ this.nodeLoc = nodeLoc;
+ return this;
+ }
- public SDNO withOperation(String operation) {
+ public SDNO withOperation(String operation) {
this.operation = operation;
return this;
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java
new file mode 100644
index 0000000000..f23d882b53
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java
@@ -0,0 +1,156 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdno.dmaap;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Optional;
+
+import org.openecomp.mso.client.dmaap.DmaapConsumer;
+import org.openecomp.mso.client.exceptions.SDNOException;
+import org.openecomp.mso.jsonpath.JsonPathUtil;
+
+public class SDNOHealthCheckDmaapConsumer extends DmaapConsumer {
+
+ private final String uuid;
+ private boolean continuePolling = true;
+ private final static String healthDiagnosticPath = "body.output.*";
+
+ public SDNOHealthCheckDmaapConsumer() throws FileNotFoundException, IOException {
+ this("none");
+ }
+
+ public SDNOHealthCheckDmaapConsumer(String uuid) throws FileNotFoundException, IOException {
+ super();
+ this.uuid = uuid;
+ }
+
+ @Override
+ public String getUserName() {
+ return msoProperties.get("sdno.health-check.dmaap.username");
+ }
+
+ @Override
+ public String getPassword() {
+ return msoProperties.get("sdno.health-check.dmaap.password");
+ }
+
+ @Override
+ public String getTopic() {
+ return msoProperties.get("sdno.health-check.dmaap.subscriber.topic");
+ }
+
+ @Override
+ public boolean continuePolling() {
+ return continuePolling;
+ }
+
+ @Override
+ public void stopProcessingMessages() {
+ continuePolling = false;
+ }
+ @Override
+ public void processMessage(String message) throws Exception {
+ if (isHealthDiagnostic(message, this.getRequestId())) {
+ if (!healthDiagnosticSuccessful(message)) {
+ Optional<String> statusMessage = this.getStatusMessage(message);
+ if (statusMessage.isPresent()) {
+ throw new SDNOException("failed with message " + statusMessage.get());
+ } else {
+ throw new SDNOException("failed with no status message");
+ }
+ } else {
+ auditLogger.info("successful health diagnostic found for request: " + this.getRequestId());
+ stopProcessingMessages();
+ }
+ }
+ }
+
+ @Override
+ public boolean isAccepted(String message) {
+ if (isResultInfo(message)) {
+ Optional<String> code = isAccepted(message, this.getRequestId());
+ if (code.isPresent()) {
+ if ("202".equals(code.get())) {
+ return true;
+ } else {
+ //TODO check other statuses 400 and 500
+ }
+ } else {
+ //TODO throw error
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean isFailure(String message) {
+ if (isResultInfo(message)) {
+ Optional<String> code = isFailure(message, this.getRequestId());
+ if (code.isPresent()) {
+ if ("500".equals(code.get())) {
+ return true;
+ } else {
+ //TODO check other statuses 400 and 500
+ }
+ } else {
+ //TODO throw error
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public String getRequestId() {
+ return uuid;
+ }
+
+ protected Optional<String> isAccepted(String json, String uuid) {
+ return JsonPathUtil.getInstance().locateResult(json, String.format("$.result-info[?(@.status=='ACCEPTED' && @.request-id=='%s')].code", uuid));
+ }
+
+ protected Optional<String> isFailure(String json, String uuid) {
+ return JsonPathUtil.getInstance().locateResult(json, String.format("$.result-info[?(@.status=='FAILURE' && @.request-id=='%s')].code", uuid));
+ }
+
+ protected boolean isResultInfo(String json) {
+ return JsonPathUtil.getInstance().pathExists(json, "$[?(@.result-info)]");
+ }
+
+ protected boolean isHealthDiagnostic(String json, String uuid) {
+ return JsonPathUtil.getInstance().pathExists(json, String.format("$[?(@.result-info.request-id=='%s')].%s", uuid, healthDiagnosticPath));
+ }
+
+ protected boolean healthDiagnosticSuccessful(String json) {
+ return JsonPathUtil.getInstance().pathExists(json, "$." + healthDiagnosticPath + "[?(@.response-status=='Success')]");
+ }
+
+ protected Optional<String> getStatusMessage(String json) {
+ return JsonPathUtil.getInstance().locateResult(json, "$." + healthDiagnosticPath + ".error-message");
+ }
+
+ @Override
+ public int getMaximumElapsedTime() {
+ return 300000;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java
new file mode 100644
index 0000000000..73f06b8e58
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.sdno.dmaap;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.openecomp.mso.client.dmaap.DmaapPublisher;
+
+public class SDNOHealthCheckDmaapPublisher extends DmaapPublisher {
+
+ public SDNOHealthCheckDmaapPublisher() throws FileNotFoundException, IOException {
+ super();
+ }
+
+ @Override
+ public String getUserName() {
+ return msoProperties.get("sdno.health-check.dmaap.username");
+ }
+
+ @Override
+ public String getPassword() {
+ return msoProperties.get("sdno.health-check.dmaap.password");
+ }
+
+ @Override
+ public String getTopic() {
+ return msoProperties.get("sdno.health-check.dmaap.publisher.topic");
+ }
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml
index d328246b2c..772867d3f2 100644
--- a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml
+++ b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml
@@ -22,7 +22,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<process-archive name="MSOCommonBPMN">
- <process-engine>infrastructure</process-engine>
+ <process-engine>default</process-engine>
<properties>
<property name="isDeleteUponUndeploy">false</property>
<property name="isScanForProcessDefinitions">true</property>
diff --git a/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/applicationContext.xml b/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/applicationContext.xml
deleted file mode 100644
index 6f61c8fbf4..0000000000
--- a/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/applicationContext.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <!-- Spring bean to be invoked through the ApplicationContextElResolver -->
-
-</beans>
diff --git a/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
deleted file mode 100644
index b68ebd943c..0000000000
--- a/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
- -->
-
-<jboss-deployment-structure>
- <deployment>
- <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
- <exclusions>
- <module name="org.apache.log4j" />
- <module name="org.slf4j" />
- <module name="org.slf4j.impl" />
- <module name="org.jboss.resteasy.resteasy-jackson-provider" />
- <module name="org.jboss.resteasy.resteasy-jettison-provider" />
- </exclusions>
- <dependencies>
- <module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import" />
- <!-- This module contain the ProviderBase class: -->
- <module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" export="true"/>
- </dependencies>
- </deployment>
-</jboss-deployment-structure>
-
diff --git a/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-web.xml b/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-web.xml
deleted file mode 100644
index a9a263b684..0000000000
--- a/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/jboss-web.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
- -->
-
-<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
-<jboss-web>
- <security-domain>other</security-domain>
- <context-root>/mso/common</context-root>
-</jboss-web>
diff --git a/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/web.xml b/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 3a42877715..0000000000
--- a/bpmn/MSOCommonBPMN/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
- -->
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
- <display-name>MSO Common BPMN Workflow Servlet</display-name>
- <servlet>
- <servlet-name>resteasy-servlet</servlet-name>
- <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
- <init-param>
- <param-name>javax.ws.rs.Application</param-name>
- <param-value>org.openecomp.mso.bpmn.common.workflow.service.WorkflowResourceApplication</param-value>
- </init-param>
- </servlet>
- <servlet-mapping>
- <servlet-name>resteasy-servlet</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/applicationContext.xml</param-value>
- </context-param>
- <context-param>
- <param-name>mso.configuration</param-name>
- <param-value>MSO_PROP_TOPOLOGY=topology.properties</param-value>
- </context-param>
- <context-param>
- <param-name>log.configuration</param-name>
- <param-value>logback.bpmn.xml</param-value>
- </context-param>
- <context-param>
- <param-name>resteasy.resources</param-name>
- <param-value>org.openecomp.mso.logger.MsoLoggingServlet,org.openecomp.mso.bpmn.core.HealthCheckHandler</param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <filter>
- <filter-name>LogFilter</filter-name>
- <filter-class>org.openecomp.mso.logger.LogFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>LogFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>HTTPBasicAuth</web-resource-name>
- <description>Authentication for Client Apps</description>
- <url-pattern>/workflow/*</url-pattern>
- <http-method>GET</http-method>
- <http-method>POST</http-method>
- </web-resource-collection>
- <auth-constraint>
- <role-name>BPMN-Client</role-name>
- </auth-constraint>
- </security-constraint>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>ApplicationRealm</realm-name>
- </login-config>
- <security-role>
- <role-name>BPMN-Client</role-name>
- </security-role>
-</web-app> \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java
index f60d984a6d..eef9ed8ee0 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java
@@ -42,7 +42,6 @@ import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
import org.jboss.resteasy.spi.AsynchronousResponse;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncCommonResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
@@ -201,7 +200,7 @@ public class BPMNUtil {
* @param variables
*/
private static void executeAsyncFlow(ProcessEngineServices processEngineServices, String processKey, AsynchronousResponse asyncResponse, Map<String,String> variables) {
- WorkflowAsyncResource workflowResource = new WorkflowAsyncCommonResource();
+ WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
VariableMapImpl variableMap = new VariableMapImpl();
Map<String, Object> variableValueType = new HashMap<String, Object>();
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java
index 51a1484cf9..426bceef4b 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java
@@ -31,7 +31,7 @@ import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
import org.jboss.resteasy.spi.AsynchronousResponse;
import org.junit.Test;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncCommonResource;
+import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
public class WorkflowAsyncResourceTest extends WorkflowTest {
@@ -53,7 +53,7 @@ public class WorkflowAsyncResourceTest extends WorkflowTest {
}
private void executeWorkflow(String request, String requestId, AsynchronousResponse asyncResponse, String processKey) {
- WorkflowAsyncCommonResource workflowResource = new WorkflowAsyncCommonResource();
+ WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
VariableMapImpl variableMap = new VariableMapImpl();
Map<String, Object> variableValueType = new HashMap<String, Object>();
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java
index 63403f40ce..15dc4f4609 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java
@@ -75,7 +75,6 @@ import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification;
import org.openecomp.mso.bpmn.common.adapter.vnf.VnfRollback;
import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl;
import org.openecomp.mso.bpmn.common.workflow.service.VnfAdapterNotifyServiceImpl;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncCommonResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowMessageResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
@@ -273,7 +272,7 @@ public class WorkflowTest {
VariableMapImpl variableMapImpl = createVariableMapImpl(variables);
System.out.println("Sending " + request + " to " + processKey + " process");
- WorkflowAsyncResource workflowResource = new WorkflowAsyncCommonResource();
+ WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
workflowResource.setProcessEngineServices4junit(processEngineRule);
TestAsyncResponse asyncResponse = new TestAsyncResponse();
@@ -306,7 +305,7 @@ public class WorkflowTest {
VariableMapImpl variableMapImpl = createVariableMapImpl(variables);
System.out.println("Sending " + request + " to " + processKey + " process");
- WorkflowAsyncResource workflowResource = new WorkflowAsyncCommonResource();
+ WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
workflowResource.setProcessEngineServices4junit(processEngineRule);
TestAsyncResponse asyncResponse = new TestAsyncResponse();
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/FileUtil.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/FileUtil.java
new file mode 100644
index 0000000000..2ebb44a644
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/FileUtil.java
@@ -0,0 +1,80 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.openecomp.mso.logger.MsoLogger;
+
+/**
+ *
+ * File utility class.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Sep 15, 2017
+ */
+public class FileUtil {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+
+ private FileUtil() {
+ /**
+ * Constructor.
+ */
+ }
+ /**
+ * Read the specified resource file and return the contents as a String.
+ *
+ * @param fileName Name of the resource file
+ * @return the contents of the resource file as a String
+ * @throws IOException if there is a problem reading the file
+ */
+ public static String readResourceFile(String fileName) {
+ InputStream stream;
+ try {
+ stream = getResourceAsStream(fileName);
+ byte[] bytes;
+ bytes = new byte[stream.available()];
+ stream.read(bytes);
+ stream.close();
+ return new String(bytes);
+ } catch (IOException e) {
+ LOGGER.debug("Exception:", e);
+ return "";
+ }
+ }
+
+ /**
+ * Get an InputStream for the resource specified.
+ *
+ * @param resourceName Name of resource for which to get InputStream.
+ * @return an InputStream for the resource specified.
+ * @throws IOException If we can't get the InputStream for whatever reason.
+ */
+ private static InputStream getResourceAsStream(String resourceName) throws IOException {
+ InputStream stream =
+ FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
+ if (stream == null) {
+ throw new IOException("Can't access resource '" + resourceName + "'");
+ }
+ return stream;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResource.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResource.java
new file mode 100644
index 0000000000..fc97e69c5c
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResource.java
@@ -0,0 +1,205 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+
+import com.github.tomakehurst.wiremock.WireMockServer;
+import com.github.tomakehurst.wiremock.client.WireMock;
+
+/**
+ *
+ * Mock Resource which is used to start, stop the WireMock Server
+ * Also up to 50 mock properties can be added at run-time to change the properties used in transformers such as sdnc_delay in SDNCAdapterMockTransformer
+ * You can also selectively setup a stub (use reset before setting up), reset all stubs
+ */
+@Path("/server")
+public class MockResource {
+
+ private boolean started = false;
+ private final Integer defaultPort = 28090;
+ private WireMockServer wireMockServer = null;
+ private static Map<String,String> mockProperties = new HashMap<String,String>();
+
+ public static String getMockProperties(String key) {
+ return mockProperties.get(key);
+ }
+
+ private synchronized void initMockServer(int portNumber) {
+ String path = FileUtil.class.getClassLoader().getResource("__files/sdncSimResponse.xml").getFile();
+ path = path.substring(0,path.indexOf("__files/"));
+
+ wireMockServer = new WireMockServer(wireMockConfig().port(portNumber).extensions("org.openecomp.mso.bpmn.mock.SDNCAdapterMockTransformer")
+ .extensions("org.openecomp.mso.bpmn.mock.SDNCAdapterNetworkTopologyMockTransformer")
+ .extensions("org.openecomp.mso.bpmn.mock.VnfAdapterCreateMockTransformer")
+ .extensions("org.openecomp.mso.bpmn.mock.VnfAdapterDeleteMockTransformer")
+ .extensions("org.openecomp.mso.bpmn.mock.VnfAdapterUpdateMockTransformer")
+ .extensions("org.openecomp.mso.bpmn.mock.VnfAdapterRollbackMockTransformer")
+ .extensions("org.openecomp.mso.bpmn.mock.VnfAdapterQueryMockTransformer"));
+ //.withRootDirectory(path));
+ //Mocks were failing - commenting out for now, both mock and transformers seem to work fine
+ WireMock.configureFor("localhost", portNumber);
+ wireMockServer.start();
+// StubResponse.setupAllMocks();
+ started= true;
+ }
+
+ public static void main(String [] args) {
+ MockResource mockresource = new MockResource();
+ mockresource.start(28090);
+ mockresource.reset();
+// mockresource.setupStub("MockCreateTenant");
+ }
+
+ /**
+ * Starts the wiremock server in default port
+ * @return
+ */
+ @GET
+ @Path("/start")
+ @Produces("application/json")
+ public Response start() {
+ return startMockServer(defaultPort);
+ }
+
+ private Response startMockServer(int port) {
+ if (!started) {
+ initMockServer(defaultPort);
+ System.out.println("Started Mock Server in port " + port);
+ return Response.status(200).entity("Started Mock Server in port " + port).build();
+ } else {
+ return Response.status(200).entity("Mock Server is already running").build();
+ }
+ }
+
+ /**
+ * Starts the wiremock server in a different port
+ * @param portNumber
+ * @return
+ */
+ @GET
+ @Path("/start/{portNumber}")
+ @Produces("application/json")
+ public Response start(@PathParam("portNumber") Integer portNumber) {
+ if (portNumber == null) portNumber = defaultPort;
+ return startMockServer(portNumber.intValue());
+ }
+
+
+ /**
+ * Stop the wiremock server
+ * @return
+ */
+ @GET
+ @Path("/stop")
+ @Produces("application/json")
+ public synchronized Response stop() {
+ if (wireMockServer.isRunning()) {
+ wireMockServer.stop();
+ started = false;
+ return Response.status(200).entity("Stopped Mock Server in port ").build();
+ }
+ return Response.status(200).entity("Mock Server is not running").build();
+ }
+
+
+ /**
+ * Return list of mock properties
+ * @return
+ */
+ @GET
+ @Path("/properties")
+ @Produces("application/json")
+ public Response getProperties() {
+ return Response.status(200).entity(mockProperties).build();
+ }
+
+ /**
+ * Update a particular mock property at run-time
+ * @param name
+ * @param value
+ * @return
+ */
+ @POST
+ @Path("/properties/{name}/{value}")
+ public Response updateProperties(@PathParam("name") String name, @PathParam("value") String value) {
+ if (mockProperties.size() > 50) return Response.serverError().build();
+ mockProperties.put(name, value);
+ return Response.status(200).build();
+ }
+
+ /**
+ * Reset all stubs
+ * @return
+ */
+ @GET
+ @Path("/reset")
+ @Produces("application/json")
+ public Response reset() {
+ WireMock.reset();
+ return Response.status(200).entity("Wiremock stubs are reset").build();
+ }
+
+
+ /**
+ * Setup a stub selectively
+ * Prior to use, make sure that stub method is available in StubResponse class
+ * @param methodName
+ * @return
+ */
+
+ // commenting for now until we figure out a way to use new StubResponse classes to setupStubs
+// @GET
+// @Path("/stub/{methodName}")
+// @Produces("application/json")
+// public Response setupStub(@PathParam("methodName") String methodName) {
+//
+// @SuppressWarnings("rawtypes")
+// Class params[] = {};
+// Object paramsObj[] = {};
+//
+// try {
+// Method thisMethod = StubResponse.class.getDeclaredMethod(methodName, params);
+// try {
+// thisMethod.invoke(StubResponse.class, paramsObj);
+// } catch (IllegalAccessException | IllegalArgumentException
+// | InvocationTargetException e) {
+// return Response.status(200).entity("Error invoking " + methodName ).build();
+// }
+// } catch (NoSuchMethodException | SecurityException e) {
+// return Response.status(200).entity("Stub " + methodName + " not found...").build();
+// }
+// return Response.status(200).entity("Successfully invoked " + methodName).build();
+// }
+
+
+ public static Map<String,String> getMockProperties(){
+ return mockProperties;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResourceApplication.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResourceApplication.java
new file mode 100644
index 0000000000..ebbfea5cd1
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResourceApplication.java
@@ -0,0 +1,50 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+/**
+ *
+ * JAX RS Application wiring for Mock Resource
+ */
+@ApplicationPath("/console")
+public class MockResourceApplication extends Application {
+
+ private Set<Object> singletons = new HashSet<Object>();
+ private Set<Class<?>> classes = new HashSet<Class<?>>();
+
+ public MockResourceApplication() {
+ singletons.add(new MockResource());
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return classes;
+ }
+
+ @Override
+ public Set<Object> getSingletons() {
+ return singletons;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterMockTransformer.java
new file mode 100644
index 0000000000..9c4e7936b1
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterMockTransformer.java
@@ -0,0 +1,140 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+import org.openecomp.mso.logger.MsoLogger;
+
+import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
+import com.github.tomakehurst.wiremock.common.FileSource;
+import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
+import com.github.tomakehurst.wiremock.http.Request;
+import com.github.tomakehurst.wiremock.http.ResponseDefinition;
+
+import org.openecomp.mso.logger.MsoLogger;
+/**
+ *
+ * Simulates SDNC Adapter Callback response
+ *
+ */
+public class SDNCAdapterMockTransformer extends ResponseTransformer {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+ private String callbackResponse;
+ private String requestId;
+
+ public SDNCAdapterMockTransformer() {
+ callbackResponse = FileUtil.readResourceFile("__files/sdncSimResponse.xml");
+ }
+
+ public SDNCAdapterMockTransformer(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public String name() {
+ return "sdnc-adapter-transformer";
+ }
+
+ /**
+ * Grab the incoming request xml,extract the request id and replace the stub response with the incoming request id
+ * so that callback response can be correlated
+ *
+ * Mock Resource can be used to add dynamic properties. If sdnc_delay is not in the list by default waits for 300ms before
+ * the callback response is sent
+ */
+ @Override
+ public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition,
+ FileSource fileSource) {
+ String requestBody = request.getBodyAsString();
+
+ String callbackUrl = requestBody.substring(requestBody.indexOf("<sdncadapter:CallbackUrl>")+25, requestBody.indexOf("</sdncadapter:CallbackUrl>"));
+ String requestId = requestBody.substring(requestBody.indexOf("<sdncadapter:RequestId>")+23, requestBody.indexOf("</sdncadapter:RequestId>"));
+
+ callbackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName());
+ System.out.println("callbackResponse:" + callbackResponse);
+
+ if (this.requestId != null) {
+ callbackResponse = callbackResponse.replace(this.requestId, requestId);
+ } else {
+ callbackResponse = callbackResponse.replace("testRequestId", requestId);
+ }
+
+
+ Object sdncDelay = MockResource.getMockProperties().get("sdnc_delay");
+ int delay = 300;
+ if (sdncDelay != null) {
+ delay = Integer.parseInt(sdncDelay.toString());
+ }
+
+ //Kick off callback thread
+ System.out.println("callback Url:" + callbackUrl + ":delay:" + delay);
+ CallbackResponseThread calbackResponseThread = new CallbackResponseThread(callbackUrl,callbackResponse, delay);
+ calbackResponseThread.start();
+
+ //return 200 OK with empty body
+ return ResponseDefinitionBuilder
+ .like(responseDefinition).but()
+ .withStatus(200).withBody("").withHeader("Content-Type", "text/xml")
+ .build();
+ }
+
+ @Override
+ public boolean applyGlobally() {
+ return false;
+ }
+
+ /**
+ *
+ * Callback response thread which sends the callback response asynchronously
+ *
+ */
+ private class CallbackResponseThread extends Thread {
+
+ private String callbackUrl;
+ private String payLoad;
+ private int delay;
+
+ public CallbackResponseThread(String callbackUrl, String payLoad, int delay) {
+ this.callbackUrl = callbackUrl;
+ this.payLoad = payLoad;
+ this.delay = delay;
+ }
+
+ public void run () {
+ try {
+ //Delay sending callback response
+ sleep(delay);
+ } catch (InterruptedException e1) {
+ LOGGER.debug("Exception :",e1);
+ }
+ LOGGER.debug("Sending callback response:" + callbackUrl);
+ ClientRequest request = new ClientRequest(callbackUrl);
+ request.body("text/xml", payLoad);
+ System.err.println(payLoad);
+ try {
+ ClientResponse result = request.post();
+ //System.err.println("Successfully posted callback:" + result.getStatus());
+ } catch (Exception e) {
+ LOGGER.debug("Exception :",e);
+ }
+ }
+
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterNetworkTopologyMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterNetworkTopologyMockTransformer.java
new file mode 100644
index 0000000000..e59e3b67d2
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterNetworkTopologyMockTransformer.java
@@ -0,0 +1,132 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+
+import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
+import com.github.tomakehurst.wiremock.common.FileSource;
+import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
+import com.github.tomakehurst.wiremock.http.Request;
+import com.github.tomakehurst.wiremock.http.ResponseDefinition;
+
+import org.openecomp.mso.logger.MsoLogger;
+
+public class SDNCAdapterNetworkTopologyMockTransformer extends ResponseTransformer {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+
+ private String callbackResponse;
+ private String requestId;
+
+ public SDNCAdapterNetworkTopologyMockTransformer() {
+ callbackResponse = ""; // FileUtil.readResourceFile("__files/sdncDeleteNetworkTopologySimResponse.xml");
+ }
+
+ public SDNCAdapterNetworkTopologyMockTransformer(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public String name() {
+ return "network-topology-operation-transformer";
+ }
+
+ @Override
+ public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, FileSource fileSource) {
+ String requestBody = request.getBodyAsString();
+
+ String callbackUrl = requestBody.substring(requestBody.indexOf("<sdncadapter:CallbackUrl>")+25, requestBody.indexOf("</sdncadapter:CallbackUrl>"));
+ String requestId = requestBody.substring(requestBody.indexOf("<sdncadapter:RequestId>")+23, requestBody.indexOf("</sdncadapter:RequestId>"));
+ System.out.println("request callbackUrl : " + callbackUrl);
+ System.out.println("request requestId : " + requestId);
+
+ System.out.println("file path/name : " + responseDefinition.getBodyFileName());
+ callbackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName());
+ // extract Response responseRequestId
+ String responseRequestId = callbackResponse.substring(callbackResponse.indexOf("<RequestId>")+11, callbackResponse.indexOf("</RequestId>"));
+ System.out.println("response requestId: " + responseRequestId);
+ System.out.println("callbackResponse (before): " + callbackResponse);
+ callbackResponse = callbackResponse.replace(responseRequestId, requestId);
+ if (this.requestId != null) {
+ callbackResponse = callbackResponse.replace(this.requestId, requestId);
+ } else {
+ callbackResponse = callbackResponse.replace(responseRequestId, requestId);
+ }
+ System.out.println("callbackResponse (after):" + callbackResponse);
+
+ Object sdncDelay = MockResource.getMockProperties().get("sdnc_delay");
+ int delay = 300;
+ if (sdncDelay != null) {
+ delay = Integer.parseInt(sdncDelay.toString());
+ }
+
+ //Kick off callback thread
+ System.out.println("(NetworkTopologyMockTransformer) callback Url:" + callbackUrl + ":delay:" + delay);
+ CallbackResponseThread calbackResponseThread = new CallbackResponseThread(callbackUrl,callbackResponse, delay);
+ calbackResponseThread.start();
+
+ //return 200 OK with body
+ return ResponseDefinitionBuilder
+ .like(responseDefinition).but()
+ .withStatus(200).withBody(callbackResponse).withHeader("Content-Type", "text/xml")
+ .build();
+ }
+
+ @Override
+ public boolean applyGlobally() {
+ return false;
+ }
+
+ private class CallbackResponseThread extends Thread {
+
+ private String callbackUrl;
+ private String payLoad;
+ private int delay;
+
+ public CallbackResponseThread(String callbackUrl, String payLoad, int delay) {
+ this.callbackUrl = callbackUrl;
+ this.payLoad = payLoad;
+ this.delay = delay;
+ }
+
+ public void run () {
+ try {
+ //Delay sending callback response
+ sleep(delay);
+ } catch (InterruptedException e1) {
+ // TODO Auto-generated catch block
+ LOGGER.debug("Exception :",e1);
+ }
+ LOGGER.debug("Sending callback response to url: " + callbackUrl);
+ ClientRequest request = new ClientRequest(callbackUrl);
+ request.body("text/xml", payLoad);
+ //System.err.println(payLoad);
+ try {
+ ClientResponse result = request.post();
+ LOGGER.debug("Successfully posted callback? Status: " + result.getStatus());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ LOGGER.debug("catch error in - request.post() ");
+ LOGGER.debug("Exception :",e);
+ }
+ }
+
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java
new file mode 100644
index 0000000000..f9a6543387
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java
@@ -0,0 +1,1069 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.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.urlEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+
+
+/**
+ * Reusable Mock StubResponses for AAI Endpoints
+ *
+ */
+public class StubResponseAAI {
+
+ public static void setupAllMocks() {
+
+ }
+
+
+ /**
+ * Tunnel-XConnect Mock Stub Response
+ */
+ public static void MockPutTunnelXConnect(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String tunnelId){
+ stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId + "/tunnel-xconnects/tunnel-xconnect/" + tunnelId))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+
+ /**
+ * Allotted Resource Mock StubResponses below
+ */
+ public static void MockGetAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String responseFile) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockPutAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void MockPutAllottedResource_500(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void MockDeleteAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String resourceVersion) {
+ stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(204)));
+ }
+
+ public static void MockPatchAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
+ stubFor(patch(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void MockQueryAllottedResourceById(String allottedResourceId, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=allotted-resource[&]filter=id:EQUALS:" + allottedResourceId))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+
+ /**
+ * Service Instance Mock StubResponses below
+ */
+ public static void MockGetServiceInstance(String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetServiceInstance_404(String customer, String serviceSubscription, String serviceInstanceId){
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+
+ public static void MockGetServiceInstance_500(String customer, String serviceSubscription, String serviceInstanceId){
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void MockGetServiceInstance_500(String customer, String serviceSubscription, String serviceInstanceId, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
+ .willReturn(aResponse()
+ .withStatus(500)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockNodeQueryServiceInstanceByName(String serviceInstanceName, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-name:EQUALS:" + serviceInstanceName))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockNodeQueryServiceInstanceByName_404(String serviceInstanceName){
+ stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+
+ public static void MockNodeQueryServiceInstanceByName_500(String serviceInstanceName){
+ stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void MockNodeQueryServiceInstanceById(String serviceInstanceId, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-id:EQUALS:" + serviceInstanceId))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockNodeQueryServiceInstanceById_404(String serviceInstanceId){
+ stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+
+ public static void MockNodeQueryServiceInstanceById_500(String serviceInstanceId){
+ stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(204)));
+ }
+
+ public static void MockGetServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ public static void MockGetServiceInstance(String customer, String serviceSubscription, String resourceVersion, int statusCode){
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")));
+ }
+
+ public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String resourceVersion, int statusCode){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" +1234))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ public static void MockDeleteServiceInstance_404(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+
+ public static void MockDeleteServiceInstance_500(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void MockPutServiceInstance(String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockPutServiceInstance_500(String globalCustId, String subscriptionType, String serviceInstanceId) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ /**
+ * Service-Subscription Mock StubResponses below
+ */
+ public static void MockGetServiceSubscription(String globalCustId, String subscriptionType, String responseFile) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockDeleteServiceSubscription(String globalCustId, String subscriptionType, int statusCode) {
+ stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ public static void MockDeleteServiceInstanceId(String globalCustId, String subscriptionType, String serviceInstanceId) {
+ stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void MockPutServiceSubscription(String globalCustId, String subscriptionType) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void MockGetServiceSubscription(String globalCustId, String subscriptionType, int statusCode) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ /**
+ * Customer Mock StubResponses below
+ */
+ public static void MockGetCustomer(String globalCustId, String responseFile) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockDeleteCustomer(String globalCustId) {
+ stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void MockPutCustomer(String globalCustId) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void MockPutCustomer_500(String globalCustId) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+
+ /**
+ * Generic-Vnf Mock StubResponses below
+ */
+
+ public static void MockGetGenericVnfById(String vnfId, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfById(String vnfId, String responseFile, int statusCode){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfByIdWithPriority(String vnfId, int statusCode, String responseFile) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
+ .atPriority(1)
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfByIdWithPriority(String vnfId, String vfModuleId, int statusCode, String responseFile, int priority) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .atPriority(priority)
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfByIdWithDepth(String vnfId, int depth, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=" + depth))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfById_404(String vnfId){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+
+ public static void MockGetGenericVnfById_500(String vnfId){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void MockGetGenericVnfByName(String vnfName, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfByNameWithDepth(String vnfName, int depth, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName + "[&]depth=" + depth))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfByName_404(String vnfName){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+
+ public static void MockDeleteGenericVnf(String vnfId, String resourceVersion){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(204)));
+ }
+
+ public static void MockDeleteGenericVnf(String vnfId, String resourceVersion, int statusCode){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ public static void MockDeleteGenericVnf_500(String vnfId, String resourceVersion){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void MockPutGenericVnf(String vnfId){
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void MockPutGenericVnf(String vnfId, String requestBodyContaining, int statusCode) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
+ .withRequestBody(containing(requestBodyContaining))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ public static void MockPutGenericVnf(String vnfId, int statusCode) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ public static void MockPutGenericVnf_Bad(String vnfId, int statusCode){
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ public static void MockPatchGenericVnf(String vnfId){
+ stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+ /**
+ * Vce Mock StubResponses below
+ */
+ public static void MockGetVceById(String vnfId, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetVceByName(String vnfName, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockDeleteVce(String vnfId, String resourceVersion, int statusCode){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ public static void MockPutVce(String vnfId){
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void MockGetGenericVceByNameWithDepth(String vnfName, int depth, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName + "[&]depth=" + depth))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetVceGenericQuery(String serviceInstanceName, int depth, int statusCode, String responseFile){
+ stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=service-instance.service-instance-name:" + serviceInstanceName + "[&]start-node-type=service-instance[&]include=vce[&]depth=" + depth))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ /**
+ * Tenant Mock StubResponses below
+ */
+ public static void MockGetTenantGenericQuery(String customer, String serviceType, String responseFile) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=customer.global-customer-id:" + customer + "&key=service-subscription.service-type:" + serviceType + "&start-node-type=service-subscription&include=tenant&include=service-subscription&depth=1"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetTenant(String tenantId, String responseFile) {
+ stubFor(get(urlEqualTo("/aai/v2/cloud-infrastructure/tenants/tenant/" + tenantId))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ /**
+ * Network Mock StubResponses below
+ */
+ public static void MockGetNetwork(String networkId, String responseFile, int statusCode) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkByIdWithDepth(String networkId, String responseFile, String depth) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "[?]depth=" + depth))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkCloudRegion(String responseFile, String cloudRegion) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/"+cloudRegion))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkByName(String networkName, String responseFile) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkByName_404(String responseFile, String networkName) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))
+ .willReturn(aResponse()
+ .withStatus(404)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkCloudRegion_404(String cloudRegion) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/"+cloudRegion))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+
+ public static void MockPutNetwork(String networkId, int statusCode, String responseFile) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockPutNetwork(String networkPolicyId, String responseFile, int statusCode) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicyId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkName(String networkPolicyName, String responseFile, int statusCode) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkPolicyName))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkVpnBinding(String responseFile, String vpnBinding) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/"+vpnBinding + "[?]depth=all"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkPolicy(String responseFile, String policy) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/"+policy + "[?]depth=all"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkVpnBinding(String networkBindingId, String responseFile, int statusCode) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + networkBindingId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkPolicy(String networkPolicy, String responseFile, int statusCode) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicy))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkTableReference(String responseFile, String tableReference) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/"+tableReference + "[?]depth=all"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockPutNetworkIdWithDepth(String responseFile, String networkId, String depth) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/"+networkId+"[?]depth="+depth ))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkPolicyfqdn(String networkPolicy, String responseFile, int statusCode) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy[?]network-policy-fqdn=" + networkPolicy))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkRouteTable(String networkRouteId, String responseFile, int statusCode) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/" + networkRouteId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockPatchVfModuleId(String vnfId, String vfModuleId) {
+ stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ /////////////
+
+ public static void MockVNFAdapterRestVfModule() {
+ stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool"))
+ .willReturn(aResponse()
+ .withStatus(202)
+ .withHeader("Content-Type", "application/xml")));
+ stubFor(post(urlMatching("/vnfs/v1/vnfs/.*/vf-modules"))
+ .willReturn(aResponse()
+ .withStatus(202)
+ .withHeader("Content-Type", "application/xml")));
+ stubFor(post(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules"))
+ .willReturn(aResponse()
+ .withStatus(202)
+ .withHeader("Content-Type", "application/xml")));
+ stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/78987"))
+ .willReturn(aResponse()
+ .withStatus(202)
+ .withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void MockDBUpdateVfModule(){
+ stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/DBUpdateResponse.xml")));
+ }
+
+ // start of mocks used locally and by other VF Module unit tests
+ public static void MockSDNCAdapterVfModule() {
+ // simplified the implementation to return "success" for all requests
+ stubFor(post(urlEqualTo("/SDNCAdapter"))
+// .withRequestBody(containing("SvcInstanceId><"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml")));
+
+ }
+
+ // start of mocks used locally and by other VF Module unit tests
+ public static void MockAAIVfModule() {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
+ .atPriority(1)
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/VfModule-supercool.xml")));
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/lukewarm"))
+ .atPriority(2)
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/VfModule-lukewarm.xml")));
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
+ .atPriority(5)
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/VfModule-new.xml")));
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask[?]depth=1"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/GenericVnf.xml")));
+ stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
+// .withRequestBody(containing("PCRF"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
+// .withRequestBody(containing("PCRF"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ // HTTP PUT stub still used by CreateAAIvfModuleVolumeGroup
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
+ .withRequestBody(containing("PCRF"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ // HTTP PUT stub still used by DoCreateVfModuleTest
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
+ .withRequestBody(containing("MODULELABEL"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
+ stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
+ stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/MDTWNJ21/volume-groups/volume-group/78987"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/VolumeGroup.xml")));
+ stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group/78987"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/VolumeGroup.xml")));
+ stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987[?]resource-version=0000020"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("DeleteCinderVolumeV1/DeleteVolumeId_AAIResponse_Success.xml")));
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/AddNetworkPolicy_AAIResponse_Success.xml")));
+ stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/NEWvBNGModuleId"))
+ .withRequestBody(containing("NEWvBNGModuleId"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+
+
+ //////////////
+
+ /**
+ * Cloud infrastructure below
+ */
+
+ public static void MockGetCloudRegion(String cloudRegionId, int statusCode, String responseFile) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ /**
+ * Volume Group StubResponse below
+ */
+ public static void MockGetVolumeGroupById(String cloudRegionId, String volumeGroupId, String responseFile) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockPutVolumeGroupById(String cloudRegionId, String volumeGroupId, String responseFile, int statusCode) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetVolumeGroupByName(String cloudRegionId, String volumeGroupName, String responseFile, int statusCode) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockDeleteVolumeGroupById(String cloudRegionId, String volumeGroupId, String resourceVersion, int statusCode) {
+ stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ public static void MockGetVolumeGroupByName_404(String cloudRegionId, String volumeGroupName) {
+ stubFor(get(urlMatching("/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+
+ public static void MockDeleteVolumeGroup(String cloudRegionId, String volumeGroupId, String resourceVersion) {
+ stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ /**
+ * VF-Module StubResponse below
+ * @param statusCode TODO
+ */
+ public static void MockGetVfModuleId(String vnfId, String vfModuleId, String responseFile, int statusCode) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetVfModuleByNameWithDepth(String vnfId, String vfModuleName, int depth, String responseFile, int statusCode) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName + "[?]depth=" + depth))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetVfModuleIdNoResponse(String vnfId, String requestContaining, String vfModuleId) {
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")));
+ }
+
+ public static void MockPutVfModuleIdNoResponse(String vnfId, String requestContaining, String vfModuleId) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId +"/vf-modules/vf-module/" +vfModuleId))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void MockPutVfModuleId(String vnfId, String vfModuleId) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void MockPutVfModuleId(String vnfId, String vfModuleId, int returnCode) {
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .willReturn(aResponse()
+ .withStatus(returnCode)));
+ }
+
+ public static void MockDeleteVfModuleId(String vnfId, String vfModuleId, String resourceVersion, int returnCode) {
+ stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId + "/[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse()
+ .withStatus(returnCode)));
+ }
+
+ public static void MockAAIVfModuleBadPatch(String endpoint, int statusCode) {
+ stubFor(patch(urlMatching(endpoint))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ /* AAI Pserver Queries */
+ public static void MockGetPserverByVnfId(String vnfId, String responseFile, int statusCode) {
+ stubFor(put(urlMatching("/v10/query.*"))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfsByVnfId(String vnfId, String responseFile, int statusCode) {
+ stubFor(get(urlMatching("/v10/network/generic-vnfs/.*"))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/json; charset=utf-8")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockSetInMaintFlagByVnfId(String vnfId, int statusCode) {
+ stubFor(patch(urlMatching("/v10/network/generic-vnfs/.*"))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ ));
+ }
+
+ //// Deprecated Stubs below - to be deleted once unit test that reference them are refactored to use common ones above ////
+ @Deprecated
+ public static void MockGetVceById(){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123?depth=1"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getVceResponse.xml")));
+ }
+ @Deprecated
+ public static void MockGetVceByName(){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=testVnfName123"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getVceByNameResponse.xml")));
+ }
+ @Deprecated
+ public static void MockPutVce(){
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+ @Deprecated
+ public static void MockDeleteVce(){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
+ .willReturn(aResponse()
+ .withStatus(204)));
+ }
+ @Deprecated
+ public static void MockDeleteVce_404(){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+
+ @Deprecated
+ public static void MockDeleteServiceSubscription(){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
+ .willReturn(aResponse()
+ .withStatus(204)));
+ }
+ @Deprecated
+ public static void MockGetServiceSubscription(){
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getServiceSubscription.xml")));
+ }
+ @Deprecated
+ public static void MockGetServiceSubscription_200Empty(){
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBody(" ")));
+ }
+ @Deprecated
+ public static void MockGetServiceSubscription_404() {
+ stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+ @Deprecated
+ public static void MockGENPSIPutServiceInstance(){
+ stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml")));
+ }
+
+ @Deprecated
+ public static void MockGENPSIPutServiceSubscription(){
+ stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml")));
+ }
+ @Deprecated
+ public static void MockGENPSIPutServiceInstance_get500(){
+ stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET"))
+ .willReturn(aResponse()
+ .withStatus(500)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericPutServiceInstance/aaiFault.xml")));
+ }
+
+ @Deprecated
+ public static void MockGetGenericVnfById(){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getGenericVnfByNameResponse.xml")));
+ }
+ @Deprecated
+ public static void MockGetGenericVnfById_404(){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+ @Deprecated
+ public static void MockGetGenericVnfByName(){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getGenericVnfResponse.xml")));
+ }
+ @Deprecated
+ public static void MockGetGenericVnfByName_hasRelationships(){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
+ }
+ @Deprecated
+ public static void MockGetGenericVnfById_hasRelationships(){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
+ }
+ @Deprecated
+ public static void MockGetGenericVnfById_500(){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+ @Deprecated
+ public static void MockGetGenericVnfByName_404(){
+ stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+ @Deprecated
+ public static void MockPutGenericVnf(){
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+ @Deprecated
+ public static void MockPutGenericVnf_400(){
+ stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ .willReturn(aResponse()
+ .withStatus(400)));
+ }
+ @Deprecated
+ public static void MockDeleteGenericVnf(){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
+ .willReturn(aResponse()
+ .withStatus(204)));
+ }
+ @Deprecated
+ public static void MockDeleteGenericVnf_404(){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
+ .willReturn(aResponse()
+ .withStatus(404)));
+ }
+ @Deprecated
+ public static void MockDeleteGenericVnf_500(){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+ @Deprecated
+ public static void MockDeleteGenericVnf_412(){
+ stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[[?]]resource-version=testReVer123"))
+ .willReturn(aResponse()
+ .withStatus(412)));
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java
new file mode 100644
index 0000000000..c9f64d9b26
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java
@@ -0,0 +1,102 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+
+/**
+ * Stub response class for Database stubs
+ * including database adapter, catalog db,
+ * and other databases.
+ */
+public class StubResponseDatabase {
+
+ public static void setupAllMocks() {
+
+ }
+
+ public static void MockUpdateRequestDB(String fileName){
+ stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(fileName)));
+ }
+
+ public static void mockUpdateRequestDB(int statusCode, String reponseFile) {
+ stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(reponseFile)));
+ }
+
+ public static void MockGetAllottedResourcesByModelInvariantId(String modelInvariantId, String responseFile){
+ stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetAllottedResourcesByModelInvariantId_500(String modelInvariantId, String responseFile){
+ stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void MockGetVnfCatalogDataCustomizationUuid(String vnfModelCustomizationUuid, String responseFile){
+ stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetVfModuleByModelNameCatalogData(String vfModuleModelName, String responseFile){
+ stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String serviceModelVersion, String responseFile){
+ stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid +
+ "&serviceModelVersion=" + serviceModelVersion))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String responseFile){
+ stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)));
+ }
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseNetworkAdapter.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseNetworkAdapter.java
new file mode 100644
index 0000000000..8baeb1b137
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseNetworkAdapter.java
@@ -0,0 +1,113 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+
+/**
+ * Please describe the StubResponseNetwork.java class
+ *
+ */
+public class StubResponseNetworkAdapter {
+
+ private static final String EOL = "\n";
+
+ public static void setupAllMocks() {
+
+ }
+
+
+ public static void MockNetworkAdapter() {
+ stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void MockNetworkAdapter(String response) {
+ stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(response)));
+ }
+
+ public static void MockNetworkAdapter_500() {
+ stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void MockNetworkAdapterPost(String responseFile, String requestContaining) {
+ stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockNetworkAdapter(String networkId, int statusCode, String responseFile) {
+ stubFor(delete(urlEqualTo("/networks/NetworkAdapter/" + networkId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockNetworkAdapterContainingRequest(String requestContaining, int statusCode, String responseFile) {
+ stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockPutNetworkAdapter(String networkId, String requestContaining, int statusCode, String responseFile) {
+ stubFor(put(urlEqualTo("/networks/NetworkAdapter/" + networkId))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockNetworkAdapterRestRollbackDelete(String responseFile, String networkId) {
+ stubFor(delete(urlEqualTo("/networks/NetworkAdapter/"+networkId+"/rollback"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockNetworkAdapterRestPut(String responseFile, String networkId) {
+ stubFor(put(urlEqualTo("/networks/NetworkAdapter/"+networkId))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponsePolicy.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponsePolicy.java
new file mode 100644
index 0000000000..fdaede1b39
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponsePolicy.java
@@ -0,0 +1,94 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.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.urlEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+
+/**
+ * Reusable Mock StubResponses for Policy
+ *
+ */
+public class StubResponsePolicy {
+
+ public static void setupAllMocks() {
+
+ }
+
+ // start of Policy mocks
+ public static void MockPolicyAbort() {
+ stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ .withRequestBody(containing("BB1"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("policyAbortResponse.json")));
+
+ stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ .withRequestBody(containing("UPDVnfI"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("policyAbortResponse.json")));
+
+ stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ .withRequestBody(containing("RPLVnfI"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("policyAbortResponse.json")));
+
+
+ }
+
+ public static void MockPolicySkip() {
+ stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ .withRequestBody(containing("BB1"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("Policy/policySkipResponse.json")));
+
+ stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ .withRequestBody(containing("UPDVnfI"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("Policy/policySkipResponse.json")));
+
+ stubFor(post(urlEqualTo("/pdp/api/getDecision"))
+ .withRequestBody(containing("RPLVnfI"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("Policy/policySkipResponse.json")));
+
+
+ }
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSDNCAdapter.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSDNCAdapter.java
new file mode 100644
index 0000000000..f41d6d7dba
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSDNCAdapter.java
@@ -0,0 +1,146 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+
+/**
+ * Please describe the StubResponseSDNC.java class
+ */
+public class StubResponseSDNCAdapter {
+
+ public static void setupAllMocks() {
+
+ }
+
+ public static void mockSDNCAdapter_500() {
+ stubFor(post(urlEqualTo("/SDNCAdapter"))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void mockSDNCAdapter_500(String requestContaining) {
+ stubFor(post(urlEqualTo("/SDNCAdapter"))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void mockSDNCAdapter(int statusCode) {
+ stubFor(post(urlEqualTo("/SDNCAdapter"))
+ .willReturn(aResponse()
+ .withStatus(statusCode)));
+ }
+
+ public static void mockSDNCAdapter(String endpoint, int statusCode, String responseFile) {
+ stubFor(post(urlEqualTo(endpoint))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void mockSDNCAdapter(String responseFile) {
+ stubFor(post(urlEqualTo("/SDNCAdapter"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void mockSDNCAdapter(String endpoint, String requestContaining, int statusCode, String responseFile) {
+ stubFor(post(urlEqualTo(endpoint))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void mockSDNCAdapterSimulator(String responseFile) {
+ MockResource mockResource = new MockResource();
+ mockResource.updateProperties("sdnc_delay", "300");
+ stubFor(post(urlEqualTo("/SDNCAdapter"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/soap+xml")
+ .withTransformers("sdnc-adapter-transformer")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void mockSDNCAdapterSimulator(String responseFile, String requestContaining) {
+ MockResource mockResource = new MockResource();
+ mockResource.updateProperties("sdnc_delay", "300");
+ stubFor(post(urlEqualTo("/SDNCAdapter"))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/soap+xml")
+ .withTransformers("sdnc-adapter-transformer")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void mockSDNCAdapterRest() {
+ stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
+ .willReturn(aResponse()
+ .withStatus(202)
+ .withHeader("Content-Type", "application/json")));
+ }
+
+ public static void mockSDNCAdapterRest_500() {
+ stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
+ .willReturn(aResponse()
+ .withStatus(500)
+ .withHeader("Content-Type", "application/json")));
+ }
+
+ public static void mockSDNCAdapterRest(String requestContaining) {
+ stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse()
+ .withStatus(202)
+ .withHeader("Content-Type", "application/json")));
+ }
+
+ public static void mockSDNCAdapterRest_500(String requestContaining) {
+ stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse()
+ .withStatus(500)
+ .withHeader("Content-Type", "application/json")));
+ }
+
+ public static void mockSDNCAdapterTopology(String responseFile, String requestContaining) {
+ MockResource mockResource = new MockResource();
+ mockResource.updateProperties("sdnc_delay", "300");
+ stubFor(post(urlEqualTo("/SDNCAdapter"))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withTransformers("network-topology-operation-transformer")
+ .withBodyFile(responseFile)));
+ }
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSNIRO.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSNIRO.java
new file mode 100644
index 0000000000..c16ac43d41
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSNIRO.java
@@ -0,0 +1,69 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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=========================================================
+ */
+
+/*
+ * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
+ */
+package org.openecomp.mso.bpmn.mock;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+
+/**
+ * Please describe the StubResponseSNIRO.java class
+ *
+ * @author cb645j
+ */
+public class StubResponseSNIRO {
+
+ public static void setupAllMocks() {
+
+ }
+
+ public static void mockSNIRO() {
+ stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
+ .willReturn(aResponse()
+ .withStatus(202)
+ .withHeader("Content-Type", "application/json")));
+ }
+
+ public static void mockSNIRO(String responseFile) {
+ stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
+ .willReturn(aResponse()
+ .withStatus(202)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void mockSNIRO_400() {
+ stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
+ .willReturn(aResponse()
+ .withStatus(400)
+ .withHeader("Content-Type", "application/json")));
+ }
+
+ public static void mockSNIRO_500() {
+ stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
+ .willReturn(aResponse()
+ .withStatus(500)
+ .withHeader("Content-Type", "application/json")));
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseVNFAdapter.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseVNFAdapter.java
new file mode 100644
index 0000000000..b4aca5081e
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseVNFAdapter.java
@@ -0,0 +1,158 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+
+/**
+ * Please describe the StubResponseVNF.java class
+ */
+public class StubResponseVNFAdapter {
+
+ public static void mockVNFAdapter() {
+ stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void mockVNFAdapter(String responseFile) {
+ stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void mockVNFAdapter_500() {
+ stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void mockVNFAdapterTransformer(String transformer, String responseFile) {
+ MockResource mockResource = new MockResource();
+ mockResource.updateProperties("vnf_delay", "300");
+ stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/soap+xml")
+ .withTransformers(transformer)
+ .withBodyFile(responseFile)));
+ }
+
+ public static void mockVNFAdapterTransformer(String transformer, String responseFile, String requestContaining) {
+ MockResource mockResource = new MockResource();
+ mockResource.updateProperties("vnf_delay", "300");
+ stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "application/soap+xml")
+ .withTransformers(transformer)
+ .withBodyFile(responseFile)));
+ }
+
+ public static void mockVNFPost(String vfModuleId, int statusCode, String vnfId) {
+ stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockVNFPut(String vfModuleId, int statusCode) {
+ stubFor(put(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockVNFPut(String vnfId, String vfModuleId, int statusCode) {
+ stubFor(put(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockVNFDelete(String vnfId, String vfModuleId, int statusCode) {
+ stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockVNFRollbackDelete(String vfModuleId, int statusCode) {
+ stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockPutVNFVolumeGroup(String volumeGroupId, int statusCode) {
+ stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockPutVNFVolumeGroupRollback(String volumeGroupId, int statusCode) {
+ stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId + "/rollback"))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/xml")));
+ }
+ public static void mockPostVNFVolumeGroup(int statusCode) {
+ stubFor(post(urlEqualTo("/vnfs/v1/volume-groups"))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockVNFAdapterRest(String vnfId) {
+ stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+ }
+
+ public static void mockVNFAdapterRest_500(String vnfId) {
+ stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules"))
+ .willReturn(aResponse()
+ .withStatus(500)));
+ }
+
+ public static void mockVfModuleDelete(String volumeGroupId) {
+ stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId))
+ .willReturn(aResponse()
+ .withStatus(202)
+ .withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockVfModuleDelete(String volumeGroupId, int statusCode) {
+ stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987"))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/xml")));
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterCreateMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterCreateMockTransformer.java
new file mode 100644
index 0000000000..23921da8d8
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterCreateMockTransformer.java
@@ -0,0 +1,148 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import javax.xml.ws.Endpoint;
+
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+import org.openecomp.mso.logger.MsoLogger;
+
+import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
+import com.github.tomakehurst.wiremock.common.FileSource;
+import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
+import com.github.tomakehurst.wiremock.http.Request;
+import com.github.tomakehurst.wiremock.http.ResponseDefinition;
+
+import org.openecomp.mso.logger.MsoLogger;
+/**
+ * Please describe the VnfAdapterCreateMockTransformer.java class
+ *
+ */
+public class VnfAdapterCreateMockTransformer extends ResponseTransformer {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+
+ private String notifyCallbackResponse;
+ private String ackResponse;
+
+ public VnfAdapterCreateMockTransformer() {
+ notifyCallbackResponse = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfCreateSimResponse.xml"); // default response
+ }
+
+ @Override
+ public String name() {
+ return "vnf-adapter-create-transformer";
+ }
+
+ @Override
+ public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition,
+ FileSource fileSource) {
+
+ String requestBody = request.getBodyAsString();
+
+ String notficationUrl = requestBody.substring(requestBody.indexOf("<notificationUrl>")+17, requestBody.indexOf("</notificationUrl>"));
+ String messageId = requestBody.substring(requestBody.indexOf("<messageId>")+11, requestBody.indexOf("</messageId>"));
+ String responseMessageId = "";
+ String updatedResponse = "";
+
+ try {
+ // try supplied response file (if any)
+ System.out.println(" Supplied fileName: " + responseDefinition.getBodyFileName());
+ ackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName());
+ notifyCallbackResponse = ackResponse;
+ responseMessageId = ackResponse.substring(ackResponse.indexOf("<messageId>")+11, ackResponse.indexOf("</messageId>"));
+ updatedResponse = ackResponse.replace(responseMessageId, messageId);
+ } catch (Exception ex) {
+ LOGGER.debug("Exception :",ex);
+ System.out.println(" ******* Use default response file in '__files/vnfAdapterMocks/vnfCreateSimResponse.xml'");
+ responseMessageId = notifyCallbackResponse.substring(notifyCallbackResponse.indexOf("<messageId>")+11, notifyCallbackResponse.indexOf("</messageId>"));
+ updatedResponse = notifyCallbackResponse.replace(responseMessageId, messageId);
+ }
+
+ System.out.println("response (mock) messageId : " + responseMessageId);
+ System.out.println("request (replacement) messageId: " + messageId);
+
+ System.out.println("vnf Response (before):" + notifyCallbackResponse);
+ System.out.println("vnf Response (after):" + updatedResponse);
+
+ Object vnfDelay = MockResource.getMockProperties().get("vnf_delay");
+ int delay = 300;
+ if (vnfDelay != null) {
+ delay = Integer.parseInt(vnfDelay.toString());
+ }
+
+ //Kick off callback thread
+ System.out.println("VnfAdapterCreateMockTransformer notficationUrl: " + notficationUrl + ":delay: " + delay);
+ CallbackResponseThread callbackResponseThread = new CallbackResponseThread(notficationUrl,updatedResponse, delay);
+ callbackResponseThread.start();
+
+ return ResponseDefinitionBuilder
+ .like(responseDefinition).but()
+ .withStatus(200).withBody(updatedResponse).withHeader("Content-Type", "text/xml")
+ .build();
+
+ }
+
+ @Override
+ public boolean applyGlobally() {
+ return false;
+ }
+
+ private class CallbackResponseThread extends Thread {
+
+ private String callbackUrl;
+ private String payLoad;
+ private int delay;
+
+ public CallbackResponseThread(String callbackUrl, String payLoad, int delay) {
+ this.callbackUrl = callbackUrl;
+ this.payLoad = payLoad;
+ this.delay = delay;
+ }
+
+ @SuppressWarnings("deprecation")
+ public void run () {
+ try {
+ //Delay sending callback response
+ sleep(delay);
+ } catch (InterruptedException e1) {
+ // TODO Auto-generated catch block
+ LOGGER.debug("Exception :",e1);
+ }
+ LOGGER.debug("Sending callback response to url: " + callbackUrl);
+ ClientRequest request = new ClientRequest(callbackUrl);
+ request.body("text/xml", payLoad);
+ //System.out.println("payLoad: " + payLoad);
+
+ try {
+ ClientResponse result = request.post();
+ LOGGER.debug("Successfully posted callback? Status: " + result.getStatus());
+ //System.err.println("Successfully posted callback:" + result.getStatus());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ LOGGER.debug("catch error in - request.post() ");
+ LOGGER.debug("Exception :",e);
+ }
+ }
+
+ }
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterDeleteMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterDeleteMockTransformer.java
new file mode 100644
index 0000000000..ee6972e46e
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterDeleteMockTransformer.java
@@ -0,0 +1,143 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+import org.openecomp.mso.logger.MsoLogger;
+
+import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
+import com.github.tomakehurst.wiremock.common.FileSource;
+import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
+import com.github.tomakehurst.wiremock.http.Request;
+import com.github.tomakehurst.wiremock.http.ResponseDefinition;
+/**
+ * Please describe the VnfAdapterCreateMockTransformer.java class
+ *
+ */
+public class VnfAdapterDeleteMockTransformer extends ResponseTransformer {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+
+ private String notifyCallbackResponse;
+ private String ackResponse;
+
+ public VnfAdapterDeleteMockTransformer() {
+ notifyCallbackResponse = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfDeleteSimResponse.xml");
+ }
+
+ @Override
+ public String name() {
+ return "vnf-adapter-delete-transformer";
+ }
+
+ @Override
+ public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition,
+ FileSource fileSource) {
+
+ // System.err.println("notifyCallbackResponse:" + notifyCallbackResponse);
+
+ String requestBody = request.getBodyAsString();
+
+ String notficationUrl = requestBody.substring(requestBody.indexOf("<notificationUrl>")+17, requestBody.indexOf("</notificationUrl>"));
+ String messageId = requestBody.substring(requestBody.indexOf("<messageId>")+11, requestBody.indexOf("</messageId>"));
+ String responseMessageId = "";
+ String updatedResponse = "";
+
+ try {
+ // try supplied response file (if any)
+ System.out.println(" Supplied fileName: " + responseDefinition.getBodyFileName());
+ ackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName());
+ notifyCallbackResponse = ackResponse;
+ responseMessageId = ackResponse.substring(ackResponse.indexOf("<messageId>")+11, ackResponse.indexOf("</messageId>"));
+ updatedResponse = ackResponse.replace(responseMessageId, messageId);
+ } catch (Exception ex) {
+ LOGGER.debug("Exception :",ex);
+ System.out.println(" ******* Use default response file in '__files/vnfAdapterMocks/vnfDeleteSimResponse.xml'");
+ responseMessageId = notifyCallbackResponse.substring(notifyCallbackResponse.indexOf("<messageId>")+11, notifyCallbackResponse.indexOf("</messageId>"));
+ updatedResponse = notifyCallbackResponse.replace(responseMessageId, messageId);
+ }
+
+ System.out.println("response (mock) messageId : " + responseMessageId);
+ System.out.println("request (replacement) messageId: " + messageId);
+
+ System.out.println("vnf Response (before):" + notifyCallbackResponse);
+ System.out.println("vnf Response (after):" + updatedResponse);
+
+ Object vnfDelay = MockResource.getMockProperties().get("vnf_delay");
+ int delay = 300;
+ if (vnfDelay != null) {
+ delay = Integer.parseInt(vnfDelay.toString());
+ }
+
+ //Kick off callback thread
+ System.out.println("VnfAdapterDeleteMockTransformer notficationUrl: " + notficationUrl + ":delay: " + delay);
+ CallbackResponseThread callbackResponseThread = new CallbackResponseThread(notficationUrl,updatedResponse, delay);
+ callbackResponseThread.start();
+
+ return ResponseDefinitionBuilder
+ .like(responseDefinition).but()
+ .withStatus(200).withBody(updatedResponse).withHeader("Content-Type", "text/xml")
+ .build();
+
+ }
+
+ @Override
+ public boolean applyGlobally() {
+ return false;
+ }
+
+ private class CallbackResponseThread extends Thread {
+
+ private String callbackUrl;
+ private String payLoad;
+ private int delay;
+
+ public CallbackResponseThread(String callbackUrl, String payLoad, int delay) {
+ this.callbackUrl = callbackUrl;
+ this.payLoad = payLoad;
+ this.delay = delay;
+ }
+
+ @SuppressWarnings("deprecation")
+ public void run () {
+ try {
+ //Delay sending callback response
+ sleep(delay);
+ } catch (InterruptedException e1) {
+ // TODO Auto-generated catch block
+ LOGGER.debug("Exception :",e1);
+ }
+ System.out.println("Sending callback response to url: " + callbackUrl);
+ ClientRequest request = new ClientRequest(callbackUrl);
+ request.body("text/xml", payLoad);
+ //System.err.println(payLoad);
+ try {
+ ClientResponse result = request.post();
+ System.out.println("Successfully posted callback? Status: " + result.getStatus());
+ //System.err.println("Successfully posted callback:" + result.getStatus());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ System.out.println("catch error in - request.post() ");
+ LOGGER.debug("Exception :",e);
+ }
+ }
+
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterQueryMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterQueryMockTransformer.java
new file mode 100644
index 0000000000..1582071d3a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterQueryMockTransformer.java
@@ -0,0 +1,161 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+
+import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
+
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+import org.openecomp.mso.logger.MsoLogger;
+
+import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
+import com.github.tomakehurst.wiremock.common.FileSource;
+import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
+import com.github.tomakehurst.wiremock.http.Request;
+import com.github.tomakehurst.wiremock.http.ResponseDefinition;
+
+import org.openecomp.mso.logger.MsoLogger;
+/**
+ * Please describe the VnfAdapterQueryMockTransformer.java class
+ *
+ */
+
+
+public class VnfAdapterQueryMockTransformer extends ResponseTransformer{
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+
+ private String notifyCallbackResponse;
+ private String ackResponse;
+ private String messageId;
+
+ public VnfAdapterQueryMockTransformer() {
+ notifyCallbackResponse = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfQuerySimResponse.xml");
+ }
+
+ public VnfAdapterQueryMockTransformer(String messageId) {
+ this.messageId = messageId;
+ }
+
+ @Override
+ public String name() {
+ return "vnf-adapter-query-transformer";
+ }
+
+ @Override
+ public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition,
+ FileSource fileSource) {
+
+ String requestBody = request.getBodyAsString();
+
+ String notficationUrl = requestBody.substring(requestBody.indexOf("<notificationUrl>")+17, requestBody.indexOf("</notificationUrl>"));
+ String messageId = requestBody.substring(requestBody.indexOf("<messageId>")+11, requestBody.indexOf("</messageId>"));
+ // String updatedResponse = notifyCallbackResponse.replace("b1a82ce6-7f5c-45fd-9273-acaf88fc2137", messageId);
+
+ String responseMessageId = "";
+ String updatedResponse = "";
+
+ // if (ackResponse == null) {
+ //System.err.println("file:" + responseDefinition.getBodyFileName());
+ // ackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName());
+ //}
+
+
+ try {
+ // try supplied response file (if any)
+ System.out.println(" Supplied fileName: " + responseDefinition.getBodyFileName());
+ ackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName());
+ notifyCallbackResponse = ackResponse;
+ responseMessageId = ackResponse.substring(ackResponse.indexOf("<messageId>")+11, ackResponse.indexOf("</messageId>"));
+ updatedResponse = ackResponse.replace(responseMessageId, messageId);
+ } catch (Exception ex) {
+ LOGGER.debug("Exception :",ex);
+ System.out.println(" ******* Use default response file in '__files/vnfAdapterMocks/vnfQuerySimResponse.xml'");
+ responseMessageId = notifyCallbackResponse.substring(notifyCallbackResponse.indexOf("<messageId>")+11, notifyCallbackResponse.indexOf("</messageId>"));
+ updatedResponse = notifyCallbackResponse.replace(responseMessageId, messageId);
+ }
+
+ System.out.println("response (mock) messageId : " + responseMessageId);
+ System.out.println("request (replacement) messageId: " + messageId);
+
+ System.out.println("vnf Response (before):" + notifyCallbackResponse);
+ System.out.println("vnf Response (after):" + updatedResponse);
+
+
+ Object vnfDelay = MockResource.getMockProperties().get("vnf_delay");
+ int delay = 300;
+ if (vnfDelay != null) {
+ delay = Integer.parseInt(vnfDelay.toString());
+ }
+
+ //Kick off callback thread
+
+ //System.out.println("notficationUrl" + notficationUrl);
+ //System.out.println("updatedResponse" + updatedResponse);
+ System.out.println("VnfAdapterQueryMockTransformer notficationUrl: " + notficationUrl + ":delay: " + delay);
+ CallbackResponseThread callbackResponseThread = new CallbackResponseThread(notficationUrl,updatedResponse, delay);
+ System.out.println("Inside Callback" );
+ callbackResponseThread.start();
+
+ return ResponseDefinitionBuilder
+ .like(responseDefinition).but()
+ .withStatus(200).withBody(updatedResponse).withHeader("Content-Type", "text/xml")
+ .build();
+ }
+
+ @Override
+ public boolean applyGlobally() {
+ return false;
+ }
+
+ private class CallbackResponseThread extends Thread {
+
+ private String callbackUrl;
+ private String payLoad;
+ private int delay;
+
+ public CallbackResponseThread(String callbackUrl, String payLoad, int delay) {
+ this.callbackUrl = callbackUrl;
+ this.payLoad = payLoad;
+ this.delay = delay;
+ }
+
+ public void run () {
+ try {
+ //Delay sending callback response
+ sleep(delay);
+ } catch (InterruptedException e1) {
+ LOGGER.debug("Exception :",e1);
+ }
+ ClientRequest request = new ClientRequest(callbackUrl);
+ request.body("text/xml", payLoad);
+ //System.err.println(payLoad);
+ try {
+ ClientResponse result = request.post();
+ //System.err.println("Successfully posted callback:" + result.getStatus());
+ } catch (Exception e) {
+ LOGGER.debug("Exception :",e);
+ }
+ }
+
+ }
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterRollbackMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterRollbackMockTransformer.java
new file mode 100644
index 0000000000..186fd35b6f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterRollbackMockTransformer.java
@@ -0,0 +1,144 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.bpmn.mock;
+
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+
+import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
+import com.github.tomakehurst.wiremock.common.FileSource;
+import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
+import com.github.tomakehurst.wiremock.http.Request;
+import com.github.tomakehurst.wiremock.http.ResponseDefinition;
+
+import org.openecomp.mso.logger.MsoLogger;
+/**
+ * Please describe the VnfAdapterCreateMockTransformer.java class
+ *
+ */
+public class VnfAdapterRollbackMockTransformer extends ResponseTransformer {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+
+ private String notifyCallbackResponse;
+ private String ackResponse;
+ private String messageId;
+
+ public VnfAdapterRollbackMockTransformer() {
+ notifyCallbackResponse = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfRollbackSimResponse.xml");
+ }
+
+ public VnfAdapterRollbackMockTransformer(String messageId) {
+ this.messageId = messageId;
+ }
+
+ @Override
+ public String name() {
+ return "vnf-adapter-rollback-transformer";
+ }
+
+ @Override
+ public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition,
+ FileSource fileSource) {
+
+ String requestBody = request.getBodyAsString();
+
+ String notficationUrl = requestBody.substring(requestBody.indexOf("<notificationUrl>")+17, requestBody.indexOf("</notificationUrl>"));
+ String messageId = requestBody.substring(requestBody.indexOf("<messageId>")+11, requestBody.indexOf("</messageId>"));
+ String responseMessageId = "";
+ String updatedResponse = "";
+
+ try {
+ // try supplied response file (if any)
+ System.out.println(" Supplied fileName: " + responseDefinition.getBodyFileName());
+ ackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName());
+ notifyCallbackResponse = ackResponse;
+ responseMessageId = ackResponse.substring(ackResponse.indexOf("<messageId>")+11, ackResponse.indexOf("</messageId>"));
+ updatedResponse = ackResponse.replace(responseMessageId, messageId);
+ } catch (Exception ex) {
+ LOGGER.debug("Exception :",ex);
+ System.out.println(" ******* Use default response file in '__files/vnfAdapterMocks/vnfRollbackSimResponse.xml'");
+ responseMessageId = notifyCallbackResponse.substring(notifyCallbackResponse.indexOf("<messageId>")+11, notifyCallbackResponse.indexOf("</messageId>"));
+ updatedResponse = notifyCallbackResponse.replace(responseMessageId, messageId);
+ }
+
+ System.out.println("response (mock) messageId : " + responseMessageId);
+ System.out.println("request (replacement) messageId: " + messageId);
+
+ System.out.println("vnf Response (before):" + notifyCallbackResponse);
+ System.out.println("vnf Response (after):" + updatedResponse);
+
+ Object vnfDelay = MockResource.getMockProperties().get("vnf_delay");
+ int delay = 300;
+ if (vnfDelay != null) {
+ delay = Integer.parseInt(vnfDelay.toString());
+ }
+
+ //Kick off callback thread
+ System.out.println("VnfAdapterRollbackMockTransformer notficationUrl: " + notficationUrl + ":delay: " + delay);
+ CallbackResponseThread callbackResponseThread = new CallbackResponseThread(notficationUrl,updatedResponse, delay);
+ callbackResponseThread.start();
+
+ return ResponseDefinitionBuilder
+ .like(responseDefinition).but()
+ .withStatus(200).withBody(updatedResponse).withHeader("Content-Type", "text/xml")
+ .build();
+
+ }
+
+ @Override
+ public boolean applyGlobally() {
+ return false;
+ }
+
+ private class CallbackResponseThread extends Thread {
+
+ private String callbackUrl;
+ private String payLoad;
+ private int delay;
+
+ public CallbackResponseThread(String callbackUrl, String payLoad, int delay) {
+ this.callbackUrl = callbackUrl;
+ this.payLoad = payLoad;
+ this.delay = delay;
+ }
+
+ public void run () {
+ try {
+ //Delay sending callback response
+ sleep(delay);
+ } catch (InterruptedException e1) {
+ LOGGER.debug("Exception :",e1);
+ }
+ System.out.println("Sending callback response to url: " + callbackUrl);
+ ClientRequest request = new ClientRequest(callbackUrl);
+ request.body("text/xml", payLoad);
+ //System.err.println(payLoad);
+ try {
+ ClientResponse result = request.post();
+ System.out.println("Successfully posted callback? Status: " + result.getStatus());
+ //System.err.println("Successfully posted callback:" + result.getStatus());
+ } catch (Exception e) {
+ System.out.println("catch error in - request.post() ");
+ LOGGER.debug("Exception :",e);
+ }
+ }
+
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterUpdateMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterUpdateMockTransformer.java
new file mode 100644
index 0000000000..7808b47d24
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterUpdateMockTransformer.java
@@ -0,0 +1,149 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.bpmn.mock;
+
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+import org.openecomp.mso.logger.MsoLogger;
+
+import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
+import com.github.tomakehurst.wiremock.common.FileSource;
+import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
+import com.github.tomakehurst.wiremock.http.Request;
+import com.github.tomakehurst.wiremock.http.ResponseDefinition;
+
+import org.openecomp.mso.logger.MsoLogger;
+/**
+ * Please describe the VnfAdapterUpdateMockTransformer.java class
+ *
+ */
+public class VnfAdapterUpdateMockTransformer extends ResponseTransformer {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+
+ private String notifyCallbackResponse;
+ private String requestId;
+ private String ackResponse;
+
+ public VnfAdapterUpdateMockTransformer() {
+ notifyCallbackResponse = FileUtil.readResourceFile("vnfAdapter/vnfUpdateSimResponse.xml");
+ }
+
+ public VnfAdapterUpdateMockTransformer(String requestId) {
+ this.requestId = requestId;
+ }
+
+
+ public String name() {
+ return "vnf-adapter-update-transformer";
+ }
+
+ @Override
+ public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition,
+ FileSource fileSource) {
+
+ String requestBody = request.getBodyAsString();
+
+ String notficationUrl = requestBody.substring(requestBody.indexOf("<notificationUrl>")+17, requestBody.indexOf("</notificationUrl>"));
+ String messageId = requestBody.substring(requestBody.indexOf("<messageId>")+11, requestBody.indexOf("</messageId>"));
+ String responseMessageId = "";
+ String updatedResponse = "";
+
+ try {
+ // try supplied response file (if any)
+ System.out.println(" Supplied fileName: " + responseDefinition.getBodyFileName());
+ ackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName());
+ notifyCallbackResponse = ackResponse;
+ responseMessageId = ackResponse.substring(ackResponse.indexOf("<messageId>")+11, ackResponse.indexOf("</messageId>"));
+ updatedResponse = ackResponse.replace(responseMessageId, messageId);
+ } catch (Exception ex) {
+ LOGGER.debug("Exception :",ex);
+ System.out.println(" ******* Use default response file in 'vnfAdapter/vnfUpdateSimResponse.xml'");
+ responseMessageId = notifyCallbackResponse.substring(notifyCallbackResponse.indexOf("<messageId>")+11, notifyCallbackResponse.indexOf("</messageId>"));
+ updatedResponse = notifyCallbackResponse.replace(responseMessageId, messageId);
+ }
+
+ System.out.println("response (mock) messageId : " + responseMessageId);
+ System.out.println("request (replacement) messageId: " + messageId);
+
+ System.out.println("vnf Response (before):" + notifyCallbackResponse);
+ System.out.println("vnf Response (after):" + updatedResponse);
+
+ Object vnfDelay = MockResource.getMockProperties().get("vnf_delay");
+ int delay = 300;
+ if (vnfDelay != null) {
+ delay = Integer.parseInt(vnfDelay.toString());
+ }
+
+ //Kick off callback thread
+ System.out.println("VnfAdapterUpdateMockTransformer notficationUrl: " + notficationUrl + ":delay: " + delay);
+ CallbackResponseThread callbackResponseThread = new CallbackResponseThread(notficationUrl,updatedResponse, delay);
+ callbackResponseThread.start();
+
+ return ResponseDefinitionBuilder
+ .like(responseDefinition).but()
+ .withStatus(200).withBody(updatedResponse).withHeader("Content-Type", "text/xml")
+ .build();
+
+ }
+
+ @Override
+ public boolean applyGlobally() {
+ return false;
+ }
+
+ private class CallbackResponseThread extends Thread {
+
+ private String callbackUrl;
+ private String payLoad;
+ private int delay;
+
+ public CallbackResponseThread(String callbackUrl, String payLoad, int delay) {
+ this.callbackUrl = callbackUrl;
+ this.payLoad = payLoad;
+ this.delay = delay;
+ }
+
+ public void run () {
+ try {
+ //Delay sending callback response
+ sleep(delay);
+ } catch (InterruptedException e1) {
+ LOGGER.debug("Exception :", e1);
+ }
+ System.out.println("Sending callback response to url: " + callbackUrl);
+ ClientRequest request = new ClientRequest(callbackUrl);
+ request.body("text/xml", payLoad);
+ //System.err.println(payLoad);
+ try {
+ ClientResponse result = request.post();
+ System.out.println("Successfully posted callback? Status: " + result.getStatus());
+ //System.err.println("Successfully posted callback:" + result.getStatus());
+ } catch (Exception e) {
+ System.out.println("catch error in - request.post() ");
+ LOGGER.debug("Exception :",e);
+ }
+ }
+
+ }
+}
+
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/policy/PolicyDecisionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/policy/PolicyDecisionTest.java
deleted file mode 100644
index 8370f74851..0000000000
--- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/policy/PolicyDecisionTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.client.policy;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class PolicyDecisionTest {
-
- @BeforeClass
- public static void setUp() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
- @Test
- public void successReadProperties() throws IOException, Exception {
- PolicyRestClient client = new PolicyRestClient();
- Map<String, String> headerMap = client.headerMap;
-
- assertEquals("Found expected Client Auth", headerMap.get("ClientAuth"), "Basic bTAzNzQzOnBvbGljeVIwY2sk");
- assertEquals("Found expected Authorization", headerMap.get("Authorization"), "Basic dGVzdHBkcDphbHBoYTEyMw==");
- assertEquals("Found expected Environment", headerMap.get("Environment"), "TEST");
- assertEquals("Has X-ECOMP-RequestID", headerMap.containsKey("X-ECOMP-RequestID"), true);
- }
-
- @Test
- @Ignore // IGNORED FOR 1710 MERGE TO ONAP
- public void restEndpointCall() throws IOException, Exception {
- PolicyRestClient client = new PolicyRestClient();
- PolicyDecision decision = client.getDecision("X", "Y", "BB1", "1", "123");
- assertEquals("Decision is correct", decision.getDecision(), "PERMIT");
- assertEquals("Decision details is correct", decision.getDetails(), "Abort");
- }
-/*
- @Test
- public void failure() throws IOException, Exception {
- when(dmaapConsumer.getMRConsumer()).thenReturn(mrConsumer);
- when(mrConsumer.fetch())
- .thenReturn(Arrays.asList(new String[] { getJson("response.json"), getJson("output-failure.json") }));
-
- SDNOValidatorImpl validator = new SDNOValidatorImpl();
- thrown.expect(SDNOException.class);
- thrown.expectMessage("my message");
- boolean result = validator.pollForResponse(dmaapConsumer, "xyz123");
-
- }*/
-}