OSAM infra seed code - merge with osam-core side-by-side - fixed warnings in onap-enabler POMs
Change-Id: I0cd9ea39d4b7c1dc088ab0ecd6fb787c7f490e5e
Signed-off-by: Aharoni, Pavel (pa0916) <pavel.aharoni@intl.att.com>
diff --git a/onap-enabler-be/pom.xml b/onap-enabler-be/pom.xml
new file mode 100644
index 0000000..9952caf
--- /dev/null
+++ b/onap-enabler-be/pom.xml
@@ -0,0 +1,636 @@
+<?xml version="1.0"?>
+<!--/*-
+ * ============LICENSE_START=======================================================
+ * OSAM Core
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * 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=========================================================
+ */-->
+
+<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>
+
+ <!-- This is the Maven project object model (POM) file for VID web application
+ based on the ECOMP SDK distribution. This file stands alone; it does not
+ inherit from a parent maven module. -->
+ <groupId>org.onap.osam</groupId>
+ <artifactId>onap-enabler-be</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>war</packaging>
+
+ <properties>
+ <encoding>UTF-8</encoding>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <epsdk.version>2.4.0</epsdk.version>
+ <springframework.version>4.2.9.RELEASE</springframework.version>
+ <hibernate.version>4.3.11.Final</hibernate.version>
+ <!-- Skip assembling the zip by default -->
+ <skipassembly>true</skipassembly>
+ <!-- Tests usually require some setup that maven cannot do, so skip. -->
+ <!--<skiptests>false</skiptests>-->
+ <nexusproxy>https://nexus.onap.org</nexusproxy>
+ <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
+ <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
+ <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
+ <sitePath>/content/sites/site/org/onap/vid/${project.version}</sitePath>
+ </properties>
+
+
+ <!-- this should be commented for local debugging -->
+ <!-- <deployenv>local</deployenv> -->
+
+ <repositories>
+ <repository>
+ <id>ecomp-releases</id>
+ <name>VID Release Repository</name>
+ <url>${nexusproxy}${releaseNexusPath}</url>
+ </repository>
+ <repository>
+ <id>ecomp-snapshots</id>
+ <name>VID Snapshot Repository</name>
+ <url>${nexusproxy}${snapshotNexusPath}</url>
+ </repository>
+ <repository>
+ <id>ecomp-staging</id>
+ <name>VID Staging Repository</name>
+ <url>${nexusproxy}${stagingNexusPath}</url>
+ </repository>
+ <repository>
+ <!-- Snapshots repository has ECOMP snapshot artifacts -->
+ <id>oss-snapshots</id>
+ <name>oss Central - Snapshots</name>
+ <url>https://oss.sonatype.org/service/local/repositories/releases/content/</url>
+ </repository>
+ <repository>
+ <id>maven2-repo</id>
+ <name>Maven2 repo</name>
+ <url>https://repo.maven.apache.org/maven2</url>
+ </repository>
+
+ </repositories>
+ <distributionManagement>
+ <repository>
+ <id>ecomp-releases</id>
+ <name>VID Release Repository</name>
+ <url>${nexusproxy}/${releaseNexusPath}</url>
+ </repository>
+ <snapshotRepository>
+ <id>ecomp-snapshots</id>
+ <name>VID Snapshot Repository</name>
+ <url>${nexusproxy}/${snapshotNexusPath}</url>
+ </snapshotRepository>
+ <!-- added for javadoc -->
+ <site>
+ <id>ecomp-site</id>
+ <url>dav:${nexusproxy}${sitePath}</url>
+ </site>
+ </distributionManagement>
+
+ <build>
+ <finalName>onap-enabler-be</finalName>
+
+ <plugins>
+ <!-- License plugin should only run once at the start of the project.
+ For new classes, the header should be added manually by the company which creates it.-->
+
+ <!-- <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <version>1.16</version>
+ <configuration>
+ <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
+ <processStartTag>============LICENSE_START=======================================================</processStartTag>
+ <processEndTag>============LICENSE_END=========================================================</processEndTag>
+ <sectionDelimiter>================================================================================</sectionDelimiter>
+ <licenseName>apache_v2</licenseName>
+ <inceptionYear>2018</inceptionYear>
+ <organizationName>AT&T</organizationName>
+ <projectName>OSAM</projectName>
+ <canUpdateCopyright>true</canUpdateCopyright>
+ <canUpdateDescription>true</canUpdateDescription>
+ <canUpdateLicense>true</canUpdateLicense>
+ <emptyLineAfterHeader>true</emptyLineAfterHeader>
+ <verbose>false</verbose>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>first</id>
+ <goals>
+ <goal>update-file-header</goal>
+ </goals>
+ <phase>process-sources</phase>
+ </execution>
+ </executions>
+ </plugin>-->
+ <plugin>
+ <groupId>org.sonatype.plugins</groupId>
+ <artifactId>nexus-staging-maven-plugin</artifactId>
+ <version>1.6.7</version>
+ <extensions>true</extensions>
+ <configuration>
+ <nexusUrl>${nexusproxy}</nexusUrl>
+ <stagingProfileId>176c31dfe190a</stagingProfileId>
+ <serverId>ecomp-staging</serverId>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.7.9</version>
+ <executions>
+ <execution>
+ <id>default-prepare-agent</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>default-report</id>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tomcat.maven</groupId>
+ <artifactId>tomcat6-maven-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tomcat.maven</groupId>
+ <artifactId>tomcat7-maven-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+
+ <!-- Generate POJOs from MSO json schema -->
+ <plugin>
+ <groupId>org.jsonschema2pojo</groupId>
+ <artifactId>jsonschema2pojo-maven-plugin</artifactId>
+ <version>0.4.23</version>
+ <configuration>
+ <sourceDirectory>${basedir}/src/main/resources/json/mso</sourceDirectory>
+ <targetPackage>org.onap.osam.domain.mso</targetPackage>
+ <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.19.1</version>
+ <configuration>
+ <!--<skipTests>${skiptests}</skipTests>-->
+ <includes>
+ <include>**/Test*.java</include>
+ <include>**/*Test.java</include>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/selenium/*.java</exclude>
+ <exclude>**/integrationTest/*.java</exclude>
+ </excludes>
+ <additionalClasspathElements>
+ <additionalClasspathElement>${basedir}/war</additionalClasspathElement>
+ </additionalClasspathElements>
+ <systemPropertyVariables>
+ <container.classpath>classpath:</container.classpath>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <skipAssembly>${skipassembly}</skipAssembly>
+ <descriptors>
+ <descriptor>${basedir}/distribution.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>3.0.0</version>
+ <configuration>
+ <!-- Build a jar with all the Java classes -->
+ <attachClasses>true</attachClasses>
+ <!-- Do not put any jars in the war -->
+ <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.6</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav-jackrabbit</artifactId>
+ <version>2.10</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>pl.project13.maven</groupId>
+ <artifactId>git-commit-id-plugin</artifactId>
+ <version>2.2.4</version>
+ <executions>
+ <execution>
+ <id>get-the-git-infos</id>
+ <goals>
+ <goal>revision</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
+ <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
+ <dateFormatTimeZone>${user.timezone}</dateFormatTimeZone>
+ <generateGitPropertiesFile>true</generateGitPropertiesFile>
+ <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
+ <includeOnlyProperties>
+ <includeOnlyProperty>^git.commit.id$</includeOnlyProperty>
+ <includeOnlyProperty>^git.commit.message.short$</includeOnlyProperty>
+ <includeOnlyProperty>^git.commit.time$</includeOnlyProperty>
+ </includeOnlyProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.4</version>
+ <configuration>
+ <failOnError>false</failOnError>
+ <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
+ <docletArtifact>
+ <groupId>org.umlgraph</groupId>
+ <artifactId>umlgraph</artifactId>
+ <version>5.6</version>
+ </docletArtifact>
+ <additionalparam>-views</additionalparam>
+ <useStandardDocletOptions>true</useStandardDocletOptions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>com.opencsv</groupId>
+ <artifactId>opencsv</artifactId>
+ <version>4.1</version>
+ </dependency>
+
+ <!-- HTTP client -->
+
+ <dependency>
+ <groupId>io.joshworks.unirest</groupId>
+ <artifactId>unirest-java</artifactId>
+ <version>0.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.3.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpasyncclient</artifactId>
+ <version>4.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpmime</artifactId>
+ <version>4.3.6</version>
+ </dependency>
+ <dependency>
+ <groupId>com.xebialabs.restito</groupId>
+ <artifactId>restito</artifactId>
+ <version>0.9.3</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Helpers -->
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.18.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.vavr</groupId>
+ <artifactId>vavr</artifactId>
+ <version>0.9.2</version>
+ </dependency>
+
+ <!-- SDK overlay war -->
+ <dependency>
+ <groupId>org.onap.portal.sdk</groupId>
+ <artifactId>epsdk-app-overlay</artifactId>
+ <version>${epsdk.version}</version>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.portal.sdk</groupId>
+ <artifactId>epsdk-app-common</artifactId>
+ <version>${epsdk.version}</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onap.portal.sdk</groupId>
+ <artifactId>epsdk-core</artifactId>
+ <version>${epsdk.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.portal.sdk</groupId>
+ <artifactId>epsdk-analytics</artifactId>
+ <version>${epsdk.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.portal.sdk</groupId>
+ <artifactId>epsdk-workflow</artifactId>
+ <version>${epsdk.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.att.eelf</groupId>
+ <artifactId>eelf-core</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>1.2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.3</version>
+ </dependency>
+
+ <!-- Mapper -->
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>2.6.3</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>2.8.6</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.6.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.mchange</groupId>
+ <artifactId>c3p0</artifactId>
+ <version>0.9.5.2</version>
+ </dependency>
+ <dependency>
+ <groupId>io.searchbox</groupId>
+ <artifactId>jest</artifactId>
+ <version>2.0.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ <!--<scope>test</scope>-->
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.bean-matchers</groupId>
+ <artifactId>bean-matchers</artifactId>
+ <version>0.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20160212</version>
+ </dependency>
+ <dependency>
+ <groupId>org.quartz-scheduler</groupId>
+ <artifactId>quartz</artifactId>
+ <version>2.2.1</version>
+ <exclusions>
+ <!-- exclude 0.9.1.1 to avoid dupe of com.mchange:c3p0:0.9.2.1 -->
+ <exclusion>
+ <groupId>c3p0</groupId>
+ <artifactId>c3p0</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <!-- bridge to implement commons-logging using slf4j -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>1.7.12</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${springframework.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>2.23.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.connectors</groupId>
+ <artifactId>jersey-jetty-connector</artifactId>
+ <version>2.23.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ <version>2.6.3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.9.3</version>
+ </dependency>
+ <dependency>
+ <groupId>com.googlecode.json-simple</groupId>
+ <artifactId>json-simple</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium</groupId>
+ <artifactId>selenium-java</artifactId>
+ <version>2.53.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium</groupId>
+ <artifactId>selenium-api</artifactId>
+ <version>2.53.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>6.8</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium</groupId>
+ <artifactId>selenium-firefox-driver</artifactId>
+ <version>2.53.1</version>
+ </dependency>
+ <dependency>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ <version>1.4.01</version>
+ </dependency>
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <version>1.16</version>
+ </dependency>
+ <dependency>
+ <groupId>org.skyscreamer</groupId>
+ <artifactId>jsonassert</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.sdc.sdc-tosca</groupId>
+ <artifactId>sdc-tosca</artifactId>
+ <version>1.4.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.javacrumbs.json-unit</groupId>
+ <artifactId>json-unit</artifactId>
+ <version>1.23.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-text</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>java-hamcrest</artifactId>
+ <version>2.0.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.togglz</groupId>
+ <artifactId>togglz-spring-core</artifactId>
+ <version>2.5.0.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.10.0</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/RelatedTo.java b/onap-enabler-be/src/main/java/org/onap/osam/RelatedTo.java
new file mode 100644
index 0000000..21fb8b8
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/RelatedTo.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.HashMap;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "id",
+ "node-type",
+ "relationship-label",
+ "url"
+})
+public class RelatedTo {
+
+ @JsonProperty("id")
+ public String id;
+ @JsonProperty("node-type")
+ public String nodeType;
+ @JsonProperty("relationship-label")
+ public String relationshipLabel;
+ @JsonProperty("url")
+ public String url;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<>();
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiClient.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiClient.java
new file mode 100644
index 0000000..e04301b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiClient.java
@@ -0,0 +1,652 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.utils.URIBuilder;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.onap.osam.aai.model.AaiGetAicZone.AicZones;
+import org.onap.osam.aai.model.AaiGetInstanceGroupsByCloudRegion;
+import org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.AaiGetNetworkCollectionDetails;
+import org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.AaiGetNetworkCollectionDetailsHelper;
+import org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.AaiGetRelatedInstanceGroupsByVnfId;
+import org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.InstanceGroup;
+import org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.Network;
+import org.onap.osam.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.osam.aai.model.AaiGetPnfResponse;
+import org.onap.osam.aai.model.AaiGetPnfs.Pnf;
+import org.onap.osam.aai.model.AaiGetPortMirroringSourcePorts;
+import org.onap.osam.aai.model.AaiGetServicesRequestModel.GetServicesAAIRespone;
+import org.onap.osam.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.osam.aai.model.AaiNodeQueryResponse;
+import org.onap.osam.aai.model.GetServiceModelsByDistributionStatusResponse;
+import org.onap.osam.aai.model.LogicalLinkResponse;
+import org.onap.osam.aai.model.OwningEntityResponse;
+import org.onap.osam.aai.model.PortDetailsTranslator;
+import org.onap.osam.aai.model.ProjectResponse;
+import org.onap.osam.aai.model.Relationship;
+import org.onap.osam.aai.model.RelationshipData;
+import org.onap.osam.aai.model.RelationshipList;
+import org.onap.osam.aai.model.ResourceType;
+import org.onap.osam.aai.model.ServiceRelationships;
+import org.onap.osam.aai.util.AAIRestInterface;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.model.SubscriberList;
+import org.onap.osam.model.probes.ErrorMetadata;
+import org.onap.osam.model.probes.ExternalComponentStatus;
+import org.onap.osam.model.probes.HttpRequestMetadata;
+import org.onap.osam.utils.Logging;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.web.util.UriUtils;
+
+import javax.inject.Inject;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.UUID;
+
+import static java.util.Collections.emptyList;
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+
+public class AaiClient implements AaiClientInterface {
+
+
+ public static final String QUERY_FORMAT_RESOURCE = "query?format=resource";
+ public static final String SERVICE_SUBSCRIPTIONS_PATH = "/service-subscriptions/service-subscription/";
+ public static final String MODEL_INVARIANT_ID = "&model-invariant-id=";
+ public static final String QUERY_FORMAT_SIMPLE = "query?format=simple";
+ public static final String BUSINESS_CUSTOMER = "/business/customers/customer/";
+ public static final String SERVICE_INSTANCE = "/service-instances/service-instance/";
+ public static final String BUSINESS_CUSTOMERS_CUSTOMER = "business/customers/customer/";
+
+ protected String fromAppId = "VidAaiController";
+
+ private PortDetailsTranslator portDetailsTranslator;
+
+ private final AAIRestInterface restController;
+
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AaiClient.class);
+
+ /**
+ * The Constant dateFormat.
+ */
+ static final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ static final String GET_SERVICE_MODELS_RESPONSE_BODY = "{\"start\" : \"service-design-and-creation/models/\", \"query\" : \"query/serviceModels-byDistributionStatus?distributionStatus=DISTRIBUTION_COMPLETE_OK\"}";
+
+ @Inject
+ public AaiClient(AAIRestInterface restController, PortDetailsTranslator portDetailsTranslator) {
+ this.restController = restController;
+ this.portDetailsTranslator = portDetailsTranslator;
+ }
+
+
+ private static String checkForNull(String local) {
+ if (local != null)
+ return local;
+ else
+ return "";
+
+ }
+
+ @Override
+ public AaiResponse getServicesByOwningEntityId(List<String> owningEntityIds){
+ Response resp = doAaiGet(getUrlFromLIst("business/owning-entities?", "owning-entity-id=", owningEntityIds), false);
+ return processAaiResponse(resp, OwningEntityResponse.class, null);
+ }
+
+ @Override
+ public AaiResponse getServicesByProjectNames(List<String> projectNames){
+ Response resp = doAaiGet(getUrlFromLIst("business/projects?", "project-name=", projectNames), false);
+ return processAaiResponse(resp, ProjectResponse.class, null);
+ }
+
+ @Override
+ public AaiResponse getServiceModelsByDistributionStatus() {
+ Response resp = doAaiPut(QUERY_FORMAT_RESOURCE, GET_SERVICE_MODELS_RESPONSE_BODY, false);
+ return processAaiResponse(resp, GetServiceModelsByDistributionStatusResponse.class, null);
+ }
+
+ @Override
+ public AaiResponse getNetworkCollectionDetails(String serviceInstanceId) {
+ Response resp = doAaiPut(QUERY_FORMAT_RESOURCE, "{\"start\": [\"nodes/service-instances/service-instance/" + serviceInstanceId + "\"],\"query\": \"query/network-collection-ByServiceInstance\"}\n", false);
+ AaiResponse<AaiGetNetworkCollectionDetailsHelper> aaiResponse = processAaiResponse(resp, AaiGetNetworkCollectionDetailsHelper.class, null);
+ return getNetworkCollectionDetailsResponse(aaiResponse);
+ }
+
+ @Override
+ public AaiResponse getInstanceGroupsByCloudRegion(String cloudOwner, String cloudRegionId, String networkFunction) {
+ Response resp = doAaiPut(QUERY_FORMAT_RESOURCE,
+ "{\"start\": [\"cloud-infrastructure/cloud-regions/cloud-region/" + cloudOwner + "/" + cloudRegionId + "\"]," +
+ "\"query\": \"query/instance-group-byCloudRegion?type=L3-NETWORK&role=SUB-INTERFACE&function=" + networkFunction + "\"}\n", false);
+ return processAaiResponse(resp, AaiGetInstanceGroupsByCloudRegion.class, null);
+ }
+
+ private AaiResponse getNetworkCollectionDetailsResponse(AaiResponse<AaiGetNetworkCollectionDetailsHelper> aaiResponse){
+ if(aaiResponse.getHttpCode() == 200) {
+ com.fasterxml.jackson.databind.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper();
+ AaiGetNetworkCollectionDetails aaiGetNetworkCollectionDetails = new AaiGetNetworkCollectionDetails();
+ try {
+ for (int i = 0; i < aaiResponse.getT().getResults().size(); i++) {
+ LinkedHashMap<String, Object> temp = ((LinkedHashMap) aaiResponse.getT().getResults().get(i));
+ if (temp.get("service-instance") != null)
+ aaiGetNetworkCollectionDetails.getResults().setServiceInstance(om.readValue(om.writeValueAsString(temp.get("service-instance")), org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.ServiceInstance.class));
+ else if (temp.get("collection") != null)
+ aaiGetNetworkCollectionDetails.getResults().setCollection(om.readValue(om.writeValueAsString(temp.get("collection")), org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.Collection.class));
+ else if (temp.get("instance-group") != null)
+ aaiGetNetworkCollectionDetails.getResults().setInstanceGroup(om.readValue(om.writeValueAsString(temp.get("instance-group")), InstanceGroup.class));
+ else if (temp.get("l3-network") != null)
+ aaiGetNetworkCollectionDetails.getResults().getNetworks().add(om.readValue(om.writeValueAsString(temp.get("l3-network")), Network.class));
+ }
+ return new AaiResponse(aaiGetNetworkCollectionDetails, null, HttpStatus.SC_OK);
+ }
+ catch (com.fasterxml.jackson.databind.JsonMappingException e) {
+ return new AaiResponse(e.getCause(), "AAI response parsing Error" , aaiResponse.getHttpCode());
+ }
+ catch (Exception e) {
+ return new AaiResponse(e.getCause(), "Got " + aaiResponse.getHttpCode() + " from a&ai" , aaiResponse.getHttpCode());
+ }
+ }
+ return aaiResponse;
+ }
+
+ @Override
+ public AaiResponse getPNFData(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion, String equipVendor, String equipModel) {
+ String siQuery = BUSINESS_CUSTOMER + globalCustomerId + SERVICE_SUBSCRIPTIONS_PATH + encodePathSegment(serviceType) + "/service-instances?model-version-id=" + modelVersionId + MODEL_INVARIANT_ID + modelInvariantId;
+ String pnfQuery = "query/pnf-fromModel-byRegion?cloudRegionId=" + encodePathSegment(cloudRegion) + "&equipVendor=" + encodePathSegment(equipVendor) + "&equipModel=" + encodePathSegment(equipModel);
+ String payload = "{\"start\":\"" + siQuery + "\",\"query\":\"" + pnfQuery + "\"}";
+ Response resp = doAaiPut(QUERY_FORMAT_SIMPLE, payload, false);
+ return processAaiResponse(resp, AaiGetPnfResponse.class, null);
+ }
+
+
+ @Override
+ public AaiResponse<Pnf> getSpecificPnf(String pnfId) {
+ Response resp = doAaiGet("network/pnfs/pnf/"+pnfId, false);
+ return processAaiResponse(resp, Pnf.class, null);
+ }
+
+
+ public AaiResponse getInstanceGroupsByVnfInstanceId(String vnfInstanceId){
+ Response resp = doAaiGet("network/generic-vnfs/generic-vnf/" + vnfInstanceId + "?depth=0", false);
+ return processAaiResponse(resp, AaiGetRelatedInstanceGroupsByVnfId.class , null);
+ }
+
+
+ @Override
+ public List<PortDetailsTranslator.PortDetails> getPortMirroringSourcePorts(String configurationID) {
+ String payload = "{\"start\":\"/network/configurations/configuration/" + configurationID + "\",\"query\":\"query/pserver-fromConfiguration\"}";
+ Response resp = doAaiPut(QUERY_FORMAT_SIMPLE, payload, false);
+ resp.bufferEntity(); // avoid later "Entity input stream has already been closed" problems
+ String rawPayload = resp.readEntity(String.class);
+ AaiResponse<AaiGetPortMirroringSourcePorts> aaiResponse = processAaiResponse(resp, AaiGetPortMirroringSourcePorts.class, rawPayload);
+ return portDetailsTranslator.extractPortDetails(aaiResponse, rawPayload);
+ }
+
+
+
+ public AaiResponse getServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId) {
+ String getServiceInstancePath = BUSINESS_CUSTOMERS_CUSTOMER + globalCustomerId+ SERVICE_SUBSCRIPTIONS_PATH +serviceType+ SERVICE_INSTANCE +serviceInstanceId;
+ Response resp = doAaiGet(getServiceInstancePath , false);
+ return processAaiResponse(resp, ServiceRelationships.class, null);
+ }
+
+ @Override
+ public AaiResponse getLogicalLink(String link) {
+ Response resp = doAaiGet("network/logical-links/logical-link/" + link , false);
+ return processAaiResponse(resp, LogicalLinkResponse.class, null);
+ }
+
+ @Override
+ public AaiResponse<AaiNodeQueryResponse> searchNodeTypeByName(String name, ResourceType type) {
+ String path = String.format(
+ "search/nodes-query?search-node-type=%s&filter=%s:EQUALS:%s",
+ type.getAaiFormat(),
+ type.getNameFilter(),
+ name
+ );
+ return typedAaiGet(path, AaiNodeQueryResponse.class);
+ }
+
+ private <T> AaiResponse<T> typedAaiGet(String path, Class<T> clz) {
+ Response resp = doAaiGet(path , false);
+ return processAaiResponse(resp, clz, null);
+ }
+
+
+
+ private String getUrlFromLIst(String url, String paramKey, List<String> params){
+ int i = 0;
+ for(String param: params){
+ i ++;
+ url = url.concat(paramKey);
+ String encodedParam= param;
+ try {
+ encodedParam= URLEncoder.encode(param, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ String methodName = "getUrlFromList";
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ }
+ url = url.concat(encodedParam);
+ if(i != params.size()){
+ url = url.concat("&");
+ }
+ }
+ return url;
+ }
+
+
+ @Override
+ public AaiResponse<SubscriberList> getAllSubscribers() {
+ return getAllSubscribers(false).getAaiResponse();
+ }
+
+ AaiResponseWithRequestInfo<SubscriberList> getAllSubscribers(boolean propagateExceptions){
+ String depth = "0";
+ ResponseWithRequestInfo aaiGetResult = doAaiGet("business/customers?subscriber-type=INFRA&depth=" + depth, false, propagateExceptions);
+ AaiResponseWithRequestInfo<SubscriberList> responseWithRequestInfo = processAaiResponse(aaiGetResult, SubscriberList.class, propagateExceptions);
+ responseWithRequestInfo.setRequestedUrl(aaiGetResult.getRequestUrl());
+ responseWithRequestInfo.setHttpMethod(aaiGetResult.getRequestHttpMethod());
+ return responseWithRequestInfo;
+ }
+
+
+ @Override
+ public AaiResponse getAllAicZones() {
+ Response resp = doAaiGet("network/zones", false);
+ return processAaiResponse(resp, AicZones.class, null);
+ }
+
+
+ @Override
+ public AaiResponse<String> getAicZoneForPnf(String globalCustomerId , String serviceType , String serviceId) {
+ String aicZonePath = BUSINESS_CUSTOMERS_CUSTOMER + globalCustomerId + SERVICE_SUBSCRIPTIONS_PATH + serviceType + SERVICE_INSTANCE + serviceId;
+ Response resp = doAaiGet(aicZonePath , false);
+ AaiResponse<ServiceRelationships> aaiResponse = processAaiResponse(resp , ServiceRelationships.class , null);
+ ServiceRelationships serviceRelationships = aaiResponse.getT();
+ RelationshipList relationshipList = serviceRelationships.getRelationshipList();
+ Relationship relationship = relationshipList.getRelationship().get(0);
+ RelationshipData relationshipData= relationship.getRelationDataList().get(0);
+ String aicZone = relationshipData.getRelationshipValue();
+ return new AaiResponse(aicZone , null ,HttpStatus.SC_OK);
+ }
+
+
+ @Override
+ public AaiResponse getVNFData() {
+ String payload = "{\"start\": [\"/business/customers/customer/e433710f-9217-458d-a79d-1c7aff376d89/service-subscriptions/service-subscription/VIRTUAL%20USP/service-instances/service-instance/3f93c7cb-2fd0-4557-9514-e189b7b04f9d\"], \"query\": \"query/vnf-topology-fromServiceInstance\"}";
+ Response resp = doAaiPut(QUERY_FORMAT_SIMPLE, payload, false);
+ return processAaiResponse(resp, AaiGetVnfResponse.class, null);
+ }
+
+ @Override
+ public Response getVNFData(String globalSubscriberId, String serviceType) {
+ String payload = "{\"start\": [\"business/customers/customer/" + globalSubscriberId + SERVICE_SUBSCRIPTIONS_PATH + encodePathSegment(serviceType) +"/service-instances\"]," +
+ "\"query\": \"query/vnf-topology-fromServiceInstance\"}";
+ return doAaiPut(QUERY_FORMAT_SIMPLE, payload, false);
+ }
+
+ @Override
+ public AaiResponse getVNFData(String globalSubscriberId, String serviceType, String serviceInstanceId) {
+ String payload = "{\"start\": [\"/business/customers/customer/" + globalSubscriberId + SERVICE_SUBSCRIPTIONS_PATH + encodePathSegment(serviceType) + SERVICE_INSTANCE + serviceInstanceId + "\"], \"query\": \"query/vnf-topology-fromServiceInstance\"}";
+ Response resp = doAaiPut(QUERY_FORMAT_SIMPLE, payload, false);
+ return processAaiResponse(resp, AaiGetVnfResponse.class, null);
+ }
+
+ @Override
+ public Response getVersionByInvariantId(List<String> modelInvariantId) {
+ StringBuilder sb = new StringBuilder();
+ for (String id : modelInvariantId){
+ sb.append(MODEL_INVARIANT_ID);
+ sb.append(id);
+
+ }
+ return doAaiGet("service-design-and-creation/models?depth=2"+ sb.toString(), false);
+ }
+
+ @Override
+ public AaiResponse getSubscriberData(String subscriberId) {
+ String depth = "2";
+ AaiResponse subscriberDataResponse;
+ Response resp = doAaiGet(BUSINESS_CUSTOMERS_CUSTOMER + subscriberId + "?depth=" + depth, false);
+ subscriberDataResponse = processAaiResponse(resp, Services.class, null);
+ return subscriberDataResponse;
+ }
+
+ @Override
+ public AaiResponse getServices() {
+ Response resp = doAaiGet("service-design-and-creation/services", false);
+ return processAaiResponse(resp, GetServicesAAIRespone.class, null);
+ }
+
+ @Override
+ public AaiResponse getOperationalEnvironments(String operationalEnvironmentType, String operationalEnvironmentStatus) {
+ String url = "cloud-infrastructure/operational-environments";
+ URIBuilder urlBuilder = new URIBuilder();
+ if (operationalEnvironmentType != null)
+ urlBuilder.addParameter("operational-environment-type", operationalEnvironmentType);
+ if (operationalEnvironmentStatus != null)
+ urlBuilder.addParameter("operational-environment-status", operationalEnvironmentStatus);
+ url += urlBuilder.toString();
+ Response resp = doAaiGet(url, false);
+ return processAaiResponse(resp, OperationalEnvironmentList.class, null);
+ }
+
+ @Override
+ public AaiResponse getTenants(String globalCustomerId, String serviceType) {
+ AaiResponse aaiResponse;
+
+ if ((globalCustomerId == null || globalCustomerId.isEmpty()) || ((serviceType == null) || (serviceType.isEmpty())) ){
+ aaiResponse = new AaiResponse<>(null, "{\"statusText\":\" Failed to retrieve LCP Region & Tenants from A&AI, Subscriber ID or Service Type is missing.\"}", HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ return aaiResponse;
+ }
+
+ String url = BUSINESS_CUSTOMERS_CUSTOMER + globalCustomerId + SERVICE_SUBSCRIPTIONS_PATH + serviceType;
+
+ Response resp = doAaiGet(url, false);
+ String responseAsString = parseForTenantsByServiceSubscription(resp.readEntity(String.class));
+ if (responseAsString.equals("")){
+ return new AaiResponse<>(null, String.format("{\"statusText\":\" A&AI has no LCP Region & Tenants associated to subscriber '%s' and service type '%s'\"}", globalCustomerId, serviceType), HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ }
+ else {
+ return processAaiResponse(resp, GetTenantsResponse[].class, responseAsString);
+ }
+ }
+
+ @Override
+ public AaiResponse getNodeTemplateInstances(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion) {
+
+ String siQuery = BUSINESS_CUSTOMER + globalCustomerId + SERVICE_SUBSCRIPTIONS_PATH + encodePathSegment(serviceType) + "/service-instances?model-version-id=" + modelVersionId + MODEL_INVARIANT_ID + modelInvariantId;
+ String vnfQuery = "query/queryvnfFromModelbyRegion?cloudRegionId=" + encodePathSegment(cloudRegion);
+ String payload1 = "{\"start\":\"" + siQuery + "\",\"query\":\"" + vnfQuery + "\"}";
+
+ Response resp1 = doAaiPut(QUERY_FORMAT_SIMPLE, payload1, false);
+ AaiResponse aaiResponse1 = processAaiResponse(resp1, AaiGetVnfResponse.class, null);
+ logger.debug(EELFLoggerDelegate.debugLogger, "getNodeTemplateInstances AAI's response: {}", aaiResponse1);
+ return aaiResponse1;
+ }
+
+ private <T> AaiResponseWithRequestInfo<T> processAaiResponse(ResponseWithRequestInfo responseWithRequestInfo, Class<? extends T> classType, boolean propagateExceptions) {
+ String responseBody = null;
+ Integer responseHttpCode = null;
+ try {
+ Response response = responseWithRequestInfo.getResponse();
+ responseHttpCode = (response != null) ? response.getStatus() : null;
+ responseBody = (response != null) ? response.readEntity(String.class) : null;
+ AaiResponse<T> processedAaiResponse = processAaiResponse(response, classType, responseBody, propagateExceptions);
+ return new AaiResponseWithRequestInfo<>(responseWithRequestInfo.getRequestHttpMethod(), responseWithRequestInfo.getRequestUrl(), processedAaiResponse,
+ responseBody);
+ } catch (Exception e) {
+ throw new ExceptionWithRequestInfo(responseWithRequestInfo.getRequestHttpMethod(),
+ responseWithRequestInfo.getRequestUrl(), responseBody, responseHttpCode, e);
+ }
+ }
+
+ private AaiResponse processAaiResponse(Response resp, Class classType, String responseBody) {
+ return processAaiResponse(resp, classType, responseBody, false);
+ }
+
+ private AaiResponse processAaiResponse(Response resp, Class classType, String responseBody, boolean propagateExceptions) {
+ AaiResponse subscriberDataResponse;
+ if (resp == null) {
+ subscriberDataResponse = new AaiResponse<>(null, null, HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "Invalid response from AAI");
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getSubscribers() resp=" + resp.getStatusInfo().toString());
+ if (resp.getStatus() != HttpStatus.SC_OK) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "Invalid response from AAI");
+ String rawData = resp.readEntity(String.class);
+ subscriberDataResponse = new AaiResponse<>(null, rawData, resp.getStatus());
+ } else {
+ subscriberDataResponse = processOkResponse(resp, classType, responseBody, propagateExceptions);
+ }
+ }
+ return subscriberDataResponse;
+ }
+
+ private AaiResponse processOkResponse(Response resp, Class classType, String responseBody, boolean propagateExceptions) {
+ AaiResponse subscriberDataResponse;
+ String finalResponse = null;
+ try {
+ if (responseBody != null) {
+ finalResponse = responseBody;
+ } else {
+ finalResponse = resp.readEntity(String.class);
+ }
+
+ subscriberDataResponse = parseFasterXmlObject(classType, finalResponse);
+
+ } catch(Exception e){
+ if (propagateExceptions) {
+ throw new GenericUncheckedException(e);
+ } else {
+ subscriberDataResponse = new AaiResponse<>(null, null, HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ logger.error("Failed to parse aai response: \"{}\" to class {}", finalResponse, classType, e);
+ }
+ }
+ return subscriberDataResponse;
+ }
+
+ private AaiResponse parseFasterXmlObject(Class classType, String finalResponse) throws IOException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ return new AaiResponse<>((objectMapper.readValue(finalResponse, classType)), null, HttpStatus.SC_OK);
+ }
+
+ public Response doAaiGet(String uri, boolean xml) {
+ return doAaiGet(uri, xml, false).getResponse();
+ }
+
+
+ public ResponseWithRequestInfo doAaiGet(String uri, boolean xml, boolean propagateExceptions) {
+ String methodName = "doAaiGet";
+ String transId = UUID.randomUUID().toString();
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ ResponseWithRequestInfo resp;
+ try {
+ resp = restController.RestGet(fromAppId, transId, uri, xml, propagateExceptions);
+
+ } catch (Exception e) {
+ if (propagateExceptions) {
+ throw (e instanceof RuntimeException) ? (RuntimeException)e : new GenericUncheckedException(e);
+ } else {
+ final Exception actual =
+ e instanceof ExceptionWithRequestInfo ? (Exception) e.getCause() : e;
+
+ final String message =
+ actual instanceof WebApplicationException ? ((WebApplicationException) actual).getResponse().readEntity(String.class) : e.toString();
+
+ //ToDo: change parameter of requestUrl to real url from RestGet function
+ resp = new ResponseWithRequestInfo(null, null, org.springframework.http.HttpMethod.GET);
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + message);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + message);
+ }
+ }
+ return resp;
+ }
+
+ private String parseForTenantsByServiceSubscription(String resp) {
+ String tenantList = "";
+
+ try {
+ JSONParser jsonParser = new JSONParser();
+
+ JSONObject jsonObject = (JSONObject) jsonParser.parse(resp);
+
+ return parseServiceSubscriptionObjectForTenants(jsonObject);
+ } catch (Exception ex) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "parseForTenantsByServiceSubscription error while parsing tenants by service subscription", ex);
+ }
+ return tenantList;
+ }
+
+ protected Response doAaiPut(String uri, String payload, boolean xml) {
+ String methodName = "doAaiPut";
+ String transId = UUID.randomUUID().toString();
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ Response resp = null;
+ try {
+
+ resp = restController.RestPut(fromAppId, uri, payload, xml);
+
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ }
+ return resp;
+ }
+
+
+ private String parseServiceSubscriptionObjectForTenants(JSONObject jsonObject) {
+ JSONArray tenantArray = new JSONArray();
+ boolean bconvert = false;
+ try {
+ JSONObject relationShipListsObj = (JSONObject) jsonObject.get("relationship-list");
+ if (relationShipListsObj != null) {
+ JSONArray rShipArray = (JSONArray) relationShipListsObj.get("relationship");
+ for (Object innerObj : defaultIfNull(rShipArray, emptyList())) {
+ if (innerObj != null) {
+ bconvert = parseTenant(tenantArray, bconvert, (JSONObject) innerObj);
+ }
+ }
+ }
+ } catch (NullPointerException ex) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "parseServiceSubscriptionObjectForTenants. error while parsing service subscription object for tenants", ex);
+ }
+
+ if (bconvert)
+ return tenantArray.toJSONString();
+ else
+ return "";
+
+ }
+
+ private static boolean parseTenant(JSONArray tenantArray, boolean bconvert, JSONObject inner1Obj) {
+ String relatedTo = checkForNull((String) inner1Obj.get("related-to"));
+ if (relatedTo.equalsIgnoreCase("tenant")) {
+ JSONObject tenantNewObj = new JSONObject();
+
+ String relatedLink = checkForNull((String) inner1Obj.get("related-link"));
+ tenantNewObj.put("link", relatedLink);
+
+ JSONArray rDataArray = (JSONArray) inner1Obj.get("relationship-data");
+ for (Object innerObj : defaultIfNull(rDataArray, emptyList())) {
+ parseRelationShip(tenantNewObj, (JSONObject) innerObj);
+ }
+
+ JSONArray relatedTPropArray = (JSONArray) inner1Obj.get("related-to-property");
+ for (Object innerObj : defaultIfNull(relatedTPropArray, emptyList())) {
+ parseRelatedTProp(tenantNewObj, (JSONObject) innerObj);
+ }
+ bconvert = true;
+ tenantArray.add(tenantNewObj);
+ }
+ return bconvert;
+ }
+
+ private static void parseRelatedTProp(JSONObject tenantNewObj, JSONObject innerObj) {
+ if (innerObj == null)
+ return;
+
+ String propKey = checkForNull((String) innerObj.get("property-key"));
+ String propVal = checkForNull((String) innerObj.get("property-value"));
+ if (propKey.equalsIgnoreCase("tenant.tenant-name")) {
+ tenantNewObj.put("tenantName", propVal);
+ }
+ }
+
+ private static void parseRelationShip(JSONObject tenantNewObj, JSONObject inner2Obj) {
+ if (inner2Obj == null)
+ return;
+
+ String rShipKey = checkForNull((String) inner2Obj.get("relationship-key"));
+ String rShipVal = checkForNull((String) inner2Obj.get("relationship-value"));
+ if (rShipKey.equalsIgnoreCase("cloud-region.cloud-owner")) {
+ tenantNewObj.put("cloudOwner", rShipVal);
+ } else if (rShipKey.equalsIgnoreCase("cloud-region.cloud-region-id")) {
+ tenantNewObj.put("cloudRegionID", rShipVal);
+ }
+
+ if (rShipKey.equalsIgnoreCase("tenant.tenant-id")) {
+ tenantNewObj.put("tenantID", rShipVal);
+ }
+ }
+
+ private static String encodePathSegment(String segmentToEncode) {
+ try {
+ return UriUtils.encodePathSegment(segmentToEncode, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new GenericUncheckedException("URI encoding failed unexpectedly", e);
+ }
+ }
+
+ @Override
+ public ExternalComponentStatus probeAaiGetAllSubscribers(){
+ long startTime = System.currentTimeMillis();
+ try {
+ AaiResponseWithRequestInfo<SubscriberList> responseWithRequestInfo = getAllSubscribers(true);
+ AaiResponse<SubscriberList> aaiResponse = responseWithRequestInfo.getAaiResponse();
+ long duration = System.currentTimeMillis() - startTime;
+
+ SubscriberList subscribersList = (aaiResponse != null) ? aaiResponse.getT() : null;
+ boolean isAvailable = subscribersList != null && subscribersList.customer != null && !subscribersList.customer.isEmpty();
+
+ HttpRequestMetadata metadata = new HttpRequestMetadata(
+ responseWithRequestInfo.getHttpMethod(),
+ (aaiResponse != null) ? aaiResponse.getHttpCode() : 0,
+ responseWithRequestInfo.getRequestedUrl(),
+ StringUtils.substring(responseWithRequestInfo.getRawData(), 0, 500),
+ isAvailable ? "OK" : "No subscriber received",
+ duration
+ );
+ return new ExternalComponentStatus(ExternalComponentStatus.Component.AAI, isAvailable, metadata);
+
+ } catch (ExceptionWithRequestInfo e) {
+ long duration = System.currentTimeMillis() - startTime;
+ return new ExternalComponentStatus(ExternalComponentStatus.Component.AAI, false,
+ new HttpRequestMetadata(
+ e.getHttpMethod(),
+ defaultIfNull(e.getHttpCode(), 0),
+ e.getRequestedUrl(),
+ e.getRawData(),
+ Logging.exceptionToDescription(e.getCause()), duration));
+ } catch (Exception e) {
+ long duration = System.currentTimeMillis() - startTime;
+ return new ExternalComponentStatus(ExternalComponentStatus.Component.AAI, false,
+ new ErrorMetadata(Logging.exceptionToDescription(e), duration));
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiClientInterface.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiClientInterface.java
new file mode 100644
index 0000000..d39dbb1
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiClientInterface.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import org.onap.osam.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.osam.aai.model.AaiGetPnfs.Pnf;
+import org.onap.osam.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.osam.aai.model.AaiNodeQueryResponse;
+import org.onap.osam.aai.model.PortDetailsTranslator;
+import org.onap.osam.aai.model.ResourceType;
+import org.onap.osam.model.SubscriberList;
+import org.onap.osam.model.probes.ExternalComponentStatus;
+
+import javax.ws.rs.core.Response;
+import java.util.List;
+
+public interface AaiClientInterface {
+
+ AaiResponse<AaiNodeQueryResponse> searchNodeTypeByName(String name, ResourceType type);
+
+ AaiResponse<SubscriberList> getAllSubscribers();
+
+ AaiResponse getSubscriberData(String subscriberId);
+
+ AaiResponse getServices();
+
+ AaiResponse getServicesByOwningEntityId(List<String> owningEntityIds);
+
+ AaiResponse<GetTenantsResponse[]> getTenants(String globalCustomerId, String serviceType);
+
+ AaiResponse<OperationalEnvironmentList> getOperationalEnvironments(String operationalEnvironmentType, String operationalEnvironmentStatus);
+
+ AaiResponse getAllAicZones();
+
+ AaiResponse getAicZoneForPnf(String globalCustomerId , String serviceType , String serviceId);
+
+ AaiResponse getVNFData();
+
+ AaiResponse getNetworkCollectionDetails(String serviceInstanceId);
+
+ AaiResponse getInstanceGroupsByCloudRegion(String cloudOwner, String cloudRegionId, String networkFunction);
+
+ Response getVNFData(String globalSubscriberId, String serviceType);
+
+ AaiResponse getVNFData(String globalSubscriberId, String serviceType, String serviceInstanceId);
+
+ AaiResponse getNodeTemplateInstances(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion);
+
+ Response getVersionByInvariantId(List<String> modelInvariantId);
+
+ AaiResponse getServicesByProjectNames(List<String> projectNames);
+
+ AaiResponse getServiceModelsByDistributionStatus();
+
+ AaiResponse getPNFData(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion, String equipVendor, String equipModel);
+
+ AaiResponse<Pnf> getSpecificPnf(String pnfId);
+
+ AaiResponse getServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId);
+
+ AaiResponse getLogicalLink(String link);
+
+ List<PortDetailsTranslator.PortDetails> getPortMirroringSourcePorts(String configurationID);
+
+ AaiResponse getInstanceGroupsByVnfInstanceId(String vnfInstanceId);
+
+ ExternalComponentStatus probeAaiGetAllSubscribers();
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiGetVnfResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiGetVnfResponse.java
new file mode 100644
index 0000000..74bad6a
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiGetVnfResponse.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.google.common.base.MoreObjects;
+import org.onap.osam.aai.model.VnfResult;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "results"
+})
+public class AaiGetVnfResponse {
+ @JsonProperty("results")
+ public List<VnfResult> results = null;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<>();
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("results", results)
+ .add("additionalProperties", additionalProperties)
+ .toString();
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiResponse.java
new file mode 100644
index 0000000..50ded45
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiResponse.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import com.google.common.base.MoreObjects;
+import org.onap.osam.model.ProxyResponse;
+
+public class AaiResponse<T> extends ProxyResponse{
+
+ T t;
+
+ public AaiResponse() {
+ }
+
+ public AaiResponse(T t, String errorMessage, int aaiHttpCode) {
+ this.t = t;
+ this.errorMessage = errorMessage;
+ this.httpCode = aaiHttpCode;
+ }
+
+ public T getT() {
+ return t;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("httpCode", httpCode)
+ .add("errorMessage", errorMessage)
+ .add("t", t)
+ .toString();
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiResponseWithRequestInfo.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiResponseWithRequestInfo.java
new file mode 100644
index 0000000..73ed78c
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/AaiResponseWithRequestInfo.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+
+import org.springframework.http.HttpMethod;
+
+import java.io.Serializable;
+
+public class AaiResponseWithRequestInfo<T> implements Serializable {
+ private AaiResponse<T> aaiResponse;
+ private String requestedUrl;
+ private String rawData;
+ private HttpMethod httpMethod;
+
+ public AaiResponseWithRequestInfo(HttpMethod httpMethod, String requestedUrl, AaiResponse<T> aaiResponse, String rawData) {
+ this.aaiResponse = aaiResponse;
+ this.requestedUrl = requestedUrl;
+ this.rawData = rawData;
+ this.httpMethod = httpMethod;
+ }
+
+ public void setRequestedUrl(String requestedUrl) {
+ this.requestedUrl = requestedUrl;
+ }
+
+ public void setHttpMethod(HttpMethod httpMethod) {
+ this.httpMethod = httpMethod;
+ }
+
+ public AaiResponse<T> getAaiResponse() {
+ return aaiResponse;
+ }
+
+ public String getRequestedUrl() {
+ return requestedUrl;
+ }
+
+ public String getRawData() {
+ return rawData;
+ }
+
+ public HttpMethod getHttpMethod() {
+ return httpMethod;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/ExceptionWithRequestInfo.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/ExceptionWithRequestInfo.java
new file mode 100644
index 0000000..8b1ff6f
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/ExceptionWithRequestInfo.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.http.HttpMethod;
+
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+
+public class ExceptionWithRequestInfo extends RuntimeException {
+
+ private final HttpMethod httpMethod;
+ private final String requestedUrl;
+ private final Integer httpCode;
+ private final String rawData;
+
+ public ExceptionWithRequestInfo(HttpMethod httpMethod, String requestedUrl, String rawData, Integer httpCode, Throwable cause) {
+ super(toMessage(httpMethod, requestedUrl, cause), cause);
+ this.httpMethod = httpMethod;
+ this.requestedUrl = requestedUrl;
+ this.rawData = rawData;
+ this.httpCode = httpCode;
+ }
+
+ public ExceptionWithRequestInfo(HttpMethod httpMethod, String requestedUrl, Throwable cause) {
+ this(httpMethod, requestedUrl, null, null, cause);
+ }
+
+ public String getRequestedUrl() {
+ return requestedUrl;
+ }
+
+ public String getRawData() {
+ return rawData;
+ }
+
+ public HttpMethod getHttpMethod() {
+ return httpMethod;
+ }
+
+ public Integer getHttpCode() {
+ return httpCode;
+ }
+
+ private static String toMessage(HttpMethod httpMethod, String requestedUrl, Throwable cause) {
+ if (StringUtils.isEmpty(requestedUrl)) {
+ return cause.toString();
+ } else {
+ return "" +
+ "Exception while handling " +
+ defaultIfNull(httpMethod, "request").toString() +
+ " " + requestedUrl +
+ ": " + cause.toString();
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/OperationalEnvironment.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/OperationalEnvironment.java
new file mode 100644
index 0000000..a96df31
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/OperationalEnvironment.java
@@ -0,0 +1,126 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.osam.aai.model.RelationshipList;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class OperationalEnvironment {
+
+ private String operationalEnvironmentId;
+ private String operationalEnvironmentName;
+ private String operationalEnvironmentType;
+ private String operationalEnvironmentStatus;
+ private String tenantContext;
+ private String workloadContext;
+ private String resourceVersion;
+ private RelationshipList relationshipList;
+
+ public OperationalEnvironment() {
+ }
+
+ public OperationalEnvironment(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, String operationalEnvironmentStatus, String tenantContext, String workloadContext, String resourceVersion, RelationshipList relationshipList) {
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ this.operationalEnvironmentName = operationalEnvironmentName;
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ this.operationalEnvironmentStatus = operationalEnvironmentStatus;
+ this.tenantContext = tenantContext;
+ this.workloadContext = workloadContext;
+ this.resourceVersion = resourceVersion;
+ this.relationshipList = relationshipList;
+ }
+
+ @JsonProperty("operational-environment-id")
+ public String getOperationalEnvironmentId() {
+ return operationalEnvironmentId;
+ }
+
+ public void setOperationalEnvironmentId(String operationalEnvironmentId) {
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ }
+
+ @JsonProperty("operational-environment-name")
+ public String getOperationalEnvironmentName() {
+ return operationalEnvironmentName;
+ }
+
+ public void setOperationalEnvironmentName(String operationalEnvironmentName) {
+ this.operationalEnvironmentName = operationalEnvironmentName;
+ }
+
+ @JsonProperty("operational-environment-type")
+ public String getOperationalEnvironmentType() {
+ return operationalEnvironmentType;
+ }
+
+ public void setOperationalEnvironmentType(String operationalEnvironmentType) {
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ }
+
+ @JsonProperty("operational-environment-status")
+ public String getOperationalEnvironmentStatus() {
+ return operationalEnvironmentStatus;
+ }
+
+ public void setOperationalEnvironmentStatus(String operationalEnvironmentStatus) {
+ this.operationalEnvironmentStatus = operationalEnvironmentStatus;
+ }
+
+ @JsonProperty("tenant-context")
+ public String getTenantContext() {
+ return tenantContext;
+ }
+
+ public void setTenantContext(String tenantContext) {
+ this.tenantContext = tenantContext;
+ }
+
+ @JsonProperty("workload-context")
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ public void setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+
+ @JsonProperty("resource-version")
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @JsonProperty("relationship-list")
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ public void setRelationshipList(RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/PombaClientImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/PombaClientImpl.java
new file mode 100644
index 0000000..0c51e17
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/PombaClientImpl.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.osam.model.PombaInstance.PombaRequest;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.core.Response;
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class PombaClientImpl implements PombaClientInterface {
+
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+ protected String fromAppId = "VidAaiController";
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AaiClient.class);
+
+ @Autowired
+ ServletContext servletContext;
+
+ @Autowired
+ PombaRestInterface pombaRestInterface;
+
+
+ @Override
+ public void verify(PombaRequest request) {
+ String methodName = "doAaiPost";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ String uri = SystemProperties.getProperty("pomba.server.url");
+
+
+ try {
+ Response response = pombaRestInterface.RestPost(fromAppId, uri, new ObjectMapper().writeValueAsString(request));
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ }
+ }
+
+
+ private File getCertificatesFile() {
+ if (servletContext != null)
+ return new File(servletContext.getRealPath("/WEB-INF/cert/"));
+ return null;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/PombaClientInterface.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/PombaClientInterface.java
new file mode 100644
index 0000000..c5f5fbb
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/PombaClientInterface.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import org.onap.osam.model.PombaInstance.PombaRequest;
+
+public interface PombaClientInterface {
+ void verify(PombaRequest request);
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/PombaRestInterface.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/PombaRestInterface.java
new file mode 100644
index 0000000..c5dd171
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/PombaRestInterface.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.osam.aai.util.*;
+import org.onap.osam.utils.Logging;
+import org.springframework.http.HttpMethod;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.UUID;
+
+import static org.onap.osam.utils.Logging.REQUEST_ID_HEADER_KEY;
+
+public class PombaRestInterface extends AAIRestInterface {
+
+ public PombaRestInterface (HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
+ super(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
+ }
+
+ private Client client = null;
+
+ private void initRestClient()
+ {
+ if (client == null) {
+ try {
+ client = httpsAuthClientFactory.getClient(HttpClientMode.UNSECURE);
+ }
+ catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, "Exception in REST call to DB in initRestClient" + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, "Exception in REST call to DB : " + e.toString());
+ }
+ }
+ }
+
+
+ public Response RestPost(String fromAppId, String url, String payload) {
+ String methodName = "RestPost";
+ String transId = UUID.randomUUID().toString();
+ try {
+ initRestClient();
+
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, payload);
+ final Response cres = client.target(url)
+ .request()
+ .accept(MediaType.APPLICATION_JSON)
+ .header(TRANSACTION_ID_HEADER, transId)
+ .header(FROM_APP_ID_HEADER, fromAppId)
+ .header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId())
+ .post(Entity.entity(payload, MediaType.APPLICATION_JSON));
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.POST, url, cres);
+
+ if (cres.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL)) {
+ logger.info(EELFLoggerDelegate.errorLogger, getValidResponseLogMessage(methodName));
+ logger.debug(EELFLoggerDelegate.debugLogger, getValidResponseLogMessage(methodName));
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger, getInvalidResponseLogMessage(url, methodName, cres));
+ }
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, getFailedResponseLogMessage(url, methodName, e));
+ }
+ return null;
+ }
+
+}
+
+
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/ResponseWithRequestInfo.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/ResponseWithRequestInfo.java
new file mode 100644
index 0000000..27804a3
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/ResponseWithRequestInfo.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import org.springframework.http.HttpMethod;
+
+import javax.ws.rs.core.Response;
+
+public class ResponseWithRequestInfo {
+ private String requestUrl;
+ private HttpMethod requestHttpMethod;
+ private Response response;
+
+ public ResponseWithRequestInfo(Response response, String requestUrl, HttpMethod requestHttpMethod) {
+ this.response = response;
+ this.requestUrl = requestUrl;
+ this.requestHttpMethod = requestHttpMethod;
+ }
+
+ public String getRequestUrl() {
+ return requestUrl;
+ }
+
+ public HttpMethod getRequestHttpMethod() {
+ return requestHttpMethod;
+ }
+
+ public Response getResponse() {
+ return response;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceInstance.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceInstance.java
new file mode 100644
index 0000000..0610969
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceInstance.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceInstance {
+
+ @JsonProperty("service-instance-id")
+ public String serviceInstanceId;
+
+ @JsonProperty("service-instance-name")
+ public String serviceInstanceName;
+
+ @JsonProperty("persona-model-id")
+ public String personaModelId;
+
+ @JsonProperty("persona-model-version")
+ public String personaModelVersion;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("orchestration-status")
+ public String orchestrationStatus;
+
+ @JsonProperty("model-invariant-id")
+ public String modelInvariantId;
+
+ @JsonProperty("model-version-id")
+ public String modelVersionId;
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceInstances.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceInstances.java
new file mode 100644
index 0000000..1e51e4b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceInstances.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceInstances {
+
+ @JsonProperty("service-instance")
+ public List<ServiceInstance> serviceInstance;
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceInstancesSearchResults.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceInstancesSearchResults.java
new file mode 100644
index 0000000..6fd8859
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceInstancesSearchResults.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.osam.model.ServiceInstanceSearchResult;
+
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceInstancesSearchResults {
+ @JsonProperty("service-instances")
+ public List<ServiceInstanceSearchResult> serviceInstances;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceSubscription.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceSubscription.java
new file mode 100644
index 0000000..6234b99
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceSubscription.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceSubscription {
+
+ @JsonProperty("service-type")
+ public String serviceType;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("service-instances")
+ public ServiceInstances serviceInstances;
+
+ @JsonProperty("is-permitted")
+ public boolean isPermitted =false;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceSubscriptions.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceSubscriptions.java
new file mode 100644
index 0000000..ed20dc0
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/ServiceSubscriptions.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+
+public class ServiceSubscriptions {
+
+ @JsonProperty("service-subscription")
+ public List<ServiceSubscription> serviceSubscription;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/Services.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/Services.java
new file mode 100644
index 0000000..eb268ab
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/Services.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Services {
+ @JsonProperty("global-customer-id")
+ public String globalCustomerId;
+
+ @JsonProperty("subscriber-name")
+ public String subscriberName;
+
+ @JsonProperty("subscriber-type")
+ public String subscriberType;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("service-subscriptions")
+ public ServiceSubscriptions serviceSubscriptions;
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberAaiResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberAaiResponse.java
new file mode 100644
index 0000000..5c0104b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberAaiResponse.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import org.onap.osam.model.ProxyResponse;
+import org.onap.osam.model.SubscriberList;
+
+public class SubscriberAaiResponse extends ProxyResponse {
+
+
+ private SubscriberList subscriberList;
+
+ public SubscriberAaiResponse(SubscriberList subscriberList, String errorMessage, int aaiHttpCode) {
+ this.subscriberList = subscriberList;
+ this.errorMessage = errorMessage;
+ this.httpCode = aaiHttpCode;
+ }
+
+
+ public SubscriberList getSubscriberList() {
+ return subscriberList;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberData.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberData.java
new file mode 100644
index 0000000..cb3132b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberData.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+public class SubscriberData {
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberFilteredResults.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberFilteredResults.java
new file mode 100644
index 0000000..20f1201
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberFilteredResults.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import org.onap.osam.model.ProxyResponse;
+import org.onap.osam.model.SubscriberList;
+import org.onap.osam.roles.RoleValidator;
+
+
+public class SubscriberFilteredResults extends ProxyResponse {
+
+ private SubscriberListWithFilterData subscriberList;
+
+ public SubscriberFilteredResults(RoleValidator roleValidator,SubscriberList subscribers, String errorMessage, int aaiHttpCode) {
+ this.subscriberList = new SubscriberListWithFilterData(subscribers,roleValidator);
+ this.errorMessage = errorMessage;
+ this.httpCode = aaiHttpCode;
+ }
+
+
+ public SubscriberListWithFilterData getSubscriberList() {
+ return subscriberList;
+ }
+
+ public void setSubscriberList(SubscriberListWithFilterData subscriberList) {
+ this.subscriberList = subscriberList;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberListWithFilterData.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberListWithFilterData.java
new file mode 100644
index 0000000..3784256
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberListWithFilterData.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import org.onap.osam.model.Subscriber;
+import org.onap.osam.model.SubscriberList;
+import org.onap.osam.roles.RoleValidator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SubscriberListWithFilterData {
+
+ public SubscriberListWithFilterData(SubscriberList subscriberList, RoleValidator roleValidator){
+ List<Subscriber> subscribers = subscriberList != null ? subscriberList.customer : new ArrayList<>();
+ List<SubscriberWithFilter> subscribersWithFilter = new ArrayList<>();
+ for (Subscriber subscriber :subscribers){
+ SubscriberWithFilter subscriberWithFilter = new SubscriberWithFilter();
+ subscriberWithFilter.setIsPermitted(roleValidator.isSubscriberPermitted(subscriber.globalCustomerId));
+ subscriberWithFilter.subscriberType = subscriber.subscriberType;
+ subscriberWithFilter.resourceVersion = subscriber.resourceVersion;
+ subscriberWithFilter.subscriberName = subscriber.subscriberName;
+ subscriberWithFilter.globalCustomerId = subscriber.globalCustomerId;
+ subscribersWithFilter.add(subscriberWithFilter);
+ }
+ this.customer = subscribersWithFilter;
+ }
+
+ public List<SubscriberWithFilter> customer;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberWithFilter.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberWithFilter.java
new file mode 100644
index 0000000..c71b0d3
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/SubscriberWithFilter.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.osam.model.Subscriber;
+
+public class SubscriberWithFilter extends Subscriber{
+
+ @JsonProperty("is-permitted")
+ private boolean isPermitted;
+
+ public boolean getIsPermitted() {
+ return isPermitted;
+ }
+
+ public void setIsPermitted(boolean isPermitted) {
+ this.isPermitted = isPermitted;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/exceptions/HttpClientBuilderException.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/exceptions/HttpClientBuilderException.java
new file mode 100644
index 0000000..dab5a34
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/exceptions/HttpClientBuilderException.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.exceptions;
+
+public class HttpClientBuilderException extends RuntimeException {
+
+ public HttpClientBuilderException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/exceptions/InvalidAAIResponseException.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/exceptions/InvalidAAIResponseException.java
new file mode 100644
index 0000000..c033d9c
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/exceptions/InvalidAAIResponseException.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.exceptions;
+
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.exceptions.GenericUncheckedException;
+
+public class InvalidAAIResponseException extends GenericUncheckedException {
+ public InvalidAAIResponseException(AaiResponse aaiResponse) {
+ super(String.format("errorCode: %d, raw: %s", aaiResponse.getHttpCode(), aaiResponse.getErrorMessage()));
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/exceptions/InvalidPropertyException.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/exceptions/InvalidPropertyException.java
new file mode 100644
index 0000000..0d3e5b1
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/exceptions/InvalidPropertyException.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.exceptions;
+
+public class InvalidPropertyException extends Exception {
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/exceptions/RoleParsingException.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/exceptions/RoleParsingException.java
new file mode 100644
index 0000000..5ab442b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/exceptions/RoleParsingException.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.exceptions;
+
+public class RoleParsingException extends Exception {
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetAicZone/AicZones.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetAicZone/AicZones.java
new file mode 100644
index 0000000..34a16fc
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetAicZone/AicZones.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetAicZone;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+public class AicZones {
+ @JsonProperty("zone")
+ public List<Zone> zones;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetAicZone/Zone.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetAicZone/Zone.java
new file mode 100644
index 0000000..e3bdc69
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetAicZone/Zone.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetAicZone;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Zone {
+ @JsonProperty("zone-id")
+ public String zoneId;
+
+ @JsonProperty("zone-name")
+ public String zoneName;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetInstanceGroupsByCloudRegion.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetInstanceGroupsByCloudRegion.java
new file mode 100644
index 0000000..a576ae2
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetInstanceGroupsByCloudRegion.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class AaiGetInstanceGroupsByCloudRegion {
+
+ private final List<InstanceGroupWrapper> results;
+
+ public AaiGetInstanceGroupsByCloudRegion(@JsonProperty("results") List<InstanceGroupWrapper> results) {
+ this.results = results;
+ }
+
+ public List<InstanceGroupWrapper> getResults() {
+ return results;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/AaiGetNetworkCollectionDetails.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/AaiGetNetworkCollectionDetails.java
new file mode 100644
index 0000000..290cc0e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/AaiGetNetworkCollectionDetails.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetNetworkCollectionDetails;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class AaiGetNetworkCollectionDetails {
+
+ public AaiGetNetworkCollectionDetails(){
+ results = new Result();
+ }
+ @JsonProperty("results")
+ private Result results = null;
+
+ @JsonProperty("results")
+ public Result getResults() {
+ return results;
+ }
+
+ @JsonProperty("results")
+ public void setResults(Result results) {
+ this.results = results;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/AaiGetNetworkCollectionDetailsHelper.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/AaiGetNetworkCollectionDetailsHelper.java
new file mode 100644
index 0000000..daade03
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/AaiGetNetworkCollectionDetailsHelper.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetNetworkCollectionDetails;
+
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class AaiGetNetworkCollectionDetailsHelper {
+ @JsonProperty("results")
+ private List<Object> results = null;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<>();
+
+ @JsonProperty("results")
+ public List<Object> getResults() {
+ return results;
+ }
+
+ @JsonProperty("results")
+ public void setResults(List<Object> results) {
+ this.results = results;
+ }
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/AaiGetRelatedInstanceGroupsByVnfId.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/AaiGetRelatedInstanceGroupsByVnfId.java
new file mode 100644
index 0000000..a1c7b44
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/AaiGetRelatedInstanceGroupsByVnfId.java
@@ -0,0 +1,203 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetNetworkCollectionDetails;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class AaiGetRelatedInstanceGroupsByVnfId {
+
+ @JsonProperty("vnf-id")
+ private String vnfId;
+ @JsonProperty("vnf-name")
+ private String vnfName;
+ @JsonProperty("vnf-type")
+ private String vnfType;
+ @JsonProperty("prov-status")
+ private String provStatus;
+ @JsonProperty("operational-status")
+ private String operationalStatus;
+ @JsonProperty("equipment-role")
+ private String equipmentRole;
+ @JsonProperty("in-maint")
+ private Boolean inMaint;
+ @JsonProperty("is-closed-loop-disabled")
+ private Boolean isClosedLoopDisabled;
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+ @JsonProperty("model-invariant-id")
+ private String modelInvariantId;
+ @JsonProperty("model-version-id")
+ private String modelVersionId;
+ @JsonProperty("model-customization-id")
+ private String modelCustomizationId;
+ @JsonProperty("selflink")
+ private String selflink;
+ @JsonProperty("relationship-list")
+ private RelationshipList relationshipList;
+
+
+ @JsonProperty("vnf-id")
+ public String getVnfId() {
+ return vnfId;
+ }
+
+ @JsonProperty("vnf-id")
+ public void setVnfId(String vnfId) {
+ this.vnfId = vnfId;
+ }
+
+ @JsonProperty("vnf-name")
+ public String getVnfName() {
+ return vnfName;
+ }
+
+ @JsonProperty("vnf-name")
+ public void setVnfName(String vnfName) {
+ this.vnfName = vnfName;
+ }
+
+ @JsonProperty("vnf-type")
+ public String getVnfType() {
+ return vnfType;
+ }
+
+ @JsonProperty("vnf-type")
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+
+ @JsonProperty("prov-status")
+ public String getProvStatus() {
+ return provStatus;
+ }
+
+ @JsonProperty("prov-status")
+ public void setProvStatus(String provStatus) {
+ this.provStatus = provStatus;
+ }
+
+ @JsonProperty("operational-status")
+ public String getOperationalStatus() {
+ return operationalStatus;
+ }
+
+ @JsonProperty("operational-status")
+ public void setOperationalStatus(String operationalStatus) {
+ this.operationalStatus = operationalStatus;
+ }
+
+ @JsonProperty("equipment-role")
+ public String getEquipmentRole() {
+ return equipmentRole;
+ }
+
+ @JsonProperty("equipment-role")
+ public void setEquipmentRole(String equipmentRole) {
+ this.equipmentRole = equipmentRole;
+ }
+
+ @JsonProperty("in-maint")
+ public Boolean getInMaint() {
+ return inMaint;
+ }
+
+ @JsonProperty("in-maint")
+ public void setInMaint(Boolean inMaint) {
+ this.inMaint = inMaint;
+ }
+
+ @JsonProperty("is-closed-loop-disabled")
+ public Boolean getIsClosedLoopDisabled() {
+ return isClosedLoopDisabled;
+ }
+
+ @JsonProperty("is-closed-loop-disabled")
+ public void setIsClosedLoopDisabled(Boolean isClosedLoopDisabled) {
+ this.isClosedLoopDisabled = isClosedLoopDisabled;
+ }
+
+ @JsonProperty("resource-version")
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ @JsonProperty("resource-version")
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @JsonProperty("model-invariant-id")
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ @JsonProperty("model-invariant-id")
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ @JsonProperty("model-version-id")
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ @JsonProperty("model-version-id")
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ @JsonProperty("model-customization-id")
+ public String getModelCustomizationId() {
+ return modelCustomizationId;
+ }
+
+ @JsonProperty("model-customization-id")
+ public void setModelCustomizationId(String modelCustomizationId) {
+ this.modelCustomizationId = modelCustomizationId;
+ }
+
+ @JsonProperty("selflink")
+ public String getSelflink() {
+ return selflink;
+ }
+
+ @JsonProperty("selflink")
+ public void setSelflink(String selflink) {
+ this.selflink = selflink;
+ }
+
+ @JsonProperty("relationship-list")
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ @JsonProperty("relationship-list")
+ public void setRelationshipList(RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/Collection.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/Collection.java
new file mode 100644
index 0000000..1d392f5
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/Collection.java
@@ -0,0 +1,152 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetNetworkCollectionDetails;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Collection {
+ @JsonProperty("collection-id")
+ private String collectionId;
+ @JsonProperty("model-invariant-id")
+ private String modelInvariantId;
+ @JsonProperty("model-version-id")
+ private String modelVersionId;
+ @JsonProperty("collection-name")
+ private String collectionName;
+ @JsonProperty("collection-type")
+ private String collectionType;
+ @JsonProperty("collection-role")
+ private String collectionRole;
+ @JsonProperty("collection-function")
+ private String collectionFunction;
+ @JsonProperty("collection-customization-id")
+ private String collectionCustomizationId;
+ @JsonProperty("relationship-list")
+ private RelationshipList relationshipList;
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+
+ @JsonProperty("collection-id")
+ public String getCollectionId() {
+ return collectionId;
+ }
+
+ @JsonProperty("collection-id")
+ public void setCollectionId(String collectionId) {
+ this.collectionId = collectionId;
+ }
+
+ @JsonProperty("model-invariant-id")
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ @JsonProperty("model-invariant-id")
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ @JsonProperty("model-version-id")
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ @JsonProperty("model-version-id")
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ @JsonProperty("collection-name")
+ public String getCollectionName() {
+ return collectionName;
+ }
+
+ @JsonProperty("collection-name")
+ public void setCollectionName(String collectionName) {
+ this.collectionName = collectionName;
+ }
+
+ @JsonProperty("collection-type")
+ public String getCollectionType() {
+ return collectionType;
+ }
+
+ @JsonProperty("collection-type")
+ public void setCollectionType(String collectionType) {
+ this.collectionType = collectionType;
+ }
+
+ @JsonProperty("collection-role")
+ public String getCollectionRole() {
+ return collectionRole;
+ }
+
+ @JsonProperty("collection-role")
+ public void setCollectionRole(String collectionRole) {
+ this.collectionRole = collectionRole;
+ }
+
+ @JsonProperty("collection-function")
+ public String getCollectionFunction() {
+ return collectionFunction;
+ }
+
+ @JsonProperty("collection-function")
+ public void setCollectionFunction(String collectionFunction) {
+ this.collectionFunction = collectionFunction;
+ }
+
+ @JsonProperty("collection-customization-id")
+ public String getCollectionCustomizationId() {
+ return collectionCustomizationId;
+ }
+
+ @JsonProperty("collection-customization-id")
+ public void setCollectionCustomizationId(String collectionCustomizationId) {
+ this.collectionCustomizationId = collectionCustomizationId;
+ }
+
+ @JsonProperty("relationship-list")
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ @JsonProperty("relationship-list")
+ public void setRelationshipList(RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ }
+
+ @JsonProperty("resource-version")
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ @JsonProperty("resource-version")
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/InstanceGroup.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/InstanceGroup.java
new file mode 100644
index 0000000..3bc6742
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/InstanceGroup.java
@@ -0,0 +1,127 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetNetworkCollectionDetails;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class InstanceGroup {
+ @JsonProperty("instance-group-role")
+ private String instanceGroupRole;
+ @JsonProperty("model-invariant-id")
+ private String modelInvariantId;
+ @JsonProperty("model-version-id")
+ private String modelVersionId;
+ private String id;
+ private String description;
+ @JsonProperty("instance-group-type")
+ private String instanceGroupType;
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+ @JsonProperty("instance-group-name")
+ private String instanceGroupName;
+ @JsonProperty("instance-group-function")
+ private String instanceGroupFunction;
+ @JsonProperty("relationship-list")
+ private RelationshipList relationshipList;
+
+ public InstanceGroup(){
+ super();
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public InstanceGroup(
+ @JsonProperty("instance-group-role")
+ String instanceGroupRole,
+ @JsonProperty("model-invariant-id")
+ String modelInvariantId,
+ @JsonProperty("model-version-id")
+ String modelVersionId,
+ @JsonProperty(value = "id", required = true)
+ String id,
+ @JsonProperty(value = "description", required = true)
+ String description,
+ @JsonProperty(value = "instance-group-type", required = true)
+ String instanceGroupType,
+ @JsonProperty("resource-version")
+ String resourceVersion,
+ @JsonProperty("instance-group-name")
+ String instanceGroupName,
+ @JsonProperty("instance-group-function")
+ String instanceGroupFunction,
+ @JsonProperty("relationship-list")
+ RelationshipList relationshipList) {
+ this.instanceGroupRole = instanceGroupRole;
+ this.modelInvariantId = modelInvariantId;
+ this.modelVersionId = modelVersionId;
+ this.id = id;
+ this.description = description;
+ this.instanceGroupType = instanceGroupType;
+ this.resourceVersion = resourceVersion;
+ this.instanceGroupName = instanceGroupName;
+ this.instanceGroupFunction = instanceGroupFunction;
+ this.relationshipList = relationshipList;
+ }
+
+ public String getInstanceGroupRole() {
+ return instanceGroupRole;
+ }
+
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getInstanceGroupType() {
+ return instanceGroupType;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public String getInstanceGroupName() {
+ return instanceGroupName;
+ }
+
+ public String getInstanceGroupFunction() {
+ return instanceGroupFunction;
+ }
+
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/Network.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/Network.java
new file mode 100644
index 0000000..6527438
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/Network.java
@@ -0,0 +1,164 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetNetworkCollectionDetails;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Network {
+ @JsonProperty("network-id")
+ private String networkId;
+ @JsonProperty("network-name")
+ private String networkName;
+ @JsonProperty("network-type")
+ private String networkType;
+ @JsonProperty("network-role")
+ private String networkRole;
+ @JsonProperty("network-technology")
+ private String networkTechnology;
+ @JsonProperty("is-bound-to-vpn")
+ private Boolean isBoundToVpn;
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+ @JsonProperty("is-provider-network")
+ private Boolean isProviderNetwork;
+ @JsonProperty("is-shared-network")
+ private Boolean isSharedNetwork;
+ @JsonProperty("is-external-network")
+ private Boolean isExternalNetwork;
+ @JsonProperty("relationship-list")
+ private RelationshipList relationshipList;
+
+
+ @JsonProperty("network-id")
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ @JsonProperty("network-id")
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ @JsonProperty("network-name")
+ public String getNetworkName() {
+ return networkName;
+ }
+
+ @JsonProperty("network-name")
+ public void setNetworkName(String networkName) {
+ this.networkName = networkName;
+ }
+
+ @JsonProperty("network-type")
+ public String getNetworkType() {
+ return networkType;
+ }
+
+ @JsonProperty("network-type")
+ public void setNetworkType(String networkType) {
+ this.networkType = networkType;
+ }
+
+ @JsonProperty("network-role")
+ public String getNetworkRole() {
+ return networkRole;
+ }
+
+ @JsonProperty("network-role")
+ public void setNetworkRole(String networkRole) {
+ this.networkRole = networkRole;
+ }
+
+ @JsonProperty("network-technology")
+ public String getNetworkTechnology() {
+ return networkTechnology;
+ }
+
+ @JsonProperty("network-technology")
+ public void setNetworkTechnology(String networkTechnology) {
+ this.networkTechnology = networkTechnology;
+ }
+
+ @JsonProperty("is-bound-to-vpn")
+ public Boolean getIsBoundToVpn() {
+ return isBoundToVpn;
+ }
+
+ @JsonProperty("is-bound-to-vpn")
+ public void setIsBoundToVpn(Boolean isBoundToVpn) {
+ this.isBoundToVpn = isBoundToVpn;
+ }
+
+ @JsonProperty("resource-version")
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ @JsonProperty("resource-version")
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @JsonProperty("is-provider-network")
+ public Boolean getIsProviderNetwork() {
+ return isProviderNetwork;
+ }
+
+ @JsonProperty("is-provider-network")
+ public void setIsProviderNetwork(Boolean isProviderNetwork) {
+ this.isProviderNetwork = isProviderNetwork;
+ }
+
+ @JsonProperty("is-shared-network")
+ public Boolean getIsSharedNetwork() {
+ return isSharedNetwork;
+ }
+
+ @JsonProperty("is-shared-network")
+ public void setIsSharedNetwork(Boolean isSharedNetwork) {
+ this.isSharedNetwork = isSharedNetwork;
+ }
+
+ @JsonProperty("is-external-network")
+ public Boolean getIsExternalNetwork() {
+ return isExternalNetwork;
+ }
+
+ @JsonProperty("is-external-network")
+ public void setIsExternalNetwork(Boolean isExternalNetwork) {
+ this.isExternalNetwork = isExternalNetwork;
+ }
+
+ @JsonProperty("relationship-list")
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ @JsonProperty("relationship-list")
+ public void setRelationshipList(RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/RelatedToProperty.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/RelatedToProperty.java
new file mode 100644
index 0000000..d201559
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/RelatedToProperty.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetNetworkCollectionDetails;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class RelatedToProperty {
+
+ public String getPropertyKey() {
+ return propertyKey;
+ }
+
+
+ public void setPropertyKey(String propertyKey) {
+ this.propertyKey = propertyKey;
+ }
+
+
+ public String getPropertyValue() {
+ return propertyValue;
+ }
+
+
+ public void setPropertyValue(String propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+
+
+ @JsonProperty("property-key")
+ public String propertyKey;
+
+
+ @JsonProperty("property-value")
+ public String propertyValue;
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/Relationship.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/Relationship.java
new file mode 100644
index 0000000..fb3497c
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/Relationship.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetNetworkCollectionDetails;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Relationship {
+
+ @JsonProperty("related-to")
+ public String relatedTo;
+
+ @JsonProperty("related-link")
+ public String relatedLink;
+
+ @JsonProperty("relationship-label")
+ public String relationshipLabel;
+
+ @JsonProperty("relationship-data")
+ public List<RelationshipData> relationshipData;
+
+ @JsonProperty("related-to-property")
+ public List<RelatedToProperty> relatedToProperty;
+
+
+ public String getRelatedTo() {
+ return relatedTo;
+ }
+
+ public void setRelatedTo(String relatedTo) {
+ this.relatedTo = relatedTo;
+ }
+
+ public String getRelatedLink() {
+ return relatedLink;
+ }
+
+ public void setRelatedLink(String relatedLink) {
+ this.relatedLink = relatedLink;
+ }
+
+ public List<RelationshipData> getRelationDataList() {
+ return relationshipData;
+ }
+
+ public void setRelationDataList(List<RelationshipData> relationDataList) {
+ this.relationshipData = relationDataList;
+ }
+
+ public List<RelatedToProperty> getRelatedToPropertyList() {
+ return relatedToProperty;
+ }
+
+ public void setRelatedToPropertyList(List<RelatedToProperty> relatedToPropertyList) {
+ this.relatedToProperty = relatedToPropertyList;
+ }
+
+ public String getRelationshipLabel() {
+ return relationshipLabel;
+ }
+
+ public void setRelationshipLabel(String relationshipLabel) {
+ this.relationshipLabel = relationshipLabel;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/RelationshipData.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/RelationshipData.java
new file mode 100644
index 0000000..15a5aef
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/RelationshipData.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetNetworkCollectionDetails;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class RelationshipData {
+ @JsonProperty("relationship-key")
+ public String getRelationshipKey() {
+ return relationshipKey;
+ }
+ @JsonProperty("relationship-key")
+ public void setRelationshipKey(String relationshipKey) {
+ this.relationshipKey = relationshipKey;
+ }
+ @JsonProperty("relationship-value")
+ public String getRelationshipValue() {
+ return relationshipValue;
+ }
+ @JsonProperty("relationship-value")
+ public void setRelationshipValue(String relationshipValue) {
+ this.relationshipValue = relationshipValue;
+ }
+
+ public String relationshipKey;
+
+ public String relationshipValue;
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/RelationshipList.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/RelationshipList.java
new file mode 100644
index 0000000..16521df
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/RelationshipList.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetNetworkCollectionDetails;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class RelationshipList {
+
+ @JsonProperty("relationship")
+ public List<Relationship> getRelationship() {
+ return relationship;
+ }
+
+ @JsonProperty("relationship")
+ public void setRelationship(List<Relationship> relationship) {
+ this.relationship = relationship;
+ }
+
+ public List<Relationship> relationship;
+
+
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/Result.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/Result.java
new file mode 100644
index 0000000..d5f6bc7
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/Result.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetNetworkCollectionDetails;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Result {
+
+ @JsonProperty("service-instance")
+ private ServiceInstance serviceInstance;
+ @JsonProperty("collection")
+ private Collection collection;
+ @JsonProperty("instance-group")
+ private InstanceGroup instanceGroup;
+ @JsonProperty("networks")
+ private List<Network> networks;
+
+ public Result(){
+ this.networks = new ArrayList<>();
+ }
+
+
+ @JsonProperty("service-instance")
+ public ServiceInstance getServiceInstance() {
+ return serviceInstance;
+ }
+
+ @JsonProperty("service-instance")
+ public void setServiceInstance(ServiceInstance serviceInstance) {
+ this.serviceInstance = serviceInstance;
+ }
+
+ @JsonProperty("collection")
+ public Collection getCollection() {
+ return collection;
+ }
+
+ @JsonProperty("collection")
+ public void setCollection(Collection collection) {
+ this.collection = collection;
+ }
+
+ @JsonProperty("instance-group")
+ public InstanceGroup getInstanceGroup() {
+ return instanceGroup;
+ }
+
+ @JsonProperty("instance-group")
+ public void setInstanceGroup(InstanceGroup instanceGroup) {
+ this.instanceGroup = instanceGroup;
+ }
+
+ @JsonProperty("networks")
+ public List<Network> getNetworks() { return networks; }
+
+ @JsonProperty("networks")
+ public void setNetworks(List<Network> networks) { this.networks = networks; }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/ServiceInstance.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/ServiceInstance.java
new file mode 100644
index 0000000..efc038f
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetNetworkCollectionDetails/ServiceInstance.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetNetworkCollectionDetails;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceInstance {
+
+ @JsonProperty("service-instance-id")
+ public String serviceInstanceId;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("relationship-list")
+ public RelationshipList relationshipList;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentList.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentList.java
new file mode 100644
index 0000000..a6416ae
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentList.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetOperationalEnvironments;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.osam.aai.OperationalEnvironment;
+
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class OperationalEnvironmentList {
+
+ @JsonProperty("operational-environment")
+ public List<OperationalEnvironment> getOperationalEnvironment() {
+ return operationalEnvironment;
+ }
+
+ @JsonProperty("operational-environment")
+ public void setOperationalEnvironment(List<OperationalEnvironment> operationalEnvironment) {
+ this.operationalEnvironment = operationalEnvironment;
+ }
+
+ public OperationalEnvironmentList() {
+ }
+
+ public OperationalEnvironmentList(List<OperationalEnvironment> operationalEnvironment) {
+ this.operationalEnvironment = operationalEnvironment;
+ }
+
+ private List<OperationalEnvironment> operationalEnvironment;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetPnfResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetPnfResponse.java
new file mode 100644
index 0000000..f60f3ad
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetPnfResponse.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.google.common.base.MoreObjects;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "results"
+})
+public class AaiGetPnfResponse {
+ @JsonProperty("results")
+ public List<PnfResult> results = null;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<>();
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("results", results)
+ .add("additionalProperties", additionalProperties)
+ .toString();
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetPnfs/Pnf.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetPnfs/Pnf.java
new file mode 100644
index 0000000..517111a
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetPnfs/Pnf.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetPnfs;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.osam.aai.model.AaiRelationResponse;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Pnf extends AaiRelationResponse {
+
+ @JsonProperty("pnf-name")
+ public String pnfName;
+ @JsonProperty("pnf-name2")
+ public String pnfName2;
+ @JsonProperty("pnf-name2-source")
+ public String pnfName2Source;
+ @JsonProperty("pnf-id")
+ public String pnfId;
+ @JsonProperty("equip-type")
+ public String equipType;
+ @JsonProperty("equip-vendor")
+ public String equipVendor;
+ @JsonProperty("equip-model")
+ public String equipModel;
+
+ public String getPnfName() {
+ return pnfName;
+ }
+
+ public void setPnfName(String pnfName) {
+ this.pnfName = pnfName;
+ }
+
+ public String getEquipType() {
+ return equipType;
+ }
+
+ public void setEquipType(String equipType) {
+ this.equipType = equipType;
+ }
+
+ public String getEquipVendor() {
+ return equipVendor;
+ }
+
+ public void setEquipVendor(String equipVendor) {
+ this.equipVendor = equipVendor;
+ }
+
+ public String getPnfName2() {
+ return pnfName2;
+ }
+
+ public void setPnfName2(String pnfName2) {
+ this.pnfName2 = pnfName2;
+ }
+
+ public String getPnfId() {
+ return pnfId;
+ }
+
+ public void setPnfId(String pnfId) {
+ this.pnfId = pnfId;
+ }
+
+ public String getEquipModel() {
+ return equipModel;
+ }
+
+ public void setEquipModel(String equipModel) {
+ this.equipModel = equipModel;
+ }
+
+ public String getPnfName2Source() { return pnfName2Source; }
+
+ public void setPnfName2Source(String pnfName2Source) { this.pnfName2Source = pnfName2Source; }
+}
+
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetPortMirroringSourcePorts.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetPortMirroringSourcePorts.java
new file mode 100644
index 0000000..2ce6dca
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetPortMirroringSourcePorts.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+public class AaiGetPortMirroringSourcePorts {
+
+ private final List<SimpleResult> results;
+
+ public AaiGetPortMirroringSourcePorts(@JsonProperty("results") List<SimpleResult> results) {
+ this.results = results;
+ }
+
+ public List<SimpleResult> getResults() {
+ return results;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java
new file mode 100644
index 0000000..a79ba9e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetServicesRequestModel;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import java.util.List;
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class GetServicesAAIRespone {
+
+ public List<Service> service;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetServicesRequestModel/Service.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetServicesRequestModel/Service.java
new file mode 100644
index 0000000..db4daeb
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetServicesRequestModel/Service.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetServicesRequestModel;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Service {
+ @JsonProperty("service-id")
+ public String serviceId;
+ @JsonProperty("service-description")
+ public String serviceDescription;
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+ @JsonProperty("is-permitted")
+ public boolean isPermitted;
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetTenatns/GetTenantsResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetTenatns/GetTenantsResponse.java
new file mode 100644
index 0000000..5caa193
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiGetTenatns/GetTenantsResponse.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetTenatns;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class GetTenantsResponse {
+
+ @JsonProperty("cloudRegionID")
+ public String cloudRegionId;
+
+ @JsonProperty("cloudOwner")
+ public String cloudOwner;
+
+ @JsonProperty("tenantName")
+ public String tenantName;
+
+ @JsonProperty("tenantID")
+ public String tenantID;
+
+ @JsonProperty("is-permitted")
+ public boolean isPermitted;
+
+ public GetTenantsResponse() {
+ }
+
+ public GetTenantsResponse(String cloudRegionId, String cloudOwner, String tenantName, String tenantID, boolean isPermitted) {
+ this.cloudRegionId = cloudRegionId;
+ this.cloudOwner = cloudOwner;
+ this.tenantName = tenantName;
+ this.tenantID = tenantID;
+ this.isPermitted = isPermitted;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiNodeQueryResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiNodeQueryResponse.java
new file mode 100644
index 0000000..6e02979
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiNodeQueryResponse.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+public class AaiNodeQueryResponse {
+
+ public static class ResultData {
+
+ public final ResourceType resourceType;
+ public final String resourceLink;
+
+ public ResultData(@JsonProperty("resource-type") ResourceType resourceType,
+ @JsonProperty("resource-link") String resourceLink) {
+ this.resourceType = resourceType;
+ this.resourceLink = resourceLink;
+ }
+ }
+
+ public final List<ResultData> resultData;
+
+ public AaiNodeQueryResponse(@JsonProperty("result-data") List<ResultData> resultData) {
+ this.resultData = resultData;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiRelationResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiRelationResponse.java
new file mode 100644
index 0000000..5ead2f8
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/AaiRelationResponse.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class AaiRelationResponse {
+
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+ @JsonProperty("relationship-list")
+ private RelationshipList relationshipList;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+
+ @JsonProperty("resource-version")
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ @JsonProperty("resource-version")
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @JsonProperty("relationship-list")
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ @JsonProperty("relationship-list")
+ public void setRelationshipList(RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/GetServiceModelsByDistributionStatusResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/GetServiceModelsByDistributionStatusResponse.java
new file mode 100644
index 0000000..028739a
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/GetServiceModelsByDistributionStatusResponse.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class GetServiceModelsByDistributionStatusResponse {
+ @JsonProperty("results")
+ private List<Result> results;
+
+
+ @JsonProperty("results")
+ public List<Result> getResults() {
+ return results;
+ }
+
+ @JsonProperty("results")
+ public void setResults(List<Result> results) {
+ this.results = results;
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/InstanceGroupInfo.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/InstanceGroupInfo.java
new file mode 100644
index 0000000..98600b8
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/InstanceGroupInfo.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+public class InstanceGroupInfo {
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ private String type;
+ private String name;
+
+ public InstanceGroupInfo(String name){
+ this.name = name;
+ this.type = "instance-group";
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/InstanceGroupWrapper.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/InstanceGroupWrapper.java
new file mode 100644
index 0000000..d4076d7
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/InstanceGroupWrapper.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.InstanceGroup;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class InstanceGroupWrapper {
+
+ private InstanceGroup instanceGroup;
+
+ @JsonProperty("instance-group")
+ public InstanceGroup getInstanceGroup() {
+ return instanceGroup;
+ }
+ @JsonProperty("instance-group")
+ public void setInstanceGroup(InstanceGroup instanceGroup) {
+ this.instanceGroup = instanceGroup;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/LogicalLinkResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/LogicalLinkResponse.java
new file mode 100644
index 0000000..e380978
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/LogicalLinkResponse.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class LogicalLinkResponse {
+
+ @JsonProperty("link-name")
+ public String linkName;
+
+ @JsonProperty("in-maint")
+ public Boolean inMaint;
+
+ @JsonProperty("link-type")
+ public String linkType;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("purpose")
+ public String purpose;
+
+ @JsonProperty("relationship-list")
+ public RelationshipList relationshipList;
+
+ public String getLinkName() {
+ return linkName;
+ }
+
+ public void setLinkName(String linkName) {
+ this.linkName = linkName;
+ }
+
+ public Boolean getInMaint() {
+ return inMaint;
+ }
+
+ public void setInMaint(Boolean inMaint) {
+ this.inMaint = inMaint;
+ }
+
+ public String getLinkType() {
+ return linkType;
+ }
+
+ public void setLinkType(String linkType) {
+ this.linkType = linkType;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public String getPurpose() {
+ return purpose;
+ }
+
+ public void setPurpose(String purpose) {
+ this.purpose = purpose;
+ }
+
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ public void setRelationshipList(RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Model.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Model.java
new file mode 100644
index 0000000..03c6906
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Model.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Model {
+
+ @JsonProperty("model-invariant-id")
+ private String modelInvariantId;
+ @JsonProperty("model-type")
+ private String modelType;
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+ @JsonProperty("model-vers")
+ private ModelVers modelVers;
+
+ @JsonProperty("model-invariant-id")
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ @JsonProperty("model-invariant-id")
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ @JsonProperty("model-type")
+ public String getModelType() {
+ return modelType;
+ }
+
+ @JsonProperty("model-type")
+ public void setModelType(String modelType) {
+ this.modelType = modelType;
+ }
+
+ @JsonProperty("resource-version")
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ @JsonProperty("resource-version")
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @JsonProperty("model-vers")
+ public ModelVers getModelVers() {
+ return modelVers;
+ }
+
+ @JsonProperty("model-vers")
+ public void setModelVers(ModelVers modelVers) {
+ this.modelVers = modelVers;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ModelVer.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ModelVer.java
new file mode 100644
index 0000000..925a875
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ModelVer.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ModelVer {
+
+ @JsonProperty("model-version-id")
+ private String modelVersionId;
+ @JsonProperty("model-name")
+ private String modelName;
+ @JsonProperty("model-version")
+ private String modelVersion;
+ @JsonProperty("distribution-status")
+ private String distributionStatus;
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+ @JsonProperty("model-description")
+ private String modelDescription;
+
+
+
+ @JsonProperty("model-version-id")
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ @JsonProperty("model-version-id")
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ @JsonProperty("model-name")
+ public String getModelName() {
+ return modelName;
+ }
+
+ @JsonProperty("model-name")
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ @JsonProperty("model-version")
+ public String getModelVersion() {
+ return modelVersion;
+ }
+
+ @JsonProperty("model-version")
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ @JsonProperty("distribution-status")
+ public String getDistributionStatus() {
+ return distributionStatus;
+ }
+
+ @JsonProperty("distribution-status")
+ public void setDistributionStatus(String distributionStatus) {
+ this.distributionStatus = distributionStatus;
+ }
+
+ @JsonProperty("resource-version")
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ @JsonProperty("resource-version")
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @JsonProperty("model-description")
+ public String getModelDescription() {
+ return modelDescription;
+ }
+
+ @JsonProperty("model-description")
+ public void setModelDescription(String modelDescription) {
+ this.modelDescription = modelDescription;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ModelVers.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ModelVers.java
new file mode 100644
index 0000000..f49c6fe
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ModelVers.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ModelVers {
+
+ @JsonProperty("model-ver")
+ private List<ModelVer> modelVer;
+
+ @JsonProperty("model-ver")
+ public List<ModelVer> getModelVer() {
+ return modelVer;
+ }
+
+ @JsonProperty("model-ver")
+ public void setModelVer(List<ModelVer> modelVer) {
+ this.modelVer = modelVer;
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/OwningEntity.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/OwningEntity.java
new file mode 100644
index 0000000..6484bad
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/OwningEntity.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class OwningEntity extends AaiRelationResponse {
+ @JsonProperty("owning-entity-id")
+ private String owningEntityId;
+ @JsonProperty("owning-entity-name")
+ private String owningEntityName;
+
+ @JsonProperty("owning-entity-id")
+ public String getOwningEntityId() {
+ return owningEntityId;
+ }
+
+ @JsonProperty("owning-entity-id")
+ public void setOwningEntityId(String owningEntityId) {
+ this.owningEntityId = owningEntityId;
+ }
+
+ @JsonProperty("owning-entity-name")
+ public String getOwningEntityName() {
+ return owningEntityName;
+ }
+
+ @JsonProperty("owning-entity-name")
+ public void setOwningEntityName(String owningEntityName) {
+ this.owningEntityName = owningEntityName;
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/OwningEntityResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/OwningEntityResponse.java
new file mode 100644
index 0000000..767a628
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/OwningEntityResponse.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+public class OwningEntityResponse {
+
+ @JsonProperty("owning-entity")
+ private List<OwningEntity> owningEntity;
+
+
+ @JsonProperty("owning-entity")
+ public List<OwningEntity> getOwningEntity() {
+ return owningEntity;
+ }
+
+ @JsonProperty("owning-entity")
+ public void setOwningEntity(List<OwningEntity> owningEntity) {
+ this.owningEntity = owningEntity;
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/PnfProperties.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/PnfProperties.java
new file mode 100644
index 0000000..4d6a6b0
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/PnfProperties.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonPropertyOrder({
+ "pnf-name",
+ "equip-type",
+ "equip-vendor",
+ "equip-model",
+ "in-maint",
+ "resource-version"
+})
+public class PnfProperties {
+
+ @JsonProperty("pnf-name")
+ public String pnfName;
+ @JsonProperty("equip-type")
+ public String equipType;
+ @JsonProperty("equip-vendor")
+ public String equipVendor;
+ @JsonProperty("equip-model")
+ public String equipModel;
+ @JsonProperty("in-maint")
+ public Boolean inMaint;
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/PnfResult.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/PnfResult.java
new file mode 100644
index 0000000..3057019
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/PnfResult.java
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.onap.osam.RelatedTo;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "id",
+ "node-type",
+ "url",
+ "properties",
+ "related-to"
+})
+public class PnfResult {
+
+ @JsonProperty("id")
+ public String id;
+ @JsonProperty("node-type")
+ public String nodeType;
+ @JsonProperty("url")
+ public String url;
+ @JsonProperty("properties")
+ public PnfProperties properties;
+ @JsonProperty("related-to")
+ public List<RelatedTo> relatedTo;
+
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/PortDetailsTranslator.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/PortDetailsTranslator.java
new file mode 100644
index 0000000..10612f8
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/PortDetailsTranslator.java
@@ -0,0 +1,160 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.google.common.collect.ImmutableList;
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.properties.Features;
+import org.togglz.core.manager.FeatureManager;
+
+import javax.inject.Inject;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+public class PortDetailsTranslator {
+
+ @Inject
+ FeatureManager featureManager;
+
+ public static class PortDetailsOk extends PortDetails {
+
+ private final String interfaceId;
+ private final String interfaceName;
+ private final boolean isPortMirrored;
+
+ public PortDetailsOk(String interfaceId, String interfaceName, boolean isPortMirrored) {
+ this.interfaceId = interfaceId;
+ this.interfaceName = interfaceName;
+ this.isPortMirrored = isPortMirrored;
+ }
+
+ public String getInterfaceId() {
+ return interfaceId;
+ }
+
+ public String getInterfaceName() {
+ return interfaceName;
+ }
+
+ public boolean getIsPortMirrored() {
+ return isPortMirrored;
+ }
+ }
+
+ public abstract static class PortDetails {
+ }
+
+ public static class PortDetailsError extends PortDetails {
+ private final String errorDescription;
+ private final String rawAaiResponse;
+
+ public PortDetailsError(String errorDescription, String rawAaiResponse){
+ this.errorDescription = errorDescription;
+ this.rawAaiResponse = rawAaiResponse;
+ }
+
+ public String getErrorDescription() {
+ return errorDescription;
+ }
+
+ public String getRawAaiResponse() {
+ return rawAaiResponse;
+ }
+ }
+
+ public static PortDetails extractPortDetailsFromProperties(Properties properties, String rawPayload){
+ List<String> errorDescriptions = new LinkedList<>();
+ describeIfNullOrEmpty("interface-id", properties.getInterfaceId(), errorDescriptions);
+ describeIfNullOrEmpty("interface-name", properties.getInterfaceName(), errorDescriptions);
+ describeIfNullOrEmpty("is-port-mirrored", properties.getIsPortMirrored(), errorDescriptions);
+
+ if(errorDescriptions.isEmpty()){
+ return new PortDetailsOk(properties.getInterfaceId(), properties.getInterfaceName(), properties.getIsPortMirrored());
+ } else {
+ return new PortDetailsError(String.join(" ", errorDescriptions), rawPayload);
+ }
+ }
+
+ private static void describeIfNullOrEmpty(String name, Object value, List<String> errorDescriptions) {
+ if (value == null) {
+ errorDescriptions.add("Value of '" + name + "' is missing.");
+ } else if (value.toString().isEmpty()) {
+ errorDescriptions.add("Value of '" + name + "' is empty.");
+ }
+ }
+
+ private static Optional<List<PortDetails>> extractErrorResponseIfHttpError(AaiResponse aaiResponse, String rawPayload) {
+ if (aaiResponse.getHttpCode() != org.springframework.http.HttpStatus.OK.value()) {
+ final String errorMessage = aaiResponse.getErrorMessage();
+ return Optional.of(ImmutableList.of(new PortDetailsError(
+ "Got " + aaiResponse.getHttpCode() + " from aai",
+ errorMessage != null ? errorMessage.toString() : rawPayload)
+ ));
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ public List<PortDetails> extractPortDetailsInternal(AaiGetPortMirroringSourcePorts aaiGetPortsResponse, String rawPayload){
+ List<SimpleResult> filteredResult = getFilteredPortList(aaiGetPortsResponse.getResults());
+
+ return filteredResult.stream()
+ .map(SimpleResult::getProperties)
+ .map(p -> extractPortDetailsFromProperties(p, rawPayload))
+ .collect(Collectors.toList());
+ }
+
+ public List<SimpleResult> getFilteredPortList(List<SimpleResult> results) {
+ String LINTERFACE = "l-interface";
+
+ final Predicate<SimpleResult> ifIsPort = (SimpleResult r) -> LINTERFACE.equals(r.getNodeType());
+ Predicate<SimpleResult> ifIsSource = getIsSourcePredicate();
+
+ return results.stream()
+ .filter(ifIsPort)
+ .filter(ifIsSource)
+ .collect(Collectors.toList());
+ }
+
+ private Predicate<SimpleResult> getIsSourcePredicate() {
+ boolean FLAG_ADVANCED_PORTS_FILTER = featureManager.isActive(Features.FLAG_ADVANCED_PORTS_FILTER);
+
+ if (FLAG_ADVANCED_PORTS_FILTER) {
+ String PORT_LABEL = "org.onap.relationships.inventory.Source";
+ return (SimpleResult r) -> r.getRelatedTo().stream()
+ .anyMatch(relatedTo -> PORT_LABEL.equalsIgnoreCase(relatedTo.getRelationshipLabel()));
+ } else {
+ return (SimpleResult r) -> true;
+ }
+ }
+
+ public List<PortDetails> extractPortDetails(AaiResponse<AaiGetPortMirroringSourcePorts> aaiGetPortsResponse, String rawPayload){
+ return extractErrorResponseIfHttpError(aaiGetPortsResponse, rawPayload).orElseGet(() -> extractPortDetailsInternal(aaiGetPortsResponse.getT(), rawPayload));
+
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Project.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Project.java
new file mode 100644
index 0000000..dc6e219
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Project.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Project extends AaiRelationResponse {
+
+ @JsonProperty("project-name")
+ private String projectName;
+
+ @JsonProperty("project-name")
+ public String getProjectName() { return projectName; }
+
+ @JsonProperty("project-name")
+ public void setProjectName(String projectName) { this.projectName = projectName; }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ProjectResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ProjectResponse.java
new file mode 100644
index 0000000..1067bff
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ProjectResponse.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+public class ProjectResponse {
+
+ @JsonProperty("project")
+ private List<Project> project;
+
+
+ @JsonProperty("project")
+ public List<Project> getProject() {
+ return project;
+ }
+
+ @JsonProperty("project")
+ public void setProject(List<Project> project) {
+ this.project = project;
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Properties.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Properties.java
new file mode 100644
index 0000000..644c429
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Properties.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Properties {
+
+ private final String interfaceName;
+ private final String interfaceId;
+ private final Boolean isPortMirrored;
+
+ public Properties(
+ @JsonProperty("interface-name") String interfaceName,
+ @JsonProperty("interface-id") String interfaceId,
+ @JsonProperty("is-port-mirrored") Boolean isPortMirrored) {
+ this.interfaceName = interfaceName;
+ this.interfaceId = interfaceId;
+ this.isPortMirrored = isPortMirrored;
+ }
+
+ public String getInterfaceName() {
+ return interfaceName;
+ }
+
+ public String getInterfaceId() {
+ return interfaceId;
+ }
+
+ public Boolean getIsPortMirrored() {
+ return isPortMirrored;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/RelatedTo.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/RelatedTo.java
new file mode 100644
index 0000000..37d622e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/RelatedTo.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class RelatedTo {
+ private final String id;
+ private final String relationshipLabel;
+ private final String nodeType;
+ private final String url;
+
+ public RelatedTo(
+ @JsonProperty("id") String id,
+ @JsonProperty("relationship-label") String relationshipLabel,
+ @JsonProperty("node-type") String nodeType,
+ @JsonProperty("url") String url) {
+ this.id = id;
+ this.relationshipLabel = relationshipLabel;
+ this.nodeType = nodeType;
+ this.url = url;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getRelationshipLabel() {
+ return relationshipLabel;
+ }
+
+ public String getNodeType() {
+ return nodeType;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/RelatedToProperty.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/RelatedToProperty.java
new file mode 100644
index 0000000..036a663
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/RelatedToProperty.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class RelatedToProperty {
+
+ public String getPropertyKey() {
+ return propertyKey;
+ }
+
+
+ public void setPropertyKey(String propertyKey) {
+ this.propertyKey = propertyKey;
+ }
+
+
+ public String getPropertyValue() {
+ return propertyValue;
+ }
+
+
+ public void setPropertyValue(String propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+
+
+ @JsonProperty("property-key")
+ public String propertyKey;
+
+
+ @JsonProperty("property-value")
+ public String propertyValue;
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Relationship.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Relationship.java
new file mode 100644
index 0000000..15f2e6a
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Relationship.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Relationship {
+
+ @JsonProperty("related-to")
+ public String relatedTo;
+
+ @JsonProperty("related-link")
+ public String relatedLink;
+
+ @JsonProperty("relationship-label")
+ public String relationshipLabel;
+
+ @JsonProperty("relationship-data")
+ public List<RelationshipData> relationshipData;
+
+ @JsonProperty("related-to-property")
+ public List<RelatedToProperty> relatedToProperty;
+
+
+ public String getRelatedTo() {
+ return relatedTo;
+ }
+
+ public void setRelatedTo(String relatedTo) {
+ this.relatedTo = relatedTo;
+ }
+
+ public String getRelatedLink() {
+ return relatedLink;
+ }
+
+ public void setRelatedLink(String relatedLink) {
+ this.relatedLink = relatedLink;
+ }
+
+ public List<RelationshipData> getRelationDataList() {
+ return relationshipData;
+ }
+
+ public void setRelationDataList(List<RelationshipData> relationDataList) {
+ this.relationshipData = relationDataList;
+ }
+
+ public List<RelatedToProperty> getRelatedToPropertyList() {
+ return relatedToProperty;
+ }
+
+ public void setRelatedToPropertyList(List<RelatedToProperty> relatedToPropertyList) {
+ this.relatedToProperty = relatedToPropertyList;
+ }
+
+ public String getRelationshipLabel() {
+ return relationshipLabel;
+ }
+
+ public void setRelationshipLabel(String relationshipLabel) {
+ this.relationshipLabel = relationshipLabel;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/RelationshipData.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/RelationshipData.java
new file mode 100644
index 0000000..107ac3d
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/RelationshipData.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class RelationshipData {
+ @JsonProperty("relationship-key")
+ public String getRelationshipKey() {
+ return relationshipKey;
+ }
+ @JsonProperty("relationship-key")
+ public void setRelationshipKey(String relationshipKey) {
+ this.relationshipKey = relationshipKey;
+ }
+ @JsonProperty("relationship-value")
+ public String getRelationshipValue() {
+ return relationshipValue;
+ }
+ @JsonProperty("relationship-value")
+ public void setRelationshipValue(String relationshipValue) {
+ this.relationshipValue = relationshipValue;
+ }
+
+ public String relationshipKey;
+
+ public String relationshipValue;
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/RelationshipList.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/RelationshipList.java
new file mode 100644
index 0000000..c2cd4be
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/RelationshipList.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class RelationshipList {
+
+ @JsonProperty("relationship")
+ public List<Relationship> getRelationship() {
+ return relationship;
+ }
+
+ @JsonProperty("relationship")
+ public void setRelationship(List<Relationship> relationship) {
+ this.relationship = relationship;
+ }
+
+ public List<Relationship> relationship;
+
+
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ResourceType.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ResourceType.java
new file mode 100644
index 0000000..bbe0ed5
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ResourceType.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public enum ResourceType {
+
+ SERVICE_INSTANCE("service-instance", "service-instance-name"),
+ GENERIC_VNF("generic-vnf", "vnf-name"),
+ VF_MODULE("vf-module", "vf-module-name"),
+ VOLUME_GROUP("volume-group", "volume-group-name");
+
+ private static Map<String, ResourceType> AAI_FORMAT_MAP = Stream
+ .of(ResourceType.values())
+ .collect(Collectors.toMap(s -> s.aaiFormat, Function.identity()));
+
+ private final String aaiFormat;
+ private final String nameFilter;
+
+ ResourceType(String formatted, String nameFilter) {
+ this.aaiFormat = formatted;
+ this.nameFilter = nameFilter;
+ }
+
+ public String getAaiFormat() {
+ return aaiFormat;
+ }
+
+ public String getNameFilter() {
+ return nameFilter;
+ }
+
+ @JsonCreator
+ public static ResourceType fromString(String string) {
+ return Optional
+ .ofNullable(AAI_FORMAT_MAP.get(string))
+ .orElseThrow(() -> new IllegalArgumentException(string));
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Result.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Result.java
new file mode 100644
index 0000000..d50603f
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Result.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Result {
+ @JsonProperty("model")
+ private Model model;
+
+ @JsonProperty("model")
+ public Model getModel() {
+ return model;
+ }
+
+ @JsonProperty("model")
+ public void setModel(Model model) {
+ this.model = model;
+ }
+
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceInstance.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceInstance.java
new file mode 100644
index 0000000..a6fbb50
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceInstance.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class ServiceInstance {
+
+ @JsonProperty("service-instance-id")
+ public String serviceInstanceId;
+
+ @JsonProperty("service-instance-name")
+ public String serviceInstanceName;
+
+ @JsonProperty("persona-model-id")
+ public String personaModelId;
+
+ @JsonProperty("persona-model-version")
+ public String personaModelVersion;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("orchestration-status")
+ public String orchestrationStatus;
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceInstances.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceInstances.java
new file mode 100644
index 0000000..6c2de4a
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceInstances.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+public class ServiceInstances {
+
+ @JsonProperty("service-instance")
+ public List<ServiceInstance> serviceInstance;
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceProperties.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceProperties.java
new file mode 100644
index 0000000..bd8d26e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceProperties.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.HashMap;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonPropertyOrder({
+ "service-instance-id",
+ "service-instance-name",
+ "model-invariant-id",
+ "model-version-id",
+ "resource-version",
+ "orchestration-status",
+ "global-customer-id",
+ "subscriber-name",
+ "subscriber-type",
+ "vnf-id",
+ "vnf-name",
+ "vnf-type",
+ "service-id",
+ "prov-status",
+ "in-maint",
+ "is-closed-loop-disabled",
+ "model-customization-id",
+ "nf-type",
+ "nf-function",
+ "nf-role",
+ "nf-naming-code"
+})
+public class ServiceProperties {
+
+ @JsonProperty("service-instance-id")
+ public String serviceInstanceId;
+ @JsonProperty("service-instance-name")
+ public String serviceInstanceName;
+ @JsonProperty("model-invariant-id")
+ public String modelInvariantId;
+ @JsonProperty("model-version-id")
+ public String modelVersionId;
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+ @JsonProperty("orchestration-status")
+ public String orchestrationStatus;
+ @JsonProperty("global-customer-id")
+ public String globalCustomerId;
+ @JsonProperty("subscriber-name")
+ public String subscriberName;
+ @JsonProperty("subscriber-type")
+ public String subscriberType;
+ @JsonProperty("vnf-id")
+ public String vnfId;
+ @JsonProperty("vnf-name")
+ public String vnfName;
+ @JsonProperty("vnf-type")
+ public String vnfType;
+ @JsonProperty("service-id")
+ public String serviceId;
+ @JsonProperty("prov-status")
+ public String provStatus;
+ @JsonProperty("in-maint")
+ public Boolean inMaint;
+ @JsonProperty("is-closed-loop-disabled")
+ public Boolean isClosedLoopDisabled;
+ @JsonProperty("model-customization-id")
+ public String modelCustomizationId;
+ @JsonProperty("nf-type")
+ public String nfType;
+ @JsonProperty("nf-function")
+ public String nfFunction;
+ @JsonProperty("nf-role")
+ public String nfRole;
+ @JsonProperty("nf-naming-code")
+ public String nfNamingCode;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceRelationships.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceRelationships.java
new file mode 100644
index 0000000..e7c2fc1
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceRelationships.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class ServiceRelationships {
+
+ @JsonProperty("service-instance-id")
+ public String serviceInstanceId;
+
+ @JsonProperty("service-instance-name")
+ public String serviceInstanceName;
+
+ @JsonProperty("service-type")
+ public String serviceType;
+
+ @JsonProperty("service-role")
+ public String serviceRole;
+
+ @JsonProperty("environment-context")
+ public String environmentContext;
+
+ @JsonProperty("workload-context")
+ public String workloadContext;
+
+ @JsonProperty("model-invariant-id")
+ public String modelInvariantId;
+
+ @JsonProperty("model-version-id")
+ public String modelVersionId;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("orchestration-status")
+ public String orchestrationStatus;
+
+ @JsonProperty("relationship-list")
+ public RelationshipList relationshipList;
+
+
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public String getServiceInstanceName() {
+ return serviceInstanceName;
+ }
+
+ public void setServiceInstanceName(String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ }
+
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public String getOrchestrationStatus() {
+ return orchestrationStatus;
+ }
+
+ public void setOrchestrationStatus(String orchestrationStatus) {
+ this.orchestrationStatus = orchestrationStatus;
+ }
+
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ public void setRelationshipList(RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ }
+
+
+
+
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceSubscription.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceSubscription.java
new file mode 100644
index 0000000..077903d
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/ServiceSubscription.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class ServiceSubscription {
+
+ @JsonProperty("service-type")
+ public String serviceType;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("service-instances")
+ public ServiceInstances serviceInstances;
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Services.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Services.java
new file mode 100644
index 0000000..367ee42
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/Services.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+
+public class Services {
+ @JsonProperty("global-customer-id")
+ public String globalCustomerId;
+
+ @JsonProperty("subscriber-name")
+ public String subscriberName;
+
+ @JsonProperty("subscriber-type")
+ public String subscriberType;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("service-subscriptions")
+ public List<ServiceSubscription> serviceSubscriptions;
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/SimpleResult.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/SimpleResult.java
new file mode 100644
index 0000000..92189b0
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/SimpleResult.java
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class SimpleResult {
+ @JsonProperty("id")
+ private String id;
+ @JsonProperty("node-type")
+ private String nodeType;
+ @JsonProperty("url")
+ private String url;
+ @JsonProperty("properties")
+ private Properties properties;
+ @JsonProperty("related-to")
+ private List<RelatedTo> relatedTo = null;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonProperty("id")
+ public String getId() {
+ return id;
+ }
+
+ @JsonProperty("id")
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @JsonProperty("node-type")
+ public String getNodeType() {
+ return nodeType;
+ }
+
+ @JsonProperty("node-type")
+ public void setNodeType(String nodeType) {
+ this.nodeType = nodeType;
+ }
+
+ @JsonProperty("url")
+ public String getUrl() {
+ return url;
+ }
+
+ @JsonProperty("url")
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ @JsonProperty("properties")
+ public Properties getProperties() {
+ return properties;
+ }
+
+ @JsonProperty("properties")
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+ @JsonProperty("related-to")
+ public List<RelatedTo> getRelatedTo() {
+ return relatedTo;
+ }
+
+ @JsonProperty("related-to")
+ public void setRelatedTo(List<RelatedTo> relatedTo) {
+ this.relatedTo = relatedTo;
+ }
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/model/VnfResult.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/VnfResult.java
new file mode 100644
index 0000000..9d4e0a2
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/model/VnfResult.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.annotation.*;
+import org.onap.osam.RelatedTo;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "id",
+ "node-type",
+ "url",
+ "properties",
+ "related-to"
+})
+public class VnfResult {
+
+ @JsonProperty("id")
+ public String id;
+ @JsonProperty("node-type")
+ public String nodeType;
+ @JsonProperty("url")
+ public String url;
+ @JsonProperty("properties")
+ public ServiceProperties properties;
+ @JsonProperty("related-to")
+ public List<RelatedTo> relatedTo = null;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/util/AAIProperties.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/AAIProperties.java
new file mode 100644
index 0000000..cc5c1cf
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/AAIProperties.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+
+import org.onap.portalsdk.core.util.SystemProperties;
+
+public class AAIProperties extends SystemProperties {
+
+ //VID Specific
+ public static final String AAI_SERVER_URL_BASE = "aai.server.url.base";
+
+ /** The Constant AAI_SERVER_URL. */
+ public static final String AAI_SERVER_URL = "aai.server.url";
+
+ /** The Constant AAI_OLDSERVER_URL_BASE. */
+ public static final String AAI_OLDSERVER_URL_BASE = "aai.oldserver.url.base";
+
+ /** The Constant AAI_OLDSERVER_URL. */
+ public static final String AAI_OLDSERVER_URL = "aai.oldserver.url";
+
+ /** The Constant AAI_TRUSTSTORE_FILENAME. */
+ public static final String AAI_TRUSTSTORE_FILENAME = "aai.truststore.filename";
+
+ /** The Constant AAI_TRUSTSTORE_PASSWD_X. */
+ public static final String AAI_TRUSTSTORE_PASSWD_X = "aai.truststore.passwd.x";
+
+ /** The Constant AAI_KEYSTORE_FILENAME. */
+ public static final String AAI_KEYSTORE_FILENAME = "aai.keystore.filename";
+
+ /** The Constant AAI_KEYSTORE_PASSWD_X. */
+ public static final String AAI_KEYSTORE_PASSWD_X = "aai.keystore.passwd.x";
+
+ /** The Constant AAI_VID_USERNAME. */
+ public static final String AAI_VID_USERNAME = "aai.vid.username";
+
+ /** The Constant AAI_VID_PASSWD_X. */
+ public static final String AAI_VID_PASSWD_X = "aai.vid.passwd.x";
+
+ /** The Constant FILESEPARTOR. */
+ public static final String FILESEPARTOR = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
+
+ /** The Constant AAI_USE_CLIENT_CERT */
+ public static final String AAI_USE_CLIENT_CERT = "aai.use.client.cert";
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/util/AAIRestInterface.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/AAIRestInterface.java
new file mode 100644
index 0000000..8a69076
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/AAIRestInterface.java
@@ -0,0 +1,355 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.osam.aai.util;
+
+
+import com.att.eelf.configuration.EELFLogger;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.osam.aai.ExceptionWithRequestInfo;
+import org.onap.osam.aai.ResponseWithRequestInfo;
+import org.onap.osam.aai.exceptions.InvalidPropertyException;
+import org.onap.osam.utils.Logging;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Optional;
+import java.util.UUID;
+
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+import static org.onap.osam.utils.Logging.REQUEST_ID_HEADER_KEY;
+
+
+public class AAIRestInterface {
+
+ protected EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AAIRestInterface.class);
+
+ protected final EELFLogger outgoingRequestsLogger = Logging.getRequestsLogger("aai");
+
+
+ /** The client. */
+ private Client client = null;
+
+ /** The rest srvr base URL. */
+ private String restSrvrBaseURL;
+
+ @Autowired
+ protected HttpsAuthClient httpsAuthClientFactory;
+ private final ServletRequestHelper servletRequestHelper;
+ private final SystemPropertyHelper systemPropertyHelper;
+
+ protected static final String START_STRING = " start";
+ protected static final String TRANSACTION_ID_HEADER = "X-TransactionId";
+ protected static final String FROM_APP_ID_HEADER = "X-FromAppId";
+ protected static final String SUCCESSFUL_API_MESSAGE = " REST api call was successful!";
+ protected static final String URL_DECLARATION = ", url=";
+
+ public AAIRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
+ this.httpsAuthClientFactory = httpsAuthClientFactory;
+ this.servletRequestHelper = servletRequestHelper;
+ this.systemPropertyHelper = systemPropertyHelper;
+ initRestClient();
+ }
+
+ /**
+ * For testing purpose
+ */
+ AAIRestInterface(Optional<Client> client,
+ HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper){
+ this.httpsAuthClientFactory = httpsAuthClientFactory;
+ this.servletRequestHelper = servletRequestHelper;
+ this.systemPropertyHelper = systemPropertyHelper;
+ if (client != null && client.isPresent()){
+ this.client = client.get();
+ }
+
+ }
+
+ /**
+ * Encode URL.
+ *
+ * @param nodeKey the node key
+ * @return the string
+ * @throws UnsupportedEncodingException the unsupported encoding exception
+ */
+ public String encodeURL (String nodeKey) throws UnsupportedEncodingException {
+ return URLEncoder.encode(nodeKey, "UTF-8").replaceAll("\\+", "%20");
+ }
+
+ private void initRestClient() {
+ initRestClient(false);
+ }
+
+
+ private void initRestClient(boolean propagateExceptions) {
+ if (client == null) {
+ try {
+ client = httpsAuthClientFactory.getClient(HttpClientMode.WITH_KEYSTORE);
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, "Exception in REST call to DB in initRestClient" + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, "Exception in REST call to DB : " + e.toString());
+ if (propagateExceptions) {
+ ExceptionUtils.rethrow(e);
+ }
+ }
+ }
+ }
+
+
+
+ /**
+ * Sets the rest srvr base URL.
+ *
+ * @param baseURL the base URL
+ */
+ public void SetRestSrvrBaseURL(String baseURL)
+ {
+ if (baseURL == null) {
+ logger.info(EELFLoggerDelegate.errorLogger, "REST Server base URL cannot be null.");
+ logger.debug(EELFLoggerDelegate.debugLogger, "REST Server base URL cannot be null.");
+ }
+
+ restSrvrBaseURL = baseURL;
+ }
+
+ /**
+ * Gets the rest srvr base URL.
+ *
+ * @return the rest srvr base URL
+ */
+ public String getRestSrvrBaseURL() {
+ return restSrvrBaseURL;
+ }
+
+
+ /**
+ * Rest get.
+ *
+ * @param fromAppId the from app id
+ * @param transId the trans id
+ * @param requestUri the request uri
+ * @param xml the xml
+ * @return the string
+ */
+ public ResponseWithRequestInfo RestGet(String fromAppId, String transId, String requestUri, boolean xml) {
+ return RestGet(fromAppId, transId, requestUri, xml, false);
+ }
+
+ public ResponseWithRequestInfo RestGet(String fromAppId, String transId, String requestUri, boolean xml, boolean propagateExceptions) {
+ String methodName = "RestGet";
+ String url = systemPropertyHelper.getFullServicePath(requestUri);
+ try {
+ initRestClient(propagateExceptions);
+
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_STRING);
+ logger.debug(EELFLoggerDelegate.debugLogger, url + " for the get REST API");
+
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
+
+ final Response response;
+ Invocation.Builder requestBuilder = client.target(url)
+ .request()
+ .accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON)
+ .header(TRANSACTION_ID_HEADER, transId)
+ .header(FROM_APP_ID_HEADER, fromAppId)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId());
+ response = systemPropertyHelper.isClientCertEnabled() ?
+ requestBuilder.get() : authenticateRequest(requestBuilder).get();
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, response);
+
+ if (response.getStatusInfo().equals(Response.Status.OK)) {
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + SUCCESSFUL_API_MESSAGE);
+ logger.info(EELFLoggerDelegate.errorLogger, methodName + SUCCESSFUL_API_MESSAGE);
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger, getInvalidResponseLogMessage(url, methodName, response));
+ }
+ return new ResponseWithRequestInfo(response, url, HttpMethod.GET);
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, getFailedResponseLogMessage(url, methodName, e));
+ if (propagateExceptions) {
+ throw new ExceptionWithRequestInfo(HttpMethod.GET, defaultIfNull(url, requestUri), e);
+ } else {
+ return new ResponseWithRequestInfo(null, url, HttpMethod.GET);
+ }
+ }
+ }
+
+ protected String extractOrGenerateRequestId() {
+ return servletRequestHelper.extractOrGenerateRequestId();
+ }
+
+
+ /**
+ * Delete.
+ *
+ * @param sourceID the source ID
+ * @param transId the trans id
+ * @param path the path
+ * @return true, if successful
+ */
+ public boolean Delete(String sourceID, String transId, String path) {
+ String methodName = "Delete";
+ transId += ":" + UUID.randomUUID().toString();
+ logger.debug(methodName + START_STRING);
+ Boolean response = false;
+ String url = systemPropertyHelper.getFullServicePath(path);;
+ try {
+
+ initRestClient();
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url);
+ final Response cres = client.target(url)
+ .request()
+ .accept(MediaType.APPLICATION_JSON)
+ .header(TRANSACTION_ID_HEADER, transId)
+ .header(FROM_APP_ID_HEADER, sourceID)
+ .header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId())
+ .delete();
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres);
+ if (cres.getStatusInfo().equals(Response.Status.NOT_FOUND)) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Resource does not exist...: " + cres.getStatus()
+ + ":" + cres.readEntity(String.class));
+ response = false;
+ } else if (cres.getStatusInfo().equals(Response.Status.OK) || cres.getStatusInfo().equals(Response.Status.NO_CONTENT)) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Resource " + url + " deleted");
+ logger.info(EELFLoggerDelegate.errorLogger, "Resource " + url + " deleted");
+ response = true;
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Deleting Resource failed: " + cres.getStatus()
+ + ":" + cres.readEntity(String.class));
+ response = false;
+ }
+
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, getFailedResponseLogMessage(url, methodName, e));
+ }
+ return response;
+ }
+
+
+ /**
+ * Rest put.
+ *
+ * @param fromAppId the from app id
+ * @param path the path
+ * @param payload the payload
+ * @param xml the xml
+ * @return the string
+ */
+ public Response RestPut(String fromAppId, String path, String payload, boolean xml) {
+ String methodName = "RestPut";
+ String url=systemPropertyHelper.getFullServicePath(path);
+ String transId = UUID.randomUUID().toString();
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_STRING);
+
+ Response response = null;
+ try {
+ initRestClient();
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.PUT, url, payload);
+ response = authenticateRequest(client.target(url)
+ .request()
+ .accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON)
+ .header(TRANSACTION_ID_HEADER, transId)
+ .header(FROM_APP_ID_HEADER, fromAppId))
+ .header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId())
+ .put(Entity.entity(payload, MediaType.APPLICATION_JSON));
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.PUT, url, response);
+
+ if (response.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL)) {
+ logger.info(EELFLoggerDelegate.errorLogger, getValidResponseLogMessage(methodName));
+ logger.debug(EELFLoggerDelegate.debugLogger, getValidResponseLogMessage(methodName));
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger, getInvalidResponseLogMessage(url, methodName, response));
+ }
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, getFailedResponseLogMessage(url, methodName, e));
+ }
+ return response;
+ }
+
+
+
+ /**
+ * Rest post.
+ *
+ * @param fromAppId the from app id
+ * @param path the path
+ * @param payload the payload
+ * @param xml the xml
+ * @return the string
+ */
+ public Response RestPost(String fromAppId, String path, String payload, boolean xml) {
+ String methodName = "RestPost";
+ String url=systemPropertyHelper.getServiceBasePath(path);
+ String transId = UUID.randomUUID().toString();
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_STRING);
+
+ Response response = null;
+ try {
+ initRestClient();
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, payload);
+ response = authenticateRequest(client.target(systemPropertyHelper.getServiceBasePath(path))
+ .request()
+ .accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON)
+ .header(TRANSACTION_ID_HEADER, transId)
+ .header(FROM_APP_ID_HEADER, fromAppId))
+ .header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId())
+ .post(Entity.entity(payload, MediaType.APPLICATION_JSON));
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.POST, url, response);
+
+ if (response.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL)) {
+ logger.info(EELFLoggerDelegate.errorLogger, getValidResponseLogMessage(methodName));
+ logger.debug(EELFLoggerDelegate.debugLogger, getValidResponseLogMessage(methodName));
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger, getInvalidResponseLogMessage(url, methodName, response));
+ }
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, getFailedResponseLogMessage(url, methodName, e));
+ }
+ return response;
+ }
+
+ protected String getFailedResponseLogMessage(String path, String methodName, Exception e) {
+ return methodName + URL_DECLARATION + path + ", Exception: " + e.toString();
+ }
+
+ protected String getValidResponseLogMessage(String methodName) {
+ return methodName + URL_DECLARATION;
+ }
+
+ protected String getInvalidResponseLogMessage(String path, String methodName, Response cres) {
+ return methodName + " with status=" + cres.getStatus() + URL_DECLARATION + path;
+ }
+
+ private Invocation.Builder authenticateRequest(Invocation.Builder requestBuilder) throws InvalidPropertyException, UnsupportedEncodingException {
+ return requestBuilder
+ .header("Authorization", "Basic " + systemPropertyHelper.getEncodedCredentials());
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/util/CustomJacksonJaxBJsonProvider.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/CustomJacksonJaxBJsonProvider.java
new file mode 100644
index 0000000..19c8f6b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/CustomJacksonJaxBJsonProvider.java
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
+import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
+
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class CustomJacksonJaxBJsonProvider extends JacksonJaxbJsonProvider {
+
+ private static ObjectMapper commonMapper = null;
+
+ /**
+ * Instantiates a new custom jackson jax B json provider.
+ */
+ public CustomJacksonJaxBJsonProvider() {
+ if (commonMapper == null) {
+ ObjectMapper mapper = new ObjectMapper();
+
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+ mapper.configure(SerializationFeature.INDENT_OUTPUT, false);
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
+
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
+
+ mapper.registerModule(new JaxbAnnotationModule());
+
+ commonMapper = mapper;
+ }
+ super.setMapper(commonMapper);
+ }
+
+ /**
+ * Gets the mapper.
+ *
+ * @return the mapper
+ */
+ public ObjectMapper getMapper() {
+ return commonMapper;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/util/HttpClientMode.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/HttpClientMode.java
new file mode 100644
index 0000000..fb68947
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/HttpClientMode.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+public enum HttpClientMode {
+
+ WITH_KEYSTORE,
+ WITHOUT_KEYSTORE(),
+ UNSECURE,
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/util/HttpsAuthClient.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/HttpsAuthClient.java
new file mode 100644
index 0000000..bbac7e4
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/HttpsAuthClient.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.HttpUrlConnectorProvider;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.osam.aai.exceptions.HttpClientBuilderException;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.security.GeneralSecurityException;
+
+import static org.onap.osam.aai.util.HttpClientMode.WITH_KEYSTORE;
+
+public class HttpsAuthClient {
+
+ private static final String SSL_TRUST_STORE = "javax.net.ssl.trustStore";
+ private static final String SSL_TRUST_STORE_PASS_WORD = "javax.net.ssl.trustStorePassword";
+
+ private final SystemPropertyHelper systemPropertyHelper;
+ private final SSLContextProvider sslContextProvider;
+
+ public HttpsAuthClient(String certFilePath, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider) {
+ this.certFilePath = certFilePath;
+ this.systemPropertyHelper = systemPropertyHelper;
+ this.sslContextProvider = sslContextProvider;
+ }
+
+ private final String certFilePath;
+
+ static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HttpsAuthClient.class);
+
+
+ /**
+ * Gets the client.
+ *
+ * @return the client
+ */
+ public Client getClient(HttpClientMode mode) throws GeneralSecurityException, IOException {
+ ClientConfig config = prepareClientConfig(mode);
+
+ try {
+ setSystemProperties();
+
+ ignoreHostname();
+
+ return systemPropertyHelper.isClientCertEnabled() ?
+ getTrustedClient(config, getKeystorePath(), systemPropertyHelper.getDecryptedKeystorePassword(), mode)
+ : getUntrustedClient(config);
+
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up config", e);
+ throw e;
+ }
+
+ }
+
+ private void ignoreHostname() {
+ HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> true);
+ }
+
+ private Client getUntrustedClient(ClientConfig config) {
+ return ClientBuilder.newBuilder().withConfig(config).build().register(CustomJacksonJaxBJsonProvider.class);
+ }
+
+ private Client getTrustedClient(ClientConfig config, String keystorePath, String keystorePassword, HttpClientMode httpClientMode) throws HttpClientBuilderException {
+ return ClientBuilder.newBuilder()
+ .sslContext(sslContextProvider.getSslContext(keystorePath, keystorePassword, httpClientMode))
+ .hostnameVerifier((s, sslSession) -> true)
+ .withConfig(config)
+ .build()
+ .register(CustomJacksonJaxBJsonProvider.class);
+ }
+
+ private String getKeystorePath() {
+ return getCertificatesPath() + FileSystems.getDefault().getSeparator() + systemPropertyHelper.getAAIKeystoreFilename();
+ }
+
+ private void setSystemProperties() {
+ System.setProperty(SSL_TRUST_STORE, getCertificatesPath() + FileSystems.getDefault().getSeparator() +
+ systemPropertyHelper.getAAITruststoreFilename().orElse(""));
+ System.setProperty(SSL_TRUST_STORE_PASS_WORD, systemPropertyHelper.getDecryptedTruststorePassword());
+ }
+
+ private ClientConfig prepareClientConfig(HttpClientMode mode) {
+ ClientConfig config = new ClientConfig();
+ if (mode.equals(WITH_KEYSTORE)) {
+ config.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, Boolean.TRUE);
+ config.connectorProvider(new HttpUrlConnectorProvider().useSetMethodWorkaround());
+ }
+ return config;
+ }
+
+ private String getCertificatesPath() {
+ return certFilePath;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/util/HttpsComponentsClient.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/HttpsComponentsClient.java
new file mode 100644
index 0000000..9e7e3d6
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/HttpsComponentsClient.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContextBuilder;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.eclipse.jetty.util.security.Password;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+
+import javax.net.ssl.SSLContext;
+import java.io.FileInputStream;
+import java.security.GeneralSecurityException;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+
+
+public class HttpsComponentsClient{
+
+ static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HttpsComponentsClient.class);
+
+ public static CloseableHttpClient getClient(String certFilePath) {
+ CloseableHttpClient httpclient = null;
+ try {
+
+ String truststore_path = certFilePath + AAIProperties.FILESEPARTOR + SystemProperties.getProperty(AAIProperties.AAI_TRUSTSTORE_FILENAME);
+ String truststore_password = SystemProperties.getProperty(AAIProperties.AAI_TRUSTSTORE_PASSWD_X);
+ String decrypted_truststore_password = Password.deobfuscate(truststore_password);
+ String keystore_path = certFilePath + AAIProperties.FILESEPARTOR + SystemProperties.getProperty(AAIProperties.AAI_KEYSTORE_FILENAME);
+ String keystore_password = SystemProperties.getProperty(AAIProperties.AAI_KEYSTORE_PASSWD_X);
+ String decrypted_keystore_password = Password.deobfuscate(keystore_password);
+
+ SSLContextBuilder sslContextB = new SSLContextBuilder();
+
+ KeyStore ks = KeyStore.getInstance("PKCS12");
+ char[] pwd = decrypted_keystore_password.toCharArray();
+
+ try(FileInputStream fin = new FileInputStream(keystore_path)) {
+ ks.load(fin, pwd);
+ }
+ catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up keystore");
+ logger.error(EELFLoggerDelegate.errorLogger, "Error loading keystore materials: (keystore path: {}, obfuascated keystore password: {})", keystore_path, keystore_password);
+ throw new GenericUncheckedException(e);
+ }
+
+ sslContextB.loadKeyMaterial(ks, pwd);
+
+ KeyStore ts = KeyStore.getInstance("JKS");
+ char[] pwd1 = decrypted_truststore_password.toCharArray();
+
+ try(FileInputStream fin1 = new FileInputStream(truststore_path)) {
+ ts.load(fin1, pwd1);
+ }
+ catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up truststore");
+ logger.error(EELFLoggerDelegate.errorLogger, "Error loading truststore materials: (truststore path: {}, obfuascated truststore password: {})", truststore_path, truststore_password);
+ throw new GenericUncheckedException(e);
+ }
+
+ sslContextB.loadTrustMaterial(ts);
+ sslContextB.loadKeyMaterial(ks, pwd);
+ sslContextB.useTLS();
+
+ SSLContext sslcontext = sslContextB.build();
+
+ SSLConnectionSocketFactory sslFactory = new SSLConnectionSocketFactory(
+ sslcontext,
+ new String[] { "TLSv1.1", "TLSv1.2" },
+ null,
+ SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER );
+
+ httpclient = HttpClients.custom()
+ .setSSLSocketFactory(sslFactory)
+ .build();
+
+
+ } catch (GeneralSecurityException e) {
+ throw new GenericUncheckedException(e);
+ }
+ return httpclient;
+ }
+
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/util/JettyObfuscationConversionCommandLineUtil.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/JettyObfuscationConversionCommandLineUtil.java
new file mode 100644
index 0000000..05e3f80
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/JettyObfuscationConversionCommandLineUtil.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+
+import org.apache.commons.cli.*;
+import org.eclipse.jetty.util.security.Password;
+
+
+public class JettyObfuscationConversionCommandLineUtil {
+ public static void main(String[] args){
+ Options options = new Options();
+ options.addOption("e", true, "obfuscate the given string");
+ options.addOption("d", true, "deobfuscate the given string");
+
+ CommandLineParser parser = new BasicParser();
+
+ try {
+ CommandLine cmd = parser.parse(options, args);
+ String toProcess = null;
+
+ if (cmd.hasOption("e")){
+ toProcess = cmd.getOptionValue("e");
+ String encoded = Password.obfuscate(toProcess);
+ System.out.println(encoded);
+ } else if (cmd.hasOption("d")) {
+ toProcess = cmd.getOptionValue("d");
+ String decoded_str = Password.deobfuscate(toProcess);
+ System.out.println(decoded_str);
+ } else {
+ usage();
+ }
+ } catch (ParseException e) {
+ System.out.println("failed to parse input");
+ System.out.println(e.toString());
+ usage();
+ } catch (Exception e) {
+ System.out.println("exception:" + e.toString());
+ }
+ }
+
+ private static void usage(){
+ System.out.println("usage:");
+ System.out.println("-e [string] to obfuscate");
+ System.out.println("-d [string] to deobfuscate");
+ System.out.println("-h help");
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/util/SSLContextProvider.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/SSLContextProvider.java
new file mode 100644
index 0000000..3706456
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/SSLContextProvider.java
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.osam.aai.exceptions.HttpClientBuilderException;
+
+import javax.net.ssl.*;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.security.cert.X509Certificate;
+
+public class SSLContextProvider {
+
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SSLContextProvider.class);
+
+ public SSLContext getSslContext(String keystorePath, String keystorePassword, HttpClientMode httpClientMode) throws HttpClientBuilderException {
+ try {
+ final SSLContext ctx = SSLContext.getInstance("TLSv1.2");
+ KeyManager[] keyManagers = getKeyManagerFactory(keystorePath, keystorePassword, httpClientMode);
+ ctx.init(keyManagers, getTrustManager(httpClientMode), null);
+ return ctx;
+ } catch (IOException | GeneralSecurityException e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up ssl context.");
+ throw new HttpClientBuilderException(e);
+ }
+ }
+
+ private KeyManager[] getKeyManagerFactory(String keystorePath, String keystorePassword, HttpClientMode httpClientMode) throws IOException, GeneralSecurityException {
+ switch (httpClientMode) {
+ case WITH_KEYSTORE:
+ final KeyManagerFactory kmf;
+ try (FileInputStream fin = new FileInputStream(keystorePath)) {
+ kmf = KeyManagerFactory.getInstance("SunX509");
+ KeyStore ks = KeyStore.getInstance("PKCS12");
+ char[] pwd = keystorePassword.toCharArray();
+ ks.load(fin, pwd);
+ kmf.init(ks, pwd);
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up kmf");
+ logger.error(EELFLoggerDelegate.errorLogger, "Error setting up kmf (keystore path: {}, deobfuascated keystore password: {})", keystorePath, keystorePassword, e);
+ throw e;
+ }
+ return kmf.getKeyManagers();
+
+ case WITHOUT_KEYSTORE:
+ return null;
+
+ default:
+ logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up getKeyManagerFactory. HttpClientMode is " + httpClientMode);
+ throw new IllegalStateException("Error setting up getKeyManagerFactory. HttpClientMode is " + httpClientMode);
+ }
+ }
+
+ private TrustManager[] getTrustManager(HttpClientMode httpClientMode) {
+ //Creating a trustManager that will accept all certificates.
+ //TODO - remove this one the POMBA certificate is added to the tomcat_keystore file
+ TrustManager[] trustAllCerts = null;
+ if (httpClientMode == HttpClientMode.UNSECURE) {
+
+ trustAllCerts = new TrustManager[]{new X509TrustManager() {
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return new java.security.cert.X509Certificate[]{};
+ }
+
+ public void checkClientTrusted(X509Certificate[] certs, String authType) {
+ // trust all
+ }
+
+ public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ // trust all
+ }
+ }};
+ }
+ return trustAllCerts;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/util/ServletRequestHelper.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/ServletRequestHelper.java
new file mode 100644
index 0000000..20f0040
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/ServletRequestHelper.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+import org.onap.osam.utils.Logging;
+
+public class ServletRequestHelper {
+
+ public String extractOrGenerateRequestId() {
+ return Logging.extractOrGenerateRequestId();
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/aai/util/SystemPropertyHelper.java b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/SystemPropertyHelper.java
new file mode 100644
index 0000000..34d7bcc
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/aai/util/SystemPropertyHelper.java
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+import org.eclipse.jetty.util.security.Password;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.aai.exceptions.InvalidPropertyException;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Base64;
+import java.util.Optional;
+
+public class SystemPropertyHelper {
+
+ public Optional<String> getAAIUseClientCert(){
+ return getSystemProperty(AAIProperties.AAI_USE_CLIENT_CERT);
+ }
+
+ public Optional<String> getAAIServerUrl(){
+ return getSystemProperty(AAIProperties.AAI_SERVER_URL);
+ }
+
+ public Optional<String> getAAIServerBaseUrl(){
+ return getSystemProperty(AAIProperties.AAI_SERVER_URL_BASE);
+ }
+
+ public Optional<String> getAAIVIDUsername(){
+ return getSystemProperty(AAIProperties.AAI_VID_USERNAME);
+ }
+
+ public Optional<String> getAAIVIDPasswd(){
+ return getSystemProperty(AAIProperties.AAI_VID_PASSWD_X);
+ }
+
+ public Optional<String> getAAITruststorePasswd(){
+ return getSystemProperty(AAIProperties.AAI_TRUSTSTORE_PASSWD_X);
+ }
+
+ public Optional<String> getAAITruststoreFilename(){
+ return getSystemProperty(AAIProperties.AAI_TRUSTSTORE_FILENAME);
+ }
+
+ public Optional<String> getAAIKeystoreFilename(){
+ return getSystemProperty(AAIProperties.AAI_KEYSTORE_FILENAME);
+ }
+
+ public Optional<String> getAAIKeystorePasswd(){
+ return getSystemProperty(AAIProperties.AAI_KEYSTORE_PASSWD_X);
+ }
+
+ public boolean isClientCertEnabled() {
+ return getAAIUseClientCert().orElse("false").equalsIgnoreCase("true");
+ }
+
+ public String getFullServicePath(String path) {
+ return getAAIServerUrl().orElse("") + path;
+ }
+
+ public String getServiceBasePath(String path) {
+ return getAAIServerBaseUrl().orElse("") + path;
+ }
+
+ public String getEncodedCredentials() throws InvalidPropertyException, UnsupportedEncodingException {
+ String vidUsername = getAAIVIDUsername().orElseThrow(InvalidPropertyException::new);
+ String vidPassword = Password.deobfuscate(getAAIVIDPasswd().orElseThrow(InvalidPropertyException::new));
+ return Base64.getEncoder().encodeToString((vidUsername + ":" + vidPassword).getBytes("utf-8"));
+ }
+
+ public String getDecryptedTruststorePassword(){
+ return Password.deobfuscate(getAAITruststorePasswd().orElse(""));
+ }
+
+ public String getDecryptedKeystorePassword(){
+ return Password.deobfuscate(getAAIKeystorePasswd().orElse(""));
+ }
+
+ private Optional<String> getSystemProperty(String propertyKey){
+ return Optional.ofNullable(SystemProperties.getProperty(propertyKey));
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/client/HttpBasicClient.java b/onap-enabler-be/src/main/java/org/onap/osam/client/HttpBasicClient.java
new file mode 100644
index 0000000..171d2f0
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/client/HttpBasicClient.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.client;
+
+
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.ClientProperties;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+
+public class HttpBasicClient{
+
+ @Autowired
+ private ServletContext servletContext;
+
+ /** The logger. */
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HttpBasicClient.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /**
+ * Obtain a basic HTTP client .
+ *
+ * @return Client client object
+ * @throws Exception the exception
+ */
+ public static Client getClient() {
+
+ ClientConfig config = new ClientConfig();
+ config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
+
+ return ClientBuilder.newClient(config)
+ .register(org.onap.osam.aai.util.CustomJacksonJaxBJsonProvider.class);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/client/HttpsBasicClient.java b/onap-enabler-be/src/main/java/org/onap/osam/client/HttpsBasicClient.java
new file mode 100644
index 0000000..b0fceb7
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/client/HttpsBasicClient.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.client;
+
+import org.eclipse.jetty.util.security.Password;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.ClientProperties;
+import org.onap.osam.properties.VidProperties;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+
+public class HttpsBasicClient{
+
+ static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HttpsBasicClient.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /**
+ * Retrieve an SSL client.
+ *
+ * @return Client The SSL client
+ * @throws Exception the exception
+ */
+ public static Client getClient() {
+ String methodName = "getClient";
+ ClientConfig config = new ClientConfig();
+
+ SSLContext ctx = null;
+
+ try {
+
+ config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
+
+ String truststore_path = SystemProperties.getProperty(VidProperties.VID_TRUSTSTORE_FILENAME);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + " " + methodName + " truststore_path=" + truststore_path);
+ String truststore_password = SystemProperties.getProperty(VidProperties.VID_TRUSTSTORE_PASSWD_X);
+
+
+ String decrypted_truststore_password = Password.deobfuscate(truststore_password);
+ //logger.debug(dateFormat.format(new Date()) + " " + methodName + " decrypted_truststore_password=" + decrypted_truststore_password);
+
+ File tr = new File (truststore_path);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + " " + methodName + " absolute truststore path=" + tr.getAbsolutePath());
+
+ System.setProperty("javax.net.ssl.trustStore", truststore_path);
+ System.setProperty("javax.net.ssl.trustStorePassword", decrypted_truststore_password);
+ HttpsURLConnection.setDefaultHostnameVerifier( new HostnameVerifier(){
+ public boolean verify(String string,SSLSession ssls) {
+ return true;
+ }
+ });
+
+ //May need to make the algorithm a parameter. MSO requires TLSv1.1 or TLSv1.2
+ ctx = SSLContext.getInstance("TLSv1.2");
+
+ ctx.init(null, null, null);
+ //config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
+ // new HTTPSProperties( , ctx));
+
+ return ClientBuilder.newBuilder()
+ .sslContext(ctx)
+ .hostnameVerifier(new HostnameVerifier() {
+ @Override
+ public boolean verify( String s, SSLSession sslSession ) {
+ return true;
+ }
+ }).withConfig(config)
+ .build()
+ .register(org.onap.osam.aai.util.CustomJacksonJaxBJsonProvider.class);
+
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up config: exiting", e);
+ return null;
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/client/SyncRestClient.java b/onap-enabler-be/src/main/java/org/onap/osam/client/SyncRestClient.java
new file mode 100644
index 0000000..62d673c
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/client/SyncRestClient.java
@@ -0,0 +1,231 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.client;
+
+import io.joshworks.restclient.http.HttpResponse;
+import io.joshworks.restclient.http.JsonNode;
+import io.joshworks.restclient.http.RestClient;
+import io.joshworks.restclient.http.exceptions.RestClientException;
+import io.joshworks.restclient.http.mapper.ObjectMapper;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.eclipse.jetty.util.security.Password;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.conn.ssl.SSLContexts;
+import io.vavr.CheckedFunction1;
+import lombok.SneakyThrows;
+import lombok.val;
+
+import java.security.UnrecoverableKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.KeyManagementException;
+import java.security.cert.CertificateException;
+import javax.net.ssl.SSLException;
+import java.security.KeyStoreException;
+import java.text.SimpleDateFormat;
+import javax.net.ssl.SSLContext;
+import java.io.FileInputStream;
+import java.security.KeyStore;
+import java.text.DateFormat;
+import java.io.InputStream;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+import java.io.File;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.properties.VidProperties;
+
+public class SyncRestClient implements SyncRestClientInterface {
+
+ private static final String CANNOT_INITIALIZE_CUSTOM_HTTP_CLIENT = "Cannot initialize custom http client from current configuration. Using default one.";
+ private static final String TRY_TO_CALL_OVER_HTTP = "SSL Handshake problem occured. Will try to retry over Http.";
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SyncRestClient.class);
+ private static final DateFormat DATE_FORMAT = new SimpleDateFormat("HH:mm:ss:SSSS");
+ private static final String[] SUPPORTED_SSL_VERSIONS = {"TLSv1", "TLSv1.2"};
+ private static final String HTTPS_SCHEMA = "https://";
+ private static final String HTTP_SCHEMA = "http://";
+
+ private RestClient restClient;
+
+ public SyncRestClient() {
+ restClient = RestClient.newClient().objectMapper(defaultObjectMapper()).httpClient(defaultHttpClient()).build();
+ }
+
+ public SyncRestClient(ObjectMapper objectMapper) {
+ restClient = RestClient.newClient().objectMapper(objectMapper).httpClient(defaultHttpClient()).build();
+ }
+
+ public SyncRestClient(CloseableHttpClient httpClient) {
+ restClient = RestClient.newClient().objectMapper(defaultObjectMapper()).httpClient(httpClient).build();
+ }
+
+ public SyncRestClient(CloseableHttpClient httpClient, ObjectMapper objectMapper) {
+ restClient = RestClient.newClient().objectMapper(objectMapper).httpClient(httpClient).build();
+ }
+
+ @Override
+ public HttpResponse<JsonNode> post(String url, Map<String, String> headers, Object body) {
+ return callWithRetryOverHttp(url, url2 -> restClient.post(url2).headers(headers).body(body).asJson());
+ }
+
+ @Override
+ public <T> HttpResponse<T> post(String url, Map<String, String> headers, Object body, Class<T> responseClass) {
+ return callWithRetryOverHttp(url,
+ url2 -> restClient.post(url2).headers(headers).body(body).asObject(responseClass));
+ }
+
+ @Override
+ public HttpResponse<JsonNode> get(String url, Map<String, String> headers, Map<String, String> routeParams) {
+ return callWithRetryOverHttp(url, url2 -> {
+ val getRequest = restClient.get(url2).headers(headers);
+ routeParams.forEach(getRequest::routeParam);
+ return getRequest.asJson();
+ });
+ }
+
+ @Override
+ public <T> HttpResponse<T> get(String url, Map<String, String> headers, Map<String, String> routeParams,
+ Class<T> responseClass) {
+ return callWithRetryOverHttp(url, url2 -> {
+ val getRequest = restClient.get(url2).headers(headers);
+ routeParams.forEach(getRequest::routeParam);
+ return getRequest.asObject(responseClass);
+ });
+ }
+
+ @Override
+ public HttpResponse<InputStream> getStream(String url, Map<String, String> headers,
+ Map<String, String> routeParams) {
+ return callWithRetryOverHttp(url, url2 -> {
+ val getRequest = restClient.get(url2).headers(headers);
+ routeParams.forEach(getRequest::routeParam);
+ return getRequest.asBinary();
+ });
+ }
+
+ @Override
+ public HttpResponse<JsonNode> put(String url, Map<String, String> headers, Object body) {
+ return callWithRetryOverHttp(url, url2 -> restClient.put(url2).headers(headers).body(body).asJson());
+ }
+
+ @Override
+ public <T> HttpResponse<T> put(String url, Map<String, String> headers, Object body, Class<T> responseClass) {
+ return callWithRetryOverHttp(url,
+ url2 -> restClient.put(url2).headers(headers).body(body).asObject(responseClass));
+ }
+
+ @Override
+ public <T> HttpResponse<T> delete(String url, Map<String, String> headers, Class<T> responseClass) {
+ return callWithRetryOverHttp(url, url2 -> restClient.delete(url2).headers(headers).asObject(responseClass));
+ }
+
+ @Override
+ public HttpResponse<JsonNode> delete(String url, Map<String, String> headers) {
+ return callWithRetryOverHttp(url, url2 -> restClient.delete(url2).headers(headers).asJson());
+ }
+
+ @Override
+ public void destroy() {
+ restClient.shutdown();
+ }
+
+ @SneakyThrows
+ private <T> HttpResponse<T> callWithRetryOverHttp(String url,
+ CheckedFunction1<String, HttpResponse<T>> httpRequest) {
+ try {
+ return httpRequest.apply(url);
+ } catch (RestClientException e) {
+ if (e.getCause() instanceof SSLException) {
+ logger.warn(EELFLoggerDelegate.debugLogger,
+ DATE_FORMAT.format(new Date()) + TRY_TO_CALL_OVER_HTTP, e);
+ return httpRequest.apply(url.replaceFirst(HTTPS_SCHEMA, HTTP_SCHEMA));
+ }
+ throw e;
+ }
+ }
+
+ private ObjectMapper defaultObjectMapper() {
+ val objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
+
+ return new ObjectMapper() {
+ @Override
+ @SneakyThrows
+ public <T> T readValue(String value, Class<T> aClass) {
+ return objectMapper.readValue(value, aClass);
+ }
+
+ @Override
+ @SneakyThrows
+ public String writeValue(Object value) {
+ return objectMapper.writeValueAsString(value);
+ }
+ };
+ }
+
+ private CloseableHttpClient defaultHttpClient() {
+ try {
+ val trustStorePath = SystemProperties.getProperty(VidProperties.VID_TRUSTSTORE_FILENAME);
+ val trustStorePass = SystemProperties.getProperty(VidProperties.VID_TRUSTSTORE_PASSWD_X);
+ val decryptedTrustStorePass = Password.deobfuscate(trustStorePass);
+
+ val trustStore = loadTruststore(trustStorePath, decryptedTrustStorePass);
+ val sslContext = trustOwnCACerts(decryptedTrustStorePass, trustStore);
+ val sslSf = allowTLSProtocols(sslContext);
+
+ return HttpClients.custom().setSSLSocketFactory(sslSf).build();
+ } catch (IOException | CertificateException | UnrecoverableKeyException | NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
+ logger.warn(EELFLoggerDelegate.debugLogger,
+ DATE_FORMAT.format(new Date()) + CANNOT_INITIALIZE_CUSTOM_HTTP_CLIENT, e);
+ return HttpClients.createDefault();
+ }
+ }
+
+ private SSLConnectionSocketFactory allowTLSProtocols(SSLContext sslcontext) {
+ return new SSLConnectionSocketFactory(
+ sslcontext,
+ SUPPORTED_SSL_VERSIONS,
+ null,
+ SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+ }
+
+ private SSLContext trustOwnCACerts(String trustStorePass, KeyStore trustStore)
+ throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
+ return SSLContexts.custom()
+ .useTLS()
+ .loadKeyMaterial(trustStore, trustStorePass.toCharArray())
+ .loadTrustMaterial(trustStore, new TrustSelfSignedStrategy())
+ .build();
+ }
+
+ private KeyStore loadTruststore(String trustStorePath, String trustStorePass)
+ throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
+ val trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
+ try (FileInputStream instream = new FileInputStream(new File(trustStorePath))) {
+ trustStore.load(instream, trustStorePass.toCharArray());
+ }
+ return trustStore;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/client/SyncRestClientInterface.java b/onap-enabler-be/src/main/java/org/onap/osam/client/SyncRestClientInterface.java
new file mode 100644
index 0000000..a7af206
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/client/SyncRestClientInterface.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.client;
+
+import io.joshworks.restclient.http.HttpResponse;
+import io.joshworks.restclient.http.JsonNode;
+
+import java.io.InputStream;
+import java.util.Map;
+
+public interface SyncRestClientInterface {
+ class HEADERS {
+ public static final String CONTENT_TYPE = "Content-Type";
+ public static final String AUTHORIZATION = "Authorization";
+ public static final String X_ECOMP_INSTANCE_ID = "X-ECOMP-InstanceID";
+ }
+
+ HttpResponse<JsonNode> post(String url, Map<String, String> headers, Object body);
+
+ <T> HttpResponse<T> post(String url, Map<String, String> headers, Object body, Class<T> aClass);
+
+ HttpResponse<JsonNode> get(String url, Map<String, String> headers, Map<String, String> routeParams);
+
+ <T> HttpResponse<T> get(String url, Map<String, String> headers, Map<String, String> routeParams, Class<T> aClass);
+
+ HttpResponse<InputStream> getStream(String url, Map<String, String> headers, Map<String, String> routeParams);
+
+ HttpResponse<JsonNode> put(String url, Map<String, String> headers, Object body);
+
+ <T> HttpResponse<T> put(String url, Map<String, String> headers, Object body, Class<T> aClass);
+
+ <T> HttpResponse<T> delete(String url, Map<String, String> headers, Class<T> aClass);
+
+ HttpResponse<JsonNode> delete(String url, Map<String, String> headers);
+
+ void destroy();
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/controllers/AaiController.java b/onap-enabler-be/src/main/java/org/onap/osam/controllers/AaiController.java
new file mode 100644
index 0000000..398b968
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/controllers/AaiController.java
@@ -0,0 +1,749 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.aai.ServiceInstancesSearchResults;
+import org.onap.osam.aai.SubscriberData;
+import org.onap.osam.aai.SubscriberFilteredResults;
+import org.onap.osam.aai.model.AaiGetInstanceGroupsByCloudRegion;
+import org.onap.osam.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.osam.aai.model.AaiGetPnfs.Pnf;
+import org.onap.osam.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.osam.aai.util.AAIRestInterface;
+import org.onap.osam.model.VersionByInvariantIdsRequest;
+import org.onap.osam.roles.Role;
+import org.onap.osam.roles.RoleProvider;
+import org.onap.osam.roles.RoleValidator;
+import org.onap.osam.services.IAaiService;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.HandlerMapping;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static org.onap.osam.utils.Logging.getMethodName;
+
+
+@RestController
+public class AaiController extends RestrictedBaseController {
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+ /**
+ * The from app id.
+ */
+ protected String fromAppId = "VidAaiController";
+ /**
+ * The logger.
+ */
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(AaiController.class);
+ /**
+ * The model.
+ */
+ private Map<String, Object> model = new HashMap<String, Object>();
+ /**
+ * The servlet context.
+ */
+ @Autowired
+ private ServletContext servletContext;
+ /**
+ * aai service
+ */
+ @Autowired
+ private IAaiService aaiService;
+ @Autowired
+ private RoleProvider roleProvider;
+
+ @Autowired
+ private AAIRestInterface aaiRestInterface;
+
+ /**
+ * Welcome method.
+ *
+ * @param request the request
+ * @return ModelAndView The view
+ */
+ @RequestMapping(value = {"/subscriberSearch"}, method = RequestMethod.GET)
+ public ModelAndView welcome(HttpServletRequest request) {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== AaiController welcome start");
+ return new ModelAndView(getViewName());
+ }
+
+ /* @RequestMapping(value = {"/aai_get_aic_zones"}, method = RequestMethod.GET)
+ public ResponseEntity<String> getAicZones(HttpServletRequest request) throws IOException {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== getAicZones controller start");
+ AaiResponse response = aaiService.getAaiZones();
+ return aaiResponseToResponseEntity(response);
+ }*/
+
+ @RequestMapping(value = {"/aai_get_aic_zone_for_pnf/{globalCustomerId}/{serviceType}/{serviceId}"}, method = RequestMethod.GET)
+ public ResponseEntity<String> getAicZoneForPnf(@PathVariable("globalCustomerId") String globalCustomerId ,@PathVariable("serviceType") String serviceType , @PathVariable("serviceId") String serviceId ,HttpServletRequest request) throws IOException {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== getAicZoneForPnf controller start");
+ AaiResponse response = aaiService.getAicZoneForPnf(globalCustomerId , serviceType , serviceId);
+ return aaiResponseToResponseEntity(response);
+ }
+
+ @RequestMapping(value = {"/aai_get_instance_groups_by_vnf_instance_id/{vnfInstanceId}"}, method = RequestMethod.GET)
+ public ResponseEntity<String> getInstanceGroupsByVnfInstanceId(@PathVariable("vnfInstanceId") String vnfInstanceId ,HttpServletRequest request) throws IOException {
+ AaiResponse response = aaiService.getInstanceGroupsByVnfInstanceId(vnfInstanceId);
+ return aaiResponseToResponseEntity(response);
+ }
+ /**
+ * Get services from a&ai.
+ *
+ * @return ResponseEntity<String> The response entity with the logged in user uuid.
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = {"/getuserID"}, method = RequestMethod.GET)
+ public ResponseEntity<String> getUserID(HttpServletRequest request) {
+
+ String userId = ControllersUtils.extractUserId(request);
+
+ return new ResponseEntity<String>(userId, HttpStatus.OK);
+ }
+
+ /**
+ * Get services from a&ai.
+ *
+ * @return ResponseEntity<String> The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = "/aai_get_services", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doGetServices(HttpServletRequest request) throws IOException {
+ RoleValidator roleValidator = new RoleValidator(roleProvider.getUserRoles(request));
+
+ AaiResponse subscriberList = aaiService.getServices(roleValidator);
+ ResponseEntity<String> responseEntity = aaiResponseToResponseEntity(subscriberList);
+
+ return responseEntity;
+ }
+
+
+ @RequestMapping(value = {"/aai_get_version_by_invariant_id"}, method = RequestMethod.POST)
+ public ResponseEntity<String> getVersionByInvariantId(HttpServletRequest request, @RequestBody VersionByInvariantIdsRequest versions) {
+ ResponseEntity<String> responseEntity;
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ Response result = aaiService.getVersionByInvariantId(versions.versions);
+
+ return new ResponseEntity<String>(result.readEntity(String.class), HttpStatus.OK);
+ }
+
+
+ private ResponseEntity<String> aaiResponseToResponseEntity(AaiResponse aaiResponseData)
+ throws IOException {
+ ResponseEntity<String> responseEntity;
+ ObjectMapper objectMapper = new ObjectMapper();
+ if (aaiResponseData.getHttpCode() == 200) {
+ responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(aaiResponseData.getT()), HttpStatus.OK);
+ } else {
+ responseEntity = new ResponseEntity<String>(aaiResponseData.getErrorMessage(), HttpStatus.valueOf(aaiResponseData.getHttpCode()));
+ }
+ return responseEntity;
+ }
+
+ /**
+ * Lookup single service instance in a&ai. Get the service-subscription and customer, too, i guess?
+ *
+ * @param serviceInstanceId the service instance Id
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = "/aai_get_service_instance/{service-instance-id}/{service-instance-type}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doGetServiceInstance(@PathVariable("service-instance-id") String serviceInstanceId, @PathVariable("service-instance-type") String serviceInstanceType) {
+ Response resp = null;
+
+ if (serviceInstanceType.equalsIgnoreCase("Service Instance Id")) {
+ resp = doAaiGet(
+ "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:"
+ + serviceInstanceId, false);
+ } else {
+ resp = doAaiGet(
+ "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:"
+ + serviceInstanceId, false);
+ }
+ return convertResponseToResponseEntity(resp);
+ }
+
+ /**
+ * Get services from a&ai.
+ *
+ * @param globalCustomerId the global customer id
+ * @param serviceSubscriptionId the service subscription id
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = "/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doGetServices(@PathVariable("global-customer-id") String globalCustomerId,
+ @PathVariable("service-subscription-id") String serviceSubscriptionId) {
+ Response resp = doAaiGet("business/customers/customer/" + globalCustomerId
+ + "/service-subscriptions/service-subscription/" + serviceSubscriptionId + "?depth=0", false);
+ return convertResponseToResponseEntity(resp);
+ }
+
+ /**
+ * Obtain the subscriber list from a&ai.
+ *
+ * @param fullSet the full set
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = "/aai_get_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doGetSubscriberList(HttpServletRequest request, @DefaultValue("n") @QueryParam("fullSet") String fullSet) throws IOException {
+ return getFullSubscriberList(request);
+ }
+
+ /**
+ * Obtain the Target Prov Status from the System.Properties file.
+ *
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = "/get_system_prop_vnf_prov_status", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> getTargetProvStatus() {
+ String p = SystemProperties.getProperty("aai.vnf.provstatus");
+ return new ResponseEntity<String>(p, HttpStatus.OK);
+ }
+
+
+ /**
+ * Obtain the Target Prov Status from the System.Properties file.
+ *
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = "/get_operational_environments", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public AaiResponse<OperationalEnvironmentList> getOperationalEnvironments(@RequestParam(value="operationalEnvironmentType", required = false) String operationalEnvironmentType,
+ @RequestParam(value="operationalEnvironmentStatus", required = false) String operationalEnvironmentStatus) {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({}, {})", getMethodName(), operationalEnvironmentType, operationalEnvironmentStatus);
+ AaiResponse<OperationalEnvironmentList> response = aaiService.getOperationalEnvironments(operationalEnvironmentType,operationalEnvironmentStatus);
+ if (response.getHttpCode() != 200) {
+ String errorMessage = getAaiErrorMessage(response.getErrorMessage());
+ if(errorMessage != null) {
+ response = new AaiResponse<OperationalEnvironmentList>(response.getT(), errorMessage, response.getHttpCode());
+ }
+ }
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), response);
+ return response;
+ }
+
+ /**
+ * Obtain the full subscriber list from a&ai.
+ * <p>
+ * g @return ResponseEntity The response entity
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = "/aai_get_full_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> getFullSubscriberList(HttpServletRequest request) throws IOException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ ResponseEntity<String> responseEntity;
+ RoleValidator roleValidator = new RoleValidator(roleProvider.getUserRoles(request));
+ SubscriberFilteredResults subscriberList = aaiService.getFullSubscriberList(roleValidator);
+ if (subscriberList.getHttpCode() == 200) {
+ responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(subscriberList.getSubscriberList()), HttpStatus.OK);
+ } else {
+ responseEntity = new ResponseEntity<String>(subscriberList.getErrorMessage(), HttpStatus.valueOf(subscriberList.getHttpCode()));
+ }
+
+
+ return responseEntity;
+ }
+
+
+ @RequestMapping(value = "/get_vnf_data_by_globalid_and_service_type/{globalCustomerId}/{serviceType}",
+ method = RequestMethod.GET,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> getVnfDataByGlobalIdAndServiceType(HttpServletRequest request,
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType) {
+
+ Response resp = aaiService.getVNFData(globalCustomerId, serviceType);
+ return convertResponseToResponseEntity(resp);
+ }
+
+
+ /**
+ * Refresh the subscriber list from a&ai.
+ *
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = "/aai_refresh_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doRefreshSubscriberList() {
+ Response resp = getSubscribers(false);
+ return convertResponseToResponseEntity(resp);
+ }
+
+ /**
+ * Refresh the full subscriber list from a&ai.
+ *
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = "/aai_refresh_full_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doRefreshFullSubscriberList() {
+ Response resp = getSubscribers(false);
+ return convertResponseToResponseEntity(resp);
+ }
+
+ /**
+ * Get subscriber details from a&ai.
+ *
+ * @param subscriberId the subscriber id
+ * @return ResponseEntity The response entity
+ */
+ @RequestMapping(value = "/aai_sub_details/{subscriberId}", method = RequestMethod.GET)
+ public ResponseEntity<String> GetSubscriberDetails(HttpServletRequest request, @PathVariable("subscriberId") String subscriberId) throws IOException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ ResponseEntity responseEntity;
+ List<Role> roles = roleProvider.getUserRoles(request);
+ RoleValidator roleValidator = new RoleValidator(roles);
+ AaiResponse<SubscriberData> subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator);
+ String httpMessage = subscriberData.getT() != null ?
+ objectMapper.writeValueAsString(subscriberData.getT()) :
+ subscriberData.getErrorMessage();
+
+ responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.valueOf(subscriberData.getHttpCode()));
+ return responseEntity;
+ }
+
+ /**
+ * Get service instances that match the query from a&ai.
+ *
+ * @param subscriberId the subscriber id
+ * @param instanceIdentifier the service instance name or id.
+ * @param projects the projects that are related to the instance
+ * @param owningEntities the owningEntities that are related to the instance
+ * @return ResponseEntity The response entity
+ */
+ @RequestMapping(value = "/search_service_instances", method = RequestMethod.GET)
+ public ResponseEntity<String> SearchServiceInstances(HttpServletRequest request,
+ @RequestParam(value="subscriberId", required = false) String subscriberId,
+ @RequestParam(value="serviceInstanceIdentifier", required = false) String instanceIdentifier,
+ @RequestParam(value="project", required = false) List<String> projects,
+ @RequestParam(value="owningEntity", required = false) List<String> owningEntities) throws IOException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ ResponseEntity responseEntity;
+
+ List<Role> roles = roleProvider.getUserRoles(request);
+ RoleValidator roleValidator = new RoleValidator(roles);
+
+ AaiResponse<ServiceInstancesSearchResults> searchResult = aaiService.getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator, owningEntities, projects);
+
+ String httpMessage = searchResult.getT() != null ?
+ objectMapper.writeValueAsString(searchResult.getT()) :
+ searchResult.getErrorMessage();
+
+
+ if(searchResult.getT().serviceInstances.size() == 0){
+ responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.NOT_FOUND);
+
+ } else {
+ responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.valueOf(searchResult.getHttpCode()));
+
+ }
+ return responseEntity;
+ }
+
+
+
+ /**
+ * Issue a named query to a&ai.
+ *
+ * @param namedQueryId the named query id
+ * @param globalCustomerId the global customer id
+ * @param serviceType the service type
+ * @param serviceInstance the service instance
+ * @return ResponseEntity The response entity
+ */
+ @RequestMapping(value = "/aai_sub_viewedit/{namedQueryId}/{globalCustomerId}/{serviceType}/{serviceInstance}", method = RequestMethod.GET)
+ public ResponseEntity<String> viewEditGetComponentList(
+ @PathVariable("namedQueryId") String namedQueryId,
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType,
+ @PathVariable("serviceInstance") String serviceInstance) {
+
+ String componentListPayload = getComponentListPutPayload(namedQueryId, globalCustomerId, serviceType, serviceInstance);
+
+ Response resp = doAaiPost("search/named-query", componentListPayload, false);
+ return convertResponseToResponseEntity(resp);
+ }
+
+ @RequestMapping(value = "/aai_get_vnf_data/{globalCustomerId}/{serviceType}/{serviceInstanceId}", method = RequestMethod.GET)
+ public AaiResponse<String> getVnfData(
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType,
+ @PathVariable("serviceInstanceId") String serviceInstanceId) {
+
+ return aaiService.getVNFData(globalCustomerId, serviceType, serviceInstanceId);
+
+ }
+
+
+ /**
+ * Issue a named query to a&ai.
+ *
+ * @param namedQueryId the named query id
+ * @param globalCustomerId the global customer id
+ * @param serviceType the service type
+ * @return ResponseEntity The response entity
+ */
+ @RequestMapping(value = "/aai_get_models_by_service_type/{namedQueryId}/{globalCustomerId}/{serviceType}", method = RequestMethod.GET)
+ public ResponseEntity<String> viewEditGetComponentList(
+ @PathVariable("namedQueryId") String namedQueryId,
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType) {
+
+ String componentListPayload = getModelsByServiceTypePayload(namedQueryId, globalCustomerId, serviceType);
+
+ Response resp = doAaiPost("search/named-query", componentListPayload, false);
+ return convertResponseToResponseEntity(resp);
+ }
+
+ @RequestMapping(value = "/aai_get_vnf_instances/{globalCustomerId}/{serviceType}/{modelVersionId}/{modelInvariantId}/{cloudRegion}", method = RequestMethod.GET)
+ public ResponseEntity<String> getNodeTemplateInstances(
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType,
+ @PathVariable("modelVersionId") String modelVersionId,
+ @PathVariable("modelInvariantId") String modelInvariantId,
+ @PathVariable("cloudRegion") String cloudRegion) {
+
+ AaiResponse<String> resp = aaiService.getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion);
+ return new ResponseEntity<String>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
+ }
+
+ @RequestMapping(value = "/aai_get_network_collection_details/{serviceInstanceId}", method = RequestMethod.GET)
+ public ResponseEntity<String> getNetworkCollectionDetails(@PathVariable("serviceInstanceId") String serviceInstanceId) throws IOException {
+ com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
+ AaiResponse<String> resp = aaiService.getNetworkCollectionDetails(serviceInstanceId);
+
+ String httpMessage = resp.getT() != null ?
+ objectMapper.writeValueAsString(resp.getT()) :
+ resp.getErrorMessage();
+ return new ResponseEntity<String>(httpMessage, HttpStatus.valueOf(resp.getHttpCode()));
+ }
+
+ @RequestMapping(value = "/aai_get_instance_groups_by_cloudregion/{cloudOwner}/{cloudRegionId}/{networkFunction}", method = RequestMethod.GET)
+ public ResponseEntity<String> getInstanceGroupsByCloudRegion(@PathVariable("cloudOwner") String cloudOwner,
+ @PathVariable("cloudRegionId") String cloudRegionId,
+ @PathVariable("networkFunction") String networkFunction) throws IOException {
+ com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
+ AaiResponse<AaiGetInstanceGroupsByCloudRegion> resp = aaiService.getInstanceGroupsByCloudRegion(cloudOwner, cloudRegionId, networkFunction);
+
+ String httpMessage = resp.getT() != null ?
+ objectMapper.writeValueAsString(resp.getT()) :
+ resp.getErrorMessage();
+ return new ResponseEntity<String>(httpMessage, HttpStatus.valueOf(resp.getHttpCode()));
+ }
+
+ @RequestMapping(value = "/aai_get_by_uri/**", method = RequestMethod.GET)
+ public ResponseEntity<String> getByUri(HttpServletRequest request) {
+
+ String restOfTheUrl = (String) request.getAttribute(
+ HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
+ String formattedUri = restOfTheUrl.replaceFirst("/aai_get_by_uri/", "").replaceFirst("^aai/v[\\d]+/", "");
+
+ Response resp = doAaiGet(formattedUri, false);
+
+ return convertResponseToResponseEntity(resp);
+ }
+
+
+
+ @RequestMapping(value = "/aai_get_configuration/{configuration_id}", method = RequestMethod.GET)
+ public ResponseEntity<String> getSpecificConfiguration(@PathVariable("configuration_id") String configurationId) {
+
+ Response resp = doAaiGet("network/configurations/configuration/"+configurationId, false);
+
+ return convertResponseToResponseEntity(resp);
+ }
+
+ @RequestMapping(value = "/aai_get_service_instance_pnfs/{globalCustomerId}/{serviceType}/{serviceInstanceId}", method = RequestMethod.GET)
+ public List<String> getServiceInstanceAssociatedPnfs(
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType,
+ @PathVariable("serviceInstanceId") String serviceInstanceId) {
+
+ return aaiService.getServiceInstanceAssociatedPnfs(globalCustomerId, serviceType, serviceInstanceId);
+ }
+
+ /**
+ * PNF section
+ */
+ @RequestMapping(value = "/aai_get_pnfs/pnf/{pnf_id}", method = RequestMethod.GET)
+ public ResponseEntity getSpecificPnf(@PathVariable("pnf_id") String pnfId) {
+ //logger.trace(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), pnfId);
+ AaiResponse<Pnf> resp;
+ ResponseEntity<Pnf> re;
+ try {
+ resp = aaiService.getSpecificPnf(pnfId);
+ re = new ResponseEntity<Pnf>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
+ } catch (Exception e){
+ return new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ //logger.trace(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), resp.getHttpCode());
+ return re;
+ }
+
+
+ /**
+ * Obtain tenants for a given service type.
+ *
+ * @param globalCustomerId the global customer id
+ * @param serviceType the service type
+ * @return ResponseEntity The response entity
+ */
+ @RequestMapping(value = "/aai_get_tenants/{global-customer-id}/{service-type}", method = RequestMethod.GET)
+ public ResponseEntity<String> viewEditGetTenantsFromServiceType(HttpServletRequest request,
+ @PathVariable("global-customer-id") String globalCustomerId, @PathVariable("service-type") String serviceType) {
+
+ ResponseEntity responseEntity;
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ List<Role> roles = roleProvider.getUserRoles(request);
+ RoleValidator roleValidator = new RoleValidator(roles);
+ AaiResponse<GetTenantsResponse[]> response = aaiService.getTenants(globalCustomerId, serviceType, roleValidator);
+ if (response.getHttpCode() == 200) {
+ responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(response.getT()), HttpStatus.OK);
+ } else {
+ responseEntity = new ResponseEntity<String>(response.getErrorMessage(), HttpStatus.valueOf(response.getHttpCode()));
+ }
+ } catch (Exception e) {
+ responseEntity = new ResponseEntity<String>("Unable to proccess getTenants reponse", HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ return responseEntity;
+ }
+
+ @RequestMapping(value = "/aai_get_pnf_instances/{globalCustomerId}/{serviceType}/{modelVersionId}/{modelInvariantId}/{cloudRegion}/{equipVendor}/{equipModel}", method = RequestMethod.GET)
+ public ResponseEntity<String> getPnfInstances(
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType,
+ @PathVariable("modelVersionId") String modelVersionId,
+ @PathVariable("modelInvariantId") String modelInvariantId,
+ @PathVariable("cloudRegion") String cloudRegion,
+ @PathVariable("equipVendor") String equipVendor,
+ @PathVariable("equipModel") String equipModel) {
+
+ AaiResponse<String> resp = aaiService.getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, equipModel);
+ return new ResponseEntity<String>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
+ }
+
+ @RequestMapping(value = "/aai_getPortMirroringSourcePorts", method = RequestMethod.GET)
+ public Map<String, Object> getPortMirroringSourcePorts(
+ @RequestParam ("configurationIds") List<String> configurationIds) {
+
+ return configurationIds.stream()
+ .map(id -> ImmutablePair.of(id, aaiService.getPortMirroringSourcePorts(id)))
+ .collect(Collectors.toMap(Pair::getKey, Pair::getValue));
+ }
+
+ private ResponseEntity<String> convertResponseToResponseEntity(Response resp) {
+ ResponseEntity<String> respEnt;
+ ObjectMapper objectMapper = new ObjectMapper();
+ if (resp == null) {
+ respEnt = new ResponseEntity<String>("Failed to fetch data from A&AI, check server logs for details.", HttpStatus.INTERNAL_SERVER_ERROR);
+ } else {
+ respEnt = new ResponseEntity<String>(resp.readEntity(String.class), HttpStatus.valueOf(resp.getStatus()));
+ }
+ return respEnt;
+ }
+
+ /**
+ * Gets the subscribers.
+ *
+ * @param isFullSet the is full set
+ * @return the subscribers
+ */
+ private Response getSubscribers(boolean isFullSet) {
+
+ String depth = "0";
+
+ Response resp = doAaiGet("business/customers?subscriber-type=INFRA&depth=" + depth, false);
+ if (resp != null) {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getSubscribers() resp=" + resp.getStatusInfo().toString());
+ }
+ return resp;
+ }
+
+ /**
+ * Gets the subscriber details.
+ *
+ * @param subscriberId the subscriber id
+ * @return the subscriber details
+ */
+ private Response getSubscriberDetails(String subscriberId) {
+ Response resp = doAaiGet("business/customers/customer/" + subscriberId + "?depth=2", false);
+ //String resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers/customer/" + subscriberId, false);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getSubscriberDetails() resp=" + resp.getStatusInfo().toString());
+ return resp;
+ }
+
+ /**
+ * Send a GET request to a&ai.
+ *
+ * @param uri the uri
+ * @param xml the xml
+ * @return String The response
+ */
+ protected Response doAaiGet(String uri, boolean xml) {
+ String methodName = "getSubscriberList";
+ String transId = UUID.randomUUID().toString();
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ Response resp = null;
+ try {
+
+
+ resp = aaiRestInterface.RestGet(fromAppId, transId, uri, xml).getResponse();
+
+ } catch (WebApplicationException e) {
+ final String message = e.getResponse().readEntity(String.class);
+ LOGGER.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + message);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + message);
+ } catch (Exception e) {
+ LOGGER.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ }
+
+ return resp;
+ }
+
+ /**
+ * Send a POST request to a&ai.
+ *
+ * @param uri the uri
+ * @param payload the payload
+ * @param xml the xml
+ * @return String The response
+ */
+ protected Response doAaiPost(String uri, String payload, boolean xml) {
+ String methodName = "getSubscriberList";
+ String transId = UUID.randomUUID().toString();
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ Response resp = null;
+ try {
+
+ resp = aaiRestInterface.RestPost(fromAppId, uri, payload, xml);
+
+ } catch (Exception e) {
+ LOGGER.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ }
+
+ return resp;
+ }
+
+ /**
+ * Gets the component list put payload.
+ *
+ * @param namedQueryId the named query id
+ * @param globalCustomerId the global customer id
+ * @param serviceType the service type
+ * @param serviceInstance the service instance
+ * @return the component list put payload
+ */
+ private String getComponentListPutPayload(String namedQueryId, String globalCustomerId, String serviceType, String serviceInstance) {
+ return
+ " {" +
+ " \"instance-filters\": {" +
+ " \"instance-filter\": [" +
+ " {" +
+ " \"customer\": {" +
+ " \"global-customer-id\": \"" + globalCustomerId + "\"" +
+ " }," +
+ " \"service-instance\": {" +
+ " \"service-instance-id\": \"" + serviceInstance + "\"" +
+ " }," +
+ " \"service-subscription\": {" +
+ " \"service-type\": \"" + serviceType + "\"" +
+ " }" +
+ " }" +
+ " ]" +
+ " }," +
+ " \"query-parameters\": {" +
+ " \"named-query\": {" +
+ " \"named-query-uuid\": \"" + namedQueryId + "\"" +
+ " }" +
+ " }" +
+ "}";
+
+ }
+
+ private String getModelsByServiceTypePayload(String namedQueryId, String globalCustomerId, String serviceType) {
+ // TODO Auto-generated method stub
+ return " {" +
+ " \"instance-filters\": {" +
+ " \"instance-filter\": [" +
+ " {" +
+ " \"customer\": {" +
+ " \"global-customer-id\": \"" + globalCustomerId + "\"" +
+ " }," +
+ " \"service-subscription\": {" +
+ " \"service-type\": \"" + serviceType + "\"" +
+ " }" +
+ " }" +
+ " ]" +
+ " }," +
+ " \"query-parameters\": {" +
+ " \"named-query\": {" +
+ " \"named-query-uuid\": \"" + namedQueryId + "\"" +
+ " }" +
+ " }" +
+ "}";
+
+ }
+
+ private String getAaiErrorMessage(String message) {
+ try {
+ org.json.JSONObject json = new org.json.JSONObject(message);
+ json = json.getJSONObject("requestError").getJSONObject("serviceException");
+
+ return json.getString("messageId") + ": " + json.getString("text");
+
+ } catch (Exception e) {
+ return null;
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/controllers/AsyncControllerForTests.java b/onap-enabler-be/src/main/java/org/onap/osam/controllers/AsyncControllerForTests.java
new file mode 100644
index 0000000..cfc8f48
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/controllers/AsyncControllerForTests.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.model.ExceptionResponse;
+import org.onap.osam.model.JobBulk;
+import org.onap.osam.model.JobModel;
+import org.onap.osam.services.IBulkInstantiationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.ws.rs.WebApplicationException;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.springframework.http.HttpStatus.BAD_REQUEST;
+
+@RestController
+@RequestMapping("asyncForTests")
+public class AsyncControllerForTests extends OsamCoreRestrictedBaseController {
+
+ private IBulkInstantiationService bulkInstantiationService;
+
+ @Autowired
+ public AsyncControllerForTests(IBulkInstantiationService bulkInstantiationService) {
+ this.bulkInstantiationService = bulkInstantiationService;
+ }
+
+ @RequestMapping(method = RequestMethod.POST)
+ public JobBulk createAsyncJob(@RequestBody Map<String, Object> body) {
+ return bulkInstantiationService.saveBulk(body);
+ }
+
+ @RequestMapping(value = "/job/{uuid}", method = RequestMethod.GET)
+ public JobModel getJob(@PathVariable UUID uuid) {
+ return bulkInstantiationService.getJob(uuid);
+ }
+
+ @RequestMapping(value = "/error", method = RequestMethod.GET)
+ public void throwError() {
+ throw new GenericUncheckedException("dummy error");
+ }
+
+ @ExceptionHandler({IllegalArgumentException.class})
+ @ResponseStatus(value=BAD_REQUEST)
+ private ExceptionResponse exceptionHandlerBadRequest(Exception e) {
+ return ControllersUtils.handleException(e, LOGGER);
+ }
+
+ @ExceptionHandler(WebApplicationException.class)
+ private ResponseEntity webApplicationExceptionHandler(WebApplicationException e) {
+ return ControllersUtils.handleWebApplicationException(e, LOGGER);
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/controllers/AsyncInstantiationController.java b/onap-enabler-be/src/main/java/org/onap/osam/controllers/AsyncInstantiationController.java
new file mode 100644
index 0000000..7296c20
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/controllers/AsyncInstantiationController.java
@@ -0,0 +1,92 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+
+import org.onap.osam.exceptions.OperationNotAllowedException;
+import org.onap.osam.model.ExceptionResponse;
+
+import org.onap.osam.model.JobAuditStatus;
+import org.onap.osam.model.ServiceInfo;
+import org.onap.osam.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.osam.mso.MsoResponseWrapper2;
+import org.onap.osam.services.IAsyncInstantiationBusinessLogic;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.UUID;
+import static org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED;
+
+
+@RestController
+@RequestMapping(AsyncInstantiationController.ASYNC_INSTANTIATION)
+public class AsyncInstantiationController extends OsamCoreRestrictedBaseController {
+
+ public static final String ASYNC_INSTANTIATION = "asyncInstantiation";
+
+ protected final IAsyncInstantiationBusinessLogic asyncInstantiationBL;
+
+ @Autowired
+ public AsyncInstantiationController(IAsyncInstantiationBusinessLogic asyncInstantiationBL) {
+ this.asyncInstantiationBL = asyncInstantiationBL;
+ }
+
+ @ExceptionHandler(OperationNotAllowedException.class)
+ @ResponseStatus(value=METHOD_NOT_ALLOWED)
+ public ExceptionResponse illegalStateExceptionHandler(Exception e) {
+ return ControllersUtils.handleException(e, LOGGER);
+ }
+
+ @RequestMapping(method = RequestMethod.GET)
+ public List<ServiceInfo> getServicesInfo(HttpServletRequest request) {
+ return asyncInstantiationBL.getAllServicesInfo();
+ }
+
+ @RequestMapping(value = "bulk", method = RequestMethod.POST)
+ public MsoResponseWrapper2<List<String>> createBulkOfServices(@RequestBody ServiceInstantiation request, HttpServletRequest httpServletRequest) {
+ //Push to DB according the model
+
+ String userId = ControllersUtils.extractUserId(httpServletRequest);
+ List<UUID> uuids = asyncInstantiationBL.pushBulkJob(request, userId);
+
+ return new MsoResponseWrapper2(200, uuids);
+ }
+
+ @RequestMapping(value = "job/{jobId}", method = RequestMethod.DELETE)
+ public void deleteServiceInfo(@PathVariable("jobId") UUID jobId) {
+ asyncInstantiationBL.deleteJob(jobId);
+ }
+
+ @RequestMapping(value = "hide/{jobId}", method = RequestMethod.POST)
+ public void hideServiceInfo(@PathVariable("jobId") UUID jobId) {
+ asyncInstantiationBL.hideServiceInfo(jobId);
+ }
+
+ @RequestMapping(value = "auditStatus/{jobId}", method = RequestMethod.GET)
+ public List<JobAuditStatus> getJobAuditStatus(HttpServletRequest request, @PathVariable(value="jobId") UUID jobId, @RequestParam(value="source") JobAuditStatus.SourceStatus source){
+ return asyncInstantiationBL.getAuditStatuses(jobId, source);
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/controllers/ControllersUtils.java b/onap-enabler-be/src/main/java/org/onap/osam/controllers/ControllersUtils.java
new file mode 100644
index 0000000..4aaff2e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/controllers/ControllersUtils.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.model.ExceptionResponse;
+import org.springframework.http.ResponseEntity;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.WebApplicationException;
+
+import static org.onap.osam.utils.Logging.getMethodName;
+
+public class ControllersUtils {
+
+
+ public static String extractUserId(HttpServletRequest request) {
+ String userId = "";
+ HttpSession session = request.getSession();
+ if (session != null) {
+ User user = (User) session.getAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME));
+ if (user != null) {
+ //userId = user.getHrid();
+ userId = user.getLoginId();
+ if (userId == null)
+ userId = user.getOrgUserId();
+ }
+ }
+ return userId;
+ }
+
+ public static ExceptionResponse handleException(Exception e, EELFLoggerDelegate logger) {
+ logger.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodName(), ExceptionUtils.getMessage(e), e);
+
+ ExceptionResponse exceptionResponse = new ExceptionResponse(e);
+ return exceptionResponse;
+ }
+
+ public static ResponseEntity handleWebApplicationException(WebApplicationException e, EELFLoggerDelegate logger) {
+ return ResponseEntity.status(e.getResponse().getStatus()).body(ControllersUtils.handleException(e, logger));
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/controllers/FeatureTogglingController.java b/onap-enabler-be/src/main/java/org/onap/osam/controllers/FeatureTogglingController.java
new file mode 100644
index 0000000..f145a49
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/controllers/FeatureTogglingController.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import org.onap.osam.properties.Features;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@RequestMapping("flags")
+public class FeatureTogglingController extends RestrictedBaseController {
+
+ @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public @ResponseBody Map<String,Boolean> getFeatureToggles()
+ {
+ HashMap<String,Boolean> flags = new HashMap <String, Boolean>();
+ for(Features flag : Features.values()){
+ flags.put(flag.name(), flag.isActive());
+ }
+ return flags;
+
+
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/controllers/LoggerController.java b/onap-enabler-be/src/main/java/org/onap/osam/controllers/LoggerController.java
new file mode 100644
index 0000000..e3c273b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/controllers/LoggerController.java
@@ -0,0 +1,132 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.FileAppender;
+import ch.qos.logback.core.spi.AppenderAttachable;
+import org.apache.commons.io.input.ReversedLinesFileReader;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.osam.model.ExceptionResponse;
+import org.onap.osam.roles.Role;
+import org.onap.osam.roles.RoleProvider;
+import org.onap.osam.utils.Streams;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.NotAuthorizedException;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static com.att.eelf.configuration.Configuration.GENERAL_LOGGER_NAME;
+
+
+@RestController
+@RequestMapping("logger")
+public class LoggerController extends RestrictedBaseController {
+
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(LoggerController.class);
+
+ @Autowired
+ RoleProvider roleProvider;
+
+ @RequestMapping(value = "/{loggerName:audit|error|metrics}", method = RequestMethod.GET)
+ public String getLog(@PathVariable String loggerName, HttpServletRequest request,
+ @RequestParam(value="limit", defaultValue = "5000") Integer limit) throws IOException {
+
+ List<Role> roles = roleProvider.getUserRoles(request);
+ boolean userPermitted = roleProvider.userPermissionIsReadLogs(roles);
+ if (!userPermitted) {
+ throw new NotAuthorizedException("User not authorized to get logs");
+ }
+
+ String logfilePath = getLogfilePath(loggerName);
+
+ try (final ReversedLinesFileReader reader = new ReversedLinesFileReader(new File(logfilePath))) {
+ Supplier<String> reverseLinesSupplier = () -> {
+ try {
+ return reader.readLine();
+ } catch (NullPointerException e) {
+ // EOF Reached
+ return null;
+ } catch (IOException e) {
+ throw new InternalServerErrorException("error while reading " + logfilePath, e);
+ }
+ };
+
+ return Streams.takeWhile(
+ Stream.generate(reverseLinesSupplier),
+ line -> !StringUtils.contains(line, "Logging is started"))
+ .limit(limit)
+ .limit(5_000)
+ .filter(Objects::nonNull)
+ .collect(Collectors.joining("\n"));
+ }
+ }
+
+ private String getLogfilePath(String loggerName) {
+ LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
+ return context.getLoggerList().stream()
+ .filter(logger -> logger.getName().equals(GENERAL_LOGGER_NAME + "." + loggerName))
+ .flatMap(this::pullSubAppenders)
+ .flatMap(appender -> {
+ // Appender might be "attachable", if so - roll-up its sub-appenders
+ return (appender instanceof AppenderAttachable) ?
+ pullSubAppenders((AppenderAttachable<?>) appender) : Stream.of(appender);
+ })
+ .filter(appender -> appender instanceof FileAppender)
+ .map(appender -> (FileAppender<?>) appender)
+ .map(FileAppender::getFile)
+ .findFirst()
+ .orElseThrow(() -> new InternalServerErrorException("logfile for " + loggerName + " not found"));
+ }
+
+ private <T> Stream<Appender<T>> pullSubAppenders(AppenderAttachable<T> logger) {
+ return Streams.fromIterator(logger.iteratorForAppenders());
+ }
+
+ @ExceptionHandler({ NotAuthorizedException.class })
+ @ResponseStatus(HttpStatus.UNAUTHORIZED)
+ public String notAuthorizedHandler(NotAuthorizedException e) {
+ return "UNAUTHORIZED";
+ }
+
+ @ExceptionHandler({ IOException.class, InternalServerErrorException.class })
+ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
+ public ExceptionResponse ioExceptionHandler(Exception e) {
+ return org.onap.osam.controllers.ControllersUtils.handleException(e, LOGGER);
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/controllers/MsoConfig.java b/onap-enabler-be/src/main/java/org/onap/osam/controllers/MsoConfig.java
new file mode 100644
index 0000000..fd19f0e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/controllers/MsoConfig.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.osam.controllers;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.portalsdk.core.util.SystemProperties;
+
+import org.onap.osam.client.SyncRestClient;
+import org.onap.osam.factories.MsoRequestFactory;
+import org.onap.osam.mso.MsoBusinessLogic;
+import org.onap.osam.mso.MsoBusinessLogicImpl;
+import org.onap.osam.mso.MsoInterface;
+import org.onap.osam.mso.MsoProperties;
+import org.onap.osam.mso.rest.MsoRestClientNew;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.togglz.core.manager.FeatureManager;
+
+
+@Configuration
+public class MsoConfig {
+
+ @Bean
+ public ObjectMapper getObjectMapper() {
+ return new ObjectMapper();
+ }
+
+ @Bean
+ public MsoRequestFactory createRequestDetailsFactory(){
+ return new MsoRequestFactory();
+ }
+
+ @Bean
+ public MsoInterface getMsoClient(){
+ return new MsoRestClientNew(new SyncRestClient(MsoInterface.objectMapper()), SystemProperties.getProperty(
+ MsoProperties.MSO_SERVER_URL));
+ }
+
+ @Bean
+ public MsoBusinessLogic getMsoBusinessLogic(MsoInterface msoClient, FeatureManager featureManager){
+ return new MsoBusinessLogicImpl(msoClient, featureManager);
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/controllers/MsoController.java b/onap-enabler-be/src/main/java/org/onap/osam/controllers/MsoController.java
new file mode 100644
index 0000000..53cdde7
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/controllers/MsoController.java
@@ -0,0 +1,689 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.osam.model.ExceptionResponse;
+import org.onap.osam.mso.MsoBusinessLogic;
+import org.onap.osam.mso.MsoResponseWrapper;
+import org.onap.osam.mso.rest.Request;
+import org.onap.osam.mso.rest.RequestDetails;
+import org.onap.osam.mso.rest.RequestDetailsWrapper;
+import org.onap.osam.mso.rest.Task;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import static org.onap.osam.utils.Logging.getMethodName;
+
+//import java.util.UUID;
+//import org.springframework.http.ResponseEntity;
+//import org.springframework.http.RequestEntity;
+
+@RestController
+@RequestMapping("mso")
+public class MsoController extends RestrictedBaseController {
+
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MsoController.class);
+
+ /**
+ * The Constant dateFormat.
+ */
+ private final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /**
+ * The Constant SVC_INSTANCE_ID.
+ */
+ public final static String SVC_INSTANCE_ID = "<service_instance_id>";
+ public final static String REQUEST_TYPE = "<request_type>";
+
+ /**
+ * The Constant CONFIGURATION_ID
+ */
+ public final static String CONFIGURATION_ID = "<configuration_id>";
+
+ /**
+ * The Constant VNF_INSTANCE_ID.
+ */
+ public final static String VNF_INSTANCE_ID = "<vnf_instance_id>";
+
+ private final MsoBusinessLogic msoBusinessLogic;
+
+ @Autowired
+ public MsoController(MsoBusinessLogic msoBusinessLogic) {
+ this.msoBusinessLogic = msoBusinessLogic;
+ }
+
+ /**
+ * Creates the svc instance.
+ *
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
+ public ResponseEntity<String> createSvcInstance(HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ String methodName = "createSvcInstance";
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ // always return OK, the MSO status code is embedded in the body
+
+ MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(mso_request);
+
+ return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Creates the e2e svc instance.
+ *
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_create_e2e_svc_instance", method = RequestMethod.POST)
+ public ResponseEntity<String> createE2eSvcInstance(HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> mso_request) {
+ String methodName = "createE2eSvcInstance";
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ // always return OK, the MSO status code is embedded in the body
+
+ MsoResponseWrapper w = msoBusinessLogic.createE2eSvcInstance(mso_request.get("requestDetails"));
+
+ return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Creates the vnf.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_create_vnf_instance/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+
+ MsoResponseWrapper w = msoBusinessLogic.createVnf(mso_request, serviceInstanceId);
+
+ // always return OK, the MSO status code is embedded in the body
+
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Creates the nw instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_create_nw_instance/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ String methodName = "createNwInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
+
+ MsoResponseWrapper w = msoBusinessLogic.createNwInstance(mso_request, serviceInstanceId);
+
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Creates the volume group instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_create_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
+ HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ String methodName = "createVolumeGroupInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Creates the vf module instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_create_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> createVfModuleInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ String methodName = "createVfModuleInstance";
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.createVfModuleInstance(mso_request, serviceInstanceId, vnfInstanceId);
+
+ // always return OK, the MSO status code is embedded in the body
+
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Creates a configuration instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_create_configuration_instance/{serviceInstanceId}/configurations/", method = RequestMethod.POST)
+ public ResponseEntity<String> createConfigurationInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ HttpServletRequest request, @RequestBody RequestDetailsWrapper mso_request) {
+ String methodName = "createConfigurationInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.createConfigurationInstance(mso_request, serviceInstanceId);
+
+ // always return OK, the MSO status code is embedded in the body
+
+ return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Delete E2e svc instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_delete_e2e_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> deleteE2eSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> mso_request) {
+
+ String methodName = "deleteE2eSvcInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), mso_request);
+
+ MsoResponseWrapper w = msoBusinessLogic.deleteE2eSvcInstance(mso_request.get("requestDetails"), serviceInstanceId);
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+ // always return OK, the MSO status code is embedded in the body
+
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Delete svc instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+
+ @RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
+ public String deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ HttpServletRequest request, @RequestBody RequestDetails mso_request,
+ @RequestParam(value = "serviceStatus") String serviceStatus) {
+
+ String methodName = "deleteSvcInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), mso_request);
+ MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(mso_request, serviceInstanceId, serviceStatus);
+ // always return OK, the MSO status code is embedded in the body
+
+ return w.getResponse();
+ }
+
+ /**
+ * Delete vnf.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
+
+ public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
+ HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ String methodName = "deleteVnf";
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.deleteVnf(mso_request, serviceInstanceId, vnfInstanceId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Delete configuration instance
+ * @param serviceInstanceId the service instance id
+ * @param configurationId the configuration id
+ * @param mso_request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "mso_delete_configuration/{serviceInstanceId}/configurations/{configurationId}",
+ method = RequestMethod.POST)
+ public ResponseEntity<String> deleteConfiguration(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable ("configurationId") String configurationId,
+ @RequestBody RequestDetailsWrapper mso_request) {
+
+ String methodName = "deleteConfiguration";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger,
+ dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(mso_request, serviceInstanceId, configurationId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Activate configuration instance
+ * @param serviceInstanceId the service instace id
+ * @param configurationId the configuration id
+ * @param mso_request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "mso_activate_configuration/{serviceInstanceId}/configurations/{configurationId}",
+ method = RequestMethod.POST)
+ public ResponseEntity<String> activateConfiguration(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetails mso_request) {
+
+ MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, true);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Deactivate configuration instance
+ * @param serviceInstanceId the service instace id
+ * @param configurationId the configuration id
+ * @param mso_request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "mso_deactivate_configuration/{serviceInstanceId}/configurations/{configurationId}",
+ method = RequestMethod.POST)
+ public ResponseEntity<String> deactivateConfiguration(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetails mso_request) {
+
+ MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, false);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Disable port on configuration instance
+ * @param serviceInstanceId the service instance id
+ * @param configurationId the configuration instance id
+ * @param mso_request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "mso_disable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
+ method = RequestMethod.POST)
+ public ResponseEntity<String> disablePortOnConfiguration(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetails mso_request) {
+
+ MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, false);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Enable port on configuration instance
+ * @param serviceInstanceId the service instance id
+ * @param configurationId the configuration instance id
+ * @param mso_request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "mso_enable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
+ method = RequestMethod.POST)
+ public ResponseEntity<String> enablePortOnConfiguration(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetails mso_request) {
+
+ MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, true);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Delete vf module.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param vfModuleId the vf module id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ //mso_delete_vf_module/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/fe9000-0009-9999/vfmodules/abeeee-abeeee-abeeee
+ @RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
+ public ResponseEntity<String> deleteVfModule(
+ @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
+ @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+
+ String methodName = "deleteVfModule";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.deleteVfModule(mso_request, serviceInstanceId, vnfInstanceId, vfModuleId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Delete volume group instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param volumeGroupId the volume group id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
+ public ResponseEntity<String> deleteVolumeGroupInstance(
+ @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
+ HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ String methodName = "deleteVolumeGroupInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.deleteVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId, volumeGroupId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Delete nw instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param networkInstanceId the network instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ String methodName = "deleteNwInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(mso_request, serviceInstanceId, networkInstanceId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Gets the orchestration request.
+ *
+ * @param requestId the request id
+ * @param request the request
+ * @return the orchestration request
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
+ public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
+ HttpServletRequest request) {
+
+ String methodName = "getOrchestrationRequest";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+
+ MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Gets the orchestration requests.
+ *
+ * @param filterString the filter string
+ * @param request the request
+ * @return the orchestration requests
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
+ public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
+ HttpServletRequest request) {
+
+ String methodName = "getOrchestrationRequests";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+
+ MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * activate to a pnf instance.
+ *
+ * @param serviceInstanceId the id of the service.
+ * @param requestDetails the body of the request.
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) {
+ String methodName = "activateServiceInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
+ }
+
+ /**
+ * deactivate a service instance.
+ *
+ * @param serviceInstanceId the id of the service.
+ * @param requestDetails the body of the request.
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) {
+ String methodName = "deactivateServiceInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
+ }
+
+ /**
+ * Gets the orchestration requests for the dashboard.
+ * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
+ * @return the orchestration requests
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
+ public List<Request> getOrchestrationRequestsForDashboard() {
+
+ String methodName = "getOrchestrationRequestsForDashboard";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+
+ return msoBusinessLogic.getOrchestrationRequestsForDashboard();
+ }
+
+ /**
+ * Gets the Manual Tasks for the given request id.
+ *
+ * @param originalRequestId the id of the original request.
+ * @return the tasks
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
+ public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) {
+
+ String methodName = "getManualTasksByRequestId";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
+ }
+
+ /**
+ * Complete the manual task.
+ *
+ * @param taskId the id of the task to complete.
+ * @param requestDetails the body of the request.
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
+ public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId , @RequestBody RequestDetails requestDetails) {
+
+ String methodName = "manualTaskComplete";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
+ return new ResponseEntity<String>(w.getResponse(), HttpStatus.OK);
+ }
+
+ @RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> removeRelationshipFromServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
+ @RequestBody RequestDetails requestDetails) {
+
+ String methodName = "removeRelationshipFromServiceInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w;
+ try {
+ w = msoBusinessLogic.removeRelationshipFromServiceInstance(requestDetails, serviceInstanceId);
+ } catch (Exception e){
+ LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
+ return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
+ }
+
+ @RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> addRelationshipToServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
+ @RequestBody RequestDetails requestDetails) {
+
+ String methodName = "addRelationshipToServiceInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w;
+ try {
+ w = msoBusinessLogic.addRelationshipToServiceInstance(requestDetails, serviceInstanceId);
+ } catch (Exception e){
+ LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
+ return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
+ }
+
+ /**
+ * Exception handler.
+ *
+ * @param e the e
+ * @param response the response
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @ExceptionHandler(Exception.class)
+ private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
+
+ /*
+ * The following "logger.error" lines "should" be sufficient for logging the exception.
+ * However, the console output in my Eclipse environment is NOT showing ANY of the
+ * logger statements in this class. Thus the temporary "e.printStackTrace" statement
+ * is also included.
+ */
+
+ String methodName = "exceptionHandler";
+ LOGGER.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ LOGGER.error(EELFLoggerDelegate.errorLogger, sw.toString());
+
+ /*
+ * Temporary - IF the above mentioned "logger.error" glitch is resolved ...
+ * this statement could be removed since it would then likely result in duplicate
+ * trace output.
+ */
+ e.printStackTrace(System.err);
+
+ response.setContentType("application/json; charset=UTF-8");
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+
+ ExceptionResponse exceptionResponse = new ExceptionResponse();
+ exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
+ exceptionResponse.setMessage(e.getMessage());
+
+ response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
+
+ response.flushBuffer();
+
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/controllers/OsamCoreRestrictedBaseController.java b/onap-enabler-be/src/main/java/org/onap/osam/controllers/OsamCoreRestrictedBaseController.java
new file mode 100644
index 0000000..24dbbb5
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/controllers/OsamCoreRestrictedBaseController.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.onap.osam.model.ExceptionResponse;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
+
+import static org.onap.osam.utils.Logging.getMethodCallerName;
+import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
+
+public abstract class OsamCoreRestrictedBaseController extends RestrictedBaseController {
+
+ protected final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(this.getClass().getName());
+
+ @ExceptionHandler(MethodArgumentTypeMismatchException.class)
+ @ResponseBody
+ public ResponseEntity handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e) {
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodCallerName(), ExceptionUtils.getMessage(e), e);
+ Class<?> type = e.getRequiredType();
+ String message;
+ if (type.isEnum()) {
+ message = "The parameter " + e.getName() + " must have a value among : " + StringUtils.join(type.getEnumConstants(), ", ");
+ }
+ else {
+ message = "The parameter " + e.getName() + " must be of type " + type.getTypeName();
+ }
+ ResponseEntity response = new ResponseEntity<String>(message, HttpStatus.BAD_REQUEST);
+ return response;
+ }
+
+ @ExceptionHandler(Exception.class)
+ @ResponseStatus(value=INTERNAL_SERVER_ERROR)
+ public ExceptionResponse exceptionHandler(Exception e) {
+ return ControllersUtils.handleException(e, LOGGER);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/controllers/PodDemoController.java b/onap-enabler-be/src/main/java/org/onap/osam/controllers/PodDemoController.java
new file mode 100644
index 0000000..c401d32
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/controllers/PodDemoController.java
@@ -0,0 +1,187 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.services.IAaiService;
+import org.onap.portalsdk.core.controller.UnRestrictedBaseController;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.dao.FnAppDoaImpl;
+import org.onap.osam.model.GitRepositoryState;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+
+@RestController
+@RequestMapping("/")
+public class PodDemoController extends UnRestrictedBaseController {
+
+ @Autowired
+ private IAaiService aaiService;
+
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(PodDemoController.class);
+
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ private static final String HEALTH_CHECK_PATH = "/healthCheck";
+ private static final String GIT_PROPERTIES_FILENAME = "git.properties";
+
+ /**
+ * Model for JSON response with health-check results.
+ */
+ public class HealthStatus {
+ // Either 200 or 500
+ public int statusCode;
+
+ // Additional detail in case of error, empty in case of success.
+ public String message;
+
+ public String date;
+
+ public HealthStatus(int code, String msg) {
+ this.statusCode = code;
+ this.message = msg;
+ }
+
+ public HealthStatus(int code, String date, String msg) {
+ this.statusCode = code;
+ this.message = msg;
+ this.date = date;
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ public void setStatusCode(int code) {
+ this.statusCode = code;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String msg) {
+ this.message = msg;
+ }
+
+ public String getDate() {
+ return date;
+ }
+
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public int getProfileCount(String driver, String URL, String username, String password) {
+ FnAppDoaImpl doa = new FnAppDoaImpl();
+ int count = doa.getProfileCount(driver, URL, username, password);
+ return count;
+ }
+
+
+ /**
+ * Obtain the HealthCheck Status from the System.Properties file.
+ * Used by IDNS for redundancy
+ *
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = "/healthCheck", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public HealthStatus gethealthCheckStatusforIDNS() {
+
+ String driver = SystemProperties.getProperty("db.driver");
+ String URL = SystemProperties.getProperty("db.connectionURL");
+ String username = SystemProperties.getProperty("db.userName");
+ String password = SystemProperties.getProperty("db.password");
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "driver ::" + driver);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "URL::" + URL);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "username::" + username);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "password::" + password);
+
+
+ HealthStatus healthStatus = null;
+ try {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "Performing health check");
+ int count = getProfileCount(driver, URL, username, password);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "count:::" + count);
+ healthStatus = new HealthStatus(200, "health check succeeded");
+ } catch (Exception ex) {
+
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex);
+ healthStatus = new HealthStatus(500, "health check failed: " + ex.toString());
+ }
+ return healthStatus;
+ }
+
+ @RequestMapping(value = "/pods/getAndSaveAll", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> getAndSaveAllPods() {
+
+ return (new ResponseEntity<>("", HttpStatus.OK));
+ }
+
+ @RequestMapping(value = {"/aai_test"}, method = RequestMethod.GET)
+ public ResponseEntity<String> getAicZones(HttpServletRequest request) throws IOException {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== getAicZones controller start");
+ AaiResponse response = aaiService.getAaiZones();
+ return aaiResponseToResponseEntity(response);
+ }
+
+ private ResponseEntity<String> aaiResponseToResponseEntity(AaiResponse aaiResponseData)
+ throws IOException {
+ ResponseEntity<String> responseEntity;
+ ObjectMapper objectMapper = new ObjectMapper();
+ if (aaiResponseData.getHttpCode() == 200) {
+ responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(aaiResponseData.getT()), HttpStatus.OK);
+ } else {
+ responseEntity = new ResponseEntity<String>(aaiResponseData.getErrorMessage(), HttpStatus.valueOf(aaiResponseData.getHttpCode()));
+ }
+ return responseEntity;
+ }
+
+ @RequestMapping(value = "/commitInfo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public GitRepositoryState getCommitInfo() throws IOException {
+ Properties properties = new Properties();
+ properties.load(getClass().getClassLoader().getResourceAsStream(GIT_PROPERTIES_FILENAME));
+ return new GitRepositoryState(properties);
+ }
+}
+
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/controllers/ViewLogController.java b/onap-enabler-be/src/main/java/org/onap/osam/controllers/ViewLogController.java
new file mode 100644
index 0000000..dc98503
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/controllers/ViewLogController.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+
+@RestController
+public class ViewLogController extends RestrictedBaseController{
+
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(ViewLogController.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The servlet context. */
+ private @Autowired ServletContext servletContext;
+
+ /**
+ * Welcome.
+ *
+ * @param request the request
+ * @return the model and view
+ */
+ @RequestMapping(value = {"/viewlog" }, method = RequestMethod.GET)
+ public ModelAndView welcome(HttpServletRequest request) {
+
+ return new ModelAndView(getViewName());
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/controllers/WebConfig.java b/onap-enabler-be/src/main/java/org/onap/osam/controllers/WebConfig.java
new file mode 100644
index 0000000..32e0510
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/controllers/WebConfig.java
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.osam.aai.AaiClient;
+import org.onap.osam.aai.AaiClientInterface;
+import org.onap.osam.aai.PombaClientImpl;
+import org.onap.osam.aai.PombaClientInterface;
+import org.onap.osam.aai.PombaRestInterface;
+import org.onap.osam.aai.model.PortDetailsTranslator;
+import org.onap.osam.aai.util.AAIRestInterface;
+import org.onap.osam.aai.util.HttpsAuthClient;
+import org.onap.osam.aai.util.SSLContextProvider;
+import org.onap.osam.aai.util.ServletRequestHelper;
+import org.onap.osam.aai.util.SystemPropertyHelper;
+import org.onap.osam.client.SyncRestClient;
+import org.onap.osam.client.SyncRestClientInterface;
+import org.onap.osam.scheduler.SchedulerRestInterface;
+import org.onap.osam.scheduler.SchedulerRestInterfaceIfc;
+import org.onap.osam.services.AaiServiceImpl;
+import org.onap.osam.services.IAaiService;
+import org.onap.osam.services.IPombaService;
+import org.onap.osam.services.PombaServiceImpl;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.servlet.ServletContext;
+import java.io.File;
+
+@Configuration
+public class WebConfig {
+
+ @Bean
+ public ObjectMapper getObjectMapper() {
+ return new ObjectMapper();
+ }
+
+ @Bean
+ public IAaiService getAaiService() {
+ return new AaiServiceImpl();
+ }
+
+ @Bean
+ public PortDetailsTranslator portDetailsTranslator() {
+ return new PortDetailsTranslator();
+ }
+
+ @Bean
+ public AaiClientInterface getAaiRestInterface(@Qualifier("aaiRestInterface") AAIRestInterface restController, PortDetailsTranslator portsDetailsTranslator) {
+ return new AaiClient(restController, portsDetailsTranslator);
+ }
+
+ @Bean(name = "aaiRestInterface")
+ public AAIRestInterface aaiRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
+ return new AAIRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
+ }
+
+ @Bean
+ public PombaRestInterface getPombaRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
+ return new PombaRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
+ }
+
+ @Bean
+ public SSLContextProvider sslContextProvider() {
+ return new SSLContextProvider();
+ }
+
+ @Bean
+ public SystemPropertyHelper systemPropertyHelper() {
+ return new SystemPropertyHelper();
+ }
+
+ @Bean
+ public ServletRequestHelper servletRequestHelper() {
+ return new ServletRequestHelper();
+ }
+
+ @Bean
+ public HttpsAuthClient httpsAuthClientFactory(ServletContext servletContext, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider) {
+ final String certFilePath = new File(servletContext.getRealPath("/WEB-INF/cert/")).getAbsolutePath();
+ return new HttpsAuthClient(certFilePath, systemPropertyHelper, sslContextProvider);
+ }
+
+ @Bean
+ public SyncRestClientInterface syncRestClient() {
+ return new SyncRestClient();
+ }
+
+ @Bean
+ public IPombaService getVerifyServiceInstanceService() {
+ return new PombaServiceImpl();
+ }
+
+ @Bean
+ public PombaClientInterface getVerifyServiceInstanceClientInterface() {
+ return new PombaClientImpl();
+ }
+
+ @Bean
+ public SchedulerRestInterfaceIfc getSchedulerRestInterface(){
+ return new SchedulerRestInterface();
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/dao/FnAppDoaImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/dao/FnAppDoaImpl.java
new file mode 100644
index 0000000..1bb57d8
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/dao/FnAppDoaImpl.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.dao;
+
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
+import java.sql.*;
+
+
+public class FnAppDoaImpl {
+
+ static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnAppDoaImpl.class);
+
+ public int getProfileCount(String driver, String URL, String username, String password) {
+ Connection dbc = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ String q = null;
+ int count = 0;
+ try {
+ dbc = getConnection(URL,username,password);
+ logger.debug(EELFLoggerDelegate.debugLogger, "getConnection:::"+ dbc);
+ q = "select count(*) from fn_app";
+ pst = dbc.prepareStatement(q);
+ rs = pst.executeQuery();
+
+ if (rs.next())
+ count = rs.getInt(1);
+ } catch(Exception ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex);
+ } finally {
+ cleanup(rs,pst,dbc);
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger, "count:::"+ count);
+ return count;
+ }
+
+ public static Connection getConnection(String url, String username, String password) throws SQLException {
+ java.sql.Connection con=null;
+
+ if( url!=null && username!=null && password!=null ){
+ con = DriverManager.getConnection(url, username, password);
+ }
+
+ logger.info("Connection Successful");
+
+ return con;
+
+ }
+
+ public static void cleanup(ResultSet rs, PreparedStatement st, Connection c) {
+ if (rs != null) {
+ closeResultSet(rs);
+ }
+ if (st != null) {
+ closePreparedStatement(st);
+ }
+ if (c != null) {
+ rollbackAndCloseConnection(c);
+ }
+ }
+
+ private static void rollbackAndCloseConnection(Connection c) {
+ try {
+ c.rollback();
+ } catch (Exception e) {
+ if (logger != null)
+ logger.error("Error when trying to rollback connection", e);
+ }
+ try {
+ c.close();
+ } catch (Exception e) {
+ if (logger != null)
+ logger.error("Error when trying to close connection", e);
+ }
+ }
+
+ private static void closePreparedStatement(PreparedStatement st) {
+ try {
+ st.close();
+ } catch (Exception e) {
+ if (logger != null)
+ logger.error("Error when trying to close statement", e);
+ }
+ }
+
+ private static void closeResultSet(ResultSet rs) {
+ try {
+ rs.close();
+ } catch (Exception e) {
+ if (logger != null)
+ logger.error("Error when trying to close result set", e);
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/dao/ProfileDao.java b/onap-enabler-be/src/main/java/org/onap/osam/dao/ProfileDao.java
new file mode 100644
index 0000000..22afd2e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/dao/ProfileDao.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.dao;
+
+import java.util.List;
+import org.onap.portalsdk.core.domain.Profile;
+
+public interface ProfileDao {
+
+ List<Profile> findAll();
+
+ /**
+ * Gets the profile.
+ *
+ * @param id the id
+ * @return the profile
+ */
+ Profile getProfile(int id);
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/exceptions/DbFailureUncheckedException.java b/onap-enabler-be/src/main/java/org/onap/osam/exceptions/DbFailureUncheckedException.java
new file mode 100644
index 0000000..084833e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/exceptions/DbFailureUncheckedException.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.exceptions;
+
+public class DbFailureUncheckedException extends GenericUncheckedException {
+
+
+ public DbFailureUncheckedException(String message) {
+ super(message);
+ }
+
+ public DbFailureUncheckedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DbFailureUncheckedException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/exceptions/GenericUncheckedException.java b/onap-enabler-be/src/main/java/org/onap/osam/exceptions/GenericUncheckedException.java
new file mode 100644
index 0000000..b922b90
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/exceptions/GenericUncheckedException.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.exceptions;
+
+public class GenericUncheckedException extends RuntimeException {
+ public GenericUncheckedException(String message) {
+ super(message);
+ }
+
+ public GenericUncheckedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public GenericUncheckedException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/exceptions/MaxRetriesException.java b/onap-enabler-be/src/main/java/org/onap/osam/exceptions/MaxRetriesException.java
new file mode 100644
index 0000000..6b3a77c
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/exceptions/MaxRetriesException.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.exceptions;
+
+public class MaxRetriesException extends GenericUncheckedException {
+
+ public MaxRetriesException(String operationDetails, int numberOfRetries) {
+ super(String.format("Max retries for %s, retries: %d", operationDetails, numberOfRetries));
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/exceptions/NotFoundException.java b/onap-enabler-be/src/main/java/org/onap/osam/exceptions/NotFoundException.java
new file mode 100644
index 0000000..9fa1ff2
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/exceptions/NotFoundException.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.exceptions;
+
+public class NotFoundException extends RuntimeException {
+
+ public NotFoundException(String message) {
+ super(message);
+ }
+
+ public NotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/exceptions/OperationNotAllowedException.java b/onap-enabler-be/src/main/java/org/onap/osam/exceptions/OperationNotAllowedException.java
new file mode 100644
index 0000000..c83c38d
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/exceptions/OperationNotAllowedException.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.exceptions;
+
+public class OperationNotAllowedException extends GenericUncheckedException {
+ public OperationNotAllowedException(String message) {
+ super(message);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/exceptions/VidServiceUnavailableException.java b/onap-enabler-be/src/main/java/org/onap/osam/exceptions/VidServiceUnavailableException.java
new file mode 100644
index 0000000..50432a1
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/exceptions/VidServiceUnavailableException.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@ResponseStatus(value=HttpStatus.SERVICE_UNAVAILABLE)
+public class VidServiceUnavailableException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Instantiates a new vid service unavailable exception.
+ */
+ public VidServiceUnavailableException() {
+ super();
+ }
+
+ /**
+ * Instantiates a new vid service unavailable exception.
+ *
+ * @param msg the msg
+ */
+ public VidServiceUnavailableException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Instantiates a new vid service unavailable exception.
+ *
+ * @param t the t
+ */
+ public VidServiceUnavailableException(Throwable t) {
+ super(t);
+ }
+
+ /**
+ * Instantiates a new vid service unavailable exception.
+ *
+ * @param msg the msg
+ * @param t the t
+ */
+ public VidServiceUnavailableException(String msg, Throwable t) {
+ super(msg, t);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/factories/MsoRequestFactory.java b/onap-enabler-be/src/main/java/org/onap/osam/factories/MsoRequestFactory.java
new file mode 100644
index 0000000..0e6363a
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/factories/MsoRequestFactory.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.factories;
+
+import org.onap.osam.mso.rest.RequestDetails;
+
+public class MsoRequestFactory {
+
+ public RequestDetails createMsoRequest(String path)
+ {
+ return null;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/filters/ClientCredentialsFilter.java b/onap-enabler-be/src/main/java/org/onap/osam/filters/ClientCredentialsFilter.java
new file mode 100644
index 0000000..210a289
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/filters/ClientCredentialsFilter.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.filters;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.osam.scheduler.SchedulerProperties;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.web.filter.GenericFilterBean;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@WebFilter(urlPatterns = "/change-management/workflow/*")
+public class ClientCredentialsFilter extends GenericFilterBean {
+
+ private final static EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(ClientCredentialsFilter.class);
+
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+
+ if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse))
+ return;
+
+ String expectedAuthorization = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_BASIC_AUTH);
+ String actualAuthorization = ((HttpServletRequest)request).getHeader("Authorization");
+
+ if (verifyClientCredentials(actualAuthorization, expectedAuthorization)) {
+ LOGGER.warn(EELFLoggerDelegate.debugLogger,"Client credentials authenticated.");
+ chain.doFilter(request, response);
+ return;
+ }
+
+ LOGGER.warn(EELFLoggerDelegate.debugLogger,"Client did not provide the expected credentials.");
+ ((HttpServletResponse) response).sendError(401);
+ }
+
+ public boolean verifyClientCredentials(String actualAuthorization, String expectedAuthorization)
+ {
+ if (StringUtils.isEmpty(expectedAuthorization))
+ {
+ LOGGER.warn(EELFLoggerDelegate.debugLogger,String.format("Expected Authorization is not configured (key: %s)", SchedulerProperties.SCHEDULER_BASIC_AUTH));
+ return true;
+ }
+
+ if (StringUtils.isEmpty(actualAuthorization))
+ {
+ LOGGER.warn(EELFLoggerDelegate.debugLogger,"Authorization header is missing.");
+ return false;
+ }
+
+ return actualAuthorization.equals(expectedAuthorization);
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/filters/PromiseEcompRequestIdFilter.java b/onap-enabler-be/src/main/java/org/onap/osam/filters/PromiseEcompRequestIdFilter.java
new file mode 100644
index 0000000..9c3d918
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/filters/PromiseEcompRequestIdFilter.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.filters;
+
+
+import com.google.common.collect.ImmutableList;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.web.filter.GenericFilterBean;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.UUID;
+
+import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID;
+
+@WebFilter(urlPatterns = "/*")
+public class PromiseEcompRequestIdFilter extends GenericFilterBean {
+
+ private final static EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(PromiseEcompRequestIdFilter.class);
+ private final static String REQUEST_ID_RESPONSE_HEADER = ECOMP_REQUEST_ID + "-echo";
+
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException {
+
+ if (request instanceof HttpServletRequest) {
+ request = wrapIfNeeded(request);
+
+ if (response instanceof HttpServletResponse) {
+ final String actualRequestId = ((HttpServletRequest) request).getHeader(ECOMP_REQUEST_ID);
+ ((HttpServletResponse) response).addHeader(REQUEST_ID_RESPONSE_HEADER, actualRequestId);
+ }
+ }
+
+ chain.doFilter(request, response);
+ }
+
+ public static ServletRequest wrapIfNeeded(ServletRequest request) {
+ final HttpServletRequest httpRequest = (HttpServletRequest) request;
+ final String originalRequestId = httpRequest.getHeader(ECOMP_REQUEST_ID);
+
+ if (StringUtils.isEmpty(originalRequestId)) {
+ request = new PromiseEcompRequestIdRequestWrapper(httpRequest);
+ }
+
+ return request;
+ }
+
+ private static class PromiseEcompRequestIdRequestWrapper extends HttpServletRequestWrapper {
+
+ private final UUID requestId;
+
+ PromiseEcompRequestIdRequestWrapper(HttpServletRequest request) {
+ super(request);
+ requestId = UUID.randomUUID();
+ }
+
+ @Override
+ public String getHeader(String name) {
+ return isRequestIdHeaderName(name) ?
+ requestId.toString() : super.getHeader(name);
+ }
+
+ @Override
+ public Enumeration<String> getHeaders(String name) {
+ if (isRequestIdHeaderName(name)) {
+ return Collections.enumeration(Collections.singleton(requestId.toString()));
+ } else {
+ return super.getHeaders(name);
+ }
+ }
+
+ @Override
+ public Enumeration<String> getHeaderNames() {
+ return Collections.enumeration(ImmutableList.<String>builder()
+ .add(ECOMP_REQUEST_ID)
+ .addAll(Collections.list(super.getHeaderNames()))
+ .build());
+ }
+
+ private boolean isRequestIdHeaderName(String name) {
+ return ECOMP_REQUEST_ID.equalsIgnoreCase(name);
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/filters/TempFilterForCORS.java b/onap-enabler-be/src/main/java/org/onap/osam/filters/TempFilterForCORS.java
new file mode 100644
index 0000000..5f76026
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/filters/TempFilterForCORS.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.filters;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.web.filter.GenericFilterBean;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@WebFilter(urlPatterns = "/*")
+public class TempFilterForCORS extends GenericFilterBean {
+
+ private static final String ENV_MODE = "env.mode";
+ private Boolean devMode = null;
+
+ //dev mode is initialized here since @WebFilter doesn't support @Autowired
+ //So we are sure that SystemProperties bean was initialed only after the first call to doFilter
+ private boolean isDevMode() {
+ if (devMode!=null) {
+ return devMode;
+ }
+ else {
+ if (!SystemProperties.containsProperty(ENV_MODE)) {
+ devMode = Boolean.FALSE;
+ return devMode;
+ }
+
+ String envMode = SystemProperties.getProperty(ENV_MODE);
+ devMode = StringUtils.equalsIgnoreCase(envMode, "dev") ;
+ }
+ return devMode;
+ }
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+
+ if (isDevMode() && response instanceof HttpServletResponse) {
+ ((HttpServletResponse) response).addHeader("Access-Control-Allow-Origin", "http://localhost:3000");
+ ((HttpServletResponse) response).addHeader("Access-Control-Allow-Credentials", "true");
+ }
+ chain.doFilter(request, response);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/Job.java b/onap-enabler-be/src/main/java/org/onap/osam/job/Job.java
new file mode 100644
index 0000000..8c4deed
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/Job.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import java.util.Map;
+import java.util.UUID;
+
+public interface Job {
+
+ UUID getUuid();
+
+ void setUuid(UUID uuid);
+
+ JobStatus getStatus();
+
+ void setStatus(JobStatus status);
+
+ @JsonIgnore
+ Map<String, Object> getData();
+
+ void setTypeAndData(JobType jobType, Map<String, Object> data);
+
+ UUID getTemplateId();
+
+ void setTemplateId(UUID templateId);
+
+ void setIndexInBulk(Integer indexInBulk);
+
+ JobType getType();
+
+ enum JobStatus {
+ COMPLETED(true),
+ FAILED(true),
+ IN_PROGRESS(false),
+ PAUSE(false),
+ PENDING(false),
+ STOPPED(true);
+
+ private final Boolean finalStatus;
+ public Boolean isFinal(){return finalStatus;}
+
+ JobStatus(Boolean finalStatus)
+ {
+ this.finalStatus = finalStatus ;
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/JobAdapter.java b/onap-enabler-be/src/main/java/org/onap/osam/job/JobAdapter.java
new file mode 100644
index 0000000..b7a732d
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/JobAdapter.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job;
+
+import org.onap.osam.model.JobBulk;
+import org.onap.osam.model.JobModel;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public interface JobAdapter {
+ JobModel toModel(Job job);
+
+ JobBulk toModelBulk(List<Job> jobList);
+
+ List<Job> createBulkOfJobs(Map<String, Object> bulkRequest);
+
+ Job createJob(JobType jobType, AsyncJobRequest request, UUID templateId, String userId, Integer indexInBulk);
+
+ // Marks types that are an AsyncJob payload
+ public interface AsyncJobRequest {
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/JobCommand.java b/onap-enabler-be/src/main/java/org/onap/osam/job/JobCommand.java
new file mode 100644
index 0000000..161461b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/JobCommand.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job;
+
+import java.util.Map;
+import java.util.UUID;
+
+
+public interface JobCommand {
+
+ default JobCommand init(UUID jobUuid, Map<String, Object> data) {
+ return this;
+ }
+
+ /**
+ * @return Returns the inner state of the command. This state, once passed into init(), should
+ * bring the command back to it's state.
+ */
+ Map<String, Object> getData();
+
+ /**
+ * Execute the command represented by this instance. Assumes the instance is already init().
+ * @return A NextCommand containing the next command in chain of commands, or null if chain
+ * should be terminated. Might return itself (packed in a NextCommand).
+ */
+ NextCommand call();
+
+ default JobType getType() {
+ return JobType.jobTypeOf(this.getClass());
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/JobType.java b/onap-enabler-be/src/main/java/org/onap/osam/job/JobType.java
new file mode 100644
index 0000000..6b8f5b2
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/JobType.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job;
+
+import org.onap.osam.job.command.*;
+
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public enum JobType {
+
+ HttpCall(HttpCallCommand.class),
+ AggregateState(AggregateStateCommand.class),
+ InProgressStatus(InProgressStatusCommand.class),
+ NoOp(NoOpCommand.class),
+ ServiceInstantiation(ServiceInstantiationCommand.class);
+
+ private static final Map<Class, JobType> REVERSE_MAP = Stream.of(values()).collect(Collectors.toMap(t -> t.getCommandClass(), t -> t));
+
+ private final Class commandClass;
+
+ <T extends JobCommand> JobType(Class<T> commandClass) {
+ this.commandClass = commandClass;
+ }
+
+ public Class getCommandClass() {
+ return commandClass;
+ }
+ static JobType jobTypeOf(Class commandClass) {
+ return REVERSE_MAP.get(commandClass);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/JobsBrokerService.java b/onap-enabler-be/src/main/java/org/onap/osam/job/JobsBrokerService.java
new file mode 100644
index 0000000..3554a08
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/JobsBrokerService.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job;
+
+import java.util.Collection;
+import java.util.Optional;
+import java.util.UUID;
+
+public interface JobsBrokerService {
+
+ UUID add(Job job);
+
+ Optional<Job> pull(Job.JobStatus topic, String ownerId);
+
+ void pushBack(Job job);
+
+ Collection<Job> peek();
+
+ Job peek(UUID jobId);
+
+ void delete(UUID jobId);
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/NextCommand.java b/onap-enabler-be/src/main/java/org/onap/osam/job/NextCommand.java
new file mode 100644
index 0000000..4afb54a
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/NextCommand.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job;
+
+public class NextCommand {
+ private final Job.JobStatus status;
+ private final JobCommand command;
+
+ public NextCommand(Job.JobStatus nextStatus, JobCommand nextCommand) {
+ this.status = nextStatus;
+ this.command = nextCommand;
+ }
+
+ public NextCommand(Job.JobStatus nextStatus) {
+ this.status = nextStatus;
+ this.command = null;
+ }
+
+ public Job.JobStatus getStatus() {
+ return status;
+ }
+
+ public JobCommand getCommand() {
+ return command;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/command/AggregateStateCommand.java b/onap-enabler-be/src/main/java/org/onap/osam/job/command/AggregateStateCommand.java
new file mode 100644
index 0000000..fbbb95e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/command/AggregateStateCommand.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job.command;
+
+import org.onap.osam.job.JobCommand;
+import org.onap.osam.job.NextCommand;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import java.util.Collections;
+import java.util.Map;
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class AggregateStateCommand implements JobCommand {
+
+ @Override
+ public NextCommand call() {
+ return null;
+ }
+
+ @Override
+ public Map<String, Object> getData() {
+ return Collections.emptyMap();
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/command/HttpCallCommand.java b/onap-enabler-be/src/main/java/org/onap/osam/job/command/HttpCallCommand.java
new file mode 100644
index 0000000..79d664f
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/command/HttpCallCommand.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job.command;
+
+import com.google.common.collect.ImmutableMap;
+import org.onap.osam.job.Job;
+import org.onap.osam.job.JobCommand;
+import org.onap.osam.job.NextCommand;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Response;
+import java.util.Map;
+import java.util.UUID;
+
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class HttpCallCommand implements JobCommand {
+ private String url;
+ private UUID uuid;
+
+ public HttpCallCommand() {
+ }
+
+ public HttpCallCommand(String url, UUID uuid) {
+ init(url, uuid);
+ }
+
+ @Override
+ public NextCommand call() {
+ final Response response = ClientBuilder.newClient().target(url).request().post(Entity.text(uuid.toString()));
+ return new NextCommand(Job.JobStatus.COMPLETED);
+ }
+
+ @Override
+ public HttpCallCommand init(UUID jobUuid, Map<String, Object> data) {
+ return init((String) data.get("url"), jobUuid);
+ }
+
+ private HttpCallCommand init(String url, UUID jobUuid) {
+ this.url = url;
+ this.uuid = jobUuid;
+ return this;
+ }
+
+ @Override
+ public Map<String, Object> getData() {
+ return ImmutableMap.of("url", url);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/command/InProgressStatusCommand.java b/onap-enabler-be/src/main/java/org/onap/osam/job/command/InProgressStatusCommand.java
new file mode 100644
index 0000000..dc42136
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/command/InProgressStatusCommand.java
@@ -0,0 +1,133 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.osam.job.command;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableMap;
+import io.joshworks.restclient.http.HttpResponse;
+import org.onap.osam.job.Job.JobStatus;
+import org.onap.osam.job.JobCommand;
+import org.onap.osam.job.NextCommand;
+import org.onap.osam.mso.MsoInterface;
+import org.onap.osam.mso.rest.AsyncRequestStatus;
+import org.onap.osam.services.IAsyncInstantiationBusinessLogic;
+import org.onap.osam.services.IAuditService;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+import java.util.Map;
+import java.util.UUID;
+
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class InProgressStatusCommand implements JobCommand {
+
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(InProgressStatusCommand.class);
+
+ @Inject
+ private IAsyncInstantiationBusinessLogic asyncInstantiationBL;
+
+ @Inject
+ private MsoInterface restMso;
+
+ @Inject
+ private IAuditService auditService;
+
+ private String requestId;
+
+ private UUID jobUuid;
+
+ public InProgressStatusCommand() {
+ }
+
+ InProgressStatusCommand(UUID jobUuid, String requestId) {
+ init(jobUuid, requestId);
+ }
+
+ @Override
+ public NextCommand call() {
+
+ try {
+ String path = asyncInstantiationBL.getOrchestrationRequestsPath()+"/"+requestId;
+ HttpResponse<AsyncRequestStatus> msoResponse = restMso.get(path, AsyncRequestStatus.class);
+
+
+ JobStatus jobStatus;
+ if (msoResponse.getStatus() >= 400 || msoResponse.getBody() == null) {
+ auditService.setFailedAuditStatusFromMso(jobUuid, requestId, msoResponse.getStatus(), msoResponse.getBody().toString());
+ LOGGER.error(EELFLoggerDelegate.errorLogger,
+ "Failed to get orchestration status for {}. Status code: {}, Body: {}",
+ requestId, msoResponse.getStatus(), msoResponse.getRawBody().toString());
+ return new NextCommand(JobStatus.IN_PROGRESS, this);
+ }
+ else {
+ jobStatus = asyncInstantiationBL.calcStatus(msoResponse.getBody());
+ }
+
+ asyncInstantiationBL.auditMsoStatus(jobUuid,msoResponse.getBody().request);
+
+
+ if (jobStatus == JobStatus.FAILED) {
+ asyncInstantiationBL.handleFailedInstantiation(jobUuid);
+ }
+ else {
+ asyncInstantiationBL.updateServiceInfoAndAuditStatus(jobUuid, jobStatus);
+ }
+ //in case of JobStatus.PAUSE we leave the job itself as IN_PROGRESS, for keep tracking job progress
+ if (jobStatus == JobStatus.PAUSE) {
+ return new NextCommand(JobStatus.IN_PROGRESS, this);
+ }
+ return new NextCommand(jobStatus, this);
+ } catch (javax.ws.rs.ProcessingException e) {
+ // Retry when we can't connect MSO during getStatus
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, will retry: {}", requestId, e, e);
+ return new NextCommand(JobStatus.IN_PROGRESS, this);
+ } catch (RuntimeException e) {
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, stopping: {}", requestId, e, e);
+ return new NextCommand(JobStatus.STOPPED, this);
+ }
+ }
+
+ @Override
+ public InProgressStatusCommand init(UUID jobUuid, Map<String, Object> data) {
+ return init(jobUuid, (String) data.get("requestId"));
+ }
+
+ private InProgressStatusCommand init(UUID jobUuid, String requestId) {
+ this.requestId = requestId;
+ this.jobUuid = jobUuid;
+ return this;
+ }
+
+ @Override
+ public Map<String, Object> getData() {
+ return ImmutableMap.of("requestId", requestId);
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/command/JobCommandFactory.java b/onap-enabler-be/src/main/java/org/onap/osam/job/command/JobCommandFactory.java
new file mode 100644
index 0000000..be430b8
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/command/JobCommandFactory.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job.command;
+
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.job.Job;
+import org.onap.osam.job.JobCommand;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+import java.util.function.Function;
+
+@Component
+public class JobCommandFactory {
+
+ final Function<Class<? extends JobCommand>, JobCommand> jobFactory;
+
+ @Inject
+ public JobCommandFactory(ApplicationContext applicationContext) {
+ this.jobFactory = (jobType -> {
+ final Object commandBean = applicationContext.getBean(jobType);
+
+ if (!(commandBean instanceof JobCommand)) {
+ throw new GenericUncheckedException(commandBean.getClass() + " is not a JobCommand");
+ }
+
+ return (JobCommand) commandBean;
+ });
+ }
+
+ public JobCommandFactory(Function<Class<? extends JobCommand>, JobCommand> jobFactory) {
+ this.jobFactory = jobFactory;
+ }
+
+ public JobCommand toCommand(Job job) {
+
+ final JobCommand command = jobFactory.apply(job.getType().getCommandClass());
+ command.init(job.getUuid(), job.getData());
+
+ return command;
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/command/NoOpCommand.java b/onap-enabler-be/src/main/java/org/onap/osam/job/command/NoOpCommand.java
new file mode 100644
index 0000000..92619b0
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/command/NoOpCommand.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job.command;
+
+import org.onap.osam.job.JobCommand;
+import org.onap.osam.job.NextCommand;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import java.util.Collections;
+import java.util.Map;
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class NoOpCommand implements JobCommand {
+
+ @Override
+ public NextCommand call() {
+ return null;
+ }
+
+ @Override
+ public Map<String, Object> getData() {
+ return Collections.emptyMap();
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/command/ServiceInstantiationCommand.java b/onap-enabler-be/src/main/java/org/onap/osam/job/command/ServiceInstantiationCommand.java
new file mode 100644
index 0000000..1e03d4f
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/command/ServiceInstantiationCommand.java
@@ -0,0 +1,162 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.osam.job.command;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableMap;
+import io.joshworks.restclient.http.HttpResponse;
+import org.onap.osam.services.IAsyncInstantiationBusinessLogic;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.osam.aai.exceptions.InvalidAAIResponseException;
+import org.onap.osam.exceptions.MaxRetriesException;
+import org.onap.osam.job.Job;
+import org.onap.osam.job.JobCommand;
+import org.onap.osam.job.NextCommand;
+import org.onap.osam.model.RequestReferencesContainer;
+import org.onap.osam.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.osam.mso.MsoInterface;
+import org.onap.osam.mso.rest.RequestDetailsWrapper;
+import org.onap.osam.services.IAuditService;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+import java.util.Map;
+import java.util.UUID;
+
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class ServiceInstantiationCommand implements JobCommand {
+
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(ServiceInstantiationCommand.class);
+
+ @Inject
+ private IAsyncInstantiationBusinessLogic asyncInstantiationBL;
+
+ @Inject
+ private IAuditService auditService;
+
+ @Inject
+ private MsoInterface restMso;
+
+ private UUID uuid;
+ private ServiceInstantiation serviceInstantiationRequest;
+ private String userId;
+
+ public ServiceInstantiationCommand() {
+ }
+
+ public ServiceInstantiationCommand(UUID uuid, ServiceInstantiation serviceInstantiationRequest, String userId) {
+ init(uuid, serviceInstantiationRequest, userId);
+ }
+
+ @Override
+ public NextCommand call() {
+ RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
+ try {
+ /*requestDetailsWrapper = asyncInstantiationBL.generateServiceInstantiationRequest(
+ uuid, serviceInstantiationRequest, userId
+ );*/
+ }
+
+ //Aai return bad response while checking names uniqueness
+ catch (InvalidAAIResponseException exception) {
+ LOGGER.error("Failed to check name uniqueness in AAI. VID will try again later", exception);
+ //put the job in_progress so we will keep trying to check name uniqueness in AAI
+ //And then send the request to MSO
+ return new NextCommand(Job.JobStatus.IN_PROGRESS, this);
+ }
+
+ //Vid reached to max retries while trying to find unique name in AAI
+ catch (MaxRetriesException exception) {
+ LOGGER.error("Failed to find unused name in AAI. Set the job to FAILED ", exception);
+ return handleCommandFailed();
+ }
+
+ String path = asyncInstantiationBL.getServiceInstantiationPath(serviceInstantiationRequest);
+
+ HttpResponse<RequestReferencesContainer> msoResponse = restMso.post(path,
+ requestDetailsWrapper, RequestReferencesContainer.class);
+
+
+ if (msoResponse.getStatus() >= 200 && msoResponse.getStatus() < 400) {
+ final Job.JobStatus jobStatus = Job.JobStatus.IN_PROGRESS;
+ final String requestId = msoResponse.getBody().getRequestReferences().getRequestId();
+ final String instanceId = msoResponse.getBody().getRequestReferences().getInstanceId();
+ asyncInstantiationBL.auditVidStatus(uuid, jobStatus);
+ setInitialRequestAuditStatusFromMso(requestId);
+ asyncInstantiationBL.updateServiceInfo(uuid, x-> {
+ x.setJobStatus(jobStatus);
+ x.setServiceInstanceId(instanceId);
+ });
+
+ return new NextCommand(jobStatus, new InProgressStatusCommand(uuid, requestId));
+ } else {
+ auditService.setFailedAuditStatusFromMso(uuid,null, msoResponse.getStatus(),
+ msoResponse.getBody().toString());
+ return handleCommandFailed();
+ }
+
+ }
+
+ private void setInitialRequestAuditStatusFromMso(String requestId){
+ final String initialMsoRequestStatus = "REQUESTED";
+ asyncInstantiationBL.auditMsoStatus(uuid,initialMsoRequestStatus,requestId,null);
+ }
+
+ protected NextCommand handleCommandFailed() {
+ asyncInstantiationBL.handleFailedInstantiation(uuid);
+ return new NextCommand(Job.JobStatus.FAILED);
+ }
+
+ @Override
+ public ServiceInstantiationCommand init(UUID jobUuid, Map<String, Object> data) {
+ final Object request = data.get("request");
+
+ return init(
+ jobUuid,
+ OBJECT_MAPPER.convertValue(request, ServiceInstantiation.class),
+ (String) data.get("userId")
+ );
+ }
+
+ private ServiceInstantiationCommand init(UUID jobUuid, ServiceInstantiation serviceInstantiationRequest, String userId) {
+ this.uuid = jobUuid;
+ this.serviceInstantiationRequest = serviceInstantiationRequest;
+ this.userId = userId;
+
+ return this;
+ }
+
+ @Override
+ public Map<String, Object> getData() {
+ return ImmutableMap.of(
+ "uuid", uuid,
+ "request", serviceInstantiationRequest,
+ "userId", userId
+ );
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobAdapterImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobAdapterImpl.java
new file mode 100644
index 0000000..280eb84
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobAdapterImpl.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job.impl;
+
+import com.google.common.collect.ImmutableMap;
+import org.onap.osam.job.Job;
+import org.onap.osam.job.JobAdapter;
+import org.onap.osam.job.JobType;
+import org.onap.osam.model.JobBulk;
+import org.onap.osam.model.JobModel;
+import org.springframework.stereotype.Component;
+
+import javax.ws.rs.BadRequestException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+@Component
+public class JobAdapterImpl implements JobAdapter {
+
+ @Override
+ public JobModel toModel(Job job) {
+ JobModel jobModel = new JobModel();
+ jobModel.setUuid(job.getUuid());
+ jobModel.setStatus(job.getStatus());
+ jobModel.setTemplateId(job.getTemplateId());
+ return jobModel;
+ }
+
+ @Override
+ public JobBulk toModelBulk(List<Job> jobList) {
+ return new JobBulk(jobList.stream().map(this::toModel).collect(Collectors.toList()));
+ }
+
+ @Override
+ public Job createJob(JobType jobType, AsyncJobRequest request, UUID templateId, String userId, Integer indexInBulk){
+ JobDaoImpl job = new JobDaoImpl();
+ job.setStatus(Job.JobStatus.PENDING);
+ job.setTypeAndData(jobType, ImmutableMap.of(
+ "request", request,
+ "userId", userId));
+ job.setTemplateId(templateId);
+ job.setIndexInBulk(indexInBulk);
+ job.setUserId(userId);
+ return job;
+ }
+
+ @Override
+ public List<Job> createBulkOfJobs(Map<String, Object> bulkRequest) {
+ int count;
+ JobType jobType;
+
+ try {
+ count = (Integer) bulkRequest.get("count");
+ jobType = JobType.valueOf((String) bulkRequest.get("type"));
+ } catch (Exception exception) {
+ throw new BadRequestException(exception);
+ }
+ List<Job> jobList = new ArrayList<>(count + 1);
+ UUID templateId = UUID.randomUUID();
+ for (int i = 0; i < count; i++) {
+ Job child = new JobDaoImpl();
+ child.setTypeAndData(jobType, bulkRequest);
+ child.setStatus(Job.JobStatus.PENDING);
+ child.setTemplateId(templateId);
+ child.setIndexInBulk(i);
+ jobList.add(child);
+ }
+ return jobList;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobDaoImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobDaoImpl.java
new file mode 100644
index 0000000..c1f6c61
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobDaoImpl.java
@@ -0,0 +1,214 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job.impl;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.MoreObjects;
+import org.hibernate.annotations.Type;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.job.Job;
+import org.onap.osam.job.JobType;
+import org.onap.osam.model.VidBaseEntity;
+
+import javax.persistence.*;
+import java.io.IOException;
+import java.util.*;
+
+@Entity
+@Table(name = "vid_job")
+public class JobDaoImpl extends VidBaseEntity implements Job {
+
+ private static ObjectMapper objectMapper = new ObjectMapper();
+ private Job.JobStatus status;
+ private JobType type;
+ private Map<JobType, Map<String, Object>> data = new TreeMap<>();
+ private UUID templateId;
+ private UUID uuid;
+ private String takenBy;
+ private String userId;
+ private Integer age = 0;
+ private Integer indexInBulk = 0;
+ private Date deletedAt;
+
+ @Id
+ @Column(name = "JOB_ID", columnDefinition = "CHAR(36)")
+ @Type(type="org.hibernate.type.UUIDCharType")
+ public UUID getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+ //we use uuid instead id. So making id Transient
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getId() {
+ return this.getUuid().getLeastSignificantBits();
+ }
+
+ @Column(name = "JOB_STATUS")
+ @Enumerated(EnumType.STRING)
+ public Job.JobStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(Job.JobStatus status) {
+ this.status = status;
+ }
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "JOB_TYPE")
+ public JobType getType() {
+ return type;
+ }
+
+ public void setType(JobType type) {
+ this.type = type;
+ }
+
+ //the columnDefinition is relevant only for UT
+ @Column(name = "JOB_DATA", columnDefinition = "VARCHAR(30000)")
+ public String getDataRaw() {
+ try {
+ return objectMapper.writeValueAsString(data);
+ } catch (JsonProcessingException e) {
+ throw new GenericUncheckedException(e);
+ }
+ }
+
+ public void setDataRaw(String data) {
+ try {
+ this.data = objectMapper.readValue(data, new TypeReference<Map<JobType, Map<String, Object>>>() {
+ });
+ } catch (IOException e) {
+ throw new GenericUncheckedException(e);
+ }
+ }
+
+ @Transient
+ public Map<String, Object> getData() {
+ return data.get(getType());
+ }
+
+ @Override
+ public void setTypeAndData(JobType jobType, Map<String, Object> data) {
+ // *add* the data to map,
+ // then change state to given type
+ this.type = jobType;
+ this.data.put(jobType, data);
+ }
+
+ @Column(name = "TAKEN_BY")
+ public String getTakenBy() {
+ return takenBy;
+ }
+
+ public void setTakenBy(String takenBy) {
+ this.takenBy = takenBy;
+ }
+
+ @Type(type="org.hibernate.type.UUIDCharType")
+ @Column(name = "TEMPLATE_ID", columnDefinition = "CHAR(36)")
+ public UUID getTemplateId() {
+ return templateId;
+ }
+
+ @Override
+ public void setTemplateId(UUID templateId) {
+ this.templateId = templateId;
+ }
+
+ @Column(name="INDEX_IN_BULK")
+ public Integer getIndexInBulk() {
+ return indexInBulk;
+ }
+
+ @Override
+ public void setIndexInBulk(Integer indexInBulk) {
+ this.indexInBulk = indexInBulk;
+ }
+
+ @Column(name="USER_ID")
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ @Column(name="AGE")
+ public Integer getAge() {
+ return age;
+ }
+
+ public void setAge(Integer age) {
+ this.age = age;
+ }
+
+ @Column(name="DELETED_AT")
+ public Date getDeletedAt() {
+ return deletedAt;
+ }
+
+ public void setDeletedAt(Date deletedAt) {
+ this.deletedAt = deletedAt;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof JobDaoImpl)) return false;
+ JobDaoImpl daoJob = (JobDaoImpl) o;
+ return Objects.equals(getUuid(), daoJob.getUuid());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getUuid());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("status", status)
+ .add("type", type)
+ .add("templateId", templateId)
+ .add("uuid", uuid)
+ .add("takenBy", takenBy)
+ .add("userId", userId)
+ .add("age", age)
+ .add("created", created)
+ .add("modified", modified)
+ .add("deletedAt", deletedAt)
+ .add("data", data)
+ .toString();
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobSchedulerInitializer.java b/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobSchedulerInitializer.java
new file mode 100644
index 0000000..7a983c8
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobSchedulerInitializer.java
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job.impl;
+
+import com.google.common.collect.ImmutableMap;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.job.Job;
+import org.onap.osam.job.JobsBrokerService;
+import org.onap.osam.job.command.JobCommandFactory;
+import org.onap.osam.properties.Features;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.quartz.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+import org.springframework.stereotype.Component;
+import org.togglz.core.manager.FeatureManager;
+
+import javax.annotation.PostConstruct;
+
+import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
+
+@Component
+public class JobSchedulerInitializer {
+
+ private JobsBrokerService jobsBrokerService;
+ private SchedulerFactoryBean schedulerFactoryBean;
+ private FeatureManager featureManager;
+ private JobCommandFactory jobCommandFactory;
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JobSchedulerInitializer.class);
+
+ @Autowired
+ public JobSchedulerInitializer(
+ JobsBrokerService jobsBrokerService,
+ SchedulerFactoryBean schedulerFactoryBean,
+ FeatureManager featureManager,
+ JobCommandFactory JobCommandFactory
+ ) {
+ this.jobsBrokerService = jobsBrokerService;
+ this.schedulerFactoryBean = schedulerFactoryBean;
+ this.featureManager = featureManager;
+ this.jobCommandFactory = JobCommandFactory;
+
+ }
+
+ @PostConstruct
+ public void init() {
+ if (!featureManager.isActive(Features.FLAG_ASYNC_JOBS)) {
+ return;
+ }
+ scheduleJobWorker(Job.JobStatus.PENDING, 1);
+ scheduleJobWorker(Job.JobStatus.IN_PROGRESS, 1);
+ }
+
+ private void scheduleJobWorker(Job.JobStatus topic, int intervalInSeconds) {
+ Scheduler scheduler = schedulerFactoryBean.getScheduler();
+ JobDetail jobDetail = JobBuilder.newJob().ofType(JobWorker.class)
+ .withIdentity("AsyncWorkersJob" + topic)
+ .withDescription("Job that run async worker for " + topic)
+ .setJobData(new JobDataMap(ImmutableMap.of(
+ "jobsBrokerService", jobsBrokerService,
+ "jobCommandFactory", jobCommandFactory,
+ "featureManager", featureManager,
+ "topic", topic
+ )))
+ .build();
+ Trigger asyncWorkerTrigger = TriggerBuilder.newTrigger().forJob(jobDetail)
+ .withIdentity("AsyncWorkersTrigger" + topic)
+ .withDescription("Trigger to run async worker for " + topic)
+ .withSchedule(simpleSchedule().repeatForever().withIntervalInSeconds(intervalInSeconds))
+ .build();
+ try {
+ scheduler.scheduleJob(jobDetail, asyncWorkerTrigger);
+ } catch (SchedulerException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to schedule trigger for async worker jobs: {}", e.getMessage());
+ throw new GenericUncheckedException(e);
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobWorker.java b/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobWorker.java
new file mode 100644
index 0000000..54899ec
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobWorker.java
@@ -0,0 +1,157 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job.impl;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.osam.job.Job;
+import org.onap.osam.job.JobCommand;
+import org.onap.osam.job.JobsBrokerService;
+import org.onap.osam.job.NextCommand;
+import org.onap.osam.job.command.JobCommandFactory;
+import org.onap.osam.properties.Features;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.quartz.JobExecutionContext;
+import org.springframework.scheduling.quartz.QuartzJobBean;
+import org.springframework.stereotype.Component;
+import org.togglz.core.manager.FeatureManager;
+
+import java.util.Optional;
+import java.util.UUID;
+
+import static org.onap.osam.job.Job.JobStatus.FAILED;
+import static org.onap.osam.job.Job.JobStatus.STOPPED;
+
+@Component
+public class JobWorker extends QuartzJobBean {
+
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(JobWorker.class);
+
+ private JobsBrokerService jobsBrokerService;
+ private FeatureManager featureManager;
+ private JobCommandFactory jobCommandFactory;
+ private Job.JobStatus topic;
+
+ @Override
+ protected void executeInternal(JobExecutionContext context) {
+ Optional<Job> job;
+
+ if (!isMsoNewApiActive()) {
+ return;
+ }
+
+ job = pullJob();
+
+ while (job.isPresent()) {
+ Job nextJob = executeJobAndGetNext(job.get());
+ pushBack(nextJob);
+
+ job = pullJob();
+ }
+ }
+
+ private Optional<Job> pullJob() {
+ try {
+ return jobsBrokerService.pull(topic, UUID.randomUUID().toString());
+ } catch (Exception e) {
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "failed to pull job from queue, breaking: {}", e, e);
+ return Optional.empty();
+ }
+ }
+
+ private void pushBack(Job nextJob) {
+ try {
+ jobsBrokerService.pushBack(nextJob);
+ } catch (Exception e) {
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "failed pushing back job to queue: {}", e, e);
+ }
+ }
+
+ protected Job executeJobAndGetNext(Job job) {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "going to execute job {} of {}: {}/{}",
+ StringUtils.substring(String.valueOf(job.getUuid()), 0, 8),
+ StringUtils.substring(String.valueOf(job.getTemplateId()), 0, 8),
+ job.getStatus(), job.getType());
+
+ NextCommand nextCommand = executeCommandAndGetNext(job);
+
+ Job nextJob = setNextCommandInJob(nextCommand, job);
+
+ return nextJob;
+ }
+
+ private NextCommand executeCommandAndGetNext(Job job) {
+ NextCommand nextCommand;
+ try {
+ final JobCommand jobCommand = jobCommandFactory.toCommand(job);
+ nextCommand = jobCommand.call();
+ } catch (Exception e) {
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "error while executing job from queue: {}", e, e);
+ nextCommand = new NextCommand(FAILED);
+ }
+
+ if (nextCommand == null) {
+ nextCommand = new NextCommand(STOPPED);
+ }
+ return nextCommand;
+ }
+
+ private Job setNextCommandInJob(NextCommand nextCommand, Job job) {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "transforming job {} of {}: {}/{} -> {}{}",
+ StringUtils.substring(String.valueOf(job.getUuid()), 0, 8),
+ StringUtils.substring(String.valueOf(job.getTemplateId()), 0, 8),
+ job.getStatus(), job.getType(),
+ nextCommand.getStatus(),
+ nextCommand.getCommand() != null ? ("/" + nextCommand.getCommand().getType()) : "");
+
+ job.setStatus(nextCommand.getStatus());
+
+ if (nextCommand.getCommand() != null) {
+ job.setTypeAndData(nextCommand.getCommand().getType(), nextCommand.getCommand().getData());
+ }
+
+ return job;
+ }
+
+ private boolean isMsoNewApiActive() {
+ return featureManager.isActive(Features.FLAG_ASYNC_INSTANTIATION);
+ }
+
+
+ //used by quartz to inject JobsBrokerService into the job
+ //see JobSchedulerInitializer
+ public void setJobsBrokerService(JobsBrokerService jobsBrokerService) {
+ this.jobsBrokerService = jobsBrokerService;
+ }
+
+ public void setFeatureManager(FeatureManager featureManager) {
+ this.featureManager = featureManager;
+ }
+
+ public void setJobCommandFactory(JobCommandFactory jobCommandFactory) {
+ this.jobCommandFactory = jobCommandFactory;
+ }
+
+ public void setTopic(Job.JobStatus topic) {
+ this.topic = topic;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobsBrokerServiceInDatabaseImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobsBrokerServiceInDatabaseImpl.java
new file mode 100644
index 0000000..672197c
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/job/impl/JobsBrokerServiceInDatabaseImpl.java
@@ -0,0 +1,258 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job.impl;
+
+import org.apache.commons.lang3.StringUtils;
+import org.hibernate.SessionFactory;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.exceptions.OperationNotAllowedException;
+import org.onap.osam.job.Job;
+import org.onap.osam.job.JobsBrokerService;
+import org.onap.osam.properties.VidProperties;
+import org.onap.osam.utils.DaoUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.nio.ByteBuffer;
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.util.*;
+
+@Service
+public class JobsBrokerServiceInDatabaseImpl implements JobsBrokerService {
+
+ static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JobsBrokerServiceInDatabaseImpl.class);
+
+ private final DataAccessService dataAccessService;
+
+ private final SessionFactory sessionFactory;
+ private int maxOpenedInstantiationRequestsToMso;
+ private int pollingIntervalSeconds;
+
+ @Autowired
+ public JobsBrokerServiceInDatabaseImpl(DataAccessService dataAccessService, SessionFactory sessionFactory,
+ @Value("0") int maxOpenedInstantiationRequestsToMso,
+ @Value("10") int pollingIntervalSeconds) {
+ // tha @Value will inject conservative defaults; overridden in @PostConstruct from configuration
+ this.dataAccessService = dataAccessService;
+ this.sessionFactory = sessionFactory;
+ this.maxOpenedInstantiationRequestsToMso = maxOpenedInstantiationRequestsToMso;
+ this.pollingIntervalSeconds = pollingIntervalSeconds;
+ }
+
+ @PostConstruct
+ public void configure() {
+ maxOpenedInstantiationRequestsToMso = Integer.parseInt(SystemProperties.getProperty(VidProperties.MSO_MAX_OPENED_INSTANTIATION_REQUESTS));
+ pollingIntervalSeconds = Integer.parseInt(SystemProperties.getProperty(VidProperties.MSO_ASYNC_POLLING_INTERVAL_SECONDS));
+ }
+
+ public void deleteAll() {
+ dataAccessService.deleteDomainObjects(JobDaoImpl.class, "1=1", null);
+ }
+
+ @Override
+ public UUID add(Job job) {
+ final JobDaoImpl jobDao = castToJobDaoImpl(job);
+ jobDao.setUuid(UUID.randomUUID());
+ dataAccessService.saveDomainObject(jobDao, DaoUtils.getPropsMap());
+ return job.getUuid();
+ }
+
+ @Override
+ public Optional<Job> pull(Job.JobStatus topic, String ownerId) {
+ JobDaoImpl daoJob;
+ int updatedEntities;
+ do {
+ String query = sqlQueryForTopic(topic);
+ List<JobDaoImpl> jobs = dataAccessService.executeSQLQuery(query, JobDaoImpl.class, null);
+ if (jobs.isEmpty()) {
+ return Optional.empty();
+ }
+
+ daoJob = jobs.get(0);
+
+ final UUID uuid = daoJob.getUuid();
+ final Integer age = daoJob.getAge();
+
+ daoJob.setTakenBy(ownerId);
+
+ // It might become that daoJob was taken and pushed-back already, before we
+ // arrived here, so we're verifying the age was not pushed forward.
+ // Age is actually forwarded upon pushBack().
+ String hqlUpdate = "update JobDaoImpl job set job.takenBy = :takenBy where " +
+ " job.id = :id" +
+ " and job.age = :age" +
+ " and takenBy is null";
+ updatedEntities = DaoUtils.tryWithSessionAndTransaction(sessionFactory, session ->
+ session.createQuery(hqlUpdate)
+ .setText("id", uuid.toString())
+ .setInteger("age", age)
+ .setText("takenBy", ownerId)
+ .executeUpdate());
+
+ } while (updatedEntities == 0);
+
+ return Optional.ofNullable(daoJob);
+ }
+
+ private java.sql.Timestamp nowMinusInterval() {
+ return Timestamp.valueOf(LocalDateTime.now().minusSeconds(pollingIntervalSeconds));
+ }
+
+ private String sqlQueryForTopic(Job.JobStatus topic) {
+ switch (topic) {
+ case IN_PROGRESS:
+ return "" +
+ "select * from VID_JOB" +
+ " where" +
+ // select only non-deleted in-progress jobs
+ " JOB_STATUS = 'IN_PROGRESS'" +
+ " and TAKEN_BY is null" +
+ " and DELETED_AT is null" +
+ // give some breath, don't select jos that were recently reached
+ " and MODIFIED_DATE <= '" + nowMinusInterval() +
+ // take the oldest handled one
+ "' order by MODIFIED_DATE ASC" +
+ // select only one result
+ " limit 1";
+
+ case PENDING:
+ return "" +
+ // select only pending jobs
+ "select vid_job.* from VID_JOB " +
+ // select users have in_progress jobs
+ "left join \n" +
+ " (select user_Id, 1 as has_any_in_progress_job from VID_JOB where JOB_STATUS = 'IN_PROGRESS' or TAKEN_BY IS NOT NULL \n" +
+ "group by user_id) users_have_any_in_progress_job_tbl\n" +
+ "on vid_job.user_id = users_have_any_in_progress_job_tbl.user_id " +
+ "where JOB_STATUS = 'PENDING' and TAKEN_BY is null" +
+ // job is not deleted
+ " AND DELETED_AT is null and (\n" +
+ // limit in-progress to some amount
+ "select sum(CASE WHEN JOB_STATUS='IN_PROGRESS' or (JOB_STATUS='PENDING' and TAKEN_BY IS NOT NULL) THEN 1 ELSE 0 END) as in_progress\n" +
+ "from VID_JOB ) <" + maxOpenedInstantiationRequestsToMso + " \n " +
+ // don't take jobs from templates that already in-progress/failed
+ "and TEMPLATE_Id not in \n" +
+ "(select TEMPLATE_Id from vid_job where" +
+ " (JOB_STATUS='FAILED' and DELETED_AT is null)" + // failed but not deleted
+ " or JOB_STATUS='IN_PROGRESS'" +
+ " or TAKEN_BY IS NOT NULL)" + " \n " +
+ // prefer older jobs, but the earlier in each bulk
+ "order by has_any_in_progress_job, CREATED_DATE, INDEX_IN_BULK " +
+ // select only one result
+ "limit 1";
+ default:
+ throw new GenericUncheckedException("Unsupported topic to pull from: " + topic);
+ }
+ }
+
+
+ private byte[] getUuidAsByteArray(UUID owner) {
+ ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
+ bb.putLong(owner.getMostSignificantBits());
+ bb.putLong(owner.getLeastSignificantBits());
+ return bb.array();
+ }
+
+ @Override
+ public void pushBack(Job job) {
+ final JobDaoImpl remoteDaoJob = (JobDaoImpl) dataAccessService.getDomainObject(JobDaoImpl.class, job.getUuid(), null);
+
+ if (remoteDaoJob == null) {
+ throw new IllegalStateException("Can push back only pulled jobs. Add new jobs using add()");
+ }
+
+ if (remoteDaoJob.getTakenBy() == null) {
+ throw new IllegalStateException("Can push back only pulled jobs. This one already pushed back.");
+ }
+
+ final JobDaoImpl jobDao = castToJobDaoImpl(job);
+
+ jobDao.setTakenBy(null);
+
+ Integer age = jobDao.getAge();
+ jobDao.setAge(age + 1);
+
+ logger.debug(EELFLoggerDelegate.debugLogger, "{}/{}", jobDao.getStatus(), jobDao.getType());
+
+ dataAccessService.saveDomainObject(jobDao, DaoUtils.getPropsMap());
+ }
+
+ private JobDaoImpl castToJobDaoImpl(Job job) {
+ if (!(job instanceof JobDaoImpl)) {
+ throw new UnsupportedOperationException("Can't add " + job.getClass() + " to " + this.getClass());
+ }
+ return (JobDaoImpl) job;
+ }
+
+ @Override
+ public Collection<Job> peek() {
+ return dataAccessService.getList(JobDaoImpl.class, null);
+ }
+
+ @Override
+ public Job peek(UUID jobId) {
+ return (JobDaoImpl) dataAccessService.getDomainObject(JobDaoImpl.class, jobId, null);
+ }
+
+ @Override
+ public void delete(UUID jobId) {
+ int updatedEntities;
+ Date now = new Date();
+
+ String hqlUpdate = "update JobDaoImpl job set job.deletedAt = :now where " +
+ " job.id = :id" +
+ " and job.status in(:pending, :stopped)" +
+ " and takenBy is null";
+
+ updatedEntities = DaoUtils.tryWithSessionAndTransaction(sessionFactory, session ->
+ session.createQuery(hqlUpdate)
+ .setTimestamp("now", now)
+ .setText("id", jobId.toString())
+ .setText("pending", Job.JobStatus.PENDING.toString())
+ .setText("stopped", Job.JobStatus.STOPPED.toString())
+ .executeUpdate());
+
+ if (updatedEntities == 0) {
+ final JobDaoImpl remoteDaoJob = (JobDaoImpl) dataAccessService.getDomainObject(JobDaoImpl.class, jobId, null);
+
+ if (remoteDaoJob == null || remoteDaoJob.getUuid() == null) {
+ logger.debug(EELFLoggerDelegate.debugLogger,"jobId {}: Service does not exist", jobId);
+ throw new OperationNotAllowedException("Service does not exist");
+ }
+
+ if (!remoteDaoJob.getStatus().equals(Job.JobStatus.PENDING) && !remoteDaoJob.getStatus().equals(Job.JobStatus.STOPPED) || !StringUtils.isEmpty(remoteDaoJob.getTakenBy()) ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,"jobId {}: Service status does not allow deletion from the queue, status = {}", jobId, remoteDaoJob.getStatus() +
+ ", takenBy " + remoteDaoJob.getTakenBy());
+ throw new OperationNotAllowedException("Service status does not allow deletion from the queue");
+ }
+
+ throw new OperationNotAllowedException("Service deletion failed");
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/logging/VidLoggerAspect.java b/onap-enabler-be/src/main/java/org/onap/osam/logging/VidLoggerAspect.java
new file mode 100644
index 0000000..2847354
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/logging/VidLoggerAspect.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.logging;
+
+import org.apache.commons.lang3.StringUtils;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.onap.portalsdk.core.logging.aspect.EELFLoggerAdvice;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
+
+
+@Aspect
+@org.springframework.context.annotation.Configuration
+public class VidLoggerAspect {
+
+ private String canonicalHostName;
+ @Autowired
+ EELFLoggerAdvice advice;
+
+ public VidLoggerAspect() {
+ try {
+ final InetAddress localHost = InetAddress.getLocalHost();
+ canonicalHostName = localHost.getCanonicalHostName();
+ } catch (UnknownHostException e) {
+ // YOLO
+ canonicalHostName = null;
+ }
+ }
+
+ @Pointcut("execution(public * org.onap.osam.controller.*Controller.*(..))")
+ public void vidControllers() {}
+
+ @Around("vidControllers() && (" +
+ " @within(org.onap.portalsdk.core.logging.aspect.AuditLog)" +
+ " || @annotation(org.onap.portalsdk.core.logging.aspect.AuditLog)" +
+ " || @annotation(org.springframework.web.bind.annotation.RequestMapping)" +
+ ")")
+ public Object logAuditMethodClassAround(ProceedingJoinPoint joinPoint) throws Throwable {
+ return logAroundMethod(joinPoint, SystemProperties.SecurityEventTypeEnum.INCOMING_REST_MESSAGE);
+ }
+
+ private Object logAroundMethod(ProceedingJoinPoint joinPoint, SystemProperties.SecurityEventTypeEnum securityEventType) throws Throwable {
+ //Before
+ Object[] passOnArgs = new Object[] {joinPoint.getSignature().getDeclaringType().getName(),joinPoint.getSignature().getName()};
+ Object[] returnArgs = advice.before(securityEventType, joinPoint.getArgs(), passOnArgs);
+
+ fixServerFqdnInMDC();
+
+ //Execute the actual method
+ Object result;
+ String restStatus = "COMPLETE";
+ try {
+ result = joinPoint.proceed();
+ } catch(Exception e) {
+ restStatus = "ERROR";
+ throw e;
+ } finally {
+ fixStatusCodeInMDC(restStatus);
+ advice.after(securityEventType, restStatus, joinPoint.getArgs(), returnArgs, passOnArgs);
+ }
+
+ return result;
+ }
+
+ // Set the status code into MDC *before* the metrics log is written by advice.after()
+ private void fixStatusCodeInMDC(String restStatus) {
+ EELFLoggerDelegate.mdcPut(SystemProperties.STATUS_CODE, restStatus);
+ }
+
+ // Override the non-canonical hostname set by EELFLoggerDelegate::setGlobalLoggingContext()
+ // that was invoked by advice.before() (and some other SDK cases)
+ private void fixServerFqdnInMDC() {
+ if (!StringUtils.isBlank(canonicalHostName)) {
+ EELFLoggerDelegate.mdcPut(MDC_SERVER_FQDN, canonicalHostName);
+ }
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/CategoryParameter.java b/onap-enabler-be/src/main/java/org/onap/osam/model/CategoryParameter.java
new file mode 100644
index 0000000..d05a75c
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/CategoryParameter.java
@@ -0,0 +1,97 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+//import org.hibernate.annotations.Table;
+
+import javax.persistence.*;
+import java.util.HashSet;
+import java.util.Set;
+
+//import javax.persistence.*;
+
+@Entity
+@Table(name = "vid_category_parameter", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
+public class CategoryParameter extends VidBaseEntity {
+
+ public enum Family {
+ PARAMETER_STANDARDIZATION,
+ TENANT_ISOLATION
+ }
+
+ private String name;
+ private boolean idSupported;
+
+ @Column(name = "FAMILY")
+ @Enumerated(EnumType.STRING)
+ private String family;
+
+ public String getFamily() {
+ return family;
+ }
+
+ public void setFamily(String family) {
+ this.family = family;
+ }
+
+ private Set<CategoryParameterOption> options = new HashSet<>(0);
+
+ @Override
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "CATEGORY_ID")
+ public Long getId() {
+ return super.getId();
+ }
+
+ @Column(name = "NAME", unique = true, nullable = false, length=50)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @OneToMany(fetch = FetchType.EAGER, mappedBy = "categoryParameter")
+ public Set<CategoryParameterOption> getOptions() {
+ return options;
+ }
+
+ public void setOptions(Set<CategoryParameterOption> options) {
+ this.options = options;
+ }
+
+ public boolean addOption(CategoryParameterOption option) {
+ return options.add(option);
+ }
+
+ @Column(name = "ID_SUPPORTED")
+ public boolean isIdSupported() {
+ return idSupported;
+ }
+
+ public void setIdSupported(boolean idSupported) {
+ this.idSupported = idSupported;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/CategoryParameterOption.java b/onap-enabler-be/src/main/java/org/onap/osam/model/CategoryParameterOption.java
new file mode 100644
index 0000000..3a665b1
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/CategoryParameterOption.java
@@ -0,0 +1,156 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import org.onap.portalsdk.core.domain.support.DomainVo;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Set;
+
+@Entity
+@Table(name = "vid_category_parameter_option")
+public class CategoryParameterOption extends DomainVo {
+
+ private String appId;
+ private String name;
+
+ private CategoryParameter categoryParameter;
+
+ public CategoryParameterOption() {
+ }
+
+ public CategoryParameterOption(String appId, String name, CategoryParameter categoryParameter) {
+ setAppId(appId);
+ setName(name);
+ setCategoryParameter(categoryParameter);
+ }
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "CATEGORY_OPT_DB_ID")
+ public Long getId() {
+ return id;
+ }
+
+ @Column(name = "CATEGORY_OPT_APP_ID")
+ public String getAppId() {
+ return appId;
+ }
+
+ public void setAppId(String appId) {
+ this.appId = appId;
+ }
+
+ @Column(name = "NAME")
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @ManyToOne
+ @JoinColumn(name="CATEGORY_ID", nullable=false)
+ public CategoryParameter getCategoryParameter() {
+ return categoryParameter;
+ }
+
+ public void setCategoryParameter(CategoryParameter categoryParameter) {
+ this.categoryParameter = categoryParameter;
+ }
+
+ @Override
+ @Column(name = "CREATED_DATE")
+ public Date getCreated() {
+ return super.getCreated();
+ }
+
+ @Override
+ @Column(name = "MODIFIED_DATE")
+ public Date getModified() {
+ return super.getModified();
+ }
+
+ @Override
+ @Transient
+ public Long getCreatedId() {
+ return super.getCreatedId();
+ }
+
+ @Override
+ @Transient
+ public Long getModifiedId() {
+ return super.getModifiedId();
+ }
+
+ @Override
+ @Transient
+ public Serializable getAuditUserId() {
+ return super.getAuditUserId();
+ }
+
+ @Override
+ @Transient
+ public Long getRowNum() {
+ return super.getRowNum();
+ }
+
+ @Override
+ @Transient
+ public Set getAuditTrail() {
+ return super.getAuditTrail();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ CategoryParameterOption that = (CategoryParameterOption) o;
+
+ if (getAppId() != null ? !getAppId().equals(that.getAppId()) : that.getAppId() != null) return false;
+ if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
+ return getCategoryParameter() != null ? getCategoryParameter().equals(that.getCategoryParameter()) : that.getCategoryParameter() == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = getAppId() != null ? getAppId().hashCode() : 0;
+ result = 31 * result + (getName() != null ? getName().hashCode() : 0);
+ result = 31 * result + (getCategoryParameter() != null ? getCategoryParameter().hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "CategoryParameterOption{" +
+ "id=" + id +
+ ", key='" + appId + '\'' +
+ ", value='" + name + '\'' +
+ ", categoryParameterId=" + categoryParameter.getId() +
+ '}';
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/CommandProperty.java b/onap-enabler-be/src/main/java/org/onap/osam/model/CommandProperty.java
new file mode 100644
index 0000000..85c3f85
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/CommandProperty.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+public class CommandProperty {
+
+ private String displayName;
+
+ /** The command, "get_input" */
+ private String command;
+
+ /** The input name we refer to back under the inputs section */
+ private String inputName;
+
+ /**
+ * Gets the display name.
+ *
+ * @return the displayName
+ */
+ public String getDisplayName() {
+ return displayName;
+ }
+ /**
+ * Gets the command.
+ *
+ * @return the command
+ */
+ public String getCommand() {
+ return command;
+ }
+ /**
+ * Gets the inputName.
+ *
+ * @return the inputName
+ */
+ public String getInputName() {
+ return inputName;
+ }
+ /**
+ * Sets the display name value.
+ *
+ * @param i the new get_input value
+ */
+ public void setDisplayName(String i) {
+ this.displayName = i;
+ }
+ /**
+ * Sets the command value.
+ *
+ * @param i the new command value
+ */
+ public void setCommand(String i) {
+ this.command = i;
+ }
+
+ /**
+ * Sets the input name value.
+ *
+ * @param i the new input name value
+ */
+ public void setInputName(String i) {
+ this.inputName=i;
+ }
+
+ public String toString () {
+ String result = "displayName=" + displayName + " command=" + command + " inputName" + inputName;
+ return result;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/ExceptionResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/model/ExceptionResponse.java
new file mode 100644
index 0000000..7d7db23
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/ExceptionResponse.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import org.slf4j.MDC;
+
+import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
+
+public class ExceptionResponse {
+
+ public ExceptionResponse() {
+ }
+
+ private String exception;
+
+ /** The message. */
+ private String message;
+
+ public ExceptionResponse(String exception, String message) {
+ this.exception = exception;
+ this.message = message;
+ }
+
+ public ExceptionResponse(Exception exception) {
+ setException(exception);
+ }
+
+ /**
+ * Gets the exception.
+ *
+ * @return the exception
+ */
+ public String getException() {
+ return exception;
+ }
+
+ /**
+ * Sets the exception.
+ *
+ * @param exception the new exception
+ */
+ public void setException(String exception) {
+ this.exception = exception;
+ }
+
+ public void setException(Exception exception) {
+ setException(exception.getClass().toString().replaceFirst("^.*[\\.$]", ""));
+ setMessage(exception.getMessage() + " (Request id: " + MDC.get(MDC_KEY_REQUEST_ID) + ")");
+ }
+
+ /**
+ * Gets the message.
+ *
+ * @return the message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Sets the message.
+ *
+ * @param message the new message
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/ExceptionTranslator.java b/onap-enabler-be/src/main/java/org/onap/osam/model/ExceptionTranslator.java
new file mode 100644
index 0000000..7ba9959
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/ExceptionTranslator.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
+
+import static org.onap.osam.utils.Logging.getMethodCallerName;
+
+@ControllerAdvice
+public class ExceptionTranslator {
+
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ExceptionTranslator.class);
+
+ @ExceptionHandler(MethodArgumentTypeMismatchException.class)
+ @ResponseBody
+ public ExceptionResponse handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodCallerName(), ExceptionUtils.getMessage(e), e);
+ Class<?> type = e.getRequiredType();
+ String message;
+ if (type.isEnum()) {
+ message = "The parameter " + e.getName() + " must have a value among : " + StringUtils.join(type.getEnumConstants(), ", ");
+ }
+ else {
+ message = "The parameter " + e.getName() + " must be of type " + type.getTypeName();
+ }
+ return new ExceptionResponse(new ArgumentTypeMismatchException(message));
+ }
+
+ public static class ArgumentTypeMismatchException extends RuntimeException {
+ public ArgumentTypeMismatchException(String message) {
+ super(message);
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/GitRepositoryState.java b/onap-enabler-be/src/main/java/org/onap/osam/model/GitRepositoryState.java
new file mode 100644
index 0000000..bc07da7
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/GitRepositoryState.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.util.Properties;
+
+public class GitRepositoryState {
+
+ private final String commitId;
+ private final String commitMessageShort;
+ private final String commitTime;
+
+ public GitRepositoryState(Properties properties) {
+ this.commitId = String.valueOf(properties.get("git.commit.id"));
+ this.commitMessageShort = String.valueOf(properties.get("git.commit.message.short"));
+ this.commitTime = String.valueOf(properties.get("git.commit.time"));
+ }
+
+ public String getCommitId() {
+ return commitId;
+ }
+
+ public String getCommitMessageShort() {
+ return commitMessageShort;
+ }
+
+ public String getCommitTime() {
+ return commitTime;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/GroupProperties.java b/onap-enabler-be/src/main/java/org/onap/osam/model/GroupProperties.java
new file mode 100644
index 0000000..55aa7f4
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/GroupProperties.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+public class GroupProperties {
+ private Integer minCountInstances;
+ private Integer maxCountInstances;
+ private Integer initialCount;
+ private String vfModuleLabel;
+
+ public String getVfModuleLabel() {
+ return vfModuleLabel;
+ }
+
+ public void setVfModuleLabel(String vfModuleLabel) {
+ this.vfModuleLabel = vfModuleLabel;
+ }
+
+ public Integer getMinCountInstances() {
+ return minCountInstances;
+ }
+
+ public void setMinCountInstances(Integer minCountInstances) {
+ this.minCountInstances = minCountInstances;
+ }
+
+ public Integer getMaxCountInstances() {
+ return maxCountInstances;
+ }
+
+ public void setMaxCountInstances(Integer maxCountInstances) {
+ this.maxCountInstances = maxCountInstances;
+ }
+
+ public Integer getInitialCount() {
+ return initialCount;
+ }
+
+ public void setInitialCount(Integer initialCount) {
+ this.initialCount = initialCount;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/JobAuditStatus.java b/onap-enabler-be/src/main/java/org/onap/osam/model/JobAuditStatus.java
new file mode 100644
index 0000000..153851d
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/JobAuditStatus.java
@@ -0,0 +1,181 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.hibernate.annotations.Type;
+import org.onap.osam.job.Job.JobStatus;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
+import javax.persistence.*;
+import java.util.Date;
+import java.util.UUID;
+
+@Entity
+@Table(name = "vid_job_audit_status")
+public class JobAuditStatus extends VidBaseEntity {
+
+ static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JobAuditStatus.class);
+
+ public JobAuditStatus(){}
+
+ public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source){
+ this.jobId = jobId;
+ this.jobStatus = jobStatus;
+ this.source = source;
+ }
+
+ public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, Date date){
+ this(jobId, jobStatus, source);
+ this.created = date;
+ }
+
+ public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo) {
+ this(jobId, jobStatus, source);
+ this.requestId = requestId;
+ this.additionalInfo = additionalInfo;
+ }
+
+ public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo, Date date){
+ this(jobId, jobStatus, source, requestId, additionalInfo);
+ this.created = date;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+
+ if (o == null || getClass() != o.getClass()) return false;
+
+ JobAuditStatus that = (JobAuditStatus) o;
+
+ return new EqualsBuilder()
+ .append(jobId, that.jobId)
+ .append(jobStatus, that.jobStatus)
+ .append(source, that.source)
+ .append(requestId, that.requestId)
+ .append(additionalInfo, that.additionalInfo)
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37)
+ .append(jobId)
+ .append(jobStatus)
+ .append(source)
+ .append(requestId)
+ .append(additionalInfo)
+ .toHashCode();
+ }
+
+ public enum SourceStatus {
+ MSO,
+ VID
+ }
+
+ private UUID jobId;
+ private String jobStatus;
+ private SourceStatus source;
+ private UUID requestId;
+ private String additionalInfo;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Override
+ @Column(name = "ID", columnDefinition = "INT(11)")
+ public Long getId() {
+ return this.id;
+ }
+
+ @Column(name = "JOB_ID", columnDefinition = "CHAR(36)")
+ @Type(type="org.hibernate.type.UUIDCharType")
+ public UUID getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(UUID jobId) {
+ this.jobId = jobId;
+ }
+
+
+ @Column(name = "JOB_STATUS")
+ public String getJobStatus() {
+ return jobStatus;
+ }
+
+ public void setJobStatus(String jobStatus) {
+ this.jobStatus = jobStatus;
+ }
+
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "SOURCE")
+ public SourceStatus getSource() {
+ return source;
+ }
+
+ public void setSource(SourceStatus source) {
+ this.source = source;
+ }
+
+ @Column(name = "REQUEST_ID", columnDefinition = "CHAR(36)")
+ @Type(type="org.hibernate.type.UUIDCharType")
+ public UUID getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(UUID requestId) {
+ this.requestId = requestId;
+ }
+
+ @Column(name = "ADDITIONAL_INFO")
+ public String getAdditionalInfo() {
+ return additionalInfo;
+ }
+
+ public void setAdditionalInfo(String additionalInfo) {
+ this.additionalInfo = additionalInfo;
+ }
+
+ @Transient
+ public Boolean isFinal(){
+ try {
+ if (getSource() == SourceStatus.VID) {
+ return JobStatus.valueOf(getJobStatus()).isFinal();
+ }
+ }
+ catch (IllegalArgumentException e){
+ logger.error("JobStatus: " + getJobStatus() + " from vid isn't a value of JobStatus enum" + e.getMessage());
+ return false;
+ }
+ return false;
+ }
+
+ @Transient
+ public Date getCreatedDate() {
+ return getCreated();
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/JobBulk.java b/onap-enabler-be/src/main/java/org/onap/osam/model/JobBulk.java
new file mode 100644
index 0000000..0c2637b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/JobBulk.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.util.List;
+
+public class JobBulk {
+
+ private List<JobModel> jobs;
+
+ public JobBulk(List<JobModel> jobs) {
+ this.jobs = jobs;
+ }
+
+ public List<JobModel> getJobs() {
+ return jobs;
+ }
+
+ public void setJobs(List<JobModel> jobs) {
+ this.jobs = jobs;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/JobModel.java b/onap-enabler-be/src/main/java/org/onap/osam/model/JobModel.java
new file mode 100644
index 0000000..2520b01
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/JobModel.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import org.onap.osam.job.Job;
+import org.onap.osam.job.JobType;
+
+import java.util.UUID;
+
+public class JobModel {
+
+ private UUID uuid;
+ private Job.JobStatus status;
+ private UUID templateId;
+ private JobType type;
+
+ public UUID getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+ public Job.JobStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(Job.JobStatus status) {
+ this.status = status;
+ }
+
+ public UUID getTemplateId() {
+ return templateId;
+ }
+
+ public void setTemplateId(UUID templateId) {
+ this.templateId = templateId;
+ }
+
+ public JobType getType() {
+ return type;
+ }
+
+ public void setType(JobType type) {
+ this.type = type;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/ListOfErrorsResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/model/ListOfErrorsResponse.java
new file mode 100644
index 0000000..5732389
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/ListOfErrorsResponse.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ListOfErrorsResponse {
+ protected List<String> errors;
+
+ public ListOfErrorsResponse() {
+ this.errors = new ArrayList<>();
+ }
+
+ public ListOfErrorsResponse(List<String> errors) {
+ this.errors = errors;
+ }
+
+ public List<String> getErrors() {
+ return errors;
+ }
+
+ public void setErrors(List<String> errors) {
+ this.errors = errors;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/ModelConstants.java b/onap-enabler-be/src/main/java/org/onap/osam/model/ModelConstants.java
new file mode 100644
index 0000000..799e10d
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/ModelConstants.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+public class ModelConstants {
+
+ public final static String GET_INPUT_TAG = "get_input";
+
+ public static final String ASDC_MODEL_NAMESPACE = "asdc.model.namespace";
+ public static final String ASDC_SVC_API_PATH = "sdc.svc.api.path";
+ public static final String ASDC_RESOURCE_API_PATH = "sdc.resource.api.path";
+
+ public static final String DEFAULT_ASDC_MODEL_NAMESPACE = "org.onap.";
+ public static final String DEFAULT_ASDC_SVC_API_PATH = "sdc/v1/catalog/services";
+ public static final String DEFAULT_ASDC_RESOURCE_API_PATH = "sdc/v1/catalog/resources";
+
+ public final static String VF_MODULE = "groups.VfModule";
+ public final static String VNF = "resource.vf";
+ public final static String NETWORK = "resource.vl";
+
+ public final static String ROLE_DELIMITER = "___";
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/ModelUtil.java b/onap-enabler-be/src/main/java/org/onap/osam/model/ModelUtil.java
new file mode 100644
index 0000000..821d318
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/ModelUtil.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+public class ModelUtil {
+ /**
+ * Gets the tags for the given element according to the configured namespace
+ * @param namespaces the namespace list from the configuration
+ * @param constantValue the constant portion of the tag name, i.e. resource.vf...
+ * @return the tags
+ */
+ public static String[] getTags ( String[] namespaces, String constantValue ) {
+ String[] tags;
+ if ( namespaces == null || namespaces.length == 0 ) {
+ return null;
+ }
+ int le = namespaces.length;
+ tags = new String[le];
+ for ( int i = 0; i < le; i++ ) {
+ tags[i] = namespaces[i] + constantValue;
+ }
+ return (tags);
+ }
+ /**
+ * Determine if a note template type matches a set of configurable tags
+ * @param type the node template type
+ * @param tags the model configurable namespaces
+ * @return true if type starts with a tag in the array, false otherwise
+ */
+ public static boolean isType ( String type, String[] tags ) {
+ if ( (tags != null) && (tags.length > 0) ) {
+ for ( int i = 0; i < tags.length; i++ ) {
+ if ( type.startsWith (tags[i]) ) {
+ return (true);
+ }
+ }
+ }
+ return (false);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/MsoExceptionResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/model/MsoExceptionResponse.java
new file mode 100644
index 0000000..099f027
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/MsoExceptionResponse.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+public class MsoExceptionResponse {
+
+ public static class ServiceException {
+
+ public ServiceException(String messageId, String text) {
+ this.messageId = messageId;
+ this.text = text;
+ }
+
+ public ServiceException() {
+ }
+
+ public String messageId;
+ public String text;
+ }
+
+ public ServiceException serviceException;
+
+ public MsoExceptionResponse() {
+ }
+
+ public MsoExceptionResponse(String messageId, String text) {
+ this.serviceException = new ServiceException(messageId, text);
+ }
+
+ public MsoExceptionResponse(Exception exception) {
+ ExceptionResponse exceptionResponse = new ExceptionResponse(exception);
+ this.serviceException = new ServiceException(exceptionResponse.getException(), exceptionResponse.getMessage());
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/NameCounter.java b/onap-enabler-be/src/main/java/org/onap/osam/model/NameCounter.java
new file mode 100644
index 0000000..5df0da4
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/NameCounter.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "vid_name_counter")
+public class NameCounter {
+
+ private String name;
+ private Integer counter;
+
+ public NameCounter() {
+ }
+
+ public NameCounter(String name) {
+ this.name = name;
+ this.counter = 1;
+ }
+
+ @Id
+ @Column(name = "name", columnDefinition = "VARCHAR(100)")
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Column(name = "counter", columnDefinition = "INT")
+ public Integer getCounter() {
+ return counter;
+ }
+
+ public void setCounter(Integer counter) {
+ this.counter = counter;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/NetworkCollection.java b/onap-enabler-be/src/main/java/org/onap/osam/model/NetworkCollection.java
new file mode 100644
index 0000000..8804f25
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/NetworkCollection.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+public class NetworkCollection {
+
+ private String uuid;
+
+ private String invariantUuid;
+
+ private String name;
+
+ private String version;
+
+ private NetworkCollectionProperties networkCollectionProperties;
+
+ public NetworkCollection(){
+ this.networkCollectionProperties = new NetworkCollectionProperties();
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getInvariantUuid() {
+ return invariantUuid;
+ }
+
+ public void setInvariantUuid(String invariantUuid) {
+ this.invariantUuid = invariantUuid;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public NetworkCollectionProperties getNetworkCollectionProperties() {
+ return networkCollectionProperties;
+ }
+
+ public void setNetworkCollectionProperties(NetworkCollectionProperties networkCollectionProperties) {
+ this.networkCollectionProperties = networkCollectionProperties;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/NetworkCollectionProperties.java b/onap-enabler-be/src/main/java/org/onap/osam/model/NetworkCollectionProperties.java
new file mode 100644
index 0000000..78fc945
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/NetworkCollectionProperties.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+public class NetworkCollectionProperties {
+ private String networkCollectionFunction;
+ private String networkCollectionDescription;
+
+ public String getNetworkCollectionFunction() {
+ return networkCollectionFunction;
+ }
+
+ public void setNetworkCollectionFunction(String networkCollectionFunction) {
+ this.networkCollectionFunction = networkCollectionFunction;
+ }
+
+ public String getNetworkCollectionDescription() {
+ return networkCollectionDescription;
+ }
+
+ public void setNetworkCollectionDescription(String networkCollectionDescription) {
+ this.networkCollectionDescription = networkCollectionDescription;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/PombaInstance/PombaRequest.java b/onap-enabler-be/src/main/java/org/onap/osam/model/PombaInstance/PombaRequest.java
new file mode 100644
index 0000000..6a7b887
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/PombaInstance/PombaRequest.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model.PombaInstance;
+
+import java.util.List;
+
+public class PombaRequest {
+ public List<ServiceInstance> serviceInstanceList;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/PombaInstance/ServiceInstance.java b/onap-enabler-be/src/main/java/org/onap/osam/model/PombaInstance/ServiceInstance.java
new file mode 100644
index 0000000..c97a5cd
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/PombaInstance/ServiceInstance.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model.PombaInstance;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class ServiceInstance {
+
+ @JsonProperty
+ public String serviceInstanceId;
+
+ @JsonProperty
+ public String modelVersionId;
+
+ @JsonProperty
+ public String modelInvariantId;
+
+ @JsonProperty
+ public String customerId;
+
+ @JsonProperty
+ public String serviceType;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/ProxyResponse.java b/onap-enabler-be/src/main/java/org/onap/osam/model/ProxyResponse.java
new file mode 100644
index 0000000..e6b83e1
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/ProxyResponse.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import com.google.common.base.MoreObjects;
+
+public class ProxyResponse {
+
+ protected String errorMessage;
+
+ protected int httpCode;
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+
+ public int getHttpCode() {
+ return httpCode;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("httpCode", httpCode)
+ .add("errorMessage", errorMessage)
+ .toString();
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/RequestReferencesContainer.java b/onap-enabler-be/src/main/java/org/onap/osam/model/RequestReferencesContainer.java
new file mode 100644
index 0000000..a4bc8f2
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/RequestReferencesContainer.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import com.fasterxml.jackson.annotation.*;
+import com.google.common.base.MoreObjects;
+import org.onap.osam.domain.mso.RequestReferences;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class RequestReferencesContainer {
+ private final RequestReferences requestReferences;
+
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ public RequestReferencesContainer(@JsonProperty("requestReferences") RequestReferences requestReferences) {
+ this.requestReferences = requestReferences;
+ }
+
+ public RequestReferences getRequestReferences() {
+ return requestReferences;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("requestReferences", requestReferences)
+ .add("additionalProperties", additionalProperties)
+ .toString();
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/Resource.java b/onap-enabler-be/src/main/java/org/onap/osam/model/Resource.java
new file mode 100644
index 0000000..44e1855
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/Resource.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+public class Resource {
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/Result.java b/onap-enabler-be/src/main/java/org/onap/osam/model/Result.java
new file mode 100644
index 0000000..ae8e480
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/Result.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+public class Result {
+
+ private String result;
+
+ /**
+ * Instantiates a new result.
+ *
+ * @param result the result
+ */
+ public Result(String result) {
+ this.result = result;
+ }
+
+ /**
+ * Gets the result.
+ *
+ * @return the result
+ */
+ public String getResult() {
+ return result;
+ }
+
+ /**
+ * Sets the result.
+ *
+ * @param result the new result
+ */
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/ServiceInfo.java b/onap-enabler-be/src/main/java/org/onap/osam/model/ServiceInfo.java
new file mode 100644
index 0000000..a39d75c
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/ServiceInfo.java
@@ -0,0 +1,417 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+ package org.onap.osam.model;
+
+
+ import org.hibernate.annotations.Type;
+ import org.onap.osam.job.Job;
+ import org.onap.portalsdk.core.domain.support.DomainVo;
+
+ import javax.persistence.*;
+ import java.io.Serializable;
+ import java.util.Date;
+ import java.util.Objects;
+ import java.util.Set;
+ import java.util.UUID;
+
+@Entity
+@Table(name = "vid_service_info")
+public class ServiceInfo extends DomainVo {
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ private UUID jobId;
+ private UUID templateId;
+ private String userId;
+ private Job.JobStatus jobStatus;
+ private Date statusModifiedDate;
+ private boolean hidden;
+ private boolean pause;
+ private Date deletedAt;
+ private String owningEntityId;
+ private String owningEntityName;
+ private String project;
+ private String aicZoneId;
+ private String aicZoneName;
+ private String tenantId;
+ private String tenantName;
+ private String regionId;
+ private String regionName;
+ private String serviceType;
+ private String subscriberName;
+ private String serviceInstanceId;
+ private String serviceInstanceName;
+ private String serviceModelId;
+ private String serviceModelName;
+ private String serviceModelVersion;
+ private Date createdBulkDate;
+
+ public ServiceInfo(){
+
+ }
+
+ public ServiceInfo(String userId, Job.JobStatus jobStatus, boolean pause, UUID jobId, UUID templateId, String owningEntityId, String owningEntityName, String project, String aicZoneId, String aicZoneName, String tenantId, String tenantName, String regionId, String regionName, String serviceType, String subscriberName, String serviceInstanceId, String serviceInstanceName, String serviceModelId, String serviceModelName, String serviceModelVersion, Date createdBulkDate) {
+ this.userId = userId;
+ this.jobStatus = jobStatus;
+ this.jobId = jobId;
+ this.templateId = templateId;
+ this.pause = pause;
+ this.owningEntityId = owningEntityId;
+ this.owningEntityName = owningEntityName;
+ this.project = project;
+ this.aicZoneId = aicZoneId;
+ this.aicZoneName = aicZoneName;
+ this.tenantId = tenantId;
+ this.tenantName = tenantName;
+ this.regionId = regionId;
+ this.regionName = regionName;
+ this.serviceType = serviceType;
+ this.subscriberName = subscriberName;
+ this.serviceInstanceId = serviceInstanceId;
+ this.serviceInstanceName = serviceInstanceName;
+ this.serviceModelId = serviceModelId;
+ this.serviceModelName = serviceModelName;
+ this.serviceModelVersion = serviceModelVersion;
+ this.createdBulkDate = createdBulkDate;
+ }
+
+ @Column(name = "JOB_ID", columnDefinition = "CHAR(36)")
+ @Type(type="org.hibernate.type.UUIDCharType")
+ public UUID getJobId() {
+ return jobId;
+ }
+
+ @Column(name = "TEMPLATE_ID", columnDefinition = "CHAR(36)")
+ @Type(type="org.hibernate.type.UUIDCharType")
+ public UUID getTemplateId() {
+ return templateId;
+ }
+
+ @Column(name="USER_ID")
+ public String getUserId() {
+ return userId;
+ }
+
+ @Column(name="JOB_STATUS")
+ @Enumerated(EnumType.STRING)
+ public Job.JobStatus getJobStatus() {
+ return jobStatus;
+ }
+
+ @Column(name="STATUS_MODIFIED_DATE")
+ public Date getStatusModifiedDate() {
+ return statusModifiedDate;
+ }
+
+ @Column(name="IS_HIDDEN")
+ public boolean isHidden() {
+ return hidden;
+ }
+
+ @Column(name="IS_PAUSE")
+ public boolean isPause() {
+ return pause;
+ }
+
+ @Column(name="OWNING_ENTITY_ID")
+ public String getOwningEntityId() {
+ return owningEntityId;
+ }
+
+ @Column(name="OWNING_ENTITY_NAME")
+ public String getOwningEntityName() {
+ return owningEntityName;
+ }
+
+ @Column(name="PROJECT")
+ public String getProject() {
+ return project;
+ }
+
+ @Column(name="AIC_ZONE_ID")
+ public String getAicZoneId() {
+ return aicZoneId;
+ }
+
+ @Column(name="AIC_ZONE_NAME")
+ public String getAicZoneName() {
+ return aicZoneName;
+ }
+
+ @Column(name="TENANT_ID")
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ @Column(name="TENANT_NAME")
+ public String getTenantName() {
+ return tenantName;
+ }
+
+ @Column(name="REGION_ID")
+ public String getRegionId() {
+ return regionId;
+ }
+
+ @Column(name="REGION_NAME")
+ public String getRegionName() {
+ return regionName;
+ }
+
+ @Column(name="SERVICE_TYPE")
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ @Column(name="SUBSCRIBER_NAME")
+ public String getSubscriberName() {
+ return subscriberName;
+ }
+
+ @Column(name="SERVICE_INSTANCE_ID")
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ @Column(name="SERVICE_INSTANCE_NAME")
+ public String getServiceInstanceName() {
+ return serviceInstanceName;
+ }
+
+ @Column(name="SERVICE_MODEL_ID")
+ public String getServiceModelId() {
+ return serviceModelId;
+ }
+
+ @Column(name="SERVICE_MODEL_NAME")
+ public String getServiceModelName() {
+ return serviceModelName;
+ }
+
+ @Column(name="SERVICE_MODEL_VERSION")
+ public String getServiceModelVersion() {
+ return serviceModelVersion;
+ }
+
+ @Column(name="CREATED_BULK_DATE")
+ public Date getCreatedBulkDate() {
+ return createdBulkDate;
+ }
+
+ @Column(name="DELETED_AT")
+ public Date getDeletedAt() {
+ return deletedAt;
+ }
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Override
+ @Column(name = "ID", columnDefinition = "INT(11)")
+ public Long getId() {
+ return this.id;
+ }
+
+ @Override
+ @Column(name = "CREATED_DATE")
+ public Date getCreated() {
+ return super.getCreated();
+ }
+
+ @Override
+ @Column(name = "MODIFIED_DATE")
+ public Date getModified() {
+ return super.getModified();
+ }
+
+ @Override
+ @Transient
+ public Long getCreatedId() {
+ return super.getCreatedId();
+ }
+
+ @Override
+ @Transient
+ public Long getModifiedId() {
+ return super.getModifiedId();
+ }
+
+ @Override
+ @Transient
+ public Serializable getAuditUserId() {
+ return super.getAuditUserId();
+ }
+
+ @Override
+ @Transient
+ public Long getRowNum() {
+ return super.getRowNum();
+ }
+
+ @Override
+ @Transient
+ public Set getAuditTrail() {
+ return super.getAuditTrail();
+ }
+
+ public void setJobId(UUID jobId) {
+ this.jobId = jobId;
+ }
+
+ public void setTemplateId(UUID templateId) {
+ this.templateId = templateId;
+ }
+
+ public void setJobStatus(Job.JobStatus jobStatus) {
+ this.jobStatus = jobStatus;
+ }
+
+ public void setStatusModifiedDate(Date statusModifiedDate) {
+ this.statusModifiedDate = statusModifiedDate;
+ }
+
+ public void setHidden(boolean isHidden) {
+ hidden = isHidden;
+ }
+
+ public void setPause(boolean pause) {
+ this.pause = pause;
+ }
+
+ public void setOwningEntityId(String owningEntityId) {
+ this.owningEntityId = owningEntityId;
+ }
+
+ public void setOwningEntityName(String owningEntityName) {
+ this.owningEntityName = owningEntityName;
+ }
+
+ public void setProject(String project) {
+ this.project = project;
+ }
+
+ public void setAicZoneId(String aicZoneId) {
+ this.aicZoneId = aicZoneId;
+ }
+
+ public void setAicZoneName(String aicZoneName) {
+ this.aicZoneName = aicZoneName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public void setTenantName(String tenantName) {
+ this.tenantName = tenantName;
+ }
+
+ public void setRegionId(String regionId) {
+ this.regionId = regionId;
+ }
+
+ public void setRegionName(String regionName) {
+ this.regionName = regionName;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public void setSubscriberName(String subscriberName) {
+ this.subscriberName = subscriberName;
+ }
+
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public void setServiceInstanceName(String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ }
+
+ public void setServiceModelId(String serviceModelId) {
+ this.serviceModelId = serviceModelId;
+ }
+
+ public void setServiceModelName(String serviceModelName) {
+ this.serviceModelName = serviceModelName;
+ }
+
+ public void setServiceModelVersion(String serviceModelVersion) {
+ this.serviceModelVersion = serviceModelVersion;
+ }
+
+ public void setCreatedBulkDate(Date createdBulkDate) {
+ this.createdBulkDate = createdBulkDate;
+ }
+
+ public void setDeletedAt(Date deletedAt) {
+ this.deletedAt = deletedAt;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ServiceInfo)) return false;
+ ServiceInfo that = (ServiceInfo) o;
+ return isHidden() == that.isHidden() &&
+ isPause() == that.isPause() &&
+ Objects.equals(getDeletedAt(), that.getDeletedAt()) &&
+ Objects.equals(getJobId(), that.getJobId()) &&
+ Objects.equals(getTemplateId(), that.getTemplateId()) &&
+ Objects.equals(getUserId(), that.getUserId()) &&
+ getJobStatus() == that.getJobStatus() &&
+ Objects.equals(getStatusModifiedDate(), that.getStatusModifiedDate()) &&
+ Objects.equals(getOwningEntityId(), that.getOwningEntityId()) &&
+ Objects.equals(getOwningEntityName(), that.getOwningEntityName()) &&
+ Objects.equals(getProject(), that.getProject()) &&
+ Objects.equals(getAicZoneId(), that.getAicZoneId()) &&
+ Objects.equals(getAicZoneName(), that.getAicZoneName()) &&
+ Objects.equals(getTenantId(), that.getTenantId()) &&
+ Objects.equals(getTenantName(), that.getTenantName()) &&
+ Objects.equals(getRegionId(), that.getRegionId()) &&
+ Objects.equals(getRegionName(), that.getRegionName()) &&
+ Objects.equals(getServiceType(), that.getServiceType()) &&
+ Objects.equals(getSubscriberName(), that.getSubscriberName()) &&
+ Objects.equals(getServiceInstanceId(), that.getServiceInstanceId()) &&
+ Objects.equals(getServiceInstanceName(), that.getServiceInstanceName()) &&
+ Objects.equals(getServiceModelId(), that.getServiceModelId()) &&
+ Objects.equals(getServiceModelName(), that.getServiceModelName()) &&
+ Objects.equals(getServiceModelVersion(), that.getServiceModelVersion()) &&
+ Objects.equals(getCreatedBulkDate(), that.getCreatedBulkDate());
+ }
+
+ @Override
+ public int hashCode() {
+
+ return Objects.hash(getJobId(), getTemplateId(), getUserId(), getJobStatus(), getStatusModifiedDate(),
+ isHidden(), isPause(), getDeletedAt(), getOwningEntityId(), getOwningEntityName(), getProject(),
+ getAicZoneId(), getAicZoneName(), getTenantId(), getTenantName(), getRegionId(),
+ getRegionName(), getServiceType(), getSubscriberName(), getServiceInstanceId(),
+ getServiceInstanceName(), getServiceModelId(), getServiceModelName(),
+ getServiceModelVersion(), getCreatedBulkDate());
+ }
+ }
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/ServiceInstanceSearchResult.java b/onap-enabler-be/src/main/java/org/onap/osam/model/ServiceInstanceSearchResult.java
new file mode 100644
index 0000000..c8aab29
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/ServiceInstanceSearchResult.java
@@ -0,0 +1,141 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+public class ServiceInstanceSearchResult {
+
+ private String serviceInstanceId;
+
+ private String globalCustomerId;
+
+ private String serviceType;
+
+ private String serviceInstanceName;
+
+ private String subscriberName;
+
+ private String aaiModelInvariantId;
+
+ private String aaiModelVersionId;
+
+ private boolean isPermitted;
+
+ public ServiceInstanceSearchResult(){
+
+ }
+ public ServiceInstanceSearchResult(String serviceInstanceId, String globalCustomerId, String serviceType,
+ String serviceInstanceName, String subscriberName, String aaiModelInvariantId,
+ String aaiModelVersionId, boolean isPermitted) {
+ this.serviceInstanceId = serviceInstanceId;
+ this.globalCustomerId = globalCustomerId;
+ this.serviceType = serviceType;
+ this.serviceInstanceName = serviceInstanceName;
+ this.subscriberName = subscriberName;
+ this.aaiModelInvariantId = aaiModelInvariantId;
+ this.aaiModelVersionId = aaiModelVersionId;
+ this.isPermitted = isPermitted;
+ }
+
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public String getGlobalCustomerId() {
+ return globalCustomerId;
+ }
+
+ public void setGlobalCustomerId(String globalCustomerId) {
+ this.globalCustomerId = globalCustomerId;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public String getServiceInstanceName() {
+ return serviceInstanceName;
+ }
+
+ public void setServiceInstanceName(String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ }
+
+ public String getSubscriberName() {
+ return subscriberName;
+ }
+
+ public void setSubscriberName(String subscriberName) {
+ this.subscriberName = subscriberName;
+ }
+
+ public String getAaiModelInvariantId() {
+ return aaiModelInvariantId;
+ }
+
+ public void setAaiModelInvariantId(String aaiModelInvariantId) {
+ this.aaiModelInvariantId = aaiModelInvariantId;
+ }
+
+ public String getAaiModelVersionId() {
+ return aaiModelVersionId;
+ }
+
+ public void setAaiModelVersionId(String aaiModelVersionId) {
+ this.aaiModelVersionId = aaiModelVersionId;
+ }
+
+ public boolean getIsPermitted() {
+ return isPermitted;
+ }
+
+ public void setIsPermitted(boolean isPermitted) {
+ this.isPermitted = isPermitted;
+ }
+
+ @Override
+ public boolean equals(Object other){
+ if (other instanceof ServiceInstanceSearchResult) {
+ ServiceInstanceSearchResult serviceInstanceSearchResultOther = (ServiceInstanceSearchResult) other;
+ if (this.getServiceInstanceId().equals(serviceInstanceSearchResultOther.getServiceInstanceId())) {
+ return true;
+ }
+ }
+ return false;
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ result = 31 * result + serviceInstanceId.hashCode();
+ return result;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/Subscriber.java b/onap-enabler-be/src/main/java/org/onap/osam/model/Subscriber.java
new file mode 100644
index 0000000..1afe8cc
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/Subscriber.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Subscriber {
+
+ @JsonProperty("global-customer-id")
+ public String globalCustomerId;
+
+ @JsonProperty("subscriber-name")
+ public String subscriberName;
+
+ @JsonProperty("subscriber-type")
+ public String subscriberType;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/SubscriberList.java b/onap-enabler-be/src/main/java/org/onap/osam/model/SubscriberList.java
new file mode 100644
index 0000000..8e4830e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/SubscriberList.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.util.List;
+
+public class SubscriberList {
+ public SubscriberList(List<Subscriber> customer) {
+ this.customer = customer;
+ }
+
+ public SubscriberList(){}
+
+ public List<Subscriber> customer;
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/VNFDao.java b/onap-enabler-be/src/main/java/org/onap/osam/model/VNFDao.java
new file mode 100644
index 0000000..1f0d56d
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/VNFDao.java
@@ -0,0 +1,127 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.onap.portalsdk.core.domain.support.DomainVo;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+@Entity
+@Table(name = "vid_vnf")
+public class VNFDao extends DomainVo {
+
+ private String vnfUUID;
+ private String vnfInvariantUUID;
+ private Set<VidWorkflow> workflows = new HashSet<>(0);
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "VNF_DB_ID")
+ @JsonIgnore
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ @Column(name = "CREATED_DATE")
+ @JsonIgnore
+ public Date getCreated() {
+ return super.getCreated();
+ }
+
+ @Override
+ @Column(name = "MODIFIED_DATE")
+ @JsonIgnore
+ public Date getModified() {
+ return super.getModified();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getCreatedId() {
+ return super.getCreatedId();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getModifiedId() {
+ return super.getModifiedId();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Serializable getAuditUserId() {
+ return super.getAuditUserId();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getRowNum() {
+ return super.getRowNum();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Set getAuditTrail() {
+ return super.getAuditTrail();
+ }
+
+ @Column(name = "VNF_APP_UUID")
+ public String getVnfUUID() {
+ return vnfUUID;
+ }
+
+ @Column(name = "VNF_APP_INVARIANT_UUID")
+ public String getVnfInvariantUUID() {
+ return vnfInvariantUUID;
+ }
+
+
+ public void setVnfUUID(String vnfUUID) {
+ this.vnfUUID = vnfUUID;
+ }
+
+ public void setVnfInvariantUUID(String vnfInvariantUUID) {
+ this.vnfInvariantUUID = vnfInvariantUUID;
+ }
+
+ @ManyToMany(cascade = CascadeType.ALL, fetch =FetchType.EAGER )
+ @JoinTable(name = "vid_vnf_workflow", joinColumns = { @JoinColumn(name = "VNF_DB_ID") }, inverseJoinColumns = { @JoinColumn(name = "WORKFLOW_DB_ID") })
+ public Set<VidWorkflow> getWorkflows() {
+ return workflows;
+ }
+
+ public void setWorkflows(Set<VidWorkflow> workflows) {
+ this.workflows = workflows;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/VersionByInvariantIdsRequest.java b/onap-enabler-be/src/main/java/org/onap/osam/model/VersionByInvariantIdsRequest.java
new file mode 100644
index 0000000..9cde397
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/VersionByInvariantIdsRequest.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.util.List;
+
+public class VersionByInvariantIdsRequest {
+
+ public List<String> versions;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/VfcInstanceGroup.java b/onap-enabler-be/src/main/java/org/onap/osam/model/VfcInstanceGroup.java
new file mode 100644
index 0000000..21e8593
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/VfcInstanceGroup.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+public class VfcInstanceGroup {
+
+ private String uuid;
+ private String invariantUuid;
+ private String name;
+ private String version;
+ private VfcInstanceGroupProperties vfcInstanceGroupProperties;
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getInvariantUuid() {
+ return invariantUuid;
+ }
+
+ public void setInvariantUuid(String invariantUuid) {
+ this.invariantUuid = invariantUuid;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public VfcInstanceGroupProperties getVfcInstanceGroupProperties() {
+ return vfcInstanceGroupProperties;
+ }
+
+ public void setVfcInstanceGroupProperties(VfcInstanceGroupProperties vfcInstanceGroupProperties) {
+ this.vfcInstanceGroupProperties = vfcInstanceGroupProperties;
+ }
+
+
+
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/VfcInstanceGroupProperties.java b/onap-enabler-be/src/main/java/org/onap/osam/model/VfcInstanceGroupProperties.java
new file mode 100644
index 0000000..0fb0e51
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/VfcInstanceGroupProperties.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+public class VfcInstanceGroupProperties {
+
+ private String vfcParentPortRole;
+ private String networkCollectionFunction;
+ private String vfcInstanceGroupFunction;
+ private String subinterfaceRole;
+
+ public String getVfcParentPortRole() {
+ return vfcParentPortRole;
+ }
+
+ public void setVfcParentPortRole(String vfcParentPortRole) {
+ this.vfcParentPortRole = vfcParentPortRole;
+ }
+
+ public String getNetworkCollectionFunction() {
+ return networkCollectionFunction;
+ }
+
+ public void setNetworkCollectionFunction(String networkCollectionFunction) {
+ this.networkCollectionFunction = networkCollectionFunction;
+ }
+
+ public String getVfcInstanceGroupFunction() {
+ return vfcInstanceGroupFunction;
+ }
+
+ public void setVfcInstanceGroupFunction(String vfcInstanceGroupFunction) {
+ this.vfcInstanceGroupFunction = vfcInstanceGroupFunction;
+ }
+
+ public String getSubinterfaceRole() {
+ return subinterfaceRole;
+ }
+
+ public void setSubinterfaceRole(String subinterfaceRole) {
+ this.subinterfaceRole = subinterfaceRole;
+ }
+
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/VidBaseEntity.java b/onap-enabler-be/src/main/java/org/onap/osam/model/VidBaseEntity.java
new file mode 100644
index 0000000..1d511a3
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/VidBaseEntity.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.onap.portalsdk.core.domain.support.DomainVo;
+
+import javax.persistence.Column;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Transient;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Set;
+
+@MappedSuperclass
+public class VidBaseEntity extends DomainVo {
+
+ @Override
+ @Column(name = "CREATED_DATE")
+ @JsonIgnore
+ public Date getCreated() {
+ return super.getCreated();
+ }
+
+ @Override
+ @Column(name = "MODIFIED_DATE")
+ @JsonIgnore
+ public Date getModified() {
+ return super.getModified();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getCreatedId() {
+ return super.getCreatedId();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getModifiedId() {
+ return super.getModifiedId();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Serializable getAuditUserId() {
+ return super.getAuditUserId();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getRowNum() {
+ return super.getRowNum();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Set getAuditTrail() {
+ return super.getAuditTrail();
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/VidWorkflow.java b/onap-enabler-be/src/main/java/org/onap/osam/model/VidWorkflow.java
new file mode 100644
index 0000000..3bd93e7
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/VidWorkflow.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "vid_workflow")
+public class VidWorkflow extends VidBaseEntity {
+
+ private String wokflowName;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "WORKFLOW_DB_ID")
+ @JsonIgnore
+ public Long getId() {
+ return id;
+ }
+
+ @Column(name = "WORKFLOW_APP_NAME")
+ public String getWokflowName() {
+ return wokflowName;
+ }
+
+ public void setWokflowName(String wokflowName) {
+ this.wokflowName = wokflowName;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/Workflow.java b/onap-enabler-be/src/main/java/org/onap/osam/model/Workflow.java
new file mode 100644
index 0000000..8ba781f
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/Workflow.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+
+import java.util.Collection;
+
+public class Workflow {
+ //Private members:
+ private int id;
+ private String workflowName;
+ private Collection<String> vnfNames;
+
+
+ //Constructors:
+ public Workflow() {}
+
+ public Workflow(int id, String workflowName, Collection<String> vnfNames) {
+ this.id = id;
+ this.workflowName = workflowName;
+ this.vnfNames = vnfNames;
+ }
+
+
+ //Setters and getters:
+ public int getId() {
+ return id;
+ }
+
+ public String getWorkflowName() {
+ return workflowName;
+ }
+
+ public Collection<String> getVnfNames() {
+ return this.vnfNames;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public void setWorkflowName(String workflowName) {
+ this.workflowName = workflowName;
+ }
+
+ public void setVnfName(Collection<String> vnfNames) {
+ this.vnfNames = vnfNames;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/probes/ErrorMetadata.java b/onap-enabler-be/src/main/java/org/onap/osam/model/probes/ErrorMetadata.java
new file mode 100644
index 0000000..3fb8d58
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/probes/ErrorMetadata.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model.probes;
+
+public class ErrorMetadata extends StatusMetadata {
+ public ErrorMetadata(String description, long duration) {
+ super(description, duration);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/probes/ExternalComponentStatus.java b/onap-enabler-be/src/main/java/org/onap/osam/model/probes/ExternalComponentStatus.java
new file mode 100644
index 0000000..149bc79
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/probes/ExternalComponentStatus.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model.probes;
+
+public class ExternalComponentStatus {
+ public enum Component {AAI, MSO}
+ private final Component component;
+ private final boolean available;
+ private final StatusMetadata metadata;
+
+ public ExternalComponentStatus(Component component, boolean isAvailable, StatusMetadata metadata) {
+ this.component = component;
+ this.available = isAvailable;
+ this.metadata = metadata;
+ }
+
+ public Component getComponent() {
+ return component;
+ }
+
+ public boolean isAvailable() {
+ return available;
+ }
+
+ public StatusMetadata getMetadata() {
+ return metadata;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/probes/HttpRequestMetadata.java b/onap-enabler-be/src/main/java/org/onap/osam/model/probes/HttpRequestMetadata.java
new file mode 100644
index 0000000..ba9c15f
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/probes/HttpRequestMetadata.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model.probes;
+
+import org.springframework.http.HttpMethod;
+
+public class HttpRequestMetadata extends StatusMetadata {
+ private final HttpMethod httpMethod;
+ private final int httpCode;
+ private final String url;
+ private final String rawData;
+
+ public HttpRequestMetadata(HttpMethod httpMethod, int httpCode, String url, String rawData, String description, long duration) {
+ super(description, duration);
+ this.httpMethod = httpMethod;
+ this.url = url;
+ this.httpCode = httpCode;
+ this.rawData = rawData;
+ }
+
+ public HttpMethod getHttpMethod() {
+ return httpMethod;
+ }
+
+ public int getHttpCode() {
+ return httpCode;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public String getRawData() {
+ return rawData;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/probes/StatusMetadata.java b/onap-enabler-be/src/main/java/org/onap/osam/model/probes/StatusMetadata.java
new file mode 100644
index 0000000..a2b8d90
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/probes/StatusMetadata.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model.probes;
+
+public abstract class StatusMetadata {
+ protected final long duration;
+ protected final String description;
+
+ public StatusMetadata(String description, long duration) {
+ this.description = description;
+ this.duration = duration;
+ }
+
+ public long getDuration() {
+ return duration;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/serviceInstantiation/ServiceInstantiation.java b/onap-enabler-be/src/main/java/org/onap/osam/model/serviceInstantiation/ServiceInstantiation.java
new file mode 100644
index 0000000..b1282a4
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/serviceInstantiation/ServiceInstantiation.java
@@ -0,0 +1,196 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model.serviceInstantiation;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.osam.domain.mso.ModelInfo;
+import org.onap.osam.job.JobAdapter;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+public class ServiceInstantiation implements JobAdapter.AsyncJobRequest {
+
+ private final ModelInfo modelInfo;
+
+ private final String owningEntityId;
+
+ private final String owningEntityName;
+
+ private final String projectName;
+
+ private final String subscriberName;
+
+ private final String globalSubscriberId;
+
+ private final String productFamilyId;
+
+ private final String instanceName;
+
+ private final Boolean isUserProvidedNaming;
+
+ private final String subscriptionServiceType;
+
+ private final String lcpCloudRegionId;
+
+ private final String tenantId;
+
+ private final String tenantName;
+
+ private final String aicZoneId;
+
+ private final String aicZoneName;
+
+ private final Map<String, Vnf> vnfs;
+
+ private final List<Map<String,String>> instanceParams;
+
+ private final boolean isPause;
+
+ private final int bulkSize;
+
+ private final boolean rollbackOnFailure;
+
+ public ServiceInstantiation(@JsonProperty("modelInfo") ModelInfo modelInfo,
+ @JsonProperty("owningEntityId") String owningEntityId,
+ @JsonProperty("owningEntityName") String owningEntityName,
+ @JsonProperty("projectName") String projectName,
+ @JsonProperty("globalSubscriberId") String globalSubscriberId,
+ @JsonProperty("subscriberName") String subscriberName,
+ @JsonProperty("productFamilyId") String productFamilyId,
+ @JsonProperty("instanceName") String instanceName,
+ @JsonProperty("isUserProvidedNaming") Boolean isUserProvidedNaming,
+ @JsonProperty("subscriptionServiceType") String subscriptionServiceType,
+ @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
+ @JsonProperty("tenantId") String tenantId,
+ @JsonProperty("tenantName") String tenantName,
+ @JsonProperty("aicZoneId") String aicZoneId,
+ @JsonProperty("aicZoneName") String aicZoneName,
+ @JsonProperty("vnfs") Map<String, Vnf> vnfs,
+ @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
+ @JsonProperty("pause") boolean isPause,
+ @JsonProperty("bulkSize") int bulkSize,
+ @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure
+ ) {
+
+ this.modelInfo = modelInfo;
+ this.modelInfo.setModelType("service");
+ this.owningEntityId = owningEntityId;
+ this.owningEntityName = owningEntityName;
+ this.projectName = projectName;
+ this.globalSubscriberId = globalSubscriberId;
+ this.subscriberName = subscriberName;
+ this.productFamilyId = productFamilyId;
+ this.instanceName = instanceName;
+ this.isUserProvidedNaming = isUserProvidedNaming;
+ this.subscriptionServiceType = subscriptionServiceType;
+ this.lcpCloudRegionId = lcpCloudRegionId;
+ this.tenantId = tenantId;
+ this.tenantName = tenantName;
+ this.aicZoneId = aicZoneId;
+ this.aicZoneName = aicZoneName;
+ this.vnfs = vnfs;
+ this.instanceParams = instanceParams;
+ this.isPause = isPause;
+ this.bulkSize = bulkSize;
+ this.rollbackOnFailure = rollbackOnFailure;
+ }
+
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+
+ public String getOwningEntityId() {
+ return owningEntityId;
+ }
+
+ public String getOwningEntityName() {
+ return owningEntityName;
+ }
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public String getGlobalSubscriberId() {
+ return globalSubscriberId;
+ }
+
+ public String getSubscriberName() {
+ return subscriberName;
+ }
+
+ public String getProductFamilyId() {
+ return productFamilyId;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ @JsonProperty("isUserProvidedNaming")
+ public Boolean isUserProvidedNaming() { return isUserProvidedNaming; }
+
+ public String getSubscriptionServiceType() {
+ return subscriptionServiceType;
+ }
+
+ public String getLcpCloudRegionId() {
+ return lcpCloudRegionId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ public String getTenantName() {
+ return tenantName;
+ }
+
+ public String getAicZoneId() {
+ return aicZoneId;
+ }
+
+ public String getAicZoneName() {
+ return aicZoneName;
+ }
+
+ public Map<String, Vnf> getVnfs() {
+ return vnfs;
+ }
+
+ public List<Map<String, String>> getInstanceParams() {
+ return instanceParams == null ? Collections.emptyList() : instanceParams;
+ }
+
+ public boolean isPause() {
+ return isPause;
+ }
+
+ public int getBulkSize() { return bulkSize; }
+
+ public boolean isRollbackOnFailure() {
+ return rollbackOnFailure;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/serviceInstantiation/VfModule.java b/onap-enabler-be/src/main/java/org/onap/osam/model/serviceInstantiation/VfModule.java
new file mode 100644
index 0000000..dec47cd
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/serviceInstantiation/VfModule.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model.serviceInstantiation;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.osam.domain.mso.ModelInfo;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+
+public class VfModule {
+
+
+
+ private final ModelInfo modelInfo;
+
+ @JsonInclude(NON_NULL) private final String instanceName;
+
+ private final List<Map<String, String>> instanceParams;
+ @JsonInclude(NON_NULL) private final String volumeGroupInstanceName;
+
+ public VfModule(@JsonProperty("modelInfo") ModelInfo modelInfo,
+ @JsonProperty("instanceName") String instanceName,
+ @JsonProperty(value = "volumeGroupName") String volumeGroupInstanceName,
+ @JsonProperty("instanceParams") List<Map<String, String>> instanceParams) {
+ this.modelInfo = modelInfo;
+ this.modelInfo.setModelType("vfModule");
+ this.instanceName = instanceName;
+ this.instanceParams = instanceParams;
+ this.volumeGroupInstanceName = volumeGroupInstanceName;
+ }
+
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public String getVolumeGroupInstanceName() {
+ return volumeGroupInstanceName;
+ }
+
+ public List<Map<String, String>> getInstanceParams() {
+ return instanceParams == null ? Collections.emptyList() : instanceParams;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/model/serviceInstantiation/Vnf.java b/onap-enabler-be/src/main/java/org/onap/osam/model/serviceInstantiation/Vnf.java
new file mode 100644
index 0000000..1fb61da
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/model/serviceInstantiation/Vnf.java
@@ -0,0 +1,118 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model.serviceInstantiation;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.osam.domain.mso.ModelInfo;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+public class Vnf {
+ private final ModelInfo modelInfo;
+
+ private final String productFamilyId;
+
+ private final String instanceName;
+
+ private final String platformName;
+
+ private final String lcpCloudRegionId;
+
+ private final String tenantId;
+
+ private final Boolean isUserProvidedNaming;
+
+ private final List<Map<String, String>> instanceParams;
+
+ private final String lineOfBusiness;
+
+
+ private final Map<String, Map<String, VfModule>> vfModules;
+
+ public Vnf(@JsonProperty("modelInfo") ModelInfo modelInfo,
+ @JsonProperty("productFamilyId") String productFamilyId,
+ @JsonProperty("instanceName") String instanceName,
+ @JsonProperty("isUserProvidedNaming") Boolean isUserProvidedNaming,
+ @JsonProperty("platformName") String platformName,
+ @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
+ @JsonProperty("tenantId") String tenantId,
+ @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
+ @JsonProperty("lineOfBusinessName") String lineOfBusiness,
+ @JsonProperty("vfModules") Map<String, Map<String, VfModule>> vfModules) {
+ this.modelInfo = modelInfo;
+ this.modelInfo.setModelType("vnf");
+ this.productFamilyId = productFamilyId;
+ this.instanceName = instanceName;
+ this.isUserProvidedNaming = isUserProvidedNaming;
+ this.platformName = platformName;
+ this.lcpCloudRegionId = lcpCloudRegionId;
+ this.tenantId = tenantId;
+ this.instanceParams = instanceParams;
+ this.vfModules = vfModules;
+ this.lineOfBusiness = lineOfBusiness;
+ }
+
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+
+ public String getProductFamilyId() {
+ return productFamilyId;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ @JsonProperty("isUserProvidedNaming")
+ public Boolean isUserProvidedNaming() {
+ return isUserProvidedNaming;
+ }
+
+ public String getPlatformName() {
+ return platformName;
+ }
+
+ public String getLcpCloudRegionId() {
+ return lcpCloudRegionId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ public List<Map<String, String>> getInstanceParams() {
+ return instanceParams == null ? Collections.emptyList() : instanceParams;
+ }
+
+ public Map<String, Map<String, VfModule>> getVfModules() {
+ return vfModules;
+ }
+
+ public String getLineOfBusiness() {
+ return lineOfBusiness;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoBusinessLogic.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoBusinessLogic.java
new file mode 100644
index 0000000..d63f1e7
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoBusinessLogic.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import org.onap.osam.mso.rest.Request;
+import org.onap.osam.mso.rest.RequestDetails;
+import org.onap.osam.mso.rest.RequestDetailsWrapper;
+import org.onap.osam.mso.rest.Task;
+
+import java.util.List;
+
+public interface MsoBusinessLogic {
+
+ // this function should get params from tosca and send them to instance at mso, then return success response.
+ MsoResponseWrapper createSvcInstance(RequestDetails msoRequest);
+
+ MsoResponseWrapper createE2eSvcInstance(Object msoRequest);
+
+ MsoResponseWrapper deleteE2eSvcInstance(Object requestDetails, String serviceInstanceId);
+
+ MsoResponseWrapper createVnf(RequestDetails requestDetails, String serviceInstanceId);
+
+ MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String serviceInstanceId);
+
+ MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId);
+
+ MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId);
+
+ MsoResponseWrapper scaleOutVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId);
+
+ MsoResponseWrapper createConfigurationInstance(org.onap.osam.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String serviceInstanceId);
+
+ MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId, String serviceStatus);
+
+ MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId);
+
+ MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String vfModuleId);
+
+ MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String volumeGroupId);
+
+ MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String serviceInstanceId, String networkInstanceId);
+
+ MsoResponseWrapper getOrchestrationRequest(String requestId);
+
+ MsoResponseWrapper getOrchestrationRequests(String filterString);
+
+ List<Request> getOrchestrationRequestsForDashboard();
+
+ List<Task> getManualTasksByRequestId(String originalRequestId);
+
+ MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String taskId);
+
+ MsoResponseWrapper activateServiceInstance(RequestDetails requestDetails, String serviceInstanceId);
+
+ //MsoResponseWrapperInterface updateVnf(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId);
+
+ //MsoResponseWrapperInterface replaceVnf(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId);
+
+ MsoResponseWrapperInterface updateVnfSoftware(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId);
+
+ MsoResponseWrapperInterface updateVnfConfig(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId);
+
+ MsoResponseWrapper deleteConfiguration(
+ org.onap.osam.mso.rest.RequestDetailsWrapper requestDetailsWrapper,
+ String serviceInstanceId,
+ String configurationId);
+
+ MsoResponseWrapper setConfigurationActiveStatus(
+ RequestDetails requestDetails,
+ String serviceInstanceId,
+ String configurationId,
+ boolean isActivate);
+
+ MsoResponseWrapper setPortOnConfigurationStatus(
+ RequestDetails requestDetails,
+ String serviceInstanceId,
+ String configurationId,
+ boolean isEnable);
+
+ String getCloudResourcesRequestsStatusPath(String requestId);
+
+ MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String serviceInstanceId);
+
+ MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String serviceInstanceId);
+
+ MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails , String serviceInstanceId, boolean isActivate);
+
+ RequestDetailsWrapper generateInPlaceMsoRequest(RequestDetails requestDetails);
+
+ RequestDetailsWrapper generateConfigMsoRequest(RequestDetails requestDetails);
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoBusinessLogicImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoBusinessLogicImpl.java
new file mode 100644
index 0000000..cfe0bad
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoBusinessLogicImpl.java
@@ -0,0 +1,799 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.osam.mso;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableList;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.mso.rest.Request;
+import org.onap.osam.mso.rest.RequestDetails;
+import org.onap.osam.mso.rest.RequestDetailsWrapper;
+import org.onap.osam.mso.rest.RequestList;
+import org.onap.osam.mso.rest.RequestWrapper;
+import org.onap.osam.mso.rest.Task;
+import org.onap.osam.mso.rest.TaskList;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.togglz.core.manager.FeatureManager;
+
+import javax.ws.rs.BadRequestException;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import static org.apache.commons.lang.StringUtils.upperCase;
+import static org.onap.osam.controllers.MsoController.*;
+import static org.onap.osam.mso.MsoProperties.*;
+import static org.onap.osam.properties.Features.FLAG_UNASSIGN_SERVICE;
+
+public class MsoBusinessLogicImpl implements MsoBusinessLogic {
+
+ public static final String START = " start";
+ public static final String RESOURCE_TYPE = "resourceType";
+ FeatureManager featureManager;
+
+ private static final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+ private static final Pattern SOFTWARE_VERSION_PATTERN = Pattern.compile("^[A-Za-z0-9.\\-]+$");
+ private static final Pattern NUMBER_PATTERN = Pattern.compile("^[0-9]+$");
+ private static final String ACTIVATE = "/activate";
+ private static final String DEACTIVATE = "/deactivate";
+ private static final String ENABLE_PORT = "/enablePort";
+ private static final String DISABLE_PORT = "/disablePort";
+ private static final String RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT = "operationalEnvironment";
+ private static final String SOURCE_OPERATIONAL_ENVIRONMENT = "VID";
+ private static final ObjectMapper objectMapper = new ObjectMapper();
+ private final MsoInterface msoClientInterface;
+
+ /**
+ * The logger.
+ */
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoBusinessLogicImpl.class);
+
+ @Autowired
+ public MsoBusinessLogicImpl(MsoInterface msoClientInterface, FeatureManager featureManager) {
+ this.msoClientInterface = msoClientInterface;
+ this.featureManager = featureManager;
+ }
+
+ public static String validateEndpointPath(String endpointEnvVariable) {
+ String endpoint = SystemProperties.getProperty(endpointEnvVariable);
+ if (endpoint == null || endpoint.isEmpty()) {
+ throw new GenericUncheckedException(endpointEnvVariable + " env variable is not defined");
+ }
+ return endpoint;
+ }
+
+ // this function should get params from tosca and send them to instance at mso, then return success response.
+ @Override
+ public MsoResponseWrapper createSvcInstance(RequestDetails msoRequest) {
+ String methodName = "createSvcInstance ";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+
+ return msoClientInterface.createSvcInstance(msoRequest, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createE2eSvcInstance(Object msoRequest){
+ String methodName = "createE2eSvcInstance ";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE);
+
+
+ return msoClientInterface.createE2eSvcInstance(msoRequest, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createVnf(RequestDetails requestDetails, String serviceInstanceId) {
+ String methodName = "createVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE);
+
+ String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ return msoClientInterface.createVnf(requestDetails, vnf_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String serviceInstanceId) {
+ String methodName = "createNwInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
+
+ String nw_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ return msoClientInterface.createNwInstance(requestDetails, nw_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
+ String methodName = "createVolumeGroupInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
+
+ String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ vnf_endpoint = vnf_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+
+ return msoClientInterface.createVolumeGroupInstance(requestDetails, vnf_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
+ String methodName = "createVfModuleInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
+
+ String partial_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+
+ return msoClientInterface.createVfModuleInstance(requestDetails, vf_module_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper scaleOutVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
+ String methodName = "scaleOutVfModuleInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_SCALE_OUT);
+
+ String partial_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+ RequestDetailsWrapper wrapper = new RequestDetailsWrapper();
+ //requestDetails.setVnfName(null);
+ //requestDetails.setVnfInstanceId(null);
+ wrapper.requestDetails = requestDetails;
+
+ return msoClientInterface.scaleOutVFModuleInstance(wrapper, vf_module_endpoint);
+ }
+ @Override
+ public MsoResponseWrapper createConfigurationInstance(org.onap.osam.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String serviceInstanceId) {
+ String methodName = "createConfigurationInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATIONS);
+ endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId);
+
+ return msoClientInterface.createConfigurationInstance(requestDetailsWrapper, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteE2eSvcInstance(Object requestDetails, String serviceInstanceId) {
+ String methodName = "deleteE2eSvcInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_E2E_SVC_INSTANCE) + "/" + serviceInstanceId;
+
+ return msoClientInterface.deleteE2eSvcInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId, String serviceStatus) {
+ String methodName = "deleteSvcInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String endpoint;
+
+ if (featureManager.isActive(FLAG_UNASSIGN_SERVICE)){
+ endpoint = validateEndpointPath(MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE);
+ if (shouldUnassignService(serviceStatus)){
+ logger.debug(EELFLoggerDelegate.debugLogger, "unassign service");
+ String svc_endpoint = endpoint + "/" + serviceInstanceId + "/unassign";
+ return msoClientInterface.unassignSvcInstance(requestDetails, svc_endpoint);
+ }
+ } else {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ }
+
+ String svc_endpoint = endpoint + "/" + serviceInstanceId;
+ return msoClientInterface.deleteSvcInstance(requestDetails, svc_endpoint);
+ }
+
+ private boolean shouldUnassignService(String serviceStatus) {
+ return ImmutableList.of("created","pendingdelete","pending-delete", "assigned").contains(serviceStatus.toLowerCase());
+ }
+
+ @Override
+ public MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
+ String methodName = "deleteVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE);
+ String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ vnf_endpoint = vnf_endpoint + '/' + vnfInstanceId;
+
+ return msoClientInterface.deleteVnf(requestDetails, vnf_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String vfModuleId) {
+ String methodName = "deleteVfModule";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
+
+ String vf__modules_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId).replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+
+ String delete_vf_endpoint = vf__modules_endpoint + '/' + vfModuleId;
+
+ return msoClientInterface.deleteVfModule(requestDetails, delete_vf_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String volumeGroupId) {
+ String methodName = "deleteVolumeGroupInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
+
+ String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ String vnf_endpoint = svc_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+ String delete_volume_group_endpoint = vnf_endpoint + "/" + volumeGroupId;
+
+ return msoClientInterface.deleteVolumeGroupInstance(requestDetails, delete_volume_group_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String serviceInstanceId, String networkInstanceId) {
+ String methodName = "deleteNwInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint;
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
+
+ String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ String delete_nw_endpoint = svc_endpoint + "/" + networkInstanceId;
+
+ return msoClientInterface.deleteNwInstance(requestDetails, delete_nw_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper getOrchestrationRequest(String requestId) {
+ String methodName = "getOrchestrationRequest";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ try {
+ String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ);
+ String path = p + "/" + requestId;
+
+ return msoClientInterface.getOrchestrationRequest(path);
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper getOrchestrationRequests(String filterString) {
+ String methodName = "getOrchestrationRequest";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ try {
+ String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS);
+ String path = p + filterString;
+
+ return msoClientInterface.getOrchestrationRequest(path);
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public List<Request> getOrchestrationRequestsForDashboard() {
+ String methodName = "getOrchestrationRequestsForDashboard";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ List<Request> filteredOrchestrationRequests = new ArrayList<>();
+ try {
+ String path = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS);
+ path += "filter=modelType:EQUALS:vnf";
+ RestObject<String> restObjStr = new RestObject<>();
+ String str = new String();
+ restObjStr.set(str);
+
+ MsoResponseWrapper msoResponseWrapper = msoClientInterface.getOrchestrationRequestsForDashboard(str, "", path, restObjStr);
+ List<RequestWrapper> allOrchestrationRequests = deserializeOrchestrationRequestsJson(msoResponseWrapper.getEntity());
+
+ final ImmutableList<String> suppoertedRequestTypes = ImmutableList.of(
+ RequestType.REPLACE_INSTANCE.toString().toUpperCase(),
+ RequestType.UPDATE_INSTANCE.toString().toUpperCase(),
+ RequestType.APPLY_UPDATED_CONFIG.toString().toUpperCase(),
+ RequestType.IN_PLACE_SOFTWARE_UPDATE.toString().toUpperCase()
+ );
+
+ for (RequestWrapper currentRequest : allOrchestrationRequests) {
+ if (currentRequest.getRequest() != null
+ && "vnf".equalsIgnoreCase(currentRequest.getRequest().getRequestScope())
+ && suppoertedRequestTypes.contains(upperCase(currentRequest.getRequest().getRequestType()))
+ ) {
+ filteredOrchestrationRequests.add(currentRequest.getRequest());
+ }
+ }
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ }
+ return filteredOrchestrationRequests;
+ }
+
+ private List<RequestWrapper> deserializeOrchestrationRequestsJson(String orchestrationRequestsJson) {
+ String methodName = "deserializeOrchestrationRequestsJson";
+ logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true);
+ RequestList requestList = null;
+ try {
+ requestList = mapper.readValue(orchestrationRequestsJson, RequestList.class);
+ } catch (IOException e) {
+ throw new GenericUncheckedException(e);
+ }
+ return requestList.getRequestList();
+ }
+
+
+ @Override
+ public List<Task> getManualTasksByRequestId(String originalRequestId) {
+ String methodName = "getManualTasksByRequestId";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ try {
+ String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_MAN_TASKS);
+ String path = p + "?originalRequestId=" + originalRequestId;
+
+ RestObject<String> restObjStr = new RestObject<>();
+ String str = new String();
+ restObjStr.set(str);
+
+ MsoResponseWrapper msoResponseWrapper = msoClientInterface.getManualTasksByRequestId(str, "", path, restObjStr);
+ return deserializeManualTasksJson(msoResponseWrapper.getEntity());
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ private List<Task> deserializeManualTasksJson(String manualTasksJson) {
+ String methodName = "deserializeManualTasksJson";
+ logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ TaskList taskList = mapper.readValue(manualTasksJson, TaskList.class);
+ return taskList.getTaskList();
+ } catch (IOException e) {
+ throw new GenericUncheckedException(e);
+ }
+ }
+
+
+ @Override
+ public MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String taskId) {
+ String methodName = "completeManualTask";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ try {
+ String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_MAN_TASKS);
+ String path = p + "/" + taskId + "/complete";
+
+ RestObject<String> restObjStr = new RestObject<>();
+ String str = new String();
+ restObjStr.set(str);
+
+ msoClientInterface.completeManualTask(requestDetails, str, "", path, restObjStr);
+
+ return MsoUtil.wrapResponse(restObjStr);
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper activateServiceInstance(RequestDetails requestDetails, String serviceInstanceId) {
+ String methodName = "activateServiceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ try {
+ String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String activateServicePath = serviceEndpoint + "/" + serviceInstanceId + ACTIVATE;
+
+ RestObject<String> restObjStr = new RestObject<>();
+ String str = "";
+ restObjStr.set(str);
+
+ msoClientInterface.setServiceInstanceStatus(requestDetails, str, "", activateServicePath, restObjStr);
+
+ return MsoUtil.wrapResponse(restObjStr);
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ public RequestDetailsWrapper generateInPlaceMsoRequest(RequestDetails requestDetails) {
+ validateUpdateVnfSoftwarePayload(requestDetails);
+ RequestDetails inPlaceSoftwareUpdateRequest = new RequestDetails();
+ inPlaceSoftwareUpdateRequest.setCloudConfiguration(requestDetails.getCloudConfiguration());
+ inPlaceSoftwareUpdateRequest.setRequestParameters(requestDetails.getRequestParameters());
+ inPlaceSoftwareUpdateRequest.setRequestInfo(requestDetails.getRequestInfo());
+ RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
+ requestDetailsWrapper.requestDetails = inPlaceSoftwareUpdateRequest;
+ return requestDetailsWrapper;
+ }
+
+ @Override
+ public RequestDetailsWrapper generateConfigMsoRequest(RequestDetails requestDetails) {
+ validateUpdateVnfConfig(requestDetails);
+ RequestDetails ConfigUpdateRequest = new RequestDetails();
+ ConfigUpdateRequest.setRequestParameters(requestDetails.getRequestParameters());
+ ConfigUpdateRequest.setRequestInfo(requestDetails.getRequestInfo());
+ RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
+ requestDetailsWrapper.requestDetails = ConfigUpdateRequest;
+ return requestDetailsWrapper;
+ }
+
+
+ @Override
+ public MsoResponseWrapperInterface updateVnfSoftware(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
+ String methodName = "updateVnfSoftware";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ //String vnf_endpoint = getChangeManagementEndpoint(serviceInstanceId, vnfInstanceId, MsoChangeManagementRequest.SOFTWARE_UPDATE); //workflow name in mso is different than workflow name in vid UI
+ String vnf_endpoint = "";
+
+ RequestDetailsWrapper finalRequestDetails = generateInPlaceMsoRequest(requestDetails);
+ return msoClientInterface.changeManagementUpdate(finalRequestDetails, vnf_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapperInterface updateVnfConfig(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
+ String methodName = "updateVnfConfig";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ RequestDetailsWrapper finalRequestDetails = generateConfigMsoRequest(requestDetails);
+ //String vnf_endpoint = getChangeManagementEndpoint(serviceInstanceId, vnfInstanceId, MsoChangeManagementRequest.CONFIG_UPDATE);
+ String vnf_endpoint = "";
+
+
+ return msoClientInterface.changeManagementUpdate(finalRequestDetails, vnf_endpoint);
+ }
+
+ private String getChangeManagementEndpoint(String serviceInstanceId, String vnfInstanceId, String vnfRequestType) {
+ String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE);
+ String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ vnf_endpoint = vnf_endpoint.replace(VNF_INSTANCE_ID, vnfInstanceId);
+ vnf_endpoint = vnf_endpoint.replace(REQUEST_TYPE, vnfRequestType);
+ return vnf_endpoint;
+ }
+
+ private Map getChangeManagementPayload(RequestDetails requestDetails, String message){
+ if(requestDetails.getRequestParameters()==null||requestDetails.getRequestParameters().getAdditionalProperties()==null){
+ throw new BadRequestException(message);
+ }
+ Object payloadRaw=requestDetails.getRequestParameters().getAdditionalProperties().get("payload");
+ try{
+ return objectMapper.readValue((String)payloadRaw,Map.class);
+ }
+ catch(Exception exception){
+ throw new BadRequestException(message);
+ }
+ }
+
+ private void validateUpdateVnfSoftwarePayload(RequestDetails requestDetails) {
+ //final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.VNF_IN_PLACE_SOFTWARE_UPDATE + " request";
+ final String noValidPayloadMsg = "";
+
+ Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg);
+ validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "existing_software_version", SOFTWARE_VERSION_PATTERN);
+ validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "new_software_version", SOFTWARE_VERSION_PATTERN);
+
+ //if "operations_timeout" is not integer, trying to read it as String that represent a number
+ if (!(payload.get("operations_timeout") instanceof Integer)) {
+ validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "operations_timeout", NUMBER_PATTERN);
+ }
+ }
+
+ private void validateUpdateVnfSoftwarePayloadProperty(Map payload, String noValidPayloadMsg, String propertyName, Pattern pattern) {
+ Object forValidation = payload.get(propertyName);
+ final String noValidPayloadPropertyMsg = noValidPayloadMsg + ", " + propertyName + " property is not valid";
+ if (!(forValidation instanceof String)) {
+ throw new BadRequestException(noValidPayloadPropertyMsg);
+ }
+ if (!pattern.matcher((String) forValidation).matches()) {
+ throw new BadRequestException(noValidPayloadPropertyMsg);
+ }
+ }
+
+ private void validateUpdateVnfConfig(RequestDetails requestDetails) {
+ //final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.CONFIG_UPDATE + " request";
+ final String noValidPayloadMsg = "";
+
+ Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg);
+ validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "request-parameters");
+ validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "configuration-parameters");
+ }
+
+ private void validateConfigUpdateVnfPayloadProperty(Map payload, String noValidPayloadMsg, String propertyName) {
+ final String noValidPayloadPropertyMsg = noValidPayloadMsg+ ", "+ propertyName + " property is not valid";
+ if(!payload.containsKey(propertyName)) {
+ throw new BadRequestException( noValidPayloadPropertyMsg);
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper deleteConfiguration(
+ org.onap.osam.mso.rest.RequestDetailsWrapper requestDetailsWrapper,
+ String serviceInstanceId,
+ String configurationId) {
+
+ String methodName = "deleteConfiguration";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE);
+ endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId);
+ endpoint = endpoint.replace(CONFIGURATION_ID, configurationId);
+
+ return msoClientInterface.deleteConfiguration(requestDetailsWrapper, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper setConfigurationActiveStatus(
+ RequestDetails requestDetails,
+ String serviceInstanceId,
+ String configurationId,
+ boolean isActivate) {
+
+ String methodName = "setConfigurationActiveStatus";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE);
+ endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId);
+ endpoint = endpoint.replace(CONFIGURATION_ID, configurationId);
+
+ String isActivateState = (isActivate ? ACTIVATE : DEACTIVATE);
+ endpoint = endpoint + isActivateState;
+
+ return msoClientInterface.setConfigurationActiveStatus(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails , String serviceInstanceId, boolean isActivate) {
+ String methodName = "setServiceInstanceStatus";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ try {
+ String serviceEndpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String endpoint = serviceEndpoint + "/" + serviceInstanceId;
+
+ String isActivateState = (isActivate ? ACTIVATE : DEACTIVATE);
+ endpoint = endpoint + isActivateState;
+
+
+ RestObject<String> restObjStr = new RestObject<>();
+ String str = "";
+ restObjStr.set(str);
+
+ msoClientInterface.setServiceInstanceStatus(requestDetails , str, "", endpoint, restObjStr);
+
+ return MsoUtil.wrapResponse(restObjStr);
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper setPortOnConfigurationStatus(
+ RequestDetails requestDetails,
+ String serviceInstanceId,
+ String configurationId,
+ boolean isEnable) {
+ String methodName = "setPortOnConfigurationStatus";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE);
+ endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId);
+ endpoint = endpoint.replace(CONFIGURATION_ID, configurationId);
+
+ String isEnablePortStatus = (isEnable ? ENABLE_PORT : DISABLE_PORT);
+ endpoint = endpoint + isEnablePortStatus;
+
+ return msoClientInterface.setPortOnConfigurationStatus(requestDetails, endpoint);
+ }
+
+
+ /* @Override
+ public RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentActivationRequestDetails(OperationalEnvironmentActivateInfo details) {
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setAdditionalProperty(RESOURCE_TYPE, RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT);
+ requestInfo.setSource(SOURCE_OPERATIONAL_ENVIRONMENT);
+ requestInfo.setRequestorId(details.getUserId());
+ requestDetails.setRequestInfo(requestInfo);
+
+ org.onap.vid.domain.mso.RelatedInstance relatedInstance = new org.onap.vid.domain.mso.RelatedInstance();
+ relatedInstance.setAdditionalProperty(RESOURCE_TYPE, RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT);
+ relatedInstance.setInstanceId(details.getRelatedInstanceId());
+ relatedInstance.setInstanceName(details.getRelatedInstanceName());
+ requestDetails.setAdditionalProperty("relatedInstanceList", Collections.singletonList(ImmutableMap.of("relatedInstance", relatedInstance)));
+
+ org.onap.vid.domain.mso.RequestParameters requestParameters = new org.onap.vid.domain.mso.RequestParameters();
+ requestParameters.setUserParams(null);
+ requestParameters.setAdditionalProperty("operationalEnvironmentType", "VNF");
+ requestParameters.setAdditionalProperty("workloadContext", details.getWorkloadContext());
+ requestParameters.setAdditionalProperty("manifest", details.getManifest());
+ requestDetails.setRequestParameters(requestParameters);
+
+ RequestDetailsWrapper<RequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails);
+
+ debugRequestDetails(requestDetailsWrapper, logger);
+
+ return requestDetailsWrapper;
+ }*/
+
+ /* @Override
+ public RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentDeactivationRequestDetails(OperationalEnvironmentDeactivateInfo details) {
+ RequestDetails requestDetails = new RequestDetails();
+
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setAdditionalProperty(RESOURCE_TYPE, RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT);
+ requestInfo.setSource(SOURCE_OPERATIONAL_ENVIRONMENT);
+ requestInfo.setRequestorId(details.getUserId());
+ requestDetails.setRequestInfo(requestInfo);
+
+ org.onap.vid.domain.mso.RequestParameters requestParameters = new org.onap.vid.domain.mso.RequestParameters();
+ requestParameters.setUserParams(null);
+ requestParameters.setAdditionalProperty("operationalEnvironmentType", "VNF");
+ requestDetails.setRequestParameters(requestParameters);
+ RequestDetailsWrapper<RequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails);
+ debugRequestDetails(requestDetailsWrapper, logger);
+ return requestDetailsWrapper;
+ }*/
+
+ @Override
+ public String getCloudResourcesRequestsStatusPath(String requestId) {
+ String path = validateEndpointPath(MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS);
+ path = path.replace("<request_id>", requestId);
+ return path;
+ }
+
+ /*@Override
+ public RequestDetailsWrapper<OperationEnvironmentRequestDetails> convertParametersToRequestDetails(OperationalEnvironmentController.OperationalEnvironmentCreateBody input, String userId) {
+ OperationEnvironmentRequestDetails.RequestInfo requestInfo = new OperationEnvironmentRequestDetails.RequestInfo(
+ RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT,
+ input.getInstanceName(),
+ SOURCE_OPERATIONAL_ENVIRONMENT,
+ userId);
+
+ OperationEnvironmentRequestDetails.RelatedInstance relatedInstance = new OperationEnvironmentRequestDetails.RelatedInstance(
+ RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT,
+ input.getEcompInstanceId(),
+ input.getEcompInstanceName());
+
+ List<OperationEnvironmentRequestDetails.RelatedInstance> relatedInstanceList = Collections.singletonList((relatedInstance));
+
+ OperationEnvironmentRequestDetails.RequestParameters requestParameters = new OperationEnvironmentRequestDetails.RequestParameters(
+ input.getOperationalEnvironmentType(),
+ input.getTenantContext(),
+ input.getWorkloadContext());
+
+ OperationEnvironmentRequestDetails requestDetails = new OperationEnvironmentRequestDetails(requestInfo, relatedInstanceList, requestParameters);
+ RequestDetailsWrapper<OperationEnvironmentRequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails);
+ debugRequestDetails(requestDetailsWrapper, logger);
+ return requestDetailsWrapper;
+ }*/
+
+ @Override
+ public MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String serviceInstanceId) {
+ String methodName = "removeRelationshipFromServiceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String removeRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/removeRelationships";
+
+ return msoClientInterface.removeRelationshipFromServiceInstance(requestDetails, removeRelationshipsPath);
+ }
+
+ @Override
+ public MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String serviceInstanceId) {
+ String methodName = "addRelationshipToServiceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String addRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/addRelationships";
+
+ return msoClientInterface.addRelationshipToServiceInstance(requestDetails, addRelationshipsPath);
+ }
+
+
+ public enum RequestType {
+
+ CREATE_INSTANCE("createInstance"),
+ DELETE_INSTANCE("deleteInstance"),
+ REPLACE_INSTANCE("replaceInstance"),
+ UPDATE_INSTANCE("updateInstance"),
+ ACTIVATE_INSTANCE("activateInstance"),
+ DEACTIVATE_INSTANCE("deactivateInstance"),
+ APPLY_UPDATED_CONFIG("applyUpdatedConfig"),
+ IN_PLACE_SOFTWARE_UPDATE("inPlaceSoftwareUpdate"),
+ UNKNOWN("unknown"),
+ NOT_PROVIDED("not provided");
+ private final String value;
+ private static final Map<String, RequestType> CONSTANTS = new HashMap<>();
+
+ static {
+ for (RequestType c: values()) {
+ CONSTANTS.put(c.value, c);
+ }
+ }
+
+ RequestType(String value) {
+ this.value = value;
+ }
+
+ @JsonValue
+ @Override
+ public String toString() {
+ return this.value;
+ }
+
+ @JsonCreator
+ public static RequestType fromValue(String value) {
+ RequestType constant = CONSTANTS.get(value);
+ if (constant == null) {
+ throw new IllegalArgumentException(value);
+ } else {
+ return constant;
+ }
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoInterface.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoInterface.java
new file mode 100644
index 0000000..3e78814
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoInterface.java
@@ -0,0 +1,130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.osam.mso;
+
+import io.joshworks.restclient.http.HttpResponse;
+import io.joshworks.restclient.http.mapper.ObjectMapper;
+import lombok.SneakyThrows;
+import org.onap.osam.aai.util.CustomJacksonJaxBJsonProvider;
+import org.onap.osam.mso.rest.RequestDetails;
+import org.onap.osam.mso.rest.RequestDetailsWrapper;
+
+public interface MsoInterface {
+
+ MsoResponseWrapper createSvcInstance(RequestDetails requestDetails, String endpoint);
+
+ //For VoLTE E2E services
+ MsoResponseWrapper createE2eSvcInstance(Object requestDetails, String endpoint);
+ MsoResponseWrapper deleteE2eSvcInstance(Object requestDetails, String endpoint);
+
+ /**
+ * will create a virtual network function using MSO service.
+ * @param requestDetails - information about the vnf to create
+ * @return - the response body recived from MSO
+ * @throws Exception
+ */
+ MsoResponseWrapper createVnf(RequestDetails requestDetails, String endpoint);
+
+ MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String endpoint);
+ /**
+ *
+ * @param requestDetails
+ * @param path
+ * @return
+ * @throws Exception
+ */
+ MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String path);
+
+ /**
+ *
+ * @param requestDetails
+ * @return
+ * @throws Exception
+ */
+ MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String endpoint);
+
+ MsoResponseWrapper createConfigurationInstance(org.onap.osam.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String endpoint);
+
+ MsoResponseWrapper scaleOutVFModuleInstance(RequestDetailsWrapper requestDetailsWrapper, String endpoint);
+
+ MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String endpoint);
+
+ MsoResponseWrapper unassignSvcInstance(RequestDetails requestDetails, String endpoint);
+
+ MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String endpoint);
+
+ MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String endpoint);
+
+ MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String endpoint);
+
+ MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String endpoint);
+
+ MsoResponseWrapper getOrchestrationRequest(String endpoint);
+
+ MsoResponseWrapper getOrchestrationRequestsForDashboard(String t , String sourceId , String endpoint , RestObject restObject);
+
+ MsoResponseWrapper getManualTasksByRequestId(String t , String sourceId , String endpoint , RestObject restObject);
+
+ MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject restObject);
+
+ //MsoResponseWrapper updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String vnf_endpoint);
+
+ //MsoResponseWrapper replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String vnf_endpoint);
+
+ MsoResponseWrapper deleteConfiguration(org.onap.osam.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String pmc_endpoint);
+
+ MsoResponseWrapper setConfigurationActiveStatus(RequestDetails requestDetails, String endpoint);
+
+ MsoResponseWrapper setPortOnConfigurationStatus(RequestDetails requestDetails, String endpoint);
+
+ void setServiceInstanceStatus(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject<String> restObject);
+
+ MsoResponseWrapperInterface changeManagementUpdate(RequestDetailsWrapper requestDetails, String endpoint);
+
+ MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String endpoint);
+
+ MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath);
+
+ <T> HttpResponse<T> get(String path, Class<T> responseClass);
+
+ <T> HttpResponse<T> post(String path, RequestDetailsWrapper requestDetailsWrapper,
+ Class<T> responseClass);
+
+ static ObjectMapper objectMapper() {
+ return new ObjectMapper() {
+ CustomJacksonJaxBJsonProvider mapper = new CustomJacksonJaxBJsonProvider();
+
+ @SneakyThrows
+ @Override
+ public <T> T readValue(String s, Class<T> aClass) {
+ return mapper.getMapper().readValue(s, aClass);
+ }
+
+ @SneakyThrows
+ @Override
+ public String writeValue(Object o) {
+ return mapper.getMapper().writeValueAsString(o);
+ }
+ };
+ }
+}
+
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoProperties.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoProperties.java
new file mode 100644
index 0000000..674ac08
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoProperties.java
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+public class MsoProperties extends SystemProperties {
+
+ //VID Properties related to MSO
+ public static final String MSO_SERVER_URL = "mso.server.url";
+
+ /** The Constant MSO_DME2_SERVER_URL. */
+ public static final String MSO_DME2_SERVER_URL = "mso.dme2.server.url";
+
+ /** The Constant MSO_DME2_CLIENT_TIMEOUT. */
+ public static final String MSO_DME2_CLIENT_TIMEOUT = "mso.dme2.client.timeout";
+
+ /** The Constant MSO_DME2_CLIENT_READ_TIMEOUT. */
+ public static final String MSO_DME2_CLIENT_READ_TIMEOUT = "mso.dme2.client.read.timeout";
+
+ /** The Constant MSO_SERVER_URL_DEFAULT. */
+ public static final String MSO_SERVER_URL_DEFAULT= "";
+
+ /** The Constant MSO_POLLING_INTERVAL_MSECS. */
+ // number of msecs to wait between polling requests
+ public static final String MSO_POLLING_INTERVAL_MSECS = "mso.polling.interval.msecs";
+
+ /** The Constant MSO_POLLING_INTERVAL_MSECS_DEFAULT. */
+ public static final String MSO_POLLING_INTERVAL_MSECS_DEFAULT = "60000";
+
+ /** The Constant MSO_DME2_ENABLED. */
+ public static final String MSO_DME2_ENABLED = "mso.dme2.enabled";
+
+ /** The Constant MSO_MAX_POLLS. */
+ public static final String MSO_MAX_POLLS = "mso.max.polls";
+
+ /** The Constant MSO_MAX_POLLS_DEFAULT. */
+ public static final String MSO_MAX_POLLS_DEFAULT = "10"; //10
+
+ /** The Constant MSO_USER_NAME. */
+ public static final String MSO_USER_NAME = "mso.user.name"; //m03346
+
+ /** The Constant MSO_PASSWORD. */
+ public static final String MSO_PASSWORD = "mso.password.x";
+
+ /** The Constant MSO_REST_API_SVC_INSTANCE. */
+ public static final String MSO_REST_API_E2E_SVC_INSTANCE = "mso.restapi.svc.e2einstance"; // /e2eServiceInstances/v3
+
+ /** The Constant MSO_REST_API_SVC_INSTANCE. */
+ public static final String MSO_REST_API_SVC_INSTANCE = "mso.restapi.svc.instance"; // /serviceInstances/v2
+
+ /** The Constant MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE. */
+ public static final String MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE = "mso.restapi.svc.instance.deleteAndUnassign";
+
+ /** The Constant MSO_REST_API_VNF_INSTANCE. */
+ public static final String MSO_REST_API_VNF_INSTANCE = "mso.restapi.vnf.instance"; // /serviceInstances/v2/{service_instance_id}/vnfs
+
+ /** The Constant MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE. */
+ public static final String MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE = "mso.restapi.vnf.changemanagement.instance"; // /serviceInstances/v2/{service_instance_id}/vnfs/{request_type}
+
+ /** The Constant MSO_REST_API_NETWORK_INSTANCE. */
+ public static final String MSO_REST_API_NETWORK_INSTANCE = "mso.restapi.network.instance"; // /serviceInstances/v2/{serviceInstanceId}/networks
+
+ /** The Constant MSO_REST_API_GET_ORC_REQ. */
+ public static final String MSO_REST_API_GET_ORC_REQ = "mso.restapi.get.orc.req";
+
+ /** The Constant MSO_REST_API_GET_ORC_REQS. */
+ public static final String MSO_REST_API_GET_ORC_REQS = "mso.restapi.get.orc.reqs";
+
+ /** The Constant MSO_REST_API_GET_MAN_TASK. */
+ public static final String MSO_REST_API_GET_MAN_TASKS = "mso.restapi.get.man.tasks";
+
+ /** The Constant MSO_REST_API_VF_MODULE_INSTANCE. */
+ public static final String MSO_REST_API_VF_MODULE_INSTANCE = "mso.restapi.vf.module.instance";
+
+ public static final String MSO_REST_API_VF_MODULE_SCALE_OUT = "mso.restapi.vf.module.scaleout";
+
+ /** The Constant MSO_REST_API_VOLUME_GROUP_INSTANCE. */
+ public static final String MSO_REST_API_VOLUME_GROUP_INSTANCE = "mso.restapi.volume.group.instance"; //serviceInstances/v2/{serviceInstanceId}/volumeGroups
+
+ /** The Constant MSO_REST_API_CONFIGURATION_INSTANCE. */
+ public static final String MSO_REST_API_CONFIGURATIONS = "mso.restapi.configurations"; //serviceInstances/v5/{serviceInstanceId}/configurations
+ public static final String MSO_REST_API_CONFIGURATION_INSTANCE = "mso.restapi.configuration.instance"; //serviceInstances/v5/{serviceInstanceId}/configurations/{configurationId}
+
+ /** The Constant MSO_REST_API_OPERATIONAL_ENVIRONMENT */
+ public static final String MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE = "mso.restapi.operationalEnvironment.activate";
+ public static final String MSO_REST_API_OPERATIONAL_ENVIRONMENT_DEACTIVATE = "mso.restapi.operationalEnvironment.deactivate";
+
+ /** The Constant MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE */
+ public static final String MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE = "mso.restapi.operationalEnvironment.create";
+
+ /** The Constant MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS */
+ public static final String MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS = "mso.restapi.operationalEnvironment.cloudResourcesRequests.status";
+
+ /** The logger. */
+ public EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoProperties.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoResponseWrapper.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoResponseWrapper.java
new file mode 100644
index 0000000..1723c44
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoResponseWrapper.java
@@ -0,0 +1,127 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import javax.ws.rs.core.Response;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "status",
+ "entity"
+})
+
+public class MsoResponseWrapper implements MsoResponseWrapperInterface {
+
+
+ public MsoResponseWrapper() {
+ }
+
+ public MsoResponseWrapper(Response response) {
+ setEntity(response.readEntity(String.class));
+ setStatus(response.getStatus());
+ }
+
+
+ @JsonProperty("status")
+ private int status;
+
+ /** The entity. */
+ @JsonProperty("entity")
+ private String entity;
+
+ /**
+ * Gets the entity.
+ *
+ * @return the entity
+ */
+ @Override
+ @JsonProperty("entity")
+ public String getEntity() {
+ return entity;
+ }
+
+ /**
+ * Gets the status.
+ *
+ * @return the status
+ */
+ @Override
+ @JsonProperty("status")
+ public int getStatus() {
+ return status;
+ }
+
+ /**
+ * Sets the status.
+ *
+ * @param v the new status
+ */
+ @JsonProperty("status")
+ public void setStatus(int v) {
+ this.status = v;
+ }
+
+ /**
+ * Sets the entity.
+ *
+ * @param v the new entity
+ */
+ @JsonProperty("entity")
+ public void setEntity(String v) {
+ this.entity = v;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /**
+ * Gets the response.
+ *
+ * @return the response
+ */
+ @JsonIgnore
+ public String getResponse () {
+
+ StringBuilder b = new StringBuilder ("{ \"status\": ");
+ b.append(getStatus()).append(", \"entity\": " );
+ if (this.getEntity() == null || this.getEntity().isEmpty()) {
+ b.append("\"\"");
+ } else {
+ b.append(this.getEntity());
+ }
+ b.append("}");
+ return (b.toString());
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoResponseWrapper2.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoResponseWrapper2.java
new file mode 100644
index 0000000..f23fd42
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoResponseWrapper2.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.osam.mso;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.joshworks.restclient.http.HttpResponse;
+
+@JsonPropertyOrder({
+ "status",
+ "entity"
+})
+
+public class MsoResponseWrapper2<T> implements MsoResponseWrapperInterface {
+
+ final static ObjectMapper objectMapper = new ObjectMapper();
+
+ private final int status;
+ private final T entity;
+ private final String raw;
+
+ public MsoResponseWrapper2(RestObject<T> msoResponse) {
+ this.status = msoResponse.getStatusCode();
+ this.entity = msoResponse.get();
+ this.raw = msoResponse.getRaw();
+ }
+
+ public MsoResponseWrapper2(HttpResponse<T> msoResponse) {
+ this.status = msoResponse.getStatus();
+ this.entity = msoResponse.getBody();
+ this.raw = msoResponse.getBody().toString();
+ }
+
+ public MsoResponseWrapper2(
+ @JsonProperty(value = "status", required = true) int status,
+ @JsonProperty(value = "entity", required = true) T entity) {
+ this.status = status;
+ this.entity = entity;
+ this.raw = null;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ @Override
+ @JsonIgnore
+ public String getResponse() {
+ try {
+ return objectMapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ return getEntity() != null ? getEntity().toString() : null;
+ }
+ }
+
+ @JsonProperty
+ public Object getEntity() {
+ return entity != null ? entity : raw;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoResponseWrapperInterface.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoResponseWrapperInterface.java
new file mode 100644
index 0000000..e0b542b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoResponseWrapperInterface.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public interface MsoResponseWrapperInterface {
+ @JsonProperty("entity")
+ Object getEntity();
+
+ @JsonProperty("status")
+ int getStatus();
+
+ @JsonIgnore
+ String getResponse();
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoUtil.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoUtil.java
new file mode 100644
index 0000000..d4ec72e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/MsoUtil.java
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.joshworks.restclient.http.HttpResponse;
+import org.apache.commons.lang3.ObjectUtils;
+import org.glassfish.jersey.client.ClientResponse;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+import static org.onap.osam.utils.Logging.getMethodName;
+
+public class MsoUtil {
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoUtil.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /**
+ * Wrap response.
+ *
+ * @param body the body
+ * @param statusCode the status code
+ * @return the mso response wrapper
+ */
+ public static MsoResponseWrapper wrapResponse ( String body, int statusCode ) {
+
+ MsoResponseWrapper w = new MsoResponseWrapper();
+ w.setStatus (statusCode);
+ w.setEntity(body);
+
+ return w;
+ }
+
+ /**
+ * Wrap response.
+ *
+ * @param cres the cres
+ * @return the mso response wrapper
+ */
+ public static MsoResponseWrapper wrapResponse (ClientResponse cres) {
+ String resp_str = "";
+ if ( cres != null ) {
+ resp_str = cres.readEntity(String.class);
+ }
+ int statuscode = cres.getStatus();
+ MsoResponseWrapper w = MsoUtil.wrapResponse ( resp_str, statuscode );
+ return (w);
+ }
+
+ /**
+ * Wrap response.
+ *
+ * @param rs the rs
+ * @return the mso response wrapper
+ */
+ public static MsoResponseWrapper wrapResponse (RestObject<String> rs) {
+ String resp_str = null;
+ int status = 0;
+ if ( rs != null ) {
+ resp_str = rs.get() != null ? rs.get() : rs.getRaw();
+ status = rs.getStatusCode();
+ }
+ MsoResponseWrapper w = MsoUtil.wrapResponse ( resp_str, status );
+ return (w);
+ }
+
+ public static <T> MsoResponseWrapper wrapResponse (HttpResponse<T> rs) {
+ MsoResponseWrapper w = new MsoResponseWrapper();
+ w.setStatus (rs.getStatus());
+ if(rs.getRawBody() != null) {
+ w.setEntity(ObjectUtils.toString(rs.getBody()));
+ }
+ return w;
+ }
+
+ /**
+ * Convert pojo to string.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @return the string
+ * @throws JsonProcessingException the json processing exception
+ */
+ public static <T> String convertPojoToString ( T t ) {
+
+ String methodName = "convertPojoToString";
+ ObjectMapper mapper = new ObjectMapper();
+ String r_json_str = "";
+ if ( t != null ) {
+ try {
+ r_json_str = mapper.writeValueAsString(t);
+ }
+ catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,getMethodName() + " Unable to parse object of type " + t.getClass().getName() + " as json", j);
+ }
+ }
+ return (r_json_str);
+ }
+
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/RestMsoImplementation.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/RestMsoImplementation.java
new file mode 100644
index 0000000..be9ff9b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/RestMsoImplementation.java
@@ -0,0 +1,406 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.codec.binary.Base64;
+import org.eclipse.jetty.util.security.Password;
+import org.onap.osam.aai.util.HttpClientMode;
+import org.onap.osam.aai.util.HttpsAuthClient;
+import org.onap.osam.client.HttpBasicClient;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.mso.rest.RequestDetailsWrapper;
+import org.onap.osam.mso.rest.RestInterface;
+import org.onap.osam.utils.Logging;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.Response;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Date;
+import java.util.UUID;
+
+import static org.onap.osam.utils.Logging.*;
+
+public class RestMsoImplementation implements RestInterface {
+
+ public static final String START_LOG = " start";
+ public static final String APPLICATION_JSON = "application/json";
+ public static final String WITH_STATUS = " with status=";
+ public static final String URL_LOG = ", url=";
+ public static final String NO_RESPONSE_ENTITY_LOG = " No response entity, this is probably ok, e=";
+ public static final String WITH_URL_LOG = " with url=";
+ public static final String EXCEPTION_LOG = ", Exception: ";
+ public static final String REST_API_SUCCESSFULL_LOG = " REST api was successfull!";
+ public static final String REST_API_POST_WAS_SUCCESSFUL_LOG = " REST api POST was successful!";
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMsoImplementation.class);
+ private final EELFLogger outgoingRequestsLogger = Logging.getRequestsLogger("mso");
+
+ /**
+ * The Constant dateFormat.
+ */
+ static final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The client. */
+ private Client client = null;
+
+ @Autowired
+ HttpsAuthClient httpsAuthClient;
+
+ /** The common headers. */
+ /**
+ * Instantiates a new mso rest interface.
+ */
+
+ @SuppressWarnings("Duplicates")
+ @Override
+ public MultivaluedHashMap<String, Object> initMsoClient()
+ {
+ final String methodname = "initRestClient()";
+
+ final String username = SystemProperties.getProperty(MsoProperties.MSO_USER_NAME);
+ final String password = SystemProperties.getProperty(MsoProperties.MSO_PASSWORD);
+ final String mso_url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL);
+ final String decrypted_password = Password.deobfuscate(password);
+
+ String authString = username + ":" + decrypted_password;
+
+ byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
+ String authStringEnc = new String(authEncBytes);
+
+ MultivaluedHashMap<String, Object> commonHeaders = new MultivaluedHashMap();
+ commonHeaders.put("Authorization", Collections.singletonList(("Basic " + authStringEnc)));
+ //Pass calling application identifier to SO
+ commonHeaders.put("X-FromAppId", Collections.singletonList(SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME)));
+ try {
+ commonHeaders.put(REQUEST_ID_HEADER_KEY, Collections.singletonList(Logging.extractOrGenerateRequestId()));
+ }
+ catch (IllegalStateException e){
+ //in async jobs we don't have any HttpServletRequest
+ commonHeaders.put(REQUEST_ID_HEADER_KEY, Collections.singletonList(UUID.randomUUID().toString()));
+ }
+
+
+ boolean useSsl = true;
+ if ( (mso_url != null) && ( !(mso_url.isEmpty()) ) ) {
+ useSsl = mso_url.startsWith("https");
+ }
+ if (client == null) {
+
+ try {
+ if ( useSsl ) {
+ client = httpsAuthClient.getClient(HttpClientMode.WITHOUT_KEYSTORE);
+ }
+ else {
+ client = HttpBasicClient.getClient();
+ }
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodname + " Unable to get the SSL client");
+ }
+ }
+
+ return commonHeaders;
+ }
+
+ public <T> void Get (T t, String sourceId, String path, RestObject<T> restObject ) {
+ String methodName = "Get";
+
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_LOG);
+
+ String url="";
+ restObject.set(t);
+
+ url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+
+ MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
+ final Response cres = client.target(url)
+ .request()
+ .accept(APPLICATION_JSON)
+ .headers(commonHeaders)
+ .get();
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, cres);
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if (status == 200 || status == 202) {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + REST_API_SUCCESSFULL_LOG);
+
+ } else {
+ throw new GenericUncheckedException(methodName + WITH_STATUS + status + ", url= " + url );
+ }
+
+ logger.debug(EELFLoggerDelegate.debugLogger,methodName + " received status=" + status );
+
+ return;
+ }
+
+ public <T> RestObject<T> GetForObject(String sourceID, String path, Class<T> clazz) {
+ final String methodName = getMethodName();
+ logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {}, {})", getMethodCallerName(), methodName, sourceID, path, clazz);
+
+ String url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " sending request to url= " + url);
+
+ MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
+ final Response cres = client.target(url)
+ .request()
+ .accept(APPLICATION_JSON)
+ .headers(commonHeaders)
+ .get();
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, cres);
+ final RestObject<T> restObject = cresToRestObject(cres, clazz);
+ int status = cres.getStatus();
+
+ if (status == 200 || status == 202) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + REST_API_SUCCESSFULL_LOG);
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + WITH_STATUS +status+ URL_LOG +url);
+ }
+
+ logger.debug(EELFLoggerDelegate.debugLogger,methodName + " received status=" + status );
+
+ return restObject;
+ }
+
+ @Override
+ public <T> void Delete(T t, Object r, String sourceID, String path, RestObject<T> restObject) {
+
+ String methodName = "Delete";
+ String url="";
+ Response cres = null;
+
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + START_LOG);
+
+ try {
+ MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
+
+ url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url, r);
+ cres = client.target(url)
+ .request()
+
+ .accept(APPLICATION_JSON)
+ .headers(commonHeaders)
+ //.entity(r)
+ .build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON)).invoke();
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres);
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if (status == 404) { // resource not found
+ String msg = "Resource does not exist...: " + cres.getStatus();
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg);
+ } else if (status == 200 || status == 204){
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + "Resource " + url + " deleted");
+ } else if (status == 202) {
+ String msg = "Delete in progress: " + status;
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg);
+ }
+ else {
+ String msg = "Deleting Resource failed: " + status;
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg);
+ }
+
+ try {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + NO_RESPONSE_ENTITY_LOG
+ + e.getMessage());
+ }
+
+ }
+ catch (Exception e)
+ {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + WITH_URL_LOG +url+ EXCEPTION_LOG + e.toString());
+ throw e;
+
+ }
+ }
+
+ public <T> RestObject<T> PostForObject(Object requestDetails, String sourceID, String path, Class<T> clazz) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {}, {}, {})", getMethodCallerName(), getMethodName(), requestDetails, sourceID, path, clazz);
+ RestObject<T> restObject = new RestObject<>();
+ Post(clazz, requestDetails, path, restObject);
+ return restObject;
+ }
+
+ @Override
+ public <T> void Post(T t, Object r, String sourceID, String path, RestObject<T> restObject) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {}, {}, {})", getMethodCallerName(), getMethodName(), t.getClass(), r, sourceID, path);
+ Post(t.getClass(), r, path, restObject);
+ }
+
+ public Invocation.Builder prepareClient(String path, String methodName) {
+ MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
+
+ String url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " sending request to url= " + url);
+ // Change the content length
+ return client.target(url)
+ .request()
+ .accept(APPLICATION_JSON)
+ .headers(commonHeaders);
+ }
+
+
+
+ public <T> void Post(Class<?> tClass, Object requestDetails, String path, RestObject<T> restObject) {
+ String methodName = "Post";
+ String url="";
+
+ try {
+
+ MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
+
+ url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, requestDetails);
+ // Change the content length
+ final Response cres = client.target(url)
+ .request()
+ .accept(APPLICATION_JSON)
+ .headers(commonHeaders)
+ .post(Entity.entity(requestDetails, MediaType.APPLICATION_JSON));
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.POST, url, cres);
+ final RestObject<T> cresToRestObject = cresToRestObject(cres, tClass);
+ restObject.set(cresToRestObject.get());
+ restObject.setStatusCode(cresToRestObject.getStatusCode());
+ restObject.setRaw(cresToRestObject.getRaw());
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if ( status >= 200 && status <= 299 ) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + REST_API_POST_WAS_SUCCESSFUL_LOG);
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + REST_API_POST_WAS_SUCCESSFUL_LOG);
+
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + WITH_STATUS +status+ URL_LOG +url);
+ }
+
+ } catch (Exception e)
+ {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + WITH_URL_LOG +url+ EXCEPTION_LOG + e.toString());
+ throw e;
+
+ }
+
+ logger.debug(EELFLoggerDelegate.debugLogger, "end {}() => ({}){}", getMethodName(), tClass, restObject);
+ }
+
+ private <T> RestObject<T> cresToRestObject(Response cres, Class<?> tClass) {
+ RestObject<T> restObject = new RestObject<>();
+
+ String rawEntity = null;
+ try {
+ cres.bufferEntity();
+ rawEntity = cres.readEntity(String.class);
+ restObject.setRaw(rawEntity);
+ T t = (T) new ObjectMapper().readValue(rawEntity, tClass);
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + getMethodCallerName() + " Error reading response entity as " + tClass + ": , e="
+ + e.getMessage() + ", Entity=" + rawEntity);
+ } catch (Exception e2) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + getMethodCallerName() + NO_RESPONSE_ENTITY_LOG
+ + e.getMessage());
+ }
+ }
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ return restObject;
+
+ }
+
+ @Override
+ public <T> void Put(T t, RequestDetailsWrapper r, String sourceID, String path, RestObject<T> restObject) {
+
+ String methodName = "Put";
+ String url="";
+
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + START_LOG);
+
+ try {
+
+ MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
+
+ url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.PUT, url, r);
+ // Change the content length
+ final Response cres = client.target(url)
+ .request()
+ .accept(APPLICATION_JSON)
+ .headers(commonHeaders)
+ //.header("content-length", 201)
+ //.header("X-FromAppId", sourceID)
+ .put(Entity.entity(r, MediaType.APPLICATION_JSON));
+
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.PUT, url, cres);
+
+ try {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + NO_RESPONSE_ENTITY_LOG
+ + e.getMessage());
+ }
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if ( status >= 200 && status <= 299 ) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + REST_API_POST_WAS_SUCCESSFUL_LOG);
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + REST_API_POST_WAS_SUCCESSFUL_LOG);
+
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + WITH_STATUS +status+ URL_LOG +url);
+ }
+
+ } catch (Exception e)
+ {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + WITH_URL_LOG +url+ EXCEPTION_LOG + e.toString());
+ throw e;
+
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/RestObject.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/RestObject.java
new file mode 100644
index 0000000..aa38226
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/RestObject.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.MoreObjects;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
+import javax.ws.rs.core.Response;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import static org.onap.osam.utils.Logging.getMethodCallerName;
+
+public class RestObject<T> {
+
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ final static ObjectMapper objectMapper = new ObjectMapper();
+
+ // T stands for "Type"
+ private T t;
+
+ // The string source of t, if available
+ private String rawT;
+
+ /** The status code. */
+ private int statusCode= 0;
+
+ public RestObject() {
+ }
+
+ public RestObject(Response cres, Class<?> tClass, EELFLoggerDelegate logger) {
+
+ String rawEntity = null;
+ try {
+ cres.bufferEntity();
+ rawEntity = cres.readEntity(String.class);
+ T t = (T) objectMapper.readValue(rawEntity, tClass);
+ this.set(t);
+ }
+ catch ( Exception e ) {
+ try {
+ this.setRaw(rawEntity);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + getMethodCallerName() + " Error reading response entity as " + tClass + ": , e="
+ + e.getMessage() + ", Entity=" + rawEntity);
+ } catch (Exception e2) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + getMethodCallerName() + " No response entity, this is probably ok, e="
+ + e.getMessage());
+ }
+ }
+
+ int status = cres.getStatus();
+ this.setStatusCode (status);
+ }
+
+
+ /**
+ * Sets the.
+ *
+ * @param t the t
+ */
+ public void set(T t) { this.t = t; }
+
+ /**
+ * Gets the.
+ *
+ * @return the t
+ */
+ public T get() { return t; }
+
+ /**
+ * Sets the status code.
+ *
+ * @param v the new status code
+ */
+ public void setStatusCode(int v) { this.statusCode = v; }
+
+ /**
+ * Gets the status code.
+ *
+ * @return the status code
+ */
+ public int getStatusCode() { return this.statusCode; }
+
+ public String getRaw() {
+ return rawT;
+ }
+
+ public void setRaw(String rawT) {
+ this.rawT = rawT;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("t", t)
+ .add("rawT", rawT)
+ .add("statusCode", statusCode)
+ .toString();
+ }
+}
+
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/model/ServiceInstantiationRequestDetails.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/model/ServiceInstantiationRequestDetails.java
new file mode 100644
index 0000000..cd67cbd
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/model/ServiceInstantiationRequestDetails.java
@@ -0,0 +1,187 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import org.onap.osam.domain.mso.CloudConfiguration;
+import org.onap.osam.domain.mso.ModelInfo;
+import org.onap.osam.domain.mso.SubscriberInfo;
+import org.onap.osam.model.serviceInstantiation.VfModule;
+
+import java.util.List;
+import java.util.Map;
+
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+
+public class ServiceInstantiationRequestDetails {
+
+ @JsonProperty("modelInfo")
+ private ModelInfo modelInfo;
+
+ @JsonProperty("owningEntity")
+ private ServiceInstantiationOwningEntity owningEntity;
+
+ @JsonProperty("subscriberInfo")
+ private SubscriberInfo subscriberInfo;
+
+ @JsonProperty("project")
+ private Project project;
+
+ @JsonProperty("requestParameters")
+ private RequestParameters requestParameters;
+
+ @JsonProperty("requestInfo")
+ private RequestInfo requestInfo;
+
+ public ServiceInstantiationRequestDetails(@JsonProperty(value = "modelInfo", required = true) ModelInfo modelInfo,
+ @JsonProperty(value = "owningEntity", required = true) ServiceInstantiationOwningEntity owningEntity,
+ @JsonProperty(value = "subscriberInfo", required = true) SubscriberInfo subscriberInfo,
+ @JsonProperty(value = "project", required = true) Project project,
+ @JsonProperty(value = "requestInfo", required = true) RequestInfo requestInfo,
+ @JsonProperty(value = "requestParameters", required = true) RequestParameters requestParameters) {
+ this.modelInfo = modelInfo;
+ this.owningEntity = owningEntity;
+ this.subscriberInfo = subscriberInfo;
+ this.project = project;
+ this.requestInfo = requestInfo;
+ this.requestParameters = requestParameters;
+ }
+
+ public static class ServiceInstantiationOwningEntity{
+ public final String owningEntityId;
+ public final String owningEntityName;
+
+ public ServiceInstantiationOwningEntity(String owningEntityId, String owningEntityName) {
+ this.owningEntityId = owningEntityId;
+ this.owningEntityName = owningEntityName;
+ }
+ }
+
+ public static class RequestInfo {
+
+ @JsonInclude(NON_NULL) public final String instanceName;
+ public final String productFamilyId;
+ public final String source;
+ public final boolean suppressRollback;
+ public final String requestorId;
+
+ public RequestInfo(String instanceName, String productFamilyId, String source, boolean rollbackOnFailure, String requestorId) {
+ this.instanceName = instanceName;
+ this.productFamilyId = productFamilyId;
+ this.source = source;
+ this.requestorId = requestorId;
+ // in the FE we are asking for "RollbackOnFailure" but to MSO we are passing the negative value "suppressRollback"
+ this.suppressRollback = !rollbackOnFailure;
+ }
+ }
+
+ public static class Project{
+ public final String projectName;
+
+ public Project(String projectName) {
+ this.projectName = projectName;
+ }
+ }
+
+ public static class RequestParameters {
+
+ public final String subscriptionServiceType;
+ public final boolean aLaCarte;
+ public final List<ServiceInstantiationService> userParams;
+
+ public RequestParameters(String subscriptionServiceType, boolean aLaCarte, List<ServiceInstantiationService> userParams) {
+ this.subscriptionServiceType = subscriptionServiceType;
+ this.aLaCarte = aLaCarte;
+ this.userParams = userParams;
+ }
+ }
+
+ @JsonTypeName("service")
+ @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
+ public static class ServiceInstantiationService{
+ public ModelInfo modelInfo = new ModelInfo();
+ @JsonInclude(NON_NULL) public String instanceName;
+ public List<Map<String,String>> instanceParams;
+ public ServiceInstantiationVnfList resources;
+
+ public ServiceInstantiationService (ModelInfo modelInfo, String instanceName, List<Map<String,String>> instanceParams, ServiceInstantiationVnfList vnfs){
+ this.modelInfo.setModelType(modelInfo.getModelType());
+ this.modelInfo.setModelName(modelInfo.getModelName());
+ this.modelInfo.setModelVersionId(modelInfo.getModelVersionId());
+ this.instanceName = instanceName;
+ this.instanceParams = instanceParams;
+ this.resources = vnfs;
+ }
+ }
+
+ public static class ServiceInstantiationVnfList{
+ public final List<ServiceInstantiationVnf> vnfs;
+
+ public ServiceInstantiationVnfList(List<ServiceInstantiationVnf> vnfList) {
+ this.vnfs = vnfList;
+ }
+ }
+
+ public static class ServiceInstantiationVnf{
+ public final ModelInfo modelInfo;
+ public final CloudConfiguration cloudConfiguration;
+ public final Platform platform;
+ public final LineOfBusiness lineOfBusiness;
+ public final String productFamilyId;
+ public final List<Map<String, String>> instanceParams;
+ @JsonInclude(NON_EMPTY) public final List<VfModule> vfModules;
+ @JsonInclude(NON_NULL) public final String instanceName;
+
+ public ServiceInstantiationVnf(ModelInfo modelInfo, CloudConfiguration cloudConfiguration, String platform, String lineOfBusiness, String productFamilyId, List<Map<String, String>> instanceParams, List<VfModule> vfModules, String instanceName) {
+ this.modelInfo = modelInfo;
+ this.cloudConfiguration = cloudConfiguration;
+ this.platform = new Platform(platform);
+ this.lineOfBusiness = new LineOfBusiness(lineOfBusiness);
+ this.productFamilyId = productFamilyId;
+ this.instanceParams = instanceParams;
+ this.vfModules = vfModules;
+ this.instanceName = instanceName;
+ }
+ }
+
+ public static class Platform{
+ public final String platformName;
+
+ public Platform(String platformName) {
+ this.platformName = platformName;
+ }
+ }
+
+ public static class LineOfBusiness{
+ public final String lineOfBusinessName;
+
+ public LineOfBusiness(String lineOfBusiness) {
+ this.lineOfBusinessName = lineOfBusiness;
+ }
+ }
+}
+
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/AsyncRequestStatus.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/AsyncRequestStatus.java
new file mode 100644
index 0000000..722e7dc
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/AsyncRequestStatus.java
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.onap.osam.domain.mso.RequestStatus;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class AsyncRequestStatus {
+
+ public Request request;
+
+ public AsyncRequestStatus(Request request) {
+ this.request = request;
+ }
+
+ public AsyncRequestStatus() {
+
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Request {
+
+ public Request(RequestStatus requestStatus) {
+ this.requestStatus = requestStatus;
+ }
+
+ public Request() {
+ }
+
+ public String requestId;
+
+ public InstanceReferences instanceReferences;
+
+ /**
+ * The request status.
+ */
+ public RequestStatus requestStatus;
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class InstanceReferences {
+
+ public String serviceInstanceId;
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/MsoRestClientNew.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/MsoRestClientNew.java
new file mode 100644
index 0000000..3964f3e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/MsoRestClientNew.java
@@ -0,0 +1,515 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.osam.mso.rest;
+
+import com.google.common.collect.ImmutableMap;
+import io.joshworks.restclient.http.HttpResponse;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.codec.binary.Base64;
+import org.eclipse.jetty.util.security.Password;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.client.SyncRestClient;
+import org.onap.osam.model.RequestReferencesContainer;
+import org.onap.osam.mso.*;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import org.onap.osam.utils.Logging;
+
+
+public class MsoRestClientNew implements MsoInterface {
+
+ public static final String X_FROM_APP_ID = "X-FromAppId";
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+ private static final String START = " start";
+ private final SyncRestClient client;
+ private final String baseUrl;
+ private final Map<String, String> commonHeaders;
+ /**
+ * The logger.
+ */
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestClientNew.class);
+
+ public MsoRestClientNew(SyncRestClient client, String baseUrl) {
+ this.client = client;
+ this.baseUrl = baseUrl;
+ this.commonHeaders = initCommonHeaders();
+ }
+
+ @Override
+ public MsoResponseWrapper createSvcInstance(RequestDetails requestDetails, String endpoint) {
+ String methodName = "createSvcInstance ";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+
+ return createInstance(requestDetails, path);
+ }
+
+ @Override
+ public MsoResponseWrapper createE2eSvcInstance(Object requestDetails, String endpoint) {
+ String methodName = "createE2eSvcInstance ";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+
+ return createInstance(requestDetails, path);
+ }
+
+ @Override
+ public MsoResponseWrapper createVnf(RequestDetails requestDetails, String endpoint) {
+
+ String methodName = "createVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+
+ return createInstance(requestDetails, path);
+ }
+
+ @Override
+ public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String endpoint) {
+
+ String methodName = "createNwInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+
+ return createInstance(requestDetails, path);
+ }
+
+ @Override
+ public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String endpoint) {
+ String methodName = "createVolumeGroupInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+
+ return createInstance(requestDetails, path);
+ }
+
+ @Override
+ public MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String endpoint) {
+ String methodName = "createVfModuleInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+
+ return createInstance(requestDetails, path);
+ }
+
+ @Override
+ public MsoResponseWrapper scaleOutVFModuleInstance(RequestDetailsWrapper requestDetailsWrapper, String endpoint) {
+ String methodName = "scaleOutVFModuleInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+ return createInstance(requestDetailsWrapper, path);
+ }
+
+ @Override
+ public MsoResponseWrapper createConfigurationInstance(org.onap.osam.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String endpoint) {
+ String methodName = "createConfigurationInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+
+ return createInstance(requestDetailsWrapper, path);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteE2eSvcInstance(Object requestDetails, String endpoint) {
+ String methodName = "deleteE2eSvcInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+ return deleteInstance(requestDetails, path);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String endpoint) {
+ String methodName = "deleteSvcInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+ return deleteInstance(requestDetails, path);
+ }
+
+ @Override
+ public MsoResponseWrapper unassignSvcInstance(RequestDetails requestDetails, String endpoint) {
+ String methodName = "unassignSvcInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ HttpResponse<String> response = client.post(endpoint, commonHeaders, requestDetails, String.class);
+ return MsoUtil.wrapResponse(response);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String endpoint) {
+ String methodName = "deleteVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+
+ return deleteInstance(requestDetails, path);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String endpoint) {
+ String methodName = "deleteVfModule";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+
+ return deleteInstance(requestDetails, path);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String endpoint) {
+ String methodName = "deleteVolumeGroupInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+
+ return deleteInstance(requestDetails, path);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String endpoint) {
+ String methodName = "deleteNwInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+
+ return deleteInstance(requestDetails, path);
+ }
+
+ @Override
+ public MsoResponseWrapper getOrchestrationRequest(String endpoint) {
+ String path = baseUrl + endpoint;
+
+ HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class);
+ return MsoUtil.wrapResponse(response);
+ }
+
+ public MsoResponseWrapper getManualTasks(String endpoint) {
+ String path = baseUrl + endpoint;
+
+ HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class);
+ return MsoUtil.wrapResponse(response);
+ }
+
+ public MsoResponseWrapper getOrchestrationRequestsForDashboard(String t, String sourceId, String path, RestObject restObject) {
+ String methodName = "getOrchestrationRequestsForDashboard";
+ logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ try {
+ MsoResponseWrapper w = getOrchestrationRequest(path);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+
+ return w;
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ public MsoResponseWrapper getManualTasksByRequestId(String t, String sourceId, String endpoint, RestObject restObject) {
+ String methodName = "getManualTasksByRequestId";
+ logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ try {
+ String path = baseUrl + endpoint;
+
+ MsoResponseWrapper w =getManualTasks(path);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+
+ return w;
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject restObject) {
+ String methodName = "completeManualTask";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Complete ");
+ try {
+ String path = baseUrl + endpoint;
+
+ HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
+ MsoResponseWrapper w = MsoUtil.wrapResponse(response);
+
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+ return w;
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ /* @Override
+ public MsoResponseWrapper replaceVnf(RequestDetails requestDetails, String endpoint) {
+ String methodName = "replaceVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+ return replaceInstance(requestDetails, path);
+ }*/
+
+ @Override
+ public MsoResponseWrapper deleteConfiguration(org.onap.osam.mso.rest.RequestDetailsWrapper requestDetailsWrapper, String pmc_endpoint) {
+ String methodName = "deleteConfiguration";
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + pmc_endpoint;
+
+ return deleteInstance(requestDetailsWrapper, path);
+ }
+
+ @Override
+ public MsoResponseWrapper setConfigurationActiveStatus(RequestDetails request, String endpoint) {
+ String methodName = "setConfigurationActiveStatus";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ try {
+ String path = baseUrl + endpoint;
+
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== "
+ + methodName + " calling change configuration active status, path =[" + path + "]");
+ HttpResponse<String> response = client.post(path, commonHeaders, request, String.class);
+ return MsoUtil.wrapResponse(response);
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper setPortOnConfigurationStatus(RequestDetails request, String endpoint) {
+ String methodName = "setPortOnConfigurationStatus";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ try {
+ String path = baseUrl + endpoint;
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== "
+ + methodName + " calling change port configuration status, path =[" + path + "]");
+ HttpResponse<String> response = client.post(path, commonHeaders, request, String.class);
+ return MsoUtil.wrapResponse(response);
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapperInterface changeManagementUpdate(RequestDetailsWrapper requestDetails, String endpoint) {
+ String path = baseUrl + endpoint;
+ HttpResponse<RequestReferencesContainer> response = client.post(path, commonHeaders, requestDetails, RequestReferencesContainer.class);
+ return MsoUtil.wrapResponse(response);
+ }
+
+ public MsoResponseWrapper replaceInstance(RequestDetails request, String path) {
+ String methodName = "replaceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Replace VNF, path =[" + path + "]");
+
+ HttpResponse<String> response = client.post(path, commonHeaders, request, String.class);
+ MsoResponseWrapper msoResponseWrapperObject = MsoUtil.wrapResponse(response);
+ int status = msoResponseWrapperObject.getStatus();
+ if (status == 202) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName +
+ ",post succeeded, msoResponseWrapperObject response:" + msoResponseWrapperObject.getResponse());
+ } else {
+ logger.error(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName +
+ ": post failed, msoResponseWrapperObject status" + status + ", response:" + msoResponseWrapperObject.getResponse());
+
+ // TODO
+ }
+ return msoResponseWrapperObject;
+
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+
+ }
+
+ /*@Override
+ public MsoResponseWrapper updateVnf(RequestDetails requestDetails, String endpoint) {
+ String methodName = "updateVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+ String path = baseUrl + endpoint;
+
+ RequestDetailsWrapper wrapper = new RequestDetailsWrapper();
+ wrapper.requestDetails = new MsoRequestDetails(requestDetails);
+ return updateInstance(requestDetails, path);
+ }*/
+
+ public MsoResponseWrapper updateInstance(RequestDetails request, String path) {
+ String methodName = "updateInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]");
+
+ HttpResponse<String> response = client.post(path, commonHeaders, request, String.class);
+ MsoResponseWrapper w = MsoUtil.wrapResponse(response);
+
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+ return w;
+
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+
+ }
+
+ public void setServiceInstanceStatus(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject<String> restObject) {
+ String methodName = "activateServiceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start ");
+ try {
+ String path = baseUrl + endpoint;
+ HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
+ MsoResponseWrapper w = MsoUtil.wrapResponse(response);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w =" + w.getResponse());
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String endpoint) {
+ String methodName = "removeRelationshipFromServiceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Remove relationship from service instance, path =[" + endpoint + "]");
+ String path = baseUrl + endpoint;
+ HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
+ return MsoUtil.wrapResponse(response);
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath) {
+ String methodName = "addRelationshipToServiceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Add relationship to service instance, path =[" + addRelationshipsPath + "]");
+ String path = baseUrl + addRelationshipsPath;
+
+ HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
+ return MsoUtil.wrapResponse(response);
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public <T> HttpResponse<T> get(String path, Class<T> responseClass) {
+ return client.get(path, commonHeaders, new HashMap<>(), responseClass);
+ }
+
+ @Override
+ public <T> HttpResponse<T> post(String path, RequestDetailsWrapper requestDetailsWrapper,
+ Class<T> responseClass) {
+ return client.post(path, commonHeaders, requestDetailsWrapper, responseClass);
+ }
+
+
+ private MsoResponseWrapper createInstance(Object request, String endpoint) {
+ String methodName = "createInstance";
+ logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ try {
+ HttpResponse<String> response = client.post(endpoint, commonHeaders, request, String.class);
+ return MsoUtil.wrapResponse(response);
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ /**
+ * Delete instance.
+ *
+ * @param request the request
+ * @param path the path
+ * @return the mso response wrapper
+ * @throws Exception the exception
+ */
+ private MsoResponseWrapper deleteInstance(Object request, String path) {
+ String methodName = "deleteInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START);
+
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]");
+
+ HttpResponse<String> response = client.delete(path, commonHeaders, String.class);
+ MsoResponseWrapper w = MsoUtil.wrapResponse(response);
+
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+ return w;
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+
+ }
+
+ private Map<String, String> initCommonHeaders() {
+ String username = SystemProperties.getProperty(MsoProperties.MSO_USER_NAME);
+ String password = SystemProperties.getProperty(MsoProperties.MSO_PASSWORD);
+ String decrypted_password = Password.deobfuscate(password);
+
+ String authString = username + ":" + decrypted_password;
+
+ byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
+ String authStringEnc = new String(authEncBytes);
+
+ Map<String, String> map = new HashMap<>();
+ map.put(HttpHeaders.AUTHORIZATION, "Basic " + authStringEnc);
+ map.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
+ map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ map.put(X_FROM_APP_ID, SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME));
+ map.put(SystemProperties.ECOMP_REQUEST_ID, Logging.extractOrGenerateRequestId());
+ return ImmutableMap.copyOf(map);
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/OperationalEnvironment/OperationEnvironmentRequestDetails.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/OperationalEnvironment/OperationEnvironmentRequestDetails.java
new file mode 100644
index 0000000..0a26b3b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/OperationalEnvironment/OperationEnvironmentRequestDetails.java
@@ -0,0 +1,142 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest.OperationalEnvironment;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+
+import java.util.List;
+
+public class OperationEnvironmentRequestDetails {
+ private final RequestInfo requestInfo;
+ private final List<RelatedInstance> relatedInstanceList;
+ private final RequestParameters requestParameters;
+
+ public OperationEnvironmentRequestDetails(@JsonProperty(value = "requestInfo", required = true) RequestInfo requestInfo,
+ @JsonProperty(value = "relatedInstanceList", required = true) List<RelatedInstance> relatedInstanceList,
+ @JsonProperty(value = "requestParameters", required = true) RequestParameters requestParameters) {
+ this.requestInfo = requestInfo;
+ this.relatedInstanceList = relatedInstanceList;
+ this.requestParameters = requestParameters;
+ }
+
+ public RequestInfo getRequestInfo() {
+ return requestInfo;
+ }
+
+ public List<RelatedInstance> getRelatedInstanceList() {
+ return relatedInstanceList;
+ }
+
+ public RequestParameters getRequestParameters() {
+ return requestParameters;
+ }
+
+ public static class RequestInfo {
+ private final String resourceType;
+ private final String instanceName;
+ private final String source;
+ private final String requestorId;
+
+ public RequestInfo(@JsonProperty(value = "resourceType", required = true) String resourceType,
+ @JsonProperty(value = "instanceName", required = true) String instanceName,
+ @JsonProperty(value = "source", required = true) String source,
+ @JsonProperty(value = "requestorId", required = true) String requestorId) {
+ this.resourceType = resourceType;
+ this.instanceName = instanceName;
+ this.source = source;
+ this.requestorId = requestorId;
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public String getRequestorId() {
+ return requestorId;
+ }
+ }
+
+ public static class RequestParameters {
+ private final String operationalEnvironmentType;
+ private final String tenantContext;
+ private final String workloadContext;
+
+ public RequestParameters(@JsonProperty(value = "operationalEnvironmentType", required = true) String operationalEnvironmentType,
+ @JsonProperty(value = "tenantContext", required = true) String tenantContext,
+ @JsonProperty(value = "workloadContext", required = true) String workloadContext) {
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ this.tenantContext = tenantContext;
+ this.workloadContext = workloadContext;
+ }
+ public String getOperationalEnvironmentType() {
+ return operationalEnvironmentType;
+ }
+
+ public String getTenantContext() {
+ return tenantContext;
+ }
+
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+ }
+
+ @JsonTypeName("relatedInstance")
+ @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
+ public static class RelatedInstance {
+ private final String resourceType;
+ private final String instanceId;
+ private final String instanceName;
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public RelatedInstance(@JsonProperty(value = "instanceName", required = true) String resourceType,
+ @JsonProperty(value = "instanceId", required = true) String instanceId,
+ @JsonProperty(value = "instanceName", required = true) String instanceName) {
+ this.resourceType = resourceType;
+ this.instanceId = instanceId;
+ this.instanceName = instanceName;
+ }
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RelatedInstance.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RelatedInstance.java
new file mode 100644
index 0000000..4bcacc9
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RelatedInstance.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "instanceName",
+ "instanceId",
+ "modelInfo"
+})
+public class RelatedInstance extends org.onap.osam.domain.mso.RelatedInstance{
+
+
+ @JsonProperty("modelInfo")
+ private org.onap.osam.domain.mso.ModelInfo modelInfo;
+
+ /** The additional properties. */
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * (Required).
+ *
+ * @return The modelInfo
+ */
+ @JsonProperty("modelInfo")
+ public org.onap.osam.domain.mso.ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+
+ /**
+ * (Required).
+ *
+ * @param modelInfo The modelInfo
+ */
+ @JsonProperty("modelInfo")
+ public void setModelInfo(org.onap.osam.domain.mso.ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RelatedInstance#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RelatedInstance#getAdditionalProperties()
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RelatedInstance#setAdditionalProperty(java.lang.String, java.lang.Object)
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RelatedInstance#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(getInstanceName()).append(getInstanceId()).append(modelInfo).append(additionalProperties).toHashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RelatedInstance#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof RelatedInstance) == false) {
+ return false;
+ }
+ RelatedInstance rhs = ((RelatedInstance) other);
+ return new EqualsBuilder().append(getInstanceName(), rhs.getInstanceName()).append(getInstanceId(), rhs.getInstanceId()).append(modelInfo, rhs.getModelInfo()).append(additionalProperties, rhs.additionalProperties).isEquals();
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RelatedInstanceWrapper.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RelatedInstanceWrapper.java
new file mode 100644
index 0000000..d32b8a5
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RelatedInstanceWrapper.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+public class RelatedInstanceWrapper {
+ public RelatedInstance relatedInstance;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RelatedModel.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RelatedModel.java
new file mode 100644
index 0000000..4a400bb
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RelatedModel.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import java.util.HashMap;
+import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "instanceId",
+ "modelInfo"
+})
+public class RelatedModel extends org.onap.osam.domain.mso.RelatedModel {
+
+ @JsonProperty("modelInfo")
+ private org.onap.osam.domain.mso.ModelInfo modelInfo;
+
+// /** The related model object instance list. */
+// @JsonProperty("instanceId")
+// private org.onap.vid.domain.mso.InstanceIds instanceId;
+
+ /** The additional properties. */
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * (Required).
+ *
+ * @return The modelInfo
+ */
+ @JsonProperty("modelInfo")
+ public org.onap.osam.domain.mso.ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+
+ /**
+ * (Required).
+ *
+ * @param modelInfo The modelInfo
+ */
+ @JsonProperty("modelInfo")
+ public void setModelInfo(org.onap.osam.domain.mso.ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RelatedModel#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RelatedModel#getAdditionalProperties()
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RelatedModel#setAdditionalProperty(java.lang.String, java.lang.Object)
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RelatedModel#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(getInstanceId()).append(modelInfo).append(additionalProperties).toHashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RelatedModel#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof RelatedModel) == false) {
+ return false;
+ }
+ RelatedModel rhs = ((RelatedModel) other);
+ return new EqualsBuilder().append(getInstanceId(), rhs.getInstanceId()).append(modelInfo, rhs.modelInfo).append(additionalProperties, rhs.additionalProperties).isEquals();
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/Request.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/Request.java
new file mode 100644
index 0000000..831f0c5
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/Request.java
@@ -0,0 +1,144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+//import java.util.HashMap;
+//import java.util.Map;
+//import javax.annotation.Generated;
+
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.onap.osam.domain.mso.InstanceIds;
+import org.onap.osam.domain.mso.RequestStatus;
+//import com.fasterxml.jackson.annotation.JsonAnyGetter;
+//import com.fasterxml.jackson.annotation.JsonAnySetter;
+//import com.fasterxml.jackson.annotation.JsonCreator;
+//import com.fasterxml.jackson.annotation.JsonIgnore;
+//import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+//import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+//import com.fasterxml.jackson.annotation.JsonValue;
+import org.apache.commons.lang.builder.EqualsBuilder;
+//import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+
+public class Request extends org.onap.osam.domain.mso.Request {
+
+
+ private InstanceIds instanceIds;
+
+ /** The request details. */
+ private RequestDetails requestDetails;
+
+ /** The request status. */
+ private RequestStatus requestStatus;
+
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.Request#getInstanceIds()
+ */
+ @JsonProperty("instanceIds")
+ public InstanceIds getInstanceIds() {
+ return instanceIds;
+ }
+
+ /**
+ * Sets the instance ids.
+ *
+ * @param instanceIds The instanceIds
+ */
+ @JsonProperty("instanceIds")
+ public void setInstanceIds(InstanceIds instanceIds) {
+ this.instanceIds = instanceIds;
+ }
+
+ /**
+ * (Required).
+ *
+ * @return The requestDetails
+ */
+ @JsonProperty("requestDetails")
+ public RequestDetails getRequestDetails() {
+ return requestDetails;
+ }
+
+ /**
+ * (Required).
+ *
+ * @param requestDetails The requestDetails
+ */
+ @JsonProperty("requestDetails")
+ public void setRequestDetails(RequestDetails requestDetails) {
+ this.requestDetails = requestDetails;
+ }
+
+
+ /**
+ * Gets the request status.
+ *
+ * @return The requestStatus
+ */
+ @JsonProperty("requestStatus")
+ public RequestStatus getRequestStatus() {
+ return requestStatus;
+ }
+
+ /**
+ * Sets the request status.
+ *
+ * @param requestStatus The requestStatus
+ */
+ @JsonProperty("requestStatus")
+ public void setRequestStatus(RequestStatus requestStatus) {
+ this.requestStatus = requestStatus;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.Request#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.Request#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof Request) == false) {
+ return false;
+ }
+ Request rhs = ((Request) other);
+ return new EqualsBuilder().append(getFinishTime(), rhs.getFinishTime()).append(getInstanceIds(), rhs.getInstanceIds()).append(getRequestDetails(), rhs.getRequestDetails()).append(getRequestId(), rhs.getRequestId()).append(getRequestScope(), rhs.getRequestScope()).append(getRequestStatus(), rhs.getRequestStatus()).append(getRequestType(), rhs.getRequestType()).append(getStartTime(), rhs.getStartTime()).append(getAdditionalProperties(), rhs.getAdditionalProperties()).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37).append(getFinishTime()).append(getInstanceIds()).append(getRequestDetails()).append(getRequestId()).append(getRequestScope()).append(getRequestStatus()).append(getRequestType()).append(getStartTime()).append(getAdditionalProperties()).toHashCode();
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestDetails.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestDetails.java
new file mode 100644
index 0000000..35496cb
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestDetails.java
@@ -0,0 +1,270 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.onap.osam.domain.mso.CloudConfiguration;
+import org.onap.osam.domain.mso.ModelInfo;
+import org.onap.osam.domain.mso.RequestInfo;
+import org.onap.osam.domain.mso.RequestParameters;
+import org.onap.osam.domain.mso.SubscriberInfo;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "cloudConfiguration",
+ "modelInfo",
+ "relatedModelList",
+ "requestInfo",
+ "subscriberInfo",
+ "requestParameters",
+ "configurationParameters"
+})
+public class RequestDetails{
+
+
+
+ @JsonProperty("cloudConfiguration")
+ private CloudConfiguration cloudConfiguration;
+
+ /** The model info. */
+ @JsonProperty("modelInfo")
+ private ModelInfo modelInfo;
+
+ /** The related model list. */
+ @JsonProperty("relatedInstanceList")
+ private List<RelatedInstanceWrapper> relatedInstanceList;
+
+ /** The request info. */
+ @JsonProperty("requestInfo")
+ private RequestInfo requestInfo;
+
+ /** The subscriber info. */
+ @JsonProperty("subscriberInfo")
+ private SubscriberInfo subscriberInfo;
+
+ /** The request parameters. */
+ @JsonProperty("requestParameters")
+ private RequestParameters requestParameters;
+
+ @JsonProperty("configurationParameters")
+ protected List<Map<String, String>> configurationParameters;
+
+ /** The additional properties. */
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * Gets the cloud configuration.
+ *
+ * @return The cloudConfiguration
+ */
+ @JsonProperty("cloudConfiguration")
+ public CloudConfiguration getCloudConfiguration() {
+ return cloudConfiguration;
+ }
+
+ /**
+ * Sets the cloud configuration.
+ *
+ * @param cloudConfiguration The cloudConfiguration
+ */
+ @JsonProperty("cloudConfiguration")
+ public void setCloudConfiguration(CloudConfiguration cloudConfiguration) {
+ this.cloudConfiguration = cloudConfiguration;
+ }
+
+ /**
+ * Gets the model info.
+ *
+ * @return The modelInfo
+ */
+ @JsonProperty("modelInfo")
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+
+ /**
+ * Sets the model info.
+ *
+ * @param modelInfo The modelInfo
+ */
+ @JsonProperty("modelInfo")
+ public void setModelInfo(ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
+ /**
+ * Gets the related instance list.
+ *
+ * @return The relatedInstanceList
+ */
+ @JsonProperty("relatedInstanceList")
+ public List<RelatedInstanceWrapper> getRelatedInstanceList() {
+ return relatedInstanceList;
+ }
+
+ /**
+ * Sets the related model list.
+ *
+ * @param relatedInstanceList The relatedInstanceList
+ */
+ @JsonProperty("relatedInstanceList")
+ public void setRelatedInstanceList(List<RelatedInstanceWrapper> relatedInstanceList) {
+ this.relatedInstanceList = relatedInstanceList;
+ }
+
+ /**
+ * Gets the request info.
+ *
+ * @return The requestInfo
+ */
+ @JsonProperty("requestInfo")
+ public RequestInfo getRequestInfo() {
+ return requestInfo;
+ }
+
+ /**
+ * Sets the request info.
+ *
+ * @param requestInfo The requestInfo
+ */
+ @JsonProperty("requestInfo")
+ public void setRequestInfo(RequestInfo requestInfo) {
+ this.requestInfo = requestInfo;
+ }
+
+ /**
+ * Gets the subscriber info.
+ *
+ * @return The subscriberInfo
+ */
+ @JsonProperty("subscriberInfo")
+ public SubscriberInfo getSubscriberInfo() {
+ return subscriberInfo;
+ }
+
+ /**
+ * Sets the subscriber info.
+ *
+ * @param subscriberInfo The subscriberInfo
+ */
+ @JsonProperty("subscriberInfo")
+ public void setSubscriberInfo(SubscriberInfo subscriberInfo) {
+ this.subscriberInfo = subscriberInfo;
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RequestDetails#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RequestDetails#getAdditionalProperties()
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RequestDetails#setAdditionalProperty(java.lang.String, java.lang.Object)
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ @JsonProperty("configurationParameters")
+ public List<Map<String, String>> getConfigurationParameters() {
+ return configurationParameters;
+ }
+
+ @JsonProperty("configurationParameters")
+ public void setConfigurationParameters(List<Map<String, String>> configurationParameters) {
+ this.configurationParameters = configurationParameters;
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RequestDetails#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder()
+ .append(cloudConfiguration)
+ .append(modelInfo)
+ .append(relatedInstanceList)
+ .append(requestInfo)
+ .append(getRequestParameters())
+ .append(subscriberInfo)
+ .append(additionalProperties)
+ .append(configurationParameters)
+ .toHashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.domain.mso.RequestDetails#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if (!(other instanceof RequestDetails)) {
+ return false;
+ }
+ RequestDetails rhs = ((RequestDetails) other);
+ return new EqualsBuilder()
+ .append(cloudConfiguration, rhs.cloudConfiguration)
+ .append(modelInfo, rhs.modelInfo)
+ .append(relatedInstanceList, rhs.relatedInstanceList)
+ .append(requestInfo, rhs.requestInfo)
+ .append(getRequestParameters(), rhs.getRequestParameters())
+ .append(subscriberInfo, rhs.subscriberInfo)
+ .append(additionalProperties, rhs.additionalProperties)
+ .append(configurationParameters, rhs.configurationParameters)
+ .isEquals();
+ }
+
+ public RequestParameters getRequestParameters() {
+ return requestParameters;
+ }
+
+ public void setRequestParameters(RequestParameters requestParameters) {
+ this.requestParameters = requestParameters;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestDetailsWrapper.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestDetailsWrapper.java
new file mode 100644
index 0000000..d5a36a4
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestDetailsWrapper.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+public class RequestDetailsWrapper {
+ public RequestDetails requestDetails;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestList.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestList.java
new file mode 100644
index 0000000..79f7055
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestList.java
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.Generated;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+//import com.fasterxml.jackson.annotation.JsonInclude;
+//import com.fasterxml.jackson.annotation.JsonProperty;
+//import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import java.util.List;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "finishTime",
+ "instanceIds",
+ "requestDetails",
+ "requestId",
+ "requestScope",
+ "requestStatus",
+ "requestType",
+ "startTime"
+})
+
+public class RequestList {
+
+ private List<RequestWrapper> requestList;
+
+ /** The additional properties. */
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * (Required).
+ *
+ * @return The RelatedModel List
+ */
+ public List<RequestWrapper> getRequestList() {
+ return requestList;
+ }
+
+ /**
+ * Sets the request list.
+ *
+ * @param l the new request list
+ */
+ public void setRequestList(List<RequestWrapper> l) {
+ this.requestList = l;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /**
+ * Gets the additional properties.
+ *
+ * @return the additional properties
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /**
+ * Sets the additional property.
+ *
+ * @param name the name
+ * @param value the value
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(getRequestList()).append(additionalProperties).toHashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof RequestList) == false) {
+ return false;
+ }
+ RequestList rhs = ((RequestList) other);
+ return new EqualsBuilder().append(getRequestList(), rhs.getRequestList()).append(additionalProperties, rhs.additionalProperties).isEquals();
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestParameters.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestParameters.java
new file mode 100644
index 0000000..4d1b402
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestParameters.java
@@ -0,0 +1,117 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.onap.osam.domain.mso.UserParam;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "subscriptionServiceType",
+ "userParams"
+})
+public class RequestParameters {
+
+ @JsonProperty("subscriptionServiceType")
+ private String subscriptionServiceType;
+ @JsonProperty("userParams")
+ private List<UserParam> userParams = new ArrayList<UserParam>();
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonProperty("subscriptionServiceType")
+ public String getSubscriptionServiceType() {
+ return subscriptionServiceType;
+ }
+
+ @JsonProperty("subscriptionServiceType")
+ public void setSubscriptionServiceType(String subscriptionServiceType) {
+ this.subscriptionServiceType = subscriptionServiceType;
+ }
+
+ /**
+ *
+ * @return
+ * The userParams
+ */
+ @JsonProperty("userParams")
+ public List<UserParam> getUserParams() {
+ return userParams;
+ }
+
+ /**
+ *
+ * @param userParams
+ * The userParams
+ */
+ @JsonProperty("userParams")
+ public void setUserParams(List<UserParam> userParams) {
+ this.userParams = userParams;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(subscriptionServiceType).append(userParams).append(additionalProperties).toHashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof RequestParameters) == false) {
+ return false;
+ }
+ RequestParameters rhs = ((RequestParameters) other);
+ return new EqualsBuilder().append(subscriptionServiceType, rhs.subscriptionServiceType).append(userParams, rhs.userParams).append(additionalProperties, rhs.additionalProperties).isEquals();
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestWrapper.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestWrapper.java
new file mode 100644
index 0000000..d8e9eaa
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RequestWrapper.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class RequestWrapper {
+
+
+ private Request request;
+
+
+ /**
+ * Gets the request.
+ *
+ * @return The requestDetails
+ */
+ @JsonProperty("request")
+ public Request getRequest() {
+ return request;
+ }
+
+ /**
+ * Sets the request.
+ *
+ * @param request The request
+ */
+ @JsonProperty
+ public void setRequest(Request request) {
+ this.request = request;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/Response.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/Response.java
new file mode 100644
index 0000000..ba20228
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/Response.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Response {
+
+ private int status;
+
+ private RequestList entity;
+
+ /**
+ * Gets the status.
+ *
+ * @return The status
+ */
+ @JsonProperty("status")
+ public int getStatus() {
+ return status;
+ }
+
+ /**
+ * Sets the status.
+ *
+ * @param status The status
+ */
+ @JsonProperty("status")
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ /**
+ * Gets the entity.
+ *
+ * @return The entity
+ */
+ @JsonProperty("entity")
+ public RequestList getEntity() {
+ return entity;
+ }
+
+ /**
+ * Sets the entity.
+ *
+ * @param entity The entity
+ */
+ @JsonProperty("entity")
+ public void setEntity(RequestList entity) {
+ this.entity = entity;
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RestInterface.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RestInterface.java
new file mode 100644
index 0000000..c3fe880
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/RestInterface.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import org.onap.osam.mso.RestObject;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+
+public interface RestInterface {
+
+ MultivaluedHashMap<String, Object> initMsoClient();
+
+ /**
+ * Gets the.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param sourceId the source id
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ <T> void Get (T t, String sourceId, String path, RestObject<T> restObject );
+
+ /**
+ * Delete.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param r the r
+ * @param sourceID the source ID
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ <T> void Delete(T t, Object r, String sourceID, String path, RestObject<T> restObject);
+
+ /**
+ * Post.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param r the r
+ * @param sourceID the source ID
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ <T> void Post(T t, Object r, String sourceID, String path, RestObject<T> restObject);
+
+ /**
+ * Put.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param r the r
+ * @param sourceID the source ID
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ <T> void Put(T t, RequestDetailsWrapper r, String sourceID, String path, RestObject<T> restObject);
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/Task.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/Task.java
new file mode 100644
index 0000000..1848b08
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/Task.java
@@ -0,0 +1,141 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import java.util.List;
+
+public class Task {
+
+ private String taskId;
+ private String type;
+ private String nfRole;
+ private String subscriptionServiceType;
+ private String originalRequestId;
+ private String originalRequestorId;
+ private String errorSource;
+ private String errorCode;
+ private String errorMessage;
+ private String buildingBlockName;
+ private String buildingBlockStep;
+ private List<String> validResponses;
+
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getNfRole() {
+ return nfRole;
+ }
+
+ public void setNfRole(String nfRole) {
+ this.nfRole = nfRole;
+ }
+
+ public String getSubscriptionServiceType() {
+ return subscriptionServiceType;
+ }
+
+ public void setSubscriptionServiceType(String subscriptionServiceType) {
+ this.subscriptionServiceType = subscriptionServiceType;
+ }
+
+ public String getOriginalRequestId() {
+ return originalRequestId;
+ }
+
+ public void setOriginalRequestId(String originalRequestId) {
+ this.originalRequestId = originalRequestId;
+ }
+
+ public String getOriginalRequestorId() {
+ return originalRequestorId;
+ }
+
+ public void setOriginalRequestorId(String originalRequestorId) {
+ this.originalRequestorId = originalRequestorId;
+ }
+
+ public String getErrorSource() {
+ return errorSource;
+ }
+
+ public void setErrorSource(String errorSource) {
+ this.errorSource = errorSource;
+ }
+
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public String getBuildingBlockName() {
+ return buildingBlockName;
+ }
+
+ public void setBuildingBlockName(String buildingBlockName) {
+ this.buildingBlockName = buildingBlockName;
+ }
+
+ public String getBuildingBlockStep() {
+ return buildingBlockStep;
+ }
+
+ public void setBuildingBlockStep(String buildingBlockStep) {
+ this.buildingBlockStep = buildingBlockStep;
+ }
+
+ public List<String> getValidResponses() {
+ return validResponses;
+ }
+
+ public void setValidResponses(List<String> validResponses) {
+ this.validResponses = validResponses;
+ }
+
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/TaskList.java b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/TaskList.java
new file mode 100644
index 0000000..3e49238
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/mso/rest/TaskList.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import java.util.List;
+
+public class TaskList {
+
+ public List<Task> getTaskList() {
+ return taskList;
+ }
+
+ public void setTaskList(List<Task> taskList) {
+ this.taskList = taskList;
+ }
+
+ private List<Task> taskList;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyProperties.java b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyProperties.java
new file mode 100644
index 0000000..f509051
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyProperties.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+import org.onap.portalsdk.core.util.SystemProperties;
+
+
+public class PolicyProperties extends SystemProperties {
+
+ public static final String POLICY_CLIENTAUTH_VAL = "policy.ClientAuth";
+
+ public static final String POLICY_CLIENT_MECHID_VAL = "policy.client.mechId";
+
+ public static final String POLICY_CLIENT_PASSWORD_VAL = "policy.client.password";
+
+ public static final String POLICY_USERNAME_VAL = "policy.username";
+
+ public static final String POLICY_PASSWORD_VAL = "policy.password";
+
+ public static final String POLICY_AUTHORIZATION_VAL = "policy.Authorization";
+
+ public static final String POLICY_SERVER_URL_VAL = "policy.server.url";
+
+ public static final String POLICY_ENVIRONMENT_VAL = "policy.environment";
+
+ public static final String POLICY_GET_CONFIG_VAL = "policy.get.config";
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyResponseWrapper.java b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyResponseWrapper.java
new file mode 100644
index 0000000..0569e97
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyResponseWrapper.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "status",
+ "entity"
+})
+
+public class PolicyResponseWrapper {
+
+ @JsonProperty("status")
+ private int status;
+
+ @JsonProperty("entity")
+ private String entity;
+
+ @JsonProperty("entity")
+ public String getEntity() {
+ return entity;
+ }
+
+ @JsonProperty("status")
+ public int getStatus() {
+ return status;
+ }
+
+ @JsonProperty("status")
+ public void setStatus(int v) {
+ this.status = v;
+ }
+
+ @JsonProperty("entity")
+ public void setEntity(String v) {
+ this.entity = v;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ public String getResponse () {
+
+ StringBuilder b = new StringBuilder ("{ \"status\": ");
+ b.append(getStatus()).append(", \"entity\": " ).append(this.getEntity()).append("}");
+ return (b.toString());
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyRestInt.java b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyRestInt.java
new file mode 100644
index 0000000..29fd109
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyRestInt.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.osam.policy.rest.RequestDetails;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class PolicyRestInt {
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PolicyRestInt.class);
+
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The request date format. */
+ public DateFormat requestDateFormat = new SimpleDateFormat("EEE, dd MMM YYYY HH:mm:ss z");
+
+ public PolicyRestInt() {
+ requestDateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
+ }
+
+ /**
+ * Log request.
+ *
+ * @param r the r
+ */
+ public void logRequest ( RequestDetails r ) {
+ String methodName = "logRequest";
+ ObjectMapper mapper = new ObjectMapper();
+ String r_json_str = "";
+ if ( r != null ) {
+ r_json_str = r.toString();
+ try {
+ r_json_str = mapper.writeValueAsString(r);
+ }
+ catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " Unable to parse request as json");
+ }
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " Request=(" + r_json_str + ")");
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyRestInterface.java b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyRestInterface.java
new file mode 100644
index 0000000..7773cc1
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyRestInterface.java
@@ -0,0 +1,250 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+import org.apache.commons.codec.binary.Base64;
+import org.eclipse.jetty.util.security.Password;
+import org.json.simple.JSONObject;
+import org.onap.osam.client.HttpBasicClient;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.policy.rest.RequestDetails;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.Response;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Date;
+
+public class PolicyRestInterface extends PolicyRestInt implements PolicyRestInterfaceIfc {
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PolicyRestInterface.class);
+
+ public static final String APPLICATION_JSON = "application/json";
+
+ private static Client client = null;
+
+ /** The common headers. */
+ private MultivaluedHashMap<String, Object> commonHeaders;
+ public PolicyRestInterface() {
+ super();
+ }
+
+ /** The Constant dateFormat. */
+ static final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ public void initRestClient()
+ {
+ final String methodname = "initRestClient()";
+
+ final String mechId = SystemProperties.getProperty(PolicyProperties.POLICY_CLIENT_MECHID_VAL);
+ final String clientPassword = SystemProperties.getProperty(PolicyProperties.POLICY_CLIENT_PASSWORD_VAL);
+ final String username = SystemProperties.getProperty(PolicyProperties.POLICY_USERNAME_VAL);
+ final String password = SystemProperties.getProperty(PolicyProperties.POLICY_PASSWORD_VAL);
+ final String environment = SystemProperties.getProperty(PolicyProperties.POLICY_ENVIRONMENT_VAL);
+
+ final String decrypted_client_password = Password.deobfuscate(clientPassword);
+ String mechAuthString = mechId + ":" + decrypted_client_password;
+ byte[] mechAuthEncBytes = Base64.encodeBase64(mechAuthString.getBytes());
+ String clientAuth = new String(mechAuthEncBytes);
+
+ final String decrypted_password = Password.deobfuscate(password);
+ String authString = username + ":" + decrypted_password;
+ byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
+ String authorization = new String(authEncBytes);
+
+ commonHeaders = new MultivaluedHashMap<> ();
+ commonHeaders.put("ClientAuth", Collections.singletonList((Object) ("Basic " + clientAuth)));
+ commonHeaders.put("Authorization", Collections.singletonList((Object) ("Basic " + authorization)));
+ commonHeaders.put("Environment", Collections.singletonList((Object) (environment)));
+
+ if (client == null) {
+
+ try {
+ client = HttpBasicClient.getClient();
+ } catch (Exception e) {
+ System.out.println( methodname + " Unable to get the SSL client");
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> void Get (T t, String sourceId, String path, RestObject<T> restObject ) {
+ String methodName = "Get";
+
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + " start");
+
+ String url="";
+ restObject.set(t);
+
+ url = SystemProperties.getProperty(PolicyProperties.POLICY_SERVER_URL_VAL) + path;
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " sending request to url= " + url);
+
+ initRestClient();
+
+ final Response cres = client.target(url)
+ .request()
+ .accept(APPLICATION_JSON)
+ .headers(commonHeaders)
+ .get();
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if (status == 200) {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " REST api was successfull!");
+
+ } else {
+ throw new GenericUncheckedException(methodName + " with status="+ status + ", url= " + url );
+ }
+
+ logger.debug(EELFLoggerDelegate.debugLogger,methodName + " received status=" + status );
+
+ return;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> void Delete(T t, RequestDetails r, String sourceID, String path, RestObject<T> restObject) {
+
+ String methodName = "Delete";
+ String url="";
+ Response cres = null;
+
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " start");
+ logRequest (r);
+
+ try {
+ initRestClient();
+
+ url = SystemProperties.getProperty(PolicyProperties.POLICY_SERVER_URL_VAL) + path;
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + " methodName sending request to: " + url);
+
+ cres = client.target(url)
+ .request()
+ .accept(APPLICATION_JSON)
+ .headers(commonHeaders)
+ //.entity(r)
+ .build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON)).invoke();
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if (status == 404) { // resource not found
+ String msg = "Resource does not exist...: " + cres.getStatus();
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg);
+ } else if (status == 200 || status == 204){
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + "Resource " + url + " deleted");
+ } else if (status == 202) {
+ String msg = "Delete in progress: " + status;
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg);
+ }
+ else {
+ String msg = "Deleting Resource failed: " + status;
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg);
+ }
+
+ try {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " No response entity, this is probably ok, e="
+ + e.getMessage());
+ }
+
+ }
+ catch (Exception e)
+ {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with url="+url+ ", Exception: " + e.toString());
+ throw e;
+
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> void Post(T t, JSONObject requestDetails, String uuid, String path, RestObject<T> restObject) {
+
+ String methodName = "Post";
+ String url="";
+
+ System.out.println( "POST policy rest interface");
+
+ try {
+
+ initRestClient();
+
+ url = SystemProperties.getProperty(PolicyProperties.POLICY_SERVER_URL_VAL) + path;
+ System.out.println( "<== " + methodName + " sending request to url= " + url);
+ // Change the content length
+ final Response cres = client.target(url)
+ .request()
+ .accept(APPLICATION_JSON)
+ .headers(commonHeaders)
+ //.header("content-length", 201)
+ //.header("X-FromAppId", sourceID)
+ .post(Entity.entity(requestDetails, MediaType.APPLICATION_JSON));
+
+ try {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+
+ System.out.println("<== " + methodName + " No response entity, this is probably ok, e=" + e.getMessage());
+ }
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if ( status >= 200 && status <= 299 ) {
+ System.out.println( "<== " + methodName + " REST api POST was successful!");
+
+ } else {
+ System.out.println( "<== " + methodName + " with status="+status+", url="+url);
+ }
+
+ } catch (Exception e)
+ {
+ System.out.println( "<== " + methodName + " with url="+url+ ", Exception: " + e.toString());
+ throw e;
+
+ }
+ }
+
+ public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException
+ {
+ return clazz.newInstance();
+ }
+
+ @Override
+ public void logRequest(RequestDetails r) {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyRestInterfaceFactory.java b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyRestInterfaceFactory.java
new file mode 100644
index 0000000..104a573
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyRestInterfaceFactory.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+public class PolicyRestInterfaceFactory {
+
+
+ public static PolicyRestInterfaceIfc getInstance () {
+ PolicyRestInterfaceIfc obj = null;
+
+ obj = new PolicyRestInterface();
+
+ return ( obj );
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyRestInterfaceIfc.java b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyRestInterfaceIfc.java
new file mode 100644
index 0000000..cd39351
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyRestInterfaceIfc.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+import org.json.simple.JSONObject;
+import org.onap.osam.policy.rest.RequestDetails;
+
+public interface PolicyRestInterfaceIfc {
+ public void initRestClient();
+
+ public <T> void Get (T t, String sourceId, String path, RestObject<T> restObject );
+
+ /**
+ * Delete.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param r the r
+ * @param sourceID the source ID
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ public <T> void Delete(T t, RequestDetails r, String sourceID, String path, RestObject<T> restObject);
+
+ /**
+ * Post.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param r the r
+ * @param sourceID the source ID
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ public <T> void Post(T t, JSONObject r, String sourceID, String path, RestObject<T> restObject);
+
+ /***
+ * Log request.
+ *
+ * @param r the r
+ */
+ public void logRequest ( RequestDetails r );
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyUtil.java b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyUtil.java
new file mode 100644
index 0000000..c73d529
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/policy/PolicyUtil.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.glassfish.jersey.client.ClientResponse;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class PolicyUtil {
+
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PolicyUtil.class);
+
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ public static PolicyResponseWrapper wrapResponse ( String body, int statusCode ) {
+
+ PolicyResponseWrapper w = new PolicyResponseWrapper();
+ w.setStatus (statusCode);
+ w.setEntity(body);
+
+ return w;
+ }
+
+ public static PolicyResponseWrapper wrapResponse (ClientResponse cres) {
+ String resp_str = "";
+ if ( cres != null ) {
+ resp_str = cres.readEntity(String.class);
+ }
+ int statuscode = cres.getStatus();
+ PolicyResponseWrapper w = PolicyUtil.wrapResponse ( resp_str, statuscode );
+ return (w);
+ }
+
+ public static PolicyResponseWrapper wrapResponse (RestObject<String> rs) {
+ String resp_str = "";
+ int status = 0;
+ if ( rs != null ) {
+ resp_str = rs.get();
+ status = rs.getStatusCode();
+ }
+ PolicyResponseWrapper w = PolicyUtil.wrapResponse ( resp_str, status );
+ return (w);
+ }
+
+ public static <T> String convertPojoToString ( T t ) throws com.fasterxml.jackson.core.JsonProcessingException {
+
+ String methodName = "convertPojoToString";
+ ObjectMapper mapper = new ObjectMapper();
+ String r_json_str = "";
+ if ( t != null ) {
+ try {
+ r_json_str = mapper.writeValueAsString(t);
+ }
+ catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " Unable to parse object as json");
+ }
+ }
+ return (r_json_str);
+ }
+
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/policy/RestObject.java b/onap-enabler-be/src/main/java/org/onap/osam/policy/RestObject.java
new file mode 100644
index 0000000..d098fe0
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/policy/RestObject.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+public class RestObject<T> {
+
+ // T stands for "Type"
+ private T t;
+
+ /** The status code. */
+ private int statusCode= 0;
+
+ /**
+ * Sets the.
+ *
+ * @param t the t
+ */
+ public void set(T t) { this.t = t; }
+
+ /**
+ * Gets the.
+ *
+ * @return the t
+ */
+ public T get() { return t; }
+
+ /**
+ * Sets the status code.
+ *
+ * @param v the new status code
+ */
+ public void setStatusCode(int v) { this.statusCode = v; }
+
+ /**
+ * Gets the status code.
+ *
+ * @return the status code
+ */
+ public int getStatusCode() { return this.statusCode; }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/policy/rest/RequestDetails.java b/onap-enabler-be/src/main/java/org/onap/osam/policy/rest/RequestDetails.java
new file mode 100644
index 0000000..9c2997a
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/policy/rest/RequestDetails.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy.rest;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+/*
+ [
+ {
+ "policyConfigMessage": "Config Retrieved! ",
+ "policyConfigStatus": "CONFIG_RETRIEVED",
+ "type": "JSON",
+ "config": "{\"service\":\"TimeLimitAndVerticalTopology\",\"policyName\":\"SNIRO_CM_1707.Demo_TimeLimitAndVerticalTopology_zone_localTime\",\"description\":\"dev instance\",\"templateVersion\":\"1702.03\",\"version\":\"1707\",\"priority\":\"4\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"serviceType\":\"networkOnDemand\",\"identity\":\"vnf_upgrade_policy\",\"policyScope\":{\"serviceType\":[\"networkOnDemand\"],\"aicZone\":[\" \"],\"entityType\":[\"vnf\"]},\"timeSchedule\":{\"allowedPeriodicTime\":[{\"day\":\"weekday\",\"timeRange\":[{\"start_time\":\"04:00:00\",\"end_time\":\"13:00:00\"}]}]},\"nodeType\":[\"vnf\"],\"type\":\"timeLimitAndVerticalTopology\",\"conflictScope\":\"vnf_zone\"}}",
+ "policyName": "SNIRO_CM_1707.Config_MS_Demo_TimeLimitAndVerticalTopology_zone_localTime.1.xml",
+ "policyVersion": "1",
+ "matchingConditions": {
+ "ECOMPName": "SNIRO-Placement",
+ "ConfigName": "",
+ "service": "TimeLimitAndVerticalTopology",
+ "uuid": "",
+ "Location": ""
+ },
+ "responseAttributes": {},
+ "property": null
+ },
+ {
+ "policyConfigMessage": "Config Retrieved! ",
+ "policyConfigStatus": "CONFIG_RETRIEVED",
+ "type": "JSON",
+ "config": "{\"service\":\"TimeLimitAndVerticalTopology\",\"policyName\":\"SNIRO_CM_1707.Demo_TimeLimitAndVerticalTopology_pserver_localTime\",\"description\":\"dev instance\",\"templateVersion\":\"1702.03\",\"version\":\"1707\",\"priority\":\"4\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"serviceType\":\"networkOnDemand\",\"identity\":\"vnf_upgrade_policy\",\"policyScope\":{\"serviceType\":[\"networkOnDemand\"],\"aicZone\":[\" \"],\"entityType\":[\"vnf\"]},\"timeSchedule\":{\"allowedPeriodicTime\":[{\"day\":\"weekday\",\"timeRange\":[{\"start_time\":\"04:00:00\",\"end_time\":\"13:00:00\"}]}]},\"nodeType\":[\"vnf\"],\"type\":\"timeLimitAndVerticalTopology\",\"conflictScope\":\"vnf_pserver\"}}",
+ "policyName": "SNIRO_CM_1707.Config_MS_Demo_TimeLimitAndVerticalTopology_pserver_localTime.1.xml",
+ "policyVersion": "1",
+ "matchingConditions": {
+ "ECOMPName": "SNIRO-Placement",
+ "ConfigName": "",
+ "service": "TimeLimitAndVerticalTopology",
+ "uuid": "",
+ "Location": ""
+ },
+ "responseAttributes": {},
+ "property": null
+ },
+ {
+ "policyConfigMessage": "Config Retrieved! ",
+ "policyConfigStatus": "CONFIG_RETRIEVED",
+ "type": "JSON",
+ "config": "{\"service\":\"TimeLimitAndVerticalTopology\",\"policyName\":\"SNIRO_CM_1707.Demo_TimeLimitAndVerticalTopology_vnf_localTime\",\"description\":\"dev instance\",\"templateVersion\":\"1702.03\",\"version\":\"1707\",\"priority\":\"4\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"serviceType\":\"networkOnDemand\",\"identity\":\"vnf_upgrade_policy\",\"policyScope\":{\"serviceType\":[\"networkOnDemand\"],\"aicZone\":[\" \"],\"entityType\":[\"vnf\"]},\"timeSchedule\":{\"allowedPeriodicTime\":[{\"day\":\"weekday\",\"timeRange\":[{\"start_time\":\"04:00:00\",\"end_time\":\"13:00:00\"}]}]},\"nodeType\":[\"vnf\"],\"type\":\"timeLimitAndVerticalTopology\",\"conflictScope\":\"vnf\"}}",
+ "policyName": "SNIRO_CM_1707.Config_MS_Demo_TimeLimitAndVerticalTopology_vnf_localTime.1.xml",
+ "policyVersion": "1",
+ "matchingConditions": {
+ "ECOMPName": "SNIRO-Placement",
+ "ConfigName": "",
+ "service": "TimeLimitAndVerticalTopology",
+ "uuid": "",
+ "Location": ""
+ },
+ "responseAttributes": {},
+ "property": null
+ }
+ ]
+*/
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "policyConfigMessage",
+ "policyConfigStatus",
+ "type",
+ "config",
+ "policyName",
+ "policyVersion",
+ "matchingConditions"
+})
+public class RequestDetails {
+
+ @JsonProperty("policyName")
+ private String policyName;
+
+ @JsonProperty("policyName")
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ @JsonProperty("policyName")
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/properties/AsdcClientConfiguration.java b/onap-enabler-be/src/main/java/org/onap/osam/properties/AsdcClientConfiguration.java
new file mode 100644
index 0000000..625587a
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/properties/AsdcClientConfiguration.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.properties;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.annotation.PropertySources;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+
+@Configuration
+
+@PropertySources({
+ @PropertySource(value="asdc.properties", ignoreResourceNotFound = true),
+ @PropertySource(value="${container.classpath:}/WEB-INF/conf/asdc.properties", ignoreResourceNotFound = true)
+})
+public class AsdcClientConfiguration {
+
+ @Bean
+ public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
+ }
+
+ @Value("${asdc.client.type}")
+ private AsdcClientType asdcClientType;
+
+ @Value("${asdc.client.rest.host}")
+ private String asdcClientHost;
+
+ /** The asdc client port. */
+ @Value("${asdc.client.rest.port}")
+ private int asdcClientPort;
+
+ /** The asdc client auth. */
+ @Value("${asdc.client.rest.auth}")
+ public String asdcClientAuth;
+
+ /** The asdc client protocol. */
+ @Value("${asdc.client.rest.protocol}")
+ public String asdcClientProtocol;
+
+ /**
+ * Gets the asdc client type.
+ *
+ * @return the asdc client type
+ */
+ public AsdcClientType getAsdcClientType() {
+ return asdcClientType;
+ }
+
+ /**
+ * Gets the asdc client host.
+ *
+ * @return the asdc client host
+ */
+ public String getAsdcClientHost() {
+ return asdcClientHost;
+ }
+
+ /**
+ * Gets the asdc client port.
+ *
+ * @return the asdc client port
+ */
+ public int getAsdcClientPort() {
+ return asdcClientPort;
+ }
+
+ /**
+ * Gets the asdc client auth.
+ *
+ * @return the asdc client auth
+ */
+ public String getAsdcClientAuth() {
+ return asdcClientAuth;
+ }
+
+ /**
+ * Gets the asdc client protocol.
+ *
+ * @return the asdc client protocol
+ */
+ public String getAsdcClientProtocol() {
+ return asdcClientProtocol;
+ }
+
+ /**
+ * The Enum AsdcClientType.
+ */
+ public enum AsdcClientType {
+
+ /** The in memory. */
+ IN_MEMORY,
+
+ /** The rest. */
+ REST,
+
+ /** The local. */
+ LOCAL
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/properties/Features.java b/onap-enabler-be/src/main/java/org/onap/osam/properties/Features.java
new file mode 100644
index 0000000..995e608
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/properties/Features.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.properties;
+
+import org.togglz.core.Feature;
+import org.togglz.core.context.FeatureContext;
+
+public enum Features implements Feature {
+
+
+ FLAG_ASYNC_JOBS,
+ FLAG_REGION_ID_FROM_REMOTE,
+ CREATE_INSTANCE_TEST,
+ EMPTY_DRAWING_BOARD_TEST,
+ FLAG_ADVANCED_PORTS_FILTER,
+ FLAG_ADD_MSO_TESTAPI_FIELD,
+ FLAG_ASYNC_INSTANTIATION,
+ FLAG_SERVICE_MODEL_CACHE,
+ FLAG_UNASSIGN_SERVICE,
+ FLAG_NETWORK_TO_ASYNC_INSTANTIATION,
+ FLAG_COLLECTION_RESOURCE_SUPPORT,
+ FLAG_SHOW_ASSIGNMENTS,
+ FLAG_SHOW_VERIFY_SERVICE,
+ FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD,
+ FLAG_PNP_INSTANTIATION;
+
+ public boolean isActive() {
+ return FeatureContext.getFeatureManager().isActive(this);
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/properties/FeaturesTogglingConfiguration.java b/onap-enabler-be/src/main/java/org/onap/osam/properties/FeaturesTogglingConfiguration.java
new file mode 100644
index 0000000..86761a8
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/properties/FeaturesTogglingConfiguration.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.properties;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+import org.togglz.core.manager.FeatureManager;
+import org.togglz.core.manager.FeatureManagerBuilder;
+import org.togglz.core.repository.file.FileBasedStateRepository;
+import org.togglz.spring.listener.TogglzApplicationContextBinderApplicationListener;
+
+import javax.servlet.ServletContext;
+import java.io.File;
+
+@Configuration
+public class FeaturesTogglingConfiguration {
+ @Bean
+ public ApplicationListener getApplicationListener() {
+ return new TogglzApplicationContextBinderApplicationListener();
+ }
+
+ @Bean
+ public FeatureManager featureManager(ServletContext servletContext, Environment environment) {
+ final String defaultFilename = "features.properties";
+
+ String filename = environment.getProperty("featureFlags.filename");
+
+ if (StringUtils.isBlank(filename)) {
+ filename = defaultFilename;
+ }
+
+ return new FeatureManagerBuilder()
+ .featureEnum(Features.class)
+ .stateRepository(new FileBasedStateRepository(
+ new File(servletContext.getRealPath("/WEB-INF/conf/" + filename))
+ ))
+ .build();
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/properties/VidProperties.java b/onap-enabler-be/src/main/java/org/onap/osam/properties/VidProperties.java
new file mode 100644
index 0000000..1dedd29
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/properties/VidProperties.java
@@ -0,0 +1,95 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.properties;
+
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.model.ModelConstants;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+public class VidProperties extends SystemProperties {
+
+ //VID General Properties
+ public static final String MSO_DISPLAY_TEST_API_ON_SCREEN="mso.displayTestAPIOnScreen";
+ public static final String MSO_DEFAULT_TEST_API="mso.defaultTestAPI";
+ public static final String MSO_MAX_OPENED_INSTANTIATION_REQUESTS="mso.maxOpenedInstantiationRequests";
+ public static final String MSO_ASYNC_POLLING_INTERVAL_SECONDS="mso.asyncPollingIntervalSeconds";
+
+ public static final String VID_TRUSTSTORE_FILENAME = "vid.truststore.filename";
+
+ /** The Constant VID_TRUSTSTORE_PASSWD_X. */
+ public static final String VID_TRUSTSTORE_PASSWD_X = "vid.truststore.passwd.x";
+
+ /** The Constant FILESEPARATOR. */
+ public static final String FILESEPARATOR = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
+
+ /** The Constant LOG. */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VidProperties.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+ /**
+ * Gets the asdc model namespace prefix property
+ *
+ * @return the property value or a default value
+ */
+ public static String getAsdcModelNamespace() {
+ String methodName = "getAsdcModelNamespace ";
+ String asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
+ try {
+ asdcModelNamespace = SystemProperties.getProperty(ModelConstants.ASDC_MODEL_NAMESPACE);
+ if ( asdcModelNamespace == null || asdcModelNamespace.isEmpty()) {
+ asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
+ }
+ }
+ catch ( Exception e ) {
+ LOG.error (EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + "unable to find the value, using the default "
+ + ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE);
+ asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
+ }
+ return (asdcModelNamespace);
+ }
+ /**
+ * Gets the specified property value. If the property is not defined, returns a default value.
+ *
+ * @return the property value or a default value
+ */
+ public static String getPropertyWithDefault ( String propName, String defaultValue ) {
+ String methodName = "getPropertyWithDefault ";
+ String propValue = defaultValue;
+ try {
+ propValue = SystemProperties.getProperty(propName);
+ if ( propValue == null || propValue.isEmpty()) {
+ propValue = defaultValue;
+ }
+ }
+ catch ( Exception e ) {
+ LOG.error (EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + "unable to find the value, using the default "
+ + defaultValue);
+ propValue = defaultValue;
+ }
+ return (propValue);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/roles/EcompRole.java b/onap-enabler-be/src/main/java/org/onap/osam/roles/EcompRole.java
new file mode 100644
index 0000000..5a6ec35
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/roles/EcompRole.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.roles;
+
+public enum EcompRole {
+ READ;
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/roles/Role.java b/onap-enabler-be/src/main/java/org/onap/osam/roles/Role.java
new file mode 100644
index 0000000..e24eb6e
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/roles/Role.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.roles;
+
+
+public class Role {
+
+ private EcompRole ecompRole;
+
+ private String subscribeName;
+
+ private String serviceType;
+
+ private String tenant;
+
+ public Role(EcompRole ecompRole, String subscribeName, String serviceType, String tenant) {
+ this.ecompRole = ecompRole;
+ this.subscribeName = subscribeName;
+ this.serviceType = serviceType;
+ this.tenant = tenant;
+ }
+
+ public EcompRole getEcompRole() {
+ return ecompRole;
+ }
+
+
+ public String getSubscribeName() {
+ return subscribeName;
+ }
+
+ public void setSubscribeName(String subscribeName) {
+ this.subscribeName = subscribeName;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+
+ public String getTenant() {
+ return tenant;
+ }
+
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/roles/RoleProvider.java b/onap-enabler-be/src/main/java/org/onap/osam/roles/RoleProvider.java
new file mode 100644
index 0000000..e6b503a
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/roles/RoleProvider.java
@@ -0,0 +1,156 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.roles;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.web.support.UserUtils;
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.aai.exceptions.RoleParsingException;
+import org.onap.osam.model.ModelConstants;
+import org.onap.osam.model.Subscriber;
+import org.onap.osam.model.SubscriberList;
+import org.onap.osam.services.IAaiService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.*;
+
+//import org.codehaus.jackson.map.ObjectMapper;
+
+
+@Component
+public class RoleProvider {
+
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(RoleProvider.class);
+ final String readPermissionString = "read";
+ SubscriberList subscribers;
+ ObjectMapper om = new ObjectMapper();
+ @Autowired
+ private IAaiService aaiService;
+
+ public static List<String> extractRoleFromSession(HttpServletRequest request) {
+
+ return new ArrayList<String>();
+
+ }
+
+ public void init() {
+ LOG.debug(EELFLoggerDelegate.debugLogger, "Role provider => init method started");
+ AaiResponse<SubscriberList> subscribersResponse = aaiService.getFullSubscriberList();
+ subscribers = subscribersResponse.getT();
+ LOG.debug(EELFLoggerDelegate.debugLogger, "Role provider => init method finished");
+ }
+
+ public List<Role> getUserRoles(HttpServletRequest request) throws JsonProcessingException {
+ String logPrefix = "Role Provider (" + UserUtils.getUserId(request) + ") ==>";
+
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "Entering to get user role for user " + UserUtils.getUserId(request));
+
+ List<Role> roleList = new ArrayList<>();
+ //Disable roles until AAF integration finishes
+ /*HashMap roles = UserUtils.getRoles(request);
+ for (Object role : roles.keySet()) {
+ org.openecomp.portalsdk.core.domain.Role sdkRol = (org.openecomp.portalsdk.core.domain.Role) roles.get(role);
+
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "Role " + sdkRol.getName() + " is being proccessed");
+ try {
+ if (sdkRol.getName().contains(readPermissionString)) {
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + " Role " + sdkRol.getName() + " contain " + readPermissionString);
+
+ continue;
+ }
+ String[] roleParts = splitRole((sdkRol.getName()), logPrefix);
+ roleList.add(createRoleFromStringArr(roleParts, logPrefix));
+ String msg = String.format(logPrefix + " User %s got permissions %s", UserUtils.getUserId(request), Arrays.toString(roleParts));
+ LOG.debug(EELFLoggerDelegate.debugLogger, msg);
+ } catch (RoleParsingException e) {
+ LOG.error(logPrefix + " Failed to parse permission");
+
+ }
+ }*/
+
+ return roleList;
+ }
+
+ public String[] splitRole(String roleAsString, String logPrefix) {
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "Spliting role = " + roleAsString + "With delimeter = " + ModelConstants.ROLE_DELIMITER);
+ return roleAsString.split(ModelConstants.ROLE_DELIMITER);
+ }
+
+ public boolean userPermissionIsReadOnly(List<Role> roles) {
+
+ return (!(roles.size() > 0));
+ }
+
+ public boolean userPermissionIsReadLogs(List<Role> roles){
+ for(Role role: roles){
+ if(role.getServiceType().equals("LOGS")){
+ if(role.getTenant().equals("PERMITTED")){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private String replaceSubscriberNameToGlobalCustomerID(String subscriberName, String logPrefix) throws JsonProcessingException {
+ if (subscribers == null) {
+ LOG.debug(EELFLoggerDelegate.debugLogger, "replaceSubscriberNameToGlobalCustomerID calling init method");
+ init();
+ }
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "subscribers list size is " + subscribers.customer.size() + " with the values " + om.writeValueAsString(subscribers.customer));
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "subscribers list size is " + subscribers.customer.size() + " with the values " + om.writeValueAsString(subscribers.customer));
+
+
+ Optional<Subscriber> s = subscribers.customer.stream().filter(x -> x.subscriberName.equals(subscriberName)).findFirst();
+ //Fixing bug of logging "optional get" before isPresent
+ String replacement = s.isPresent() ? s.get().globalCustomerId : "";
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "Subscribername " + subscriberName + " changed to " + replacement);
+ return replacement;
+ }
+
+ public Role createRoleFromStringArr(String[] roleParts, String rolePrefix) throws JsonProcessingException, RoleParsingException {
+ String globalCustomerID = replaceSubscriberNameToGlobalCustomerID(roleParts[0], rolePrefix);
+ try {
+ if (roleParts.length > 2) {
+ return new Role(EcompRole.READ, globalCustomerID, roleParts[1], roleParts[2]);
+ } else {
+ return new Role(EcompRole.READ, globalCustomerID, roleParts[1], null);
+ }
+ } catch (ArrayIndexOutOfBoundsException e) {
+ if (roleParts.length > 0)
+ LOG.debug(EELFLoggerDelegate.debugLogger, "Could not parse role ", roleParts[0]);
+ else {
+ LOG.debug(EELFLoggerDelegate.debugLogger, "Got empty role, Could not parse it ");
+
+ }
+ throw new RoleParsingException();
+ }
+
+ }
+
+}
+
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/roles/RoleValidator.java b/onap-enabler-be/src/main/java/org/onap/osam/roles/RoleValidator.java
new file mode 100644
index 0000000..deddcee
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/roles/RoleValidator.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.roles;
+
+import org.onap.osam.mso.rest.RequestDetails;
+
+import java.util.List;
+import java.util.Map;
+
+public class RoleValidator {
+
+ private boolean disableRoles = true;
+ private List<Role> userRoles;
+
+ public RoleValidator(List<Role> roles) {
+ this.userRoles = roles;
+ }
+
+ public boolean isSubscriberPermitted(String subscriberName) {
+ if(this.disableRoles) return true;
+
+ for (Role role : userRoles) {
+ if (role.getSubscribeName().equals(subscriberName))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isServicePermitted(String subscriberName, String serviceType) {
+ if(this.disableRoles) return true;
+
+ for (Role role : userRoles) {
+ if (role.getSubscribeName().equals(subscriberName) && role.getServiceType().equals(serviceType))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isMsoRequestValid(RequestDetails mso_request) {
+ if(this.disableRoles) return true;
+
+ try {
+ String globalSubscriberIdRequested = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("subscriberInfo")).get("globalSubscriberId");
+ String serviceType = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("requestParameters")).get("subscriptionServiceType");
+ return isServicePermitted(globalSubscriberIdRequested, serviceType);
+ } catch (Exception e) {
+ //Until we'll get the exact information regarding the tenants and the global customer id, we'll return true on unknown requests to mso
+ return true;
+ }
+// return false;
+ }
+
+ public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName) {
+ if(this.disableRoles) return true;
+
+ for (Role role : userRoles) {
+ if (role.getSubscribeName().equals(globalCustomerId)
+ && role.getServiceType().equals(serviceType)
+ && (role.getTenant() == null || role.getTenant().equalsIgnoreCase(tenantName))) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/scheduler/RestObject.java b/onap-enabler-be/src/main/java/org/onap/osam/scheduler/RestObject.java
new file mode 100644
index 0000000..6bee4e4
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/scheduler/RestObject.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.scheduler;
+
+
+public class RestObject<T> {
+
+ private T t;
+
+ private int statusCode= 0;
+
+ public String uuid;
+
+ public void set(T t) { this.t = t; }
+
+ public T get() { return t; }
+
+ public void setStatusCode(int v) { this.statusCode = v; }
+
+ public int getStatusCode() { return this.statusCode; }
+
+ public void setUUID(String uuid) { this.uuid = uuid; }
+
+ public String getUUID() { return this.uuid; }
+}
+
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/scheduler/RestObjects/RestObject.java b/onap-enabler-be/src/main/java/org/onap/osam/scheduler/RestObjects/RestObject.java
new file mode 100644
index 0000000..fd01133
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/scheduler/RestObjects/RestObject.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.scheduler.RestObjects;
+
+
+public class RestObject<T> {
+
+ private T t;
+
+ private int statusCode= 0;
+
+ public void set(T t) { this.t = t; }
+
+ public T get() { return t; }
+
+ public void setStatusCode(int v) { this.statusCode = v; }
+
+ public int getStatusCode() { return this.statusCode; }
+
+}
+
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/scheduler/SchedulerProperties.java b/onap-enabler-be/src/main/java/org/onap/osam/scheduler/SchedulerProperties.java
new file mode 100644
index 0000000..e313d93
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/scheduler/SchedulerProperties.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.scheduler;
+
+import org.onap.portalsdk.core.util.SystemProperties;
+
+
+public class SchedulerProperties extends SystemProperties {
+
+ public static final String SCHEDULER_USER_NAME_VAL = "scheduler.user.name";
+
+ public static final String SCHEDULER_PASSWORD_VAL = "scheduler.password";
+
+ public static final String SCHEDULER_SERVER_URL_VAL = "scheduler.server.url";
+
+ public static final String SCHEDULER_GET_SCHEDULES = "scheduler.get.schedules";
+
+ public static final String SCHEDULER_DELETE_SCHEDULE = "scheduler.delete.schedule";
+
+ public static final String SCHEDULER_BASIC_AUTH = "scheduler.basic.auth";
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/scheduler/SchedulerRestInterface.java b/onap-enabler-be/src/main/java/org/onap/osam/scheduler/SchedulerRestInterface.java
new file mode 100644
index 0000000..c764108
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/scheduler/SchedulerRestInterface.java
@@ -0,0 +1,133 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.scheduler;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import io.joshworks.restclient.http.HttpResponse;
+import org.eclipse.jetty.util.security.Password;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.client.SyncRestClient;
+import org.onap.osam.client.SyncRestClientInterface;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.utils.Logging;
+import org.springframework.http.HttpMethod;
+import org.springframework.stereotype.Service;
+
+import java.util.Base64;
+import java.util.Collections;
+import java.util.Map;
+import java.util.function.Function;
+
+import static org.onap.osam.utils.Logging.REQUEST_ID_HEADER_KEY;
+
+@Service
+public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
+
+ final private static EELFLogger outgoingRequestsLogger = Logging.getRequestsLogger("scheduler");
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SchedulerRestInterface.class);
+ private SyncRestClientInterface syncRestClient;
+ private Function<String, String> propertyGetter;
+ private Map<String, String> commonHeaders;
+
+ public SchedulerRestInterface() {
+ this.propertyGetter = SystemProperties::getProperty;
+ }
+
+ public SchedulerRestInterface(Function<String, String> propertyGetter) {
+ this.propertyGetter = propertyGetter;
+ }
+
+ public void initRestClient() {
+ logger.info("Starting to initialize rest client ");
+ String authStringEnc = calcEncodedAuthString();
+
+ commonHeaders = Maps.newHashMap();
+ commonHeaders.put("Authorization", "Basic " + authStringEnc);
+
+ syncRestClient = new SyncRestClient();
+
+ logger.info("\t<== Client Initialized \n");
+ }
+
+ public <T> void Get(T t, String sourceId, String path, org.onap.osam.scheduler.RestObject<T> restObject) {
+ initRestClient();
+ String methodName = "Get";
+ String url = String.format("%s%s", propertyGetter.apply(SchedulerProperties.SCHEDULER_SERVER_URL_VAL), path);
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
+ Map<String, String> requestHeaders = ImmutableMap.<String, String>builder()
+ .putAll(commonHeaders)
+ .put(REQUEST_ID_HEADER_KEY, Logging.extractOrGenerateRequestId()).build();
+ final HttpResponse<T> response = ((HttpResponse<T>) syncRestClient.get(url, requestHeaders,
+ Collections.emptyMap(), t.getClass()));
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, response);
+ int status = response.getStatus();
+ restObject.setStatusCode(status);
+
+ if (status == 200) {
+ t = response.getBody();
+ restObject.set(t);
+
+ } else {
+ throw new GenericUncheckedException(String.format("%s with status=%d, url=%s", methodName, status, url));
+ }
+ }
+
+ public <T> void Delete(T t, String sourceID, String path, org.onap.osam.scheduler.RestObject<T> restObject) {
+ initRestClient();
+ String url = String.format("%s%s", propertyGetter.apply(SchedulerProperties.SCHEDULER_SERVER_URL_VAL), path);
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url);
+ Map<String, String> requestHeaders = ImmutableMap.<String, String>builder()
+ .putAll(commonHeaders)
+ .put(REQUEST_ID_HEADER_KEY, Logging.extractOrGenerateRequestId()).build();
+ final HttpResponse<T> response = (HttpResponse<T>) syncRestClient.delete(url, requestHeaders, t.getClass());
+
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, response);
+
+ int status = response.getStatus();
+ restObject.setStatusCode(status);
+
+ t = response.getBody();
+ restObject.set(t);
+ }
+
+ public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException {
+ return clazz.newInstance();
+ }
+
+ private String calcEncodedAuthString() {
+ String retrievedUsername = propertyGetter.apply(SchedulerProperties.SCHEDULER_USER_NAME_VAL);
+ final String username = retrievedUsername.isEmpty() ? "" : retrievedUsername;
+
+ String retrievedPassword = propertyGetter.apply(SchedulerProperties.SCHEDULER_PASSWORD_VAL);
+ final String password = retrievedPassword.isEmpty() ? "" : getDeobfuscatedPassword(retrievedPassword);
+
+ return Base64.getEncoder().encodeToString((username + ":" + password).getBytes());
+ }
+
+ private static String getDeobfuscatedPassword(String password) {
+ return password.contains("OBF:") ? Password.deobfuscate(password) : password;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/scheduler/SchedulerRestInterfaceIfc.java b/onap-enabler-be/src/main/java/org/onap/osam/scheduler/SchedulerRestInterfaceIfc.java
new file mode 100644
index 0000000..dbb5f67
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/scheduler/SchedulerRestInterfaceIfc.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.scheduler;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public interface SchedulerRestInterfaceIfc {
+
+ void initRestClient();
+
+ <T> void Get(T t, String sourceId, String path, org.onap.osam.scheduler.RestObject<T> restObject);
+
+ <T> void Delete(T t, String sourceID, String path, org.onap.osam.scheduler.RestObject<T> restObject)
+ throws Exception;
+
+}
+
+
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/AaiServiceImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/services/AaiServiceImpl.java
new file mode 100644
index 0000000..01de375
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/AaiServiceImpl.java
@@ -0,0 +1,480 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import org.apache.http.HttpStatus;
+import org.onap.osam.aai.AaiClientInterface;
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.aai.ServiceInstance;
+import org.onap.osam.aai.ServiceInstancesSearchResults;
+import org.onap.osam.aai.ServiceSubscription;
+import org.onap.osam.aai.ServiceSubscriptions;
+import org.onap.osam.aai.Services;
+import org.onap.osam.aai.SubscriberFilteredResults;
+import org.onap.osam.aai.model.AaiGetAicZone.AicZones;
+import org.onap.osam.aai.model.AaiGetInstanceGroupsByCloudRegion;
+import org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.AaiGetNetworkCollectionDetails;
+import org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.AaiGetRelatedInstanceGroupsByVnfId;
+import org.onap.osam.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.osam.aai.model.AaiGetPnfs.Pnf;
+import org.onap.osam.aai.model.AaiGetServicesRequestModel.GetServicesAAIRespone;
+import org.onap.osam.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.osam.aai.model.AaiRelationResponse;
+import org.onap.osam.aai.model.InstanceGroupInfo;
+import org.onap.osam.aai.model.LogicalLinkResponse;
+import org.onap.osam.aai.model.Model;
+import org.onap.osam.aai.model.OwningEntity;
+import org.onap.osam.aai.model.OwningEntityResponse;
+import org.onap.osam.aai.model.PortDetailsTranslator;
+import org.onap.osam.aai.model.Project;
+import org.onap.osam.aai.model.ProjectResponse;
+import org.onap.osam.aai.model.RelatedToProperty;
+import org.onap.osam.aai.model.Relationship;
+import org.onap.osam.aai.model.RelationshipData;
+import org.onap.osam.aai.model.RelationshipList;
+import org.onap.osam.aai.model.ServiceRelationships;
+import org.onap.osam.model.ServiceInstanceSearchResult;
+import org.onap.osam.model.SubscriberList;
+import org.onap.osam.roles.RoleValidator;
+import org.onap.osam.utils.Intersection;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.ws.rs.core.Response;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class AaiServiceImpl implements IAaiService {
+ private static final String SERVICE_INSTANCE_ID = "service-instance.service-instance-id";
+ private static final String SERVICE_TYPE = "service-subscription.service-type";
+ private static final String CUSTOMER_ID = "customer.global-customer-id";
+ private static final String SERVICE_INSTANCE_NAME = "service-instance.service-instance-name";
+ private int indexOfSubscriberName = 6;
+
+ @Autowired
+ private AaiClientInterface aaiClient;
+
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(AaiServiceImpl.class);
+
+ private boolean validateModel(Model model){
+ if (model == null) {
+ return false;
+ } else {
+ return model.getModelVers() != null && model.getModelVers().getModelVer() != null && model.getModelVers().getModelVer().get(0).getModelVersionId() != null;
+ }
+ }
+
+ private List<ServiceInstanceSearchResult> getServicesByOwningEntityId(List<String> owningEntities, RoleValidator roleValidator) {
+ AaiResponse<OwningEntityResponse> owningEntityResponse = aaiClient.getServicesByOwningEntityId(owningEntities);
+ List<ServiceInstanceSearchResult> serviceInstanceSearchResultList = new ArrayList<>();
+ if (owningEntityResponse.getT() != null) {
+ for (OwningEntity owningEntity : owningEntityResponse.getT().getOwningEntity()) {
+ if (owningEntity.getRelationshipList() != null) {
+ serviceInstanceSearchResultList = convertRelationshipToSearchResult(owningEntity, serviceInstanceSearchResultList, roleValidator);
+ }
+ }
+ }
+ return serviceInstanceSearchResultList;
+ }
+
+ private List<ServiceInstanceSearchResult> getServicesByProjectNames(List<String> projectNames, RoleValidator roleValidator) {
+ AaiResponse<ProjectResponse> projectByIdResponse = aaiClient.getServicesByProjectNames(projectNames);
+ List<ServiceInstanceSearchResult> serviceInstanceSearchResultList = new ArrayList<>();
+ if (projectByIdResponse.getT() != null) {
+ for (Project project : projectByIdResponse.getT().getProject()) {
+ if (project.getRelationshipList() != null) {
+ serviceInstanceSearchResultList = convertRelationshipToSearchResult(project, serviceInstanceSearchResultList, roleValidator);
+ }
+ }
+ }
+ return serviceInstanceSearchResultList;
+ }
+
+ private List<ServiceInstanceSearchResult> convertRelationshipToSearchResult(AaiRelationResponse owningEntityResponse, List<ServiceInstanceSearchResult> serviceInstanceSearchResultList, RoleValidator roleValidator) {
+ if (owningEntityResponse.getRelationshipList().getRelationship() != null) {
+ List<Relationship> relationshipList = owningEntityResponse.getRelationshipList().getRelationship();
+ for (Relationship relationship : relationshipList) {
+ ServiceInstanceSearchResult serviceInstanceSearchResult = new ServiceInstanceSearchResult();
+ extractRelationshipData(relationship, serviceInstanceSearchResult, roleValidator);
+ extractRelatedToProperty(relationship, serviceInstanceSearchResult);
+ serviceInstanceSearchResultList.add(serviceInstanceSearchResult);
+ }
+ }
+ return serviceInstanceSearchResultList;
+ }
+
+ private void extractRelationshipData(Relationship relationship, ServiceInstanceSearchResult serviceInstanceSearchResult, RoleValidator roleValidator) {
+ List<RelationshipData> relationshipDataList = relationship.getRelationDataList();
+ if (relationshipDataList != null) {
+ setSubscriberName(relationship, serviceInstanceSearchResult);
+ for (RelationshipData relationshipData : relationshipDataList) {
+ String key = relationshipData.getRelationshipKey();
+ if (key.equals(SERVICE_INSTANCE_ID)) {
+ serviceInstanceSearchResult.setServiceInstanceId(relationshipData.getRelationshipValue());
+ } else if (key.equals(SERVICE_TYPE)) {
+ serviceInstanceSearchResult.setServiceType(relationshipData.getRelationshipValue());
+ } else if (key.equals(CUSTOMER_ID)) {
+ serviceInstanceSearchResult.setGlobalCustomerId(relationshipData.getRelationshipValue());
+ }
+ }
+
+ boolean isPermitted = roleValidator.isServicePermitted(serviceInstanceSearchResult.getSubscriberName(), serviceInstanceSearchResult.getServiceType());
+ serviceInstanceSearchResult.setIsPermitted(isPermitted);
+ }
+ }
+
+ private void setSubscriberName(Relationship relationship, ServiceInstanceSearchResult serviceInstanceSearchResult) {
+ String relatedLink = relationship.getRelatedLink();
+ String[] subsciber = relatedLink.split("/");
+ serviceInstanceSearchResult.setSubscriberName(subsciber[indexOfSubscriberName]);
+ }
+
+ private void extractRelatedToProperty(Relationship relationship, ServiceInstanceSearchResult serviceInstanceSearchResult) {
+ List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToPropertyList();
+ if (relatedToPropertyList != null) {
+ for (RelatedToProperty relatedToProperty : relatedToPropertyList) {
+ if (relatedToProperty.getPropertyKey().equals(SERVICE_INSTANCE_NAME)) {
+ serviceInstanceSearchResult.setServiceInstanceName(relatedToProperty.getPropertyValue());
+ }
+ }
+ }
+ }
+
+ @Override
+ public SubscriberFilteredResults getFullSubscriberList(RoleValidator roleValidator) {
+ AaiResponse<SubscriberList> subscriberResponse = aaiClient.getAllSubscribers();
+
+ return new SubscriberFilteredResults(roleValidator, subscriberResponse.getT(),
+ subscriberResponse.getErrorMessage(),
+ subscriberResponse.getHttpCode());
+ }
+
+ @Override
+ public AaiResponse<OperationalEnvironmentList> getOperationalEnvironments(String operationalEnvironmentType, String operationalEnvironmentStatus) {
+ return aaiClient.getOperationalEnvironments(operationalEnvironmentType, operationalEnvironmentStatus);
+ }
+
+ @Override
+ public AaiResponse<SubscriberList> getFullSubscriberList() {
+ return aaiClient.getAllSubscribers();
+ }
+
+ @Override
+ public AaiResponse getSubscriberData(String subscriberId, RoleValidator roleValidator) {
+ AaiResponse<Services> subscriberResponse = aaiClient.getSubscriberData(subscriberId);
+ String subscriberGlobalId = subscriberResponse.getT().globalCustomerId;
+ for (ServiceSubscription serviceSubscription : subscriberResponse.getT().serviceSubscriptions.serviceSubscription) {
+ String serviceType = serviceSubscription.serviceType;
+ serviceSubscription.isPermitted = roleValidator.isServicePermitted(subscriberGlobalId, serviceType);
+ }
+ return subscriberResponse;
+
+ }
+
+ @Override
+ public AaiResponse getServiceInstanceSearchResults(String subscriberId, String instanceIdentifier, RoleValidator roleValidator, List<String> owningEntities, List<String> projects) {
+ List<List<ServiceInstanceSearchResult>> resultList = new ArrayList<>();
+ ServiceInstancesSearchResults serviceInstancesSearchResults = new ServiceInstancesSearchResults();
+
+ if (subscriberId != null || instanceIdentifier != null) {
+ resultList.add(getServicesBySubscriber(subscriberId, instanceIdentifier, roleValidator));
+ }
+ if (owningEntities != null) {
+ resultList.add(getServicesByOwningEntityId(owningEntities, roleValidator));
+ }
+ if (projects != null) {
+ resultList.add(getServicesByProjectNames(projects, roleValidator));
+ }
+ if (!resultList.isEmpty()) {
+ Intersection<ServiceInstanceSearchResult> intersection = new Intersection<>();
+ serviceInstancesSearchResults.serviceInstances = intersection.intersectMultipileArray(resultList);
+ }
+
+ return new AaiResponse<>(serviceInstancesSearchResults, null, HttpStatus.SC_OK);
+ }
+
+
+ private List<ServiceInstanceSearchResult> getServicesBySubscriber(String subscriberId, String instanceIdentifier, RoleValidator roleValidator) {
+ AaiResponse<Services> subscriberResponse = aaiClient.getSubscriberData(subscriberId);
+ String subscriberGlobalId = subscriberResponse.getT().globalCustomerId;
+ String subscriberName = subscriberResponse.getT().subscriberName;
+ ServiceSubscriptions serviceSubscriptions = subscriberResponse.getT().serviceSubscriptions;
+
+ return getSearchResultsForSubscriptions(serviceSubscriptions, subscriberId, instanceIdentifier, roleValidator, subscriberGlobalId, subscriberName);
+
+ }
+
+
+ private ArrayList<ServiceInstanceSearchResult> getSearchResultsForSubscriptions(ServiceSubscriptions serviceSubscriptions, String subscriberId, String instanceIdentifier, RoleValidator roleValidator, String subscriberGlobalId, String subscriberName) {
+ ArrayList<ServiceInstanceSearchResult> results = new ArrayList<>();
+
+ if (serviceSubscriptions != null) {
+ for (ServiceSubscription serviceSubscription : serviceSubscriptions.serviceSubscription) {
+ String serviceType = serviceSubscription.serviceType;
+ serviceSubscription.isPermitted = roleValidator.isServicePermitted(subscriberGlobalId, serviceType);
+ ArrayList<ServiceInstanceSearchResult> resultsForSubscription = getSearchResultsForSingleSubscription(serviceSubscription, subscriberId, instanceIdentifier, subscriberName, serviceType);
+ results.addAll(resultsForSubscription);
+ }
+ }
+
+ return results;
+ }
+
+ private ArrayList<ServiceInstanceSearchResult> getSearchResultsForSingleSubscription(ServiceSubscription serviceSubscription, String subscriberId, String instanceIdentifier, String subscriberName, String serviceType) {
+ ArrayList<ServiceInstanceSearchResult> results = new ArrayList<>();
+
+ if (serviceSubscription.serviceInstances != null) {
+ for (ServiceInstance serviceInstance : serviceSubscription.serviceInstances.serviceInstance) {
+ ServiceInstanceSearchResult serviceInstanceSearchResult =
+ new ServiceInstanceSearchResult(serviceInstance.serviceInstanceId, subscriberId, serviceType, serviceInstance.serviceInstanceName,
+ subscriberName, serviceInstance.modelInvariantId, serviceInstance.modelVersionId, serviceSubscription.isPermitted);
+
+ if (instanceIdentifier == null) {
+ results.add(serviceInstanceSearchResult);
+ } else if (serviceInstanceMatchesIdentifier(instanceIdentifier, serviceInstance)) {
+ results.add(serviceInstanceSearchResult);
+ }
+ }
+ }
+
+ return results;
+ }
+
+ private boolean serviceInstanceMatchesIdentifier(String instanceIdentifier, ServiceInstance serviceInstance) {
+ return instanceIdentifier.equals(serviceInstance.serviceInstanceId) || instanceIdentifier.equals(serviceInstance.serviceInstanceName);
+ }
+
+ @Override
+ public Response getVersionByInvariantId(List<String> modelInvariantId) {
+ try {
+ return aaiClient.getVersionByInvariantId(modelInvariantId);
+ } catch (Exception e) {
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to getVersionByInvariantId from A&AI", e);
+ }
+ return null;
+ }
+
+ @Override
+ public AaiResponse<Pnf> getSpecificPnf(String pnfId) {
+ return aaiClient.getSpecificPnf(pnfId);
+ }
+
+ @Override
+ public AaiResponse getPNFData(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion, String equipVendor, String equipModel) {
+ return aaiClient.getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, equipModel);
+ }
+
+
+
+ @Override
+ public AaiResponse getServices(RoleValidator roleValidator) {
+ AaiResponse<GetServicesAAIRespone> subscriberResponse = aaiClient.getServices();
+ if (subscriberResponse.getT() != null) {
+ for (org.onap.osam.aai.model.AaiGetServicesRequestModel.Service service : subscriberResponse.getT().service) {
+ service.isPermitted = true;
+ }
+ }
+ return subscriberResponse;
+ }
+
+ @Override
+ public AaiResponse<GetTenantsResponse[]> getTenants(String globalCustomerId, String serviceType, RoleValidator roleValidator) {
+ AaiResponse<GetTenantsResponse[]> aaiGetTenantsResponse = aaiClient.getTenants(globalCustomerId, serviceType);
+ GetTenantsResponse[] tenants = aaiGetTenantsResponse.getT();
+ if (tenants != null) {
+ for (int i = 0; i < tenants.length; i++) {
+ tenants[i].isPermitted = roleValidator.isTenantPermitted(globalCustomerId, serviceType, tenants[i].tenantName);
+ }
+ }
+ return aaiGetTenantsResponse;
+
+
+ }
+
+ @Override
+ public AaiResponse getVNFData(String globalSubscriberId, String serviceType, String serviceInstanceId) {
+ return aaiClient.getVNFData(globalSubscriberId, serviceType, serviceInstanceId);
+ }
+
+ @Override
+ public Response getVNFData(String globalSubscriberId, String serviceType) {
+ return aaiClient.getVNFData(globalSubscriberId, serviceType);
+ }
+
+ @Override
+ public AaiResponse getAaiZones() {
+ return (AaiResponse<AicZones>) aaiClient.getAllAicZones();
+ }
+
+ @Override
+ public AaiResponse getAicZoneForPnf(String globalCustomerId, String serviceType, String serviceId) {
+ String aicZone = "";
+
+ AaiResponse<ServiceRelationships> serviceInstanceResp = aaiClient.getServiceInstance(globalCustomerId, serviceType, serviceId);
+ if (serviceInstanceResp.getT() != null) {
+ List<String> aicZoneList = getRelationshipDataByType(serviceInstanceResp.getT().getRelationshipList(), "zone", "zone.zone-id");
+ if (!aicZoneList.isEmpty()) {
+ aicZone = aicZoneList.get(0);
+ } else {
+ LOGGER.warn("aic zone not found for service instance " + serviceId);
+ }
+ } else {
+ if (serviceInstanceResp.getErrorMessage() != null) {
+ LOGGER.error("get service instance {} return error {}", serviceId, serviceInstanceResp.getErrorMessage());
+ return new AaiResponse(aicZone , serviceInstanceResp.getErrorMessage() ,serviceInstanceResp.getHttpCode());
+ } else {
+ LOGGER.warn("get service instance {} return empty body", serviceId);
+ return new AaiResponse(aicZone , "get service instance " + serviceId + " return empty body" ,serviceInstanceResp.getHttpCode());
+ }
+ }
+
+ return new AaiResponse(aicZone , null ,HttpStatus.SC_OK);
+ }
+
+ @Override
+ public AaiResponse getNodeTemplateInstances(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion) {
+ return aaiClient.getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion);
+ }
+
+ @Override
+ public AaiResponse getNetworkCollectionDetails(String serviceInstanceId){
+ AaiResponse<AaiGetNetworkCollectionDetails> getNetworkCollectionDetailsAaiResponse = aaiClient.getNetworkCollectionDetails(serviceInstanceId);
+ return getNetworkCollectionDetailsAaiResponse;
+ }
+
+ @Override
+ public AaiResponse<AaiGetInstanceGroupsByCloudRegion> getInstanceGroupsByCloudRegion(String cloudOwner, String cloudRegionId, String networkFunction){
+ AaiResponse<AaiGetInstanceGroupsByCloudRegion> getInstanceGroupsByCloudRegionResponse = aaiClient.getInstanceGroupsByCloudRegion(cloudOwner, cloudRegionId, networkFunction);
+ return getInstanceGroupsByCloudRegionResponse;
+ }
+
+ @Override
+ public List<String> getServiceInstanceAssociatedPnfs(String globalCustomerId, String serviceType, String serviceInstanceId) {
+ List<String> pnfs = new ArrayList<>();
+
+ AaiResponse<ServiceRelationships> serviceInstanceResp = aaiClient.getServiceInstance(globalCustomerId, serviceType, serviceInstanceId);
+ if (serviceInstanceResp.getT() != null) {
+
+ addPnfsToListViaLogicalLinks(pnfs, serviceInstanceResp);
+ addPnfsToListViaDirectRelations(pnfs, serviceInstanceResp);
+
+ if (pnfs.isEmpty()) {
+ LOGGER.warn("no pnf direct relation found for service id:" + serviceInstanceId+
+ " name: "+serviceInstanceResp.getT().getServiceInstanceName());
+ }
+ } else {
+ if (serviceInstanceResp.getErrorMessage() != null) {
+ LOGGER.error("get service instance {} return error {}", serviceInstanceId, serviceInstanceResp.getErrorMessage());
+ } else {
+ LOGGER.warn("get service instance {} return empty body", serviceInstanceId);
+ }
+ }
+
+ return pnfs.stream().distinct().collect(Collectors.toList());
+ }
+
+ @Override
+ public AaiResponse getInstanceGroupsByVnfInstanceId(String vnfInstanceId){
+ AaiResponse<AaiGetRelatedInstanceGroupsByVnfId> aaiResponse = aaiClient.getInstanceGroupsByVnfInstanceId(vnfInstanceId);
+ if(aaiResponse.getHttpCode() == HttpStatus.SC_OK){
+ return new AaiResponse(convertGetInstanceGroupsResponseToSimpleResponse(aaiResponse.getT()), aaiResponse.getErrorMessage(), aaiResponse.getHttpCode());
+ }
+ return aaiClient.getInstanceGroupsByVnfInstanceId(vnfInstanceId);
+ }
+
+ private List<InstanceGroupInfo> convertGetInstanceGroupsResponseToSimpleResponse(AaiGetRelatedInstanceGroupsByVnfId response) {
+ List<InstanceGroupInfo> instanceGroupInfoList = new ArrayList<>();
+ for(org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship: response.getRelationshipList().getRelationship()){
+ getInstanceGroupInfoFromRelationship(relationship, instanceGroupInfoList);
+ }
+ return instanceGroupInfoList;
+ }
+
+ private void getInstanceGroupInfoFromRelationship(org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship, List<InstanceGroupInfo> instanceGroupInfoList) {
+ if(relationship.getRelatedTo().equals("instance-group")){
+ for(org.onap.osam.aai.model.AaiGetNetworkCollectionDetails.RelatedToProperty relatedToProperty: relationship.getRelatedToPropertyList()){
+ if(relatedToProperty.getPropertyKey().equals("instance-group.instance-group-name")){
+ instanceGroupInfoList.add(new InstanceGroupInfo(relatedToProperty.getPropertyValue()));
+ }
+ }
+ }
+ }
+
+ @Override
+ public List<PortDetailsTranslator.PortDetails> getPortMirroringSourcePorts(String configurationId){
+ return aaiClient.getPortMirroringSourcePorts(configurationId);
+ }
+
+ private void addPnfsToListViaDirectRelations(List<String> pnfs, AaiResponse<ServiceRelationships> serviceInstanceResp) {
+ pnfs.addAll(getRelationshipDataByType(serviceInstanceResp.getT().getRelationshipList(), "pnf", "pnf.pnf-name"));
+ }
+
+ private void addPnfsToListViaLogicalLinks(List<String> pnfs, AaiResponse<ServiceRelationships> serviceInstanceResp) {
+ List<String> logicalLinks = getRelationshipDataByType(serviceInstanceResp.getT().getRelationshipList(), "logical-link", "logical-link.link-name");
+ for (String logicalLink : logicalLinks) {
+ String link;
+ try {
+ link = URLEncoder.encode(logicalLink, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ LOGGER.error("Failed to encode logical link: " + logicalLink, e);
+ continue;
+ }
+
+ AaiResponse<LogicalLinkResponse> logicalLinkResp = aaiClient.getLogicalLink(link);
+ if (logicalLinkResp.getT() != null) {
+ //lag-interface is the key for pnf - approved by Bracha
+ List<String> linkPnfs = getRelationshipDataByType(logicalLinkResp.getT().getRelationshipList(), "lag-interface", "pnf.pnf-name");
+ if (!linkPnfs.isEmpty()) {
+ pnfs.addAll(linkPnfs);
+ } else {
+ LOGGER.warn("no pnf found for logical link " + logicalLink);
+ }
+ } else {
+ if (logicalLinkResp.getErrorMessage() != null) {
+ LOGGER.error("get logical link " + logicalLink + " return error", logicalLinkResp.getErrorMessage());
+ } else {
+ LOGGER.warn("get logical link " + logicalLink + " return empty body");
+ }
+ }
+ }
+ }
+
+ private List<String> getRelationshipDataByType(RelationshipList relationshipList, String relationshipType, String relationshipDataKey) {
+ List<String> relationshipValues = new ArrayList<>();
+ for (Relationship relationship : relationshipList.getRelationship()) {
+ if (relationship.getRelatedTo().equals(relationshipType)) {
+ relationshipValues.addAll( relationship.getRelationDataList().stream()
+ .filter(rel -> rel.getRelationshipKey().equals(relationshipDataKey))
+ .map(RelationshipData::getRelationshipValue)
+ .collect(Collectors.toList())
+ );
+ }
+ }
+
+
+ return relationshipValues;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/AsyncInstantiationBusinessLogicImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/services/AsyncInstantiationBusinessLogicImpl.java
new file mode 100644
index 0000000..71be06a
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/AsyncInstantiationBusinessLogicImpl.java
@@ -0,0 +1,506 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.hibernate.SessionFactory;
+import org.onap.osam.aai.AaiClientInterface;
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.aai.exceptions.InvalidAAIResponseException;
+import org.onap.osam.aai.model.AaiNodeQueryResponse;
+import org.onap.osam.aai.model.ResourceType;
+import org.onap.osam.domain.mso.CloudConfiguration;
+import org.onap.osam.exceptions.DbFailureUncheckedException;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.exceptions.MaxRetriesException;
+import org.onap.osam.exceptions.OperationNotAllowedException;
+import org.onap.osam.job.Job;
+import org.onap.osam.job.Job.JobStatus;
+import org.onap.osam.job.JobAdapter;
+import org.onap.osam.job.JobType;
+import org.onap.osam.job.JobsBrokerService;
+import org.onap.osam.model.JobAuditStatus;
+import org.onap.osam.model.NameCounter;
+import org.onap.osam.model.ServiceInfo;
+import org.onap.osam.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.osam.model.serviceInstantiation.VfModule;
+import org.onap.osam.model.serviceInstantiation.Vnf;
+import org.onap.osam.mso.MsoBusinessLogicImpl;
+import org.onap.osam.mso.MsoProperties;
+import org.onap.osam.mso.model.ServiceInstantiationRequestDetails;
+import org.onap.osam.mso.rest.AsyncRequestStatus;
+import org.onap.osam.utils.DaoUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+@Service
+public class AsyncInstantiationBusinessLogicImpl implements IAsyncInstantiationBusinessLogic {
+
+ private static final int MAX_RETRIES_GETTING_COUNTER = 100;
+ private static final int MAX_RETRIES_GETTING_FREE_NAME_FROM_AAI = 10000;
+ public static final String NAME_FOR_CHECK_AAI_STATUS = "NAME_FOR_CHECK_AAI_STATUS";
+
+ private final DataAccessService dataAccessService;
+
+ private final JobAdapter jobAdapter;
+
+ private final JobsBrokerService jobService;
+
+ private SessionFactory sessionFactory;
+
+ private AaiClientInterface aaiClient;
+
+ private int maxRetriesGettingFreeNameFromAai = MAX_RETRIES_GETTING_FREE_NAME_FROM_AAI;
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AsyncInstantiationBusinessLogicImpl.class);
+ private Map<String, JobStatus> msoStateToJobStatusMap = ImmutableMap.<String, JobStatus>builder()
+ .put("inprogress", JobStatus.IN_PROGRESS)
+ .put("failed", JobStatus.FAILED)
+ .put("pause", JobStatus.PAUSE)
+ .put("paused", JobStatus.PAUSE)
+ .put("complete", JobStatus.COMPLETED)
+ .put("pending", JobStatus.IN_PROGRESS)
+ .put("pendingmanualtask", JobStatus.PAUSE)
+ .put("unlocked", JobStatus.IN_PROGRESS)
+ .build();
+
+
+ @Autowired
+ public AsyncInstantiationBusinessLogicImpl(DataAccessService dataAccessService,
+ JobAdapter jobAdapter,
+ JobsBrokerService jobService,
+ SessionFactory sessionFactory,
+ AaiClientInterface aaiClient) {
+ this.dataAccessService = dataAccessService;
+ this.jobAdapter = jobAdapter;
+ this.jobService = jobService;
+ this.sessionFactory = sessionFactory;
+ this.aaiClient = aaiClient;
+ }
+
+ @Override
+ public List<ServiceInfo> getAllServicesInfo() {
+ return dataAccessService.getList(ServiceInfo.class, filterByCreationDateAndNotDeleted(), orderByCreatedDateAndStatus(), null);
+ }
+
+ private String filterByCreationDateAndNotDeleted() {
+ LocalDateTime minus3Months = LocalDateTime.now().minusMonths(3);
+ Timestamp filterDate = Timestamp.valueOf(minus3Months);
+ return " where" +
+ " hidden = false" +
+ " and deleted_at is null" + // don't fetch deleted
+ " and created >= '" + filterDate + "' ";
+ }
+
+ private String orderByCreatedDateAndStatus() {
+ return " createdBulkDate DESC ,\n" +
+ " (CASE jobStatus\n" +
+ " WHEN 'COMPLETED' THEN 0\n" +
+ " WHEN 'FAILED' THEN 0\n" +
+ " WHEN 'IN_PROGRESS' THEN 1\n" +
+ " WHEN 'PAUSE' THEN 2\n" +
+ " WHEN 'PENDING' THEN 3\n" +
+ " WHEN 'STOPPED' THEN 3 END),\n" +
+ " statusModifiedDate ";
+ }
+
+ @Override
+ public List<UUID> pushBulkJob(ServiceInstantiation request, String userId) {
+ List<UUID> uuids = new ArrayList<>();
+ Date createdBulkDate = Calendar.getInstance().getTime();
+ int bulkSize = request.getBulkSize();
+ UUID templateId = UUID.randomUUID();
+ for (int i = 0; i < bulkSize; i++) {
+ //Job job = jobAdapter.createJob(JobType.ServiceInstantiation, request, templateId, userId, i);
+ Job job = jobAdapter.createJob(JobType.NoOp, request, templateId, userId, i);//should be some instatiation, this was changed as part of code cleaning
+
+ UUID jobId = jobService.add(job);
+ auditVidStatus(jobId,job.getStatus());
+ uuids.add(jobId);
+ dataAccessService.saveDomainObject(createServiceInfo(userId, request, jobId, templateId, createdBulkDate), DaoUtils.getPropsMap());
+ }
+ return uuids;
+ }
+
+ private ServiceInfo createServiceInfo(String userId, ServiceInstantiation serviceInstantiation, UUID jobId, UUID templateId, Date createdBulkDate) {
+ return new ServiceInfo(
+ userId, Job.JobStatus.PENDING, serviceInstantiation.isPause(), jobId, templateId,
+ serviceInstantiation.getOwningEntityId(),
+ serviceInstantiation.getOwningEntityName(),
+ serviceInstantiation.getProjectName(),
+ serviceInstantiation.getAicZoneId(),
+ serviceInstantiation.getAicZoneName(),
+ serviceInstantiation.getTenantId(),
+ serviceInstantiation.getTenantName(),
+ serviceInstantiation.getLcpCloudRegionId(),
+ null,
+ serviceInstantiation.getSubscriptionServiceType(),
+ serviceInstantiation.getSubscriberName(),
+ null,
+ serviceInstantiation.getInstanceName(),
+ serviceInstantiation.getModelInfo().getModelInvariantId(),
+ serviceInstantiation.getModelInfo().getModelName(),
+ serviceInstantiation.getModelInfo().getModelVersion(),
+ createdBulkDate
+ );
+ }
+
+
+ /*//@Override
+ public RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateServiceInstantiationRequest(UUID jobId, ServiceInstantiation payload, String userId) {
+
+ ServiceInstantiationRequestDetails.ServiceInstantiationOwningEntity owningEntity = new ServiceInstantiationRequestDetails.ServiceInstantiationOwningEntity(payload.getOwningEntityId(), payload.getOwningEntityName());
+
+ SubscriberInfo subscriberInfo = new SubscriberInfo();
+ subscriberInfo.setGlobalSubscriberId(payload.getGlobalSubscriberId());
+
+ String serviceInstanceName = null;
+ if(payload.isUserProvidedNaming()) {
+ serviceInstanceName = getUniqueName(payload.getInstanceName(), ResourceType.SERVICE_INSTANCE);
+ String finalServiceInstanceName = serviceInstanceName;
+ updateServiceInfo(jobId, x -> x.setServiceInstanceName(finalServiceInstanceName));
+ }
+ ServiceInstantiationRequestDetails.RequestInfo requestInfo = new ServiceInstantiationRequestDetails.RequestInfo(
+ serviceInstanceName,
+ payload.getProductFamilyId(),
+ "VID",
+ payload.isRollbackOnFailure(),
+ userId);
+
+ List<ServiceInstantiationRequestDetails.ServiceInstantiationService> serviceInstantiationService = new LinkedList<>();
+ List<Map<String, String>> unFilteredInstanceParams = payload.getInstanceParams() != null ? payload.getInstanceParams() : new LinkedList<>();
+ List<Map<String, String>> filteredInstanceParams = removeUnNeededParams(unFilteredInstanceParams);
+ ServiceInstantiationRequestDetails.ServiceInstantiationService serviceInstantiationService1 = new ServiceInstantiationRequestDetails.ServiceInstantiationService(
+ payload.getModelInfo(),
+ serviceInstanceName,
+ filteredInstanceParams,
+ createServiceInstantiationVnfList(payload)
+ );
+ serviceInstantiationService.add(serviceInstantiationService1);
+
+ ServiceInstantiationRequestDetails.RequestParameters requestParameters = new ServiceInstantiationRequestDetails.RequestParameters(payload.getSubscriptionServiceType(), false, serviceInstantiationService);
+
+ ServiceInstantiationRequestDetails.Project project = payload.getProjectName() != null ? new ServiceInstantiationRequestDetails.Project(payload.getProjectName()) : null;
+
+ ServiceInstantiationRequestDetails requestDetails = new ServiceInstantiationRequestDetails(payload.getModelInfo(), owningEntity, subscriberInfo,
+ project, requestInfo, requestParameters);
+
+ RequestDetailsWrapper<ServiceInstantiationRequestDetails> requestDetailsWrapper = new RequestDetailsWrapper(requestDetails);
+ debugRequestDetails(requestDetailsWrapper, logger);
+ return requestDetailsWrapper;
+ }*/
+
+ private List<Map<String, String>> removeUnNeededParams(List<Map<String, String>> instanceParams) {
+ List<String> keysToRemove = new ArrayList<>();
+ if (instanceParams != null && !instanceParams.isEmpty()) {
+ for (String key : instanceParams.get(0).keySet()) {
+ for (String paramToIgnore : PARAMS_TO_IGNORE)
+ if ((key.equalsIgnoreCase(paramToIgnore))) {
+ keysToRemove.add(key);
+ }
+ }
+ for (String key : keysToRemove) {
+ instanceParams.get(0).remove(key);
+ }
+ //TODO will be removed on once we stop using List<Map<String, String>>
+ if (instanceParams.get(0).isEmpty()) {
+ return Collections.emptyList();
+ }
+ }
+ return instanceParams;
+ }
+
+ private ServiceInstantiationRequestDetails.ServiceInstantiationVnfList createServiceInstantiationVnfList(ServiceInstantiation payload) {
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setTenantId(payload.getTenantId());
+ cloudConfiguration.setLcpCloudRegionId(payload.getLcpCloudRegionId());
+
+ Map<String, Vnf> vnfs = payload.getVnfs();
+ List<ServiceInstantiationRequestDetails.ServiceInstantiationVnf> vnfList = new ArrayList<>();
+ for (Vnf vnf : vnfs.values()) {
+ Map<String, Map<String, VfModule>> vfModules = vnf.getVfModules();
+ List<VfModule> convertedUnFilteredVfModules = convertVfModuleMapToList(vfModules);
+ List<VfModule> filteredVfModules = filterInstanceParamsFromVfModuleAndUniqueNames(convertedUnFilteredVfModules, vnf.isUserProvidedNaming());
+ ServiceInstantiationRequestDetails.ServiceInstantiationVnf serviceInstantiationVnf = new ServiceInstantiationRequestDetails.ServiceInstantiationVnf(
+ vnf.getModelInfo(),
+ cloudConfiguration,
+ vnf.getPlatformName(),
+ vnf.getLineOfBusiness(),
+ payload.getProductFamilyId(),
+ removeUnNeededParams(vnf.getInstanceParams()),
+ filteredVfModules,
+ vnf.isUserProvidedNaming() ? getUniqueName(vnf.getInstanceName(), ResourceType.GENERIC_VNF) : null
+ );
+ vnfList.add(serviceInstantiationVnf);
+ }
+
+ return new ServiceInstantiationRequestDetails.ServiceInstantiationVnfList(vnfList);
+ }
+
+ private List<VfModule> convertVfModuleMapToList(Map<String, Map<String, VfModule>> vfModules) {
+ return vfModules.values().stream().flatMap(vfModule -> vfModule.values().stream()).collect(Collectors.toList());
+ }
+
+ private List<VfModule> filterInstanceParamsFromVfModuleAndUniqueNames(List<VfModule> unFilteredVfModules, boolean isUserProvidedNaming) {
+ return unFilteredVfModules.stream().map(vfModule ->
+ new VfModule(
+ vfModule.getModelInfo(),
+ getUniqueNameIfNeeded(isUserProvidedNaming, vfModule.getInstanceName(), ResourceType.VF_MODULE),
+ getUniqueNameIfNeeded(isUserProvidedNaming, vfModule.getVolumeGroupInstanceName(), ResourceType.VOLUME_GROUP),
+ removeUnNeededParams(vfModule.getInstanceParams())))
+ .collect(Collectors.toList());
+ }
+
+ private String getUniqueNameIfNeeded(boolean isUserProvidedNaming, String name, ResourceType resourceType) {
+ return isUserProvidedNaming && !StringUtils.isEmpty(name) ?
+ getUniqueName(name, resourceType) : null;
+ }
+
+ @Override
+ public String getServiceInstantiationPath(ServiceInstantiation serviceInstantiationRequest) {
+ //in case pause flag is true - use assign , else - use create.
+ return MsoBusinessLogicImpl.validateEndpointPath(
+ serviceInstantiationRequest.isPause() ?
+ "mso.restapi.serviceInstanceAssign" : "mso.restapi.serviceInstanceCreate"
+ );
+ }
+
+ @Override
+ public String getOrchestrationRequestsPath() {
+ return MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_GET_ORC_REQ);
+ }
+
+ @Override
+ public ServiceInfo updateServiceInfo(UUID jobUUID, Consumer<ServiceInfo> serviceUpdater) {
+ ServiceInfo serviceInfo = getServiceInfoByJobId(jobUUID);
+ serviceUpdater.accept(serviceInfo);
+ dataAccessService.saveDomainObject(serviceInfo, DaoUtils.getPropsMap());
+ return serviceInfo;
+ }
+
+ @Override
+ public ServiceInfo updateServiceInfoAndAuditStatus(UUID jobUuid, JobStatus jobStatus) {
+ auditVidStatus(jobUuid,jobStatus);
+ return updateServiceInfo(jobUuid, x -> setServiceInfoStatus(x, jobStatus));
+ }
+
+ private void setServiceInfoStatus(ServiceInfo serviceInfo, JobStatus jobStatus) {
+ serviceInfo.setJobStatus(jobStatus);
+ serviceInfo.setStatusModifiedDate(new Date());
+ }
+
+ public ServiceInfo getServiceInfoByJobId(UUID jobUUID) {
+ List<ServiceInfo> serviceInfoList = dataAccessService.getList(ServiceInfo.class, String.format(" where jobId = '%s' ", jobUUID), null, null);
+ if (serviceInfoList.size() != 1) {
+ throw new GenericUncheckedException("Failed to retrieve job with uuid " + jobUUID + " from ServiceInfo table. Instances found: " + serviceInfoList.size());
+ }
+ return serviceInfoList.get(0);
+ }
+
+ public List<JobAuditStatus> getAuditStatuses(UUID jobUUID, JobAuditStatus.SourceStatus source) {
+ return dataAccessService.getList(
+ JobAuditStatus.class,
+ String.format(" where SOURCE = '%s' and JOB_ID = '%s'",source, jobUUID),
+ " CREATED_DATE ", null);
+ }
+
+ private JobAuditStatus getLatestAuditStatus(UUID jobUUID, JobAuditStatus.SourceStatus source){
+ List<JobAuditStatus> list = getAuditStatuses(jobUUID,source);
+ return !list.isEmpty() ? list.get(list.size()-1) : null;
+ }
+
+ @Override
+ public void auditVidStatus(UUID jobUUID, JobStatus jobStatus){
+ JobAuditStatus vidStatus = new JobAuditStatus(jobUUID, jobStatus.toString(), JobAuditStatus.SourceStatus.VID);
+ auditStatus(vidStatus);
+ }
+
+ @Override
+ public void auditMsoStatus(UUID jobUUID, AsyncRequestStatus.Request msoRequestStatus){
+ auditMsoStatus(jobUUID, msoRequestStatus.requestStatus.getRequestState(), msoRequestStatus.requestId, msoRequestStatus.requestStatus.getStatusMessage());
+ }
+
+ @Override
+ public void auditMsoStatus(UUID jobUUID, String jobStatus, String requestId, String additionalInfo){
+ JobAuditStatus msoStatus = new JobAuditStatus(jobUUID, jobStatus, JobAuditStatus.SourceStatus.MSO,
+ requestId != null ? UUID.fromString(requestId) : null,
+ additionalInfo);
+ auditStatus(msoStatus);
+ }
+
+ private void auditStatus(JobAuditStatus jobAuditStatus){
+ JobAuditStatus latestStatus = getLatestAuditStatus(jobAuditStatus.getJobId(),jobAuditStatus.getSource());
+ if (latestStatus == null || !latestStatus.equals(jobAuditStatus))
+ dataAccessService.saveDomainObject(jobAuditStatus, DaoUtils.getPropsMap());
+
+ }
+
+ public Job.JobStatus calcStatus(AsyncRequestStatus asyncRequestStatus) {
+ String msoRequestState = asyncRequestStatus.request.requestStatus.getRequestState().toLowerCase().replaceAll("[^a-z]+", "");
+ JobStatus jobStatus = msoStateToJobStatusMap.get(msoRequestState);
+ return (jobStatus != null ? jobStatus : JobStatus.IN_PROGRESS);
+ }
+
+ @Override
+ public void handleFailedInstantiation(UUID jobUUID) {
+ ServiceInfo serviceInfo = updateServiceInfoAndAuditStatus(jobUUID, JobStatus.FAILED);
+ List<ServiceInfo> serviceInfoList = dataAccessService.getList(
+ ServiceInfo.class,
+ String.format(" where templateId = '%s' and jobStatus = '%s'",
+ serviceInfo.getTemplateId(),
+ JobStatus.PENDING),
+ null, null);
+ serviceInfoList.forEach(si -> updateServiceInfoAndAuditStatus(si.getJobId(), JobStatus.STOPPED));
+ }
+
+ @Override
+ public void deleteJob(UUID jobId) {
+ jobService.delete(jobId);
+ Date now = new Date();
+ updateServiceInfo(jobId, x -> x.setDeletedAt(now));
+ }
+
+ @Override
+ public void hideServiceInfo(UUID jobUUID) {
+ ServiceInfo serviceInfo = getServiceInfoByJobId(jobUUID);
+ if (!serviceInfo.getJobStatus().isFinal()) {
+ String message = String.format( "jobId %s: Service status does not allow hide service, status = %s",
+ serviceInfo.getJobId(),
+ serviceInfo.getJobStatus());
+ logger.error(EELFLoggerDelegate.errorLogger, message);
+ throw new OperationNotAllowedException(message);
+ }
+ serviceInfo.setHidden(true);
+ dataAccessService.saveDomainObject(serviceInfo, DaoUtils.getPropsMap());
+ }
+
+ @Override
+ public int
+
+
+ getCounterForName(String name) {
+
+ String hqlSelectNC = "from NameCounter where name = :name";
+ String hqlUpdateCounter = "update NameCounter set counter = :newCounter " +
+ "where name= :name " +
+ "and counter= :prevCounter";
+
+ Integer counter = null;
+ GenericUncheckedException lastException = null;
+ for (int i = 0; i< MAX_RETRIES_GETTING_COUNTER && counter==null; i++) {
+ try {
+ counter = calcCounter(name, hqlSelectNC, hqlUpdateCounter);
+ }
+ catch (GenericUncheckedException exception) {
+ lastException = exception; //do nothing, we will try again in the loop
+ }
+ }
+
+ if (counter!=null) {
+ return counter;
+ }
+
+ throw lastException!=null ? new DbFailureUncheckedException(lastException) :
+ new DbFailureUncheckedException("Failed to get counter for "+name+" due to unknown error");
+
+ }
+
+ private Integer calcCounter(String name, String hqlSelectNC, String hqlUpdateCounter) {
+ Integer counter;
+ counter = DaoUtils.tryWithSessionAndTransaction(sessionFactory, session -> {
+ NameCounter nameCounter = (NameCounter) session.createQuery(hqlSelectNC)
+ .setText("name", name)
+ .uniqueResult();
+ if (nameCounter != null) {
+ int updatedRows = session.createQuery(hqlUpdateCounter)
+ .setText("name", nameCounter.getName())
+ .setInteger("prevCounter", nameCounter.getCounter())
+ .setInteger("newCounter", nameCounter.getCounter() + 1)
+ .executeUpdate();
+ if (updatedRows == 1) {
+ return nameCounter.getCounter() + 1;
+ }
+ } else {
+ Object nameAsId = session.save(new NameCounter(name));
+ //if save success
+ if (nameAsId != null) {
+ return 1;
+ }
+ }
+ //in case of failure return null, in order to continue the loop
+ return null;
+ });
+ return counter;
+ }
+
+ @Override
+ public int getMaxRetriesGettingFreeNameFromAai() {
+ return maxRetriesGettingFreeNameFromAai;
+ }
+
+ @Override
+ public void setMaxRetriesGettingFreeNameFromAai(int maxRetriesGettingFreeNameFromAai) {
+ this.maxRetriesGettingFreeNameFromAai = maxRetriesGettingFreeNameFromAai;
+ }
+
+ @Override
+ public String getUniqueName(String name, ResourceType resourceType) {
+ //check that name aai response well before increasing counter from DB
+ //Prevents unnecessary increasing of the counter while AAI doesn't response
+ isNameFreeInAai(NAME_FOR_CHECK_AAI_STATUS, resourceType);
+
+ for (int i=0; i<getMaxRetriesGettingFreeNameFromAai(); i++) {
+ int counter = getCounterForName(name);
+ String newName = formatNameAndCounter(name, counter);
+ if (isNameFreeInAai(newName, resourceType)) {
+ return newName;
+ }
+ }
+
+ throw new MaxRetriesException("find unused name for "+name, getMaxRetriesGettingFreeNameFromAai());
+ }
+
+ //the method is protected so we can call it in the UT
+ protected String formatNameAndCounter(String name, int counter) {
+ return name + "_" + String.format("%03d", counter);
+ }
+
+ private boolean isNameFreeInAai(String name, ResourceType resourceType) throws InvalidAAIResponseException {
+ AaiResponse<AaiNodeQueryResponse> aaiResponse = aaiClient.searchNodeTypeByName(name, resourceType);
+ if (aaiResponse.getHttpCode() > 399 || aaiResponse.getT() == null) {
+ throw new InvalidAAIResponseException(aaiResponse);
+ }
+ return CollectionUtils.isEmpty(aaiResponse.getT().resultData);
+ }
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/AuditServiceImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/services/AuditServiceImpl.java
new file mode 100644
index 0000000..b4c5a10
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/AuditServiceImpl.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import java.io.IOException;
+import java.util.UUID;
+
+
+@Service
+public class AuditServiceImpl implements IAuditService {
+
+ @Inject
+ private IAsyncInstantiationBusinessLogic asyncInstantiationBL;
+
+ @Override
+ public void setFailedAuditStatusFromMso(UUID jobUuid, String requestId, int statusCode, String msoResponse){
+ final String failedMsoRequestStatus = "FAILED";
+ String additionalInfo = formatExceptionAdditionalInfo(statusCode, msoResponse);
+ asyncInstantiationBL.auditMsoStatus(jobUuid, failedMsoRequestStatus, requestId, additionalInfo);
+ }
+
+ private String formatExceptionAdditionalInfo(int statusCode, String msoResponse) {
+ String errorMsg = "Http Code:" + statusCode;
+ if (!StringUtils.isEmpty(msoResponse)) {
+ String filteredJson;
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ filteredJson = StringUtils.defaultIfEmpty(
+ objectMapper.readTree(msoResponse).path("serviceException").toString().replaceAll("[\\{\\}]","") ,
+ msoResponse
+ );
+ } catch (JsonParseException e) {
+ filteredJson = msoResponse;
+ } catch (IOException e) {
+ throw new GenericUncheckedException(e);
+ }
+
+ errorMsg = errorMsg + ", " + filteredJson;
+ }
+ return errorMsg;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/BulkInstantiationServiceImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/services/BulkInstantiationServiceImpl.java
new file mode 100644
index 0000000..8e4ae76
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/BulkInstantiationServiceImpl.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import org.onap.osam.job.Job;
+import org.onap.osam.job.JobAdapter;
+import org.onap.osam.job.JobsBrokerService;
+import org.onap.osam.model.JobBulk;
+import org.onap.osam.model.JobModel;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.ws.rs.NotFoundException;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+@Service
+public class BulkInstantiationServiceImpl implements IBulkInstantiationService {
+
+ private JobsBrokerService jobsBrokerService;
+ private JobAdapter jobAdapter;
+
+ @Autowired
+ public BulkInstantiationServiceImpl(JobsBrokerService jobsBrokerService, JobAdapter jobAdapter) {
+ this.jobsBrokerService = jobsBrokerService;
+ this.jobAdapter = jobAdapter;
+ }
+
+ @Override
+ public JobBulk saveBulk(Map<String, Object> bulkRequest) {
+ List<Job> jobList = jobAdapter.createBulkOfJobs(bulkRequest);
+ jobList.forEach(jobsBrokerService::add);
+ return jobAdapter.toModelBulk(jobList);
+ }
+
+ @Override
+ public JobModel getJob(UUID uuid) {
+ Job job = jobsBrokerService.peek(uuid);
+
+ if (job == null || job.getUuid() == null) {
+ throw new NotFoundException("Job with uuid " + uuid + " not found");
+ }
+ return jobAdapter.toModel(job);
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/CsvServiceImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/services/CsvServiceImpl.java
new file mode 100644
index 0000000..e95ab28
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/CsvServiceImpl.java
@@ -0,0 +1,272 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import com.opencsv.CSVReader;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.ws.rs.BadRequestException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.onap.osam.utils.Logging.getMethodName;
+
+@Service
+public class CsvServiceImpl implements ICsvService {
+
+
+ static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CsvServiceImpl.class);
+
+ private static final String ARRAY_REGEX = "\\[(.*?)\\]";
+
+
+ private String [] removeBOMFromCsv(String [] line){
+ if (line.length>0)
+ line[0] = line[0].replaceFirst("\uFEFF","").replaceFirst("","");
+ return line;
+ }
+
+ /**
+ * read a csv file and puts its content in list of string arrays (without the empty lines)
+ * @param filePath - the path of file to read
+ * @return the content of file
+ * @throws IOException
+ */
+ @Override
+ public List<String[]> readCsv(String filePath) throws IOException {
+ CSVReader reader = new CSVReader(new FileReader(filePath));
+ return readCsv(reader);
+ }
+
+ @Override
+ public List<String[]> readCsv(MultipartFile file) throws IOException {
+ CSVReader reader = new CSVReader(new InputStreamReader(file.getInputStream()));
+ return readCsv(reader);
+ }
+
+ private List<String[]> addLineWithoutSpaces(List<String[]> myEntries, String [] line){
+ line = Arrays.stream(line).filter(x -> !"".equals(x)).toArray(String[]::new);
+ if(line.length > 0)
+ myEntries.add(line);
+ return myEntries;
+ }
+
+
+ private List<String[]> readCsv(CSVReader reader) throws IOException {
+ try {
+ List<String[]> myEntries = new ArrayList<>() ;
+ String [] line;
+ Boolean firstLine = true;
+ while ((line = reader.readNext())!= null) {
+ if (firstLine) {
+ line = removeBOMFromCsv(line);
+ firstLine = false;
+ }
+ myEntries = addLineWithoutSpaces(myEntries, line);
+ }
+ return myEntries;
+ }
+ catch (Exception e){
+ logger.error("error during reading CSV file. exception:" + e.getMessage());
+ throw e;
+ }
+
+ }
+
+ /**
+ * main function that call to the recursive function with initial parameters
+ * @param myEntries - the matrix with file content
+ * @return the json
+ * @throws IOException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ @Override
+ public JSONObject convertCsvToJson (List<String[]> myEntries) throws InstantiationException, IllegalAccessException {
+ try {
+ return buildJSON(myEntries, 0, 0, myEntries.size(), JSONObject.class);
+ }
+ catch (Exception e){
+ logger.error("error during parsing CSV file. exception:" + e.getMessage());
+ throw e;
+ }
+
+ }
+
+ /**
+ * it goes over the matrix column while the values are the same and returns the index of changed value
+ * @param myEntries the matrix
+ * @param i row index refer to the whole matrix
+ * @param j column index
+ * @param numLines the length of the current inner matrix
+ * @param startLine row index of inner matrix
+ * @return the index of changed line
+ */
+ private int findIndexOfChangedLine(List<String[]> myEntries, final int i, final int j, final int numLines, final int startLine) {
+ int k;
+ for(k = 0; k + i - startLine < numLines && myEntries.get(i)[j].equals(myEntries.get(k + i)[j]) ; k++);
+ return k;
+ }
+
+ /**
+ * check in array if its first element or if the key already exist in the previous item
+ * @param jsonArray - the array to search in
+ * @param key - the key to check
+ * @return if exists or first element return true, otherwise- false
+ */
+ private Boolean keyExistsOrFirstElement( JSONArray jsonArray,String key){
+ Boolean exists = false;
+ Boolean first = false;
+ JSONObject lastItem = lastItemInArray(jsonArray);
+ if (lastItem == null) {
+ first = true;
+ }
+ else {
+ if (lastItem.has(key)) {
+ exists = true;
+ }
+ }
+ return exists||first;
+ }
+
+ /**
+ * return last json in json array
+ * @param jsonArray
+ * @return last item or null if the array is empty
+ */
+ private JSONObject lastItemInArray(JSONArray jsonArray){
+ JSONObject lastItem = null;
+ if(jsonArray.length()>0) {
+ lastItem = (JSONObject) jsonArray.get(jsonArray.length() - 1);
+ }
+ return lastItem;
+ }
+
+ /**
+ * append current json to the main json
+ * @param json - the main json to append to it
+ * @param key - key to append
+ * @param values - value(s) to append
+ * @param <T> can be JSONObject or JSONArray
+ * @param <E> string or jsonObject or jsonArray
+ * @return json after put
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ private <T, E> T putJson(T json, String key, E values) throws IllegalAccessException, InstantiationException {
+ if (json instanceof JSONArray){
+ JSONArray currentJson= ((JSONArray)json);
+ if (values == null) //array of strings (for last item)
+ {
+ currentJson.put(key);
+ }
+ else {
+ if (keyExistsOrFirstElement(currentJson, key)) {
+ currentJson.put(new JSONObject().put(key, values));
+ } else {
+ JSONObject lastItem = lastItemInArray(currentJson);
+ if(lastItem != null){
+ lastItem.put(key, values);
+ }
+
+ }
+ }
+ }
+ if (json instanceof JSONObject){
+ if (values == null)
+ throw new BadRequestException("Invalid csv file");
+ ((JSONObject)json).put(key,values);
+ }
+ return json;
+ }
+
+
+ /**
+ * recursive function to build JSON. Each time it counts the same values in left and send the smaller matrix
+ * (until the changed value) to the next time.
+ *
+ * @param myEntries - the whole matrix
+ * @param i- row index of the whole matrix
+ * @param j - column index
+ * @param numLines - number of lines of inner matrix (num of same values in the left column)
+ * @param clazz JSONArray or JSONObject
+ * @param <T> JSONArray or JSONObject
+ * @return the json object
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ private <T> T buildJSON(List<String[]> myEntries, int i, final int j, final int numLines, Class<T> clazz) throws IllegalAccessException, InstantiationException {
+ logger.debug(EELFLoggerDelegate.debugLogger, "start {}({}, {}, {})", getMethodName(), i, j, numLines);
+ T json = clazz.newInstance();
+ int startLine = i;
+ while(i < numLines + startLine){
+ String[] currentRow = myEntries.get(i);
+ int length = currentRow.length;
+ int currentDuplicateRows = findIndexOfChangedLine(myEntries,i,j,numLines, startLine);
+ String key = currentRow[j];
+ if (j == length-1) {
+ json = putJson(json,currentRow[j],null);
+ }
+ else
+ {
+ json = buildJsonRow(myEntries, i, j, json, currentRow, length, currentDuplicateRows, key);
+ }
+ i += currentDuplicateRows;
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger, "end {} json = {}", getMethodName(), json);
+ return json;
+ }
+
+ private <T> T buildJsonRow(List<String[]> myEntries, int i, int j, T json, String[] currentRow, int length, int currentDuplicateRows, String key) throws IllegalAccessException, InstantiationException {
+ if (key.matches(ARRAY_REGEX)){
+ JSONArray arrayObjects = buildJSON(myEntries, i, j + 1, currentDuplicateRows, JSONArray.class);
+ json = putJson(json,key.replaceAll("\\[","").replaceAll("]",""),arrayObjects);
+ }
+ else {
+ if (j < length - 2) {
+ json = putJson(json, currentRow[j], buildJSON(myEntries, i, j + 1, currentDuplicateRows, JSONObject.class));
+ }
+ else
+ {
+ if (j == length - 2)//last object
+ {
+ if(currentDuplicateRows > 1) {
+ throw new BadRequestException("Invalid csv file");
+ }
+ json = putJson(json, currentRow[j], currentRow[j + 1]);
+ }
+ }
+ }
+ return json;
+ }
+
+}
+
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/IAaiService.java b/onap-enabler-be/src/main/java/org/onap/osam/services/IAaiService.java
new file mode 100644
index 0000000..b30d957
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/IAaiService.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.aai.SubscriberFilteredResults;
+import org.onap.osam.aai.model.AaiGetInstanceGroupsByCloudRegion;
+import org.onap.osam.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.osam.aai.model.AaiGetPnfs.Pnf;
+import org.onap.osam.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.osam.aai.model.PortDetailsTranslator;
+import org.onap.osam.model.SubscriberList;
+import org.onap.osam.roles.RoleValidator;
+
+import javax.ws.rs.core.Response;
+import java.util.List;
+
+public interface IAaiService {
+
+
+ SubscriberFilteredResults getFullSubscriberList(RoleValidator roleValidator);
+
+ AaiResponse getSubscriberData(String subscriberId, RoleValidator roleValidator);
+
+ AaiResponse getServiceInstanceSearchResults(String subscriberId, String instanceIdentifier, RoleValidator roleProvider, List<String> owningEntities, List<String> projects);
+
+ AaiResponse<SubscriberList> getFullSubscriberList();
+
+ AaiResponse getServices(RoleValidator roleValidator);
+
+ AaiResponse getAaiZones();
+
+ AaiResponse getNetworkCollectionDetails(String serviceInstanceId);
+
+ AaiResponse<AaiGetInstanceGroupsByCloudRegion> getInstanceGroupsByCloudRegion(String cloudOwner, String cloudRegionId, String networkFunction);
+
+ AaiResponse<OperationalEnvironmentList> getOperationalEnvironments(String operationalEnvironmentType, String operationalEnvironmentStatus);
+
+ AaiResponse getAicZoneForPnf(String globalCustomerId , String serviceType , String serviceId);
+
+ Response getVNFData(String globalSubscriberId, String serviceType);
+
+ AaiResponse<GetTenantsResponse[]> getTenants(String globalCustomerId, String serviceType, RoleValidator roleValidator);
+
+ AaiResponse getVNFData(String globalSubscriberId, String serviceType, String serviceInstanceId);
+
+ AaiResponse getNodeTemplateInstances(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion);
+
+ Response getVersionByInvariantId(List<String> modelInvariantId);
+
+ AaiResponse<Pnf> getSpecificPnf(String pnfId);
+
+ List<String> getServiceInstanceAssociatedPnfs(String globalCustomerId, String serviceType, String serviceInstanceId);
+
+ AaiResponse getPNFData(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion, String equipVendor, String equipModel);
+
+ List<PortDetailsTranslator.PortDetails> getPortMirroringSourcePorts(String configurationId);
+
+ AaiResponse getInstanceGroupsByVnfInstanceId(String vnfInstanceId);
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/IAsyncInstantiationBusinessLogic.java b/onap-enabler-be/src/main/java/org/onap/osam/services/IAsyncInstantiationBusinessLogic.java
new file mode 100644
index 0000000..39e2b73
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/IAsyncInstantiationBusinessLogic.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import org.onap.osam.aai.model.ResourceType;
+import org.onap.osam.job.Job;
+import org.onap.osam.model.JobAuditStatus;
+import org.onap.osam.model.ServiceInfo;
+import org.onap.osam.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.osam.mso.rest.AsyncRequestStatus;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+import java.util.function.Consumer;
+
+public interface IAsyncInstantiationBusinessLogic {
+
+ List<String> PARAMS_TO_IGNORE = Arrays.asList("vnf_name", "vf_module_name");
+
+ List<ServiceInfo> getAllServicesInfo();
+
+ List<UUID> pushBulkJob(ServiceInstantiation request, String userId);
+
+ String getServiceInstantiationPath(ServiceInstantiation serviceInstantiationRequest);
+
+ String getOrchestrationRequestsPath();
+
+ ServiceInfo getServiceInfoByJobId(UUID jobUUID);
+
+ List<JobAuditStatus> getAuditStatuses(UUID jobUUID, JobAuditStatus.SourceStatus source);
+
+ ServiceInfo updateServiceInfo(UUID jobUUID, Consumer<ServiceInfo> serviceUpdater);
+
+ ServiceInfo updateServiceInfoAndAuditStatus(UUID jobUuid, Job.JobStatus jobStatus);
+
+ void auditVidStatus(UUID jobUUID, Job.JobStatus jobStatus);
+
+ void auditMsoStatus(UUID jobUUID, AsyncRequestStatus.Request msoRequestStatus);
+
+ void auditMsoStatus(UUID jobUUID, String jobStatus, String requestId, String additionalInfo);
+
+ Job.JobStatus calcStatus(AsyncRequestStatus asyncRequestStatus);
+
+ void handleFailedInstantiation(UUID jobUUID);
+
+ void deleteJob(UUID jobId);
+
+ void hideServiceInfo(UUID jobUUID);
+
+ int getCounterForName(String name);
+
+ int getMaxRetriesGettingFreeNameFromAai();
+
+ void setMaxRetriesGettingFreeNameFromAai(int maxRetriesGettingFreeNameFromAai);
+
+ String getUniqueName(String name, ResourceType resourceType);
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/IAuditService.java b/onap-enabler-be/src/main/java/org/onap/osam/services/IAuditService.java
new file mode 100644
index 0000000..c806d88
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/IAuditService.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import java.util.UUID;
+
+public interface IAuditService {
+
+ void setFailedAuditStatusFromMso(UUID jobUuid, String requestId, int statusCode, String msoResponse);
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/IBulkInstantiationService.java b/onap-enabler-be/src/main/java/org/onap/osam/services/IBulkInstantiationService.java
new file mode 100644
index 0000000..ede1a5d
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/IBulkInstantiationService.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import org.onap.osam.model.JobBulk;
+import org.onap.osam.model.JobModel;
+
+import java.util.Map;
+import java.util.UUID;
+
+public interface IBulkInstantiationService {
+
+ JobBulk saveBulk(Map<String, Object> bulkRequest);
+
+ JobModel getJob(UUID uuid);
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/ICsvService.java b/onap-enabler-be/src/main/java/org/onap/osam/services/ICsvService.java
new file mode 100644
index 0000000..dd6cdda
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/ICsvService.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import org.json.JSONObject;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.List;
+
+public interface ICsvService {
+ List<String[]> readCsv(String filePath) throws IOException;
+ JSONObject convertCsvToJson (List<String[]> myEntries) throws InstantiationException, IllegalAccessException;
+ List<String[]> readCsv(MultipartFile file) throws IOException;
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/IPodService.java b/onap-enabler-be/src/main/java/org/onap/osam/services/IPodService.java
new file mode 100644
index 0000000..5e88f07
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/IPodService.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+public interface IPodService {
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/IPombaService.java b/onap-enabler-be/src/main/java/org/onap/osam/services/IPombaService.java
new file mode 100644
index 0000000..ef2fe04
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/IPombaService.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import org.onap.osam.model.PombaInstance.PombaRequest;
+
+public interface IPombaService {
+ void verify(PombaRequest request);
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/IRoleGeneratorService.java b/onap-enabler-be/src/main/java/org/onap/osam/services/IRoleGeneratorService.java
new file mode 100644
index 0000000..a7f69bd
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/IRoleGeneratorService.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+public interface IRoleGeneratorService {
+ String generateRoleScript(Boolean firstRun);
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/IWorkflowService.java b/onap-enabler-be/src/main/java/org/onap/osam/services/IWorkflowService.java
new file mode 100644
index 0000000..e756c15
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/IWorkflowService.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import java.util.Collection;
+
+public interface IWorkflowService {
+ Collection<String> getWorkflowsForVNFs(Collection<String> vnfNames);
+ Collection<String> getAllWorkflows();
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/PombaServiceImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/services/PombaServiceImpl.java
new file mode 100644
index 0000000..dea4d39
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/PombaServiceImpl.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import org.onap.osam.aai.PombaClientInterface;
+import org.onap.osam.model.PombaInstance.PombaRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class PombaServiceImpl implements IPombaService {
+
+ @Autowired
+ private PombaClientInterface pombaClientInterface;
+
+
+ @Override
+ public void verify(PombaRequest request) {
+ pombaClientInterface.verify(request);
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/RoleGenaratorServiceImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/services/RoleGenaratorServiceImpl.java
new file mode 100644
index 0000000..c2a18eb
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/RoleGenaratorServiceImpl.java
@@ -0,0 +1,189 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import jline.internal.Log;
+import org.onap.osam.aai.AaiClientInterface;
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.aai.ServiceSubscription;
+import org.onap.osam.aai.Services;
+import org.onap.osam.model.ModelConstants;
+import org.onap.osam.model.Subscriber;
+import org.onap.osam.model.SubscriberList;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+
+@Service
+public class RoleGenaratorServiceImpl implements IRoleGeneratorService {
+
+ public static final String ROLE_ID_COLUMN = "ROLE_ID";
+ @Autowired
+ AaiClientInterface client;
+
+ public static final String DB_NAME = "vid_portal";
+ public static final String TBL_NAME = "fn_role";
+ public static final String TEMP_DELIMITER ="***";
+ public static final String OLD_DELIMITER = "_";
+
+ @Override
+ public String generateRoleScript(Boolean firstRun) {
+ String query = "USE " + DB_NAME + ";\r\n" +
+ "SET SQL_SAFE_UPDATES = 0;\r\n";
+ try {
+ AaiResponse<SubscriberList> subscribers = client.getAllSubscribers();
+ if (firstRun) {
+ query += replaceRolesToTempDelimiter("subscriber",buildSubscribersValuesForMappingsTable(subscribers.getT()));
+ }
+ query += addAvailableRolesCombination(firstRun, subscribers);
+
+ }
+ catch (Exception e) {
+ Log.error("There was an error in updating roles "+e.getMessage());
+ }
+ return query;
+ }
+
+ private String addAvailableRolesCombination(Boolean firstRun, AaiResponse<SubscriberList> subscribers) {
+ String query, availableRoles="";
+ HashMap<String,String> servicesNames = new HashMap<String,String>();
+ for (Subscriber subscriber: subscribers.getT().customer) {
+ AaiResponse<Services> subscriberResponse = client.getSubscriberData(subscriber.globalCustomerId);
+ for(ServiceSubscription service: subscriberResponse.getT().serviceSubscriptions.serviceSubscription) {
+ servicesNames.put(service.serviceType,"");
+ String roleName = "'" + subscriber.subscriberName + ModelConstants.ROLE_DELIMITER + service.serviceType + "'";
+ availableRoles += "("+roleName+"),";
+
+
+ }
+ }
+ availableRoles = availableRoles.substring(0,availableRoles.length()-1);
+ query = createTemporaryTableAvailableRoles(availableRoles);
+ if (firstRun){
+ query += replaceRolesToTempDelimiter("service",buildServicesValuesForMappingsTable(servicesNames));
+ query += replaceToNewDelimiter();
+ query += deleteWrongRecords();
+
+ }
+ query += insertAvailableRolesToFnRole();
+ query += dropTemporaryTable("available_roles");
+ return query;
+ }
+
+ private String buildSubscribersValuesForMappingsTable(SubscriberList subscribers){
+ String query="";
+ for (Subscriber subscriber : subscribers.customer) {
+ String subscriberName = subscriber.subscriberName.contains(OLD_DELIMITER) ? subscriber.subscriberName.replace(OLD_DELIMITER, TEMP_DELIMITER) : subscriber.subscriberName;
+ query = query + "('" + subscriber.globalCustomerId + "','" + subscriberName + "') ,";
+ }
+ if(query.length() > 0)
+ query = query.substring(0, query.length()-1) + ";\r\n";
+ return query;
+ }
+
+ private String buildServicesValuesForMappingsTable(HashMap<String,String> servicesNames){
+ final String[] query = {""};
+ servicesNames.forEach((k,v)->{
+ if (k.contains(OLD_DELIMITER)) {
+ query[0] += "('" + k + "' ,'" + k.replace(OLD_DELIMITER, TEMP_DELIMITER) +"'),";
+ }
+ });
+ if(query[0].length() > 0)
+ query[0] = query[0].substring(0, query[0].length()-1) + ";\r\n";
+ return query[0];
+ }
+
+ private String replaceRolesToTempDelimiter(String entityName, String valuesForMappingsTable ) {
+
+ AaiResponse<Services> services = client.getServices();
+ String query = "";
+ if (valuesForMappingsTable.length() > 0) {
+ query = "CREATE TEMPORARY TABLE IF NOT EXISTS " + entityName + "Mappings(mapKey VARCHAR(255),mapValue VARCHAR(255));\r\n" +
+ "INSERT INTO " + entityName + "Mappings VALUES ";
+ query += valuesForMappingsTable;
+ query += "UPDATE " + TBL_NAME + "\r\n" +
+ "INNER JOIN " + entityName + "Mappings ON role_name LIKE concat('%',mapKey, '%')\r\n" +
+ "SET ROLE_NAME = REPLACE(ROLE_NAME, mapKey, mapValue) ; \r\n" +
+ dropTemporaryTable(entityName + "Mappings");
+ }
+ return query;
+ }
+
+ private String replaceToNewDelimiter(){
+ String query = "UPDATE " + TBL_NAME + "\r\n" +
+ "SET ROLE_NAME = REPLACE(ROLE_NAME, '" + OLD_DELIMITER + "', '" + ModelConstants.ROLE_DELIMITER + "');\r\n" ;
+ query += "UPDATE fn_role\r\n" +
+ "SET ROLE_NAME = REPLACE(ROLE_NAME, '" + TEMP_DELIMITER + "', '" + OLD_DELIMITER + "');\r\n" ;
+ return query;
+ }
+
+ private String insertAvailableRolesToFnRole(){
+ String query="INSERT INTO fn_role (ROLE_NAME, ACTIVE_YN, PRIORITY)\r\n" +
+ "SELECT RNAME, 'Y', 5\r\n" +
+ "FROM available_roles\r\n" +
+ "WHERE NOT EXISTS (SELECT ROLE_NAME\r\n" +
+ "FROM fn_role \r\n" +
+ "where RNAME = ROLE_NAME);\r\n";
+ return query;
+ }
+
+
+
+ private String createTemporaryTableAvailableRoles(String availableRoles) {
+ String query = "CREATE TEMPORARY TABLE IF NOT EXISTS available_roles(rname VARCHAR(255));\r\n";
+ query += "INSERT INTO available_roles VALUES "+availableRoles+";\r\n";
+ return query;
+ }
+
+ private String deleteWrongRecords(){
+ String query ="CREATE TEMPORARY TABLE IF NOT EXISTS wrong_roles(roleID INT);\r\n" +
+ "INSERT INTO wrong_roles (roleID)\r\n" +
+ "SELECT ROLE_ID FROM fn_role LEFT JOIN available_roles ON role_name LIKE concat(rname, '%')\r\n" +
+ "WHERE available_roles.rname IS NULL AND ROLE_ID NOT IN (1,16);\r\n";
+ query += deleteCascade();
+ query += dropTemporaryTable("wrong_roles");
+ return query;
+ }
+
+ private String deleteCascade() {
+ String query = deleteFromTableByRoles("fn_role_composite", "PARENT_ROLE_ID");
+ query = query.substring(0, query.length()-1);
+ query += " OR wrong_roles.ROLEID = fn_role_composite.CHILD_ROLE_ID;\r\n";
+ query += deleteFromTableByRoles("fn_role_function", ROLE_ID_COLUMN)+ "\r\n";
+ query += deleteFromTableByRoles("fn_user_role", ROLE_ID_COLUMN)+ "\r\n";
+ query += deleteFromTableByRoles(TBL_NAME, ROLE_ID_COLUMN)+ "\r\n";
+ return query;
+ }
+
+ private String deleteFromTableByRoles(String table, String column) {
+ String query = "DELETE FROM " + table + "\r\n";
+ query += "using " + table + " inner join wrong_roles\r\n" +
+ "where wrong_roles.ROLEID = " + table + "." + column + ";";
+ return query;
+ }
+
+ private String dropTemporaryTable(String table) {
+ return "DROP TEMPORARY TABLE IF EXISTS " + table + ";\r\n";
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/services/WorkflowServiceImpl.java b/onap-enabler-be/src/main/java/org/onap/osam/services/WorkflowServiceImpl.java
new file mode 100644
index 0000000..b84de5b
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/services/WorkflowServiceImpl.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import org.onap.osam.model.Workflow;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.stream.Collectors;
+
+@Service
+public class WorkflowServiceImpl implements IWorkflowService {
+ //TODO: Add the list of workflows hard coded or from DB.
+ private ArrayList<Workflow> workflows = new ArrayList<>(Arrays.asList(
+ new Workflow(0, "Upgrade", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF3", "VNF4"))),
+ new Workflow(1, "Clean", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF3"))),
+ new Workflow(2, "Reinstall", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF4"))),
+ new Workflow(3, "Dump", new ArrayList<>(Arrays.asList("VNF1", "VNF3", "VNF4"))),
+ new Workflow(4, "Flush", new ArrayList<>(Arrays.asList("VNF2", "VNF3", "VNF4")))
+ ));
+
+ @Override
+ public Collection<String> getWorkflowsForVNFs(Collection<String> vnfNames) {
+ Collection<String> result = workflows.stream()
+ .filter(workflow -> workflow.getVnfNames().containsAll(vnfNames))
+ .map(workflow -> workflow.getWorkflowName())
+ .distinct()
+ .collect(Collectors.toList());
+
+ return result;
+ }
+
+ @Override
+ public Collection<String> getAllWorkflows() {
+ return workflows.stream()
+ .map(workflow -> workflow.getWorkflowName())
+ .distinct()
+ .collect(Collectors.toList());
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/utils/DaoUtils.java b/onap-enabler-be/src/main/java/org/onap/osam/utils/DaoUtils.java
new file mode 100644
index 0000000..c5612dd
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/utils/DaoUtils.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.utils;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.portalsdk.core.domain.FusionObject;
+
+import java.util.HashMap;
+import java.util.function.Function;
+
+public class DaoUtils {
+
+ //all credit for this wonderful method go to is9613
+ public static<T> T tryWithSessionAndTransaction(SessionFactory sessionFactory, Function<Session, T> update) {
+ // opens a session and transactions, executes the input query.
+ // gracefully close session and transaction once error occurres.
+ Session session = null;
+ Transaction tx = null;
+ try {
+ session = sessionFactory.openSession();
+ tx = session.beginTransaction();
+
+ T res = update.apply(session);
+
+ tx.commit();
+
+ return res;
+ } catch (RuntimeException e) {
+ try {
+ if (tx != null) {
+ tx.rollback();
+ }
+ } catch (RuntimeException e2) {
+ // e2 is ingnored; we would like to know the
+ // original failure reason, not only the reason
+ // for rollback's failure
+ throw new GenericUncheckedException("Failed rolling back transaction", e);
+ }
+ throw new GenericUncheckedException("Rolled back transaction", e);
+ } finally {
+ if (session != null) {
+ session.close();
+ }
+ }
+ }
+
+ public static HashMap<String, Object> getPropsMap() {
+ HashMap<String, Object> props = new HashMap<>();
+ props.put(FusionObject.Parameters.PARAM_USERID, 0);
+ return props;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/utils/Intersection.java b/onap-enabler-be/src/main/java/org/onap/osam/utils/Intersection.java
new file mode 100644
index 0000000..6fd9ff9
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/utils/Intersection.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.utils;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class Intersection<T> {
+ public List<T> intersectMultipileArray(List<List<T>> lists) {
+ if (lists.size() == 1) {
+ return lists.get(0);
+ } else {
+ List<T> intersectResult = intersectTwoArrays(lists.get(0),lists.get(1));
+
+ lists.remove(0);
+ lists.remove(0);
+ lists.add(0,intersectResult);
+ return intersectMultipileArray(lists);
+ }
+
+ }
+
+ public List<T> intersectTwoArrays(List<T> list1, List<T> list2) {
+
+ List<T> intersect = list1.stream()
+ .filter(list2::contains)
+ .collect(Collectors.toList());
+ return intersect;
+ }
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/utils/Logging.java b/onap-enabler-be/src/main/java/org/onap/osam/utils/Logging.java
new file mode 100644
index 0000000..ed30322
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/utils/Logging.java
@@ -0,0 +1,200 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.utils;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.google.common.collect.ImmutableList;
+import io.joshworks.restclient.http.HttpResponse;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.http.HttpMethod;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.ProcessingException;
+import javax.ws.rs.core.Response;
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.UUID;
+
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+import static org.apache.commons.lang3.exception.ExceptionUtils.getRootCause;
+import static org.apache.commons.lang3.exception.ExceptionUtils.getThrowableList;
+import static org.onap.osam.utils.Streams.not;
+
+public class Logging {
+
+ Logging() {
+ }
+
+ public static final String HTTP_REQUESTS_OUTGOING = "http.requests.outgoing.";
+
+ public static final String REQUEST_ID_HEADER_KEY = SystemProperties.ECOMP_REQUEST_ID;
+
+ private static ObjectMapper objectMapper = new ObjectMapper();
+
+ public static String getMethodName() {
+ return getMethodName(0);
+ }
+
+ public static String getMethodCallerName() {
+ return getMethodName(1);
+ }
+
+ private static String getMethodName(int depth) {
+ final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+ String thisClassName = stackTrace[1].getClassName();
+ final Optional<String> caller =
+ Arrays.stream(stackTrace)
+ .skip(1)
+ .filter(not(frame -> frame.getClassName().equals(thisClassName)))
+ .skip(depth)
+ .map(StackTraceElement::getMethodName)
+ .findFirst();
+ return caller.orElse("<unknonwn method name>");
+ }
+
+ public static EELFLogger getRequestsLogger(String serverName) {
+ return EELFLoggerDelegate.getLogger(HTTP_REQUESTS_OUTGOING +serverName);
+ }
+
+ public static void logRequest(final EELFLogger logger, final HttpMethod method, final String url, final Object body) {
+ if (!logger.isDebugEnabled()) {
+ return;
+ }
+
+ if (body == null) {
+ logRequest(logger, method, url);
+ return;
+ }
+
+ try {
+ String bodyAsJson = objectMapper.writeValueAsString(body);
+ logger.debug("Sending {} {} Body: {}", method.name(), url, bodyAsJson);
+ } catch (JsonProcessingException e) {
+ logRequest(logger, method, url);
+ logger.debug("Failed to parse object in logRequest. {}", body);
+ }
+ }
+
+ public static void logRequest(final EELFLogger logger, final HttpMethod method, final String url) {
+ logger.debug("Sending {} {}", method.name(), url);
+ }
+
+ public static <T> void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final Response response, final Class<T> entityClass) {
+ if (!logger.isDebugEnabled()) {
+ return;
+ }
+ if (response == null) {
+ logger.debug("Received {} {} response: null", method.name(), url);
+ return;
+ }
+ try {
+ response.bufferEntity();
+ logger.debug("Received {} {} Status: {} . Body: {}", method.name(), url, response.getStatus(), response.readEntity(entityClass));
+ }
+ catch (ProcessingException | IllegalStateException e) {
+ logger.debug("Received {} {} Status: {} . Failed to read response as {}", method.name(), url, response.getStatus(), entityClass.getName());
+ }
+ }
+
+ public static <T> void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final HttpResponse<T> response) {
+ try {
+ logger.debug("Received {} {} Status: {} . Body: {}", method.name(), url, response.getStatus(), response.getBody());
+ }
+ catch (ProcessingException | IllegalStateException e) {
+ logger.debug("Received {} {} Status: {} . Failed to read response", method.name(), url, response.getStatus());
+ }
+ }
+
+ public static void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final Response response) {
+ logResponse(logger, method, url, response, String.class);
+ }
+
+ public static HttpServletRequest getHttpServletRequest(){
+ return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
+ }
+
+ public static String extractOrGenerateRequestId() {
+ try {
+ return getHttpServletRequest().getHeader(REQUEST_ID_HEADER_KEY);
+ }
+ catch (IllegalStateException e) {
+ //in async jobs we don't have any HttpServletRequest
+ return UUID.randomUUID().toString();
+ }
+ }
+
+ public static void debugRequestDetails(Object requestDetails, final EELFLogger logger) {
+ if (logger.isDebugEnabled()) {
+ String requestDetailsAsString;
+ try {
+ requestDetailsAsString = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(requestDetails);
+ } catch (JsonProcessingException e) {
+ requestDetailsAsString = "error: cannot stringify RequestDetails";
+ }
+ logger.debug("requestDetailsAsString: {}", requestDetailsAsString);
+ }
+ }
+
+ public static String exceptionToDescription(Throwable exceptionToDescribe) {
+ // Ignore top-most GenericUnchecked or Runtime exceptions that has no added message
+ final Throwable top = getThrowableList(exceptionToDescribe).stream()
+ .filter(not(e -> ImmutableList.of(GenericUncheckedException.class, RuntimeException.class).contains(e.getClass())
+ && StringUtils.equals(e.getMessage(), e.getCause() == null ? null : e.getCause().toString())))
+ .findFirst().orElse(exceptionToDescribe);
+
+ final Throwable root = defaultIfNull(getRootCause(top), top);
+
+ String rootToString = root.toString();
+
+ // nullPointer description will include some context
+ if (root.getClass().equals(NullPointerException.class) && root.getStackTrace().length > 0) {
+ rootToString = String.format("NullPointerException at %s:%d",
+ root.getStackTrace()[0].getFileName(),
+ root.getStackTrace()[0].getLineNumber());
+ }
+
+ // if input is a single exception, without cause: top.toString
+ // else: return top.toString + root.toString
+ // but not if root is already described in top.toString
+ if (top.equals(root)) {
+ return rootToString;
+ } else {
+ final String topToString = top.toString();
+ if (topToString.contains(root.getClass().getName()) && topToString.contains(root.getLocalizedMessage())) {
+ return topToString;
+ } else {
+ return topToString + ": " + rootToString;
+ }
+ }
+ }
+
+
+}
diff --git a/onap-enabler-be/src/main/java/org/onap/osam/utils/Streams.java b/onap-enabler-be/src/main/java/org/onap/osam/utils/Streams.java
new file mode 100644
index 0000000..b9ee683
--- /dev/null
+++ b/onap-enabler-be/src/main/java/org/onap/osam/utils/Streams.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.utils;
+
+import java.util.Iterator;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+
+public class Streams {
+ public static <R> Predicate<R> not(Predicate<R> predicate) {
+ return predicate.negate();
+ }
+
+ public static <T> Stream<T> fromIterator(final Iterator<T> iterator) {
+ Iterable<T> iterable = () -> iterator;
+ return StreamSupport.<T>stream(iterable.spliterator(), false);
+ }
+
+
+ // https://stackoverflow.com/questions/20746429/limit-a-stream-by-a-predicate
+ private static <T> Spliterator<T> takeWhile(
+ Spliterator<T> splitr, Predicate<? super T> predicate) {
+ return new Spliterators.AbstractSpliterator<T>(splitr.estimateSize(), 0) {
+ boolean stillGoing = true;
+ @Override public boolean tryAdvance(Consumer<? super T> consumer) {
+ if (stillGoing) {
+ boolean hadNext = splitr.tryAdvance(elem -> {
+ if (predicate.test(elem)) {
+ consumer.accept(elem);
+ } else {
+ stillGoing = false;
+ }
+ });
+ return hadNext && stillGoing;
+ }
+ return false;
+ }
+ };
+ }
+
+ public static <T> Stream<T> takeWhile(Stream<T> stream, Predicate<? super T> predicate) {
+ return StreamSupport.stream(takeWhile(stream.spliterator(), predicate), false);
+ }
+
+}
diff --git a/onap-enabler-be/src/main/resources/aai_config_instance_view_edit.json b/onap-enabler-be/src/main/resources/aai_config_instance_view_edit.json
new file mode 100644
index 0000000..3cd4506
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/aai_config_instance_view_edit.json
@@ -0,0 +1,81 @@
+{
+ "model-name":"Proxy-Config-Instance",
+ "configuration":{
+ "configuration-id": "9533-config-LB1113",
+ "configuration-name": "configuration-name-9533",
+ "configuration-type": "configuration-type-9533",
+ "configuration-sub-type": "configuration-sub-type-9533",
+ "model-invariant-id": "model-invariant-id-9533",
+ "model-version-id": "model-version-id-9533",
+ "orchestration-status": "Active",
+ "operational-status": "",
+ "configuration-selflink": "",
+ "model-customization-id": "model-customization-id-9533",
+ "resource-version": "1504038855716"
+ },
+ "extra-properties": {
+ },
+ "inventory-response-items":{
+ "inventory-response-item":[
+ {
+ "model-name":"VidPcrf051517..pcrf_nimbus_pcm..module-4",
+ "l-interface": {
+ "interface-name": "9533lInterface-LB1113",
+ "interface-role": "8ni",
+ "v6-wan-link-ip": "Pnr",
+ "selflink": "Un56B",
+ "interface-id": "o74n",
+ "macaddr": "8an6",
+ "network-name": "kjOn",
+ "management-option": "0Rn7",
+ "interface-description": "XPnLr",
+ "is-port-mirrored": true,
+ "resource-version": "1504038598348",
+ "in-maint": false,
+ "is-ip-unnumbered": false,
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "logical-link",
+ "related-link": "/aai/v11/network/logical-links/logical-link/logicallink-987654321-21-LB1113",
+ "relationship-data": [
+ {
+ "relationship-key": "logical-link.link-name",
+ "relationship-value": "logicallink-987654321-21-LB1113"
+ }
+ ]
+ }
+ ]
+ },
+ "l3-interface-ipv4-address-list": [
+ {
+ "l3-interface-ipv4-address": "112.121.144.16",
+ "l3-interface-ipv4-prefix-length": 59,
+ "vlan-id-inner": 917,
+ "vlan-id-outer": 519,
+ "is-floating": true,
+ "resource-version": "1504038598353",
+ "neutron-network-id": "HX6m54p1akX",
+ "neutron-subnet-id": "nbmX5okGg"
+ }
+ ],
+ "l3-interface-ipv6-address-list": [
+ {
+ "l3-interface-ipv6-address": "2001:232E:2333:2322:122C:CDD:2AE3:3E4",
+ "l3-interface-ipv6-prefix-length": 76,
+ "vlan-id-inner": 27,
+ "vlan-id-outer": 710,
+ "is-floating": true,
+ "resource-version": "1504038598364",
+ "neutron-network-id": "xBR0OOToQ",
+ "neutron-subnet-id": "4E0gZLH"
+ }
+ ]
+ },
+ "extra-properties":{
+
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/aai_get_node_template_instances.json b/onap-enabler-be/src/main/resources/aai_get_node_template_instances.json
new file mode 100644
index 0000000..f6e3d52
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/aai_get_node_template_instances.json
@@ -0,0 +1,101 @@
+{"results": [
+ {
+ "id": "1976357096",
+ "node-type": "generic-vnf",
+ "url": "/aai/v11/network/generic-vnfs/generic-vnf/VNF-1-9887-jc689q",
+ "properties": {
+ "vnf-id": "0846287b-65bf-45a6-88f6-6a1af4149fac",
+ "vnf-name": "vnf9887-1jc689q",
+ "vnf-name2": "notused",
+ "vnf-type": "VRR",
+ "service-id": "VRRaaS",
+ "regional-resource-zone": "notusedforMobility",
+ "prov-status": "PREPROV",
+ "operational-status": "",
+ "license-key": "novalue",
+ "equipment-role": "VRR",
+ "orchestration-status": "Created",
+ "heat-stack-id": "1234",
+ "mso-catalog-key": "msokey",
+ "ipv4-oam-address": "135.60.77.25",
+ "ipv4-loopback0-address": "12.60.77.25",
+ "nm-lan-v6-address": "2001:1890:1F8:2075::1:4",
+ "management-v6-address": "2001:1890:1F8:2075::1:5",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1505337418309",
+ "model-invariant-id": "96129eb9-f0de-4e05-8af2-73146473f766",
+ "model-version-id": "5761e0a7-c6df-4d8a-9ebd-b8f445054dec",
+ "widget-model-id": "78789",
+ "widget-model-version": "7",
+ "nf-function": "nf-function in ASDC",
+ "nf-role": "nf-role in ASDC",
+ "nf-naming-code": "code in ASDC",
+ "selflink": "pathToController"
+ },
+ "related-to": [
+ {
+ "id": "1689710648",
+ "node-type": "service-instance",
+ "url": "/aai/v11/business/customers/customer/customer-9887-jc689q/service-subscriptions/service-subscription/VRR/service-instances/service-instance/SI-9887-jc689q"
+ },
+ {
+ "id": "1362120784",
+ "node-type": "vserver",
+ "url": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-id-9887-jc689q/cloudRegion-id-9887-jc689q/tenants/tenant/tenant-id-9887-jc689q/vservers/vserver/vserver-id-2-9887-jc689q"
+ },
+ {
+ "id": "2017317104",
+ "node-type": "vserver",
+ "url": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-id-9887-jc689q/cloudRegion-id-9887-jc689q/tenants/tenant/tenant-id-9887-jc689q/vservers/vserver/vserver-id-1-9887-jc689q"
+ }
+ ]
+ },
+ {
+ "id": "2362269792",
+ "node-type": "generic-vnf",
+ "url": "/aai/v11/network/generic-vnfs/generic-vnf/VNF-2-9887-jc689q",
+ "properties": {
+ "vnf-id": "c187e9fe-40c3-4862-b73e-84ff056205f6",
+ "vnf-name": "vnf9887-2jc689q",
+ "vnf-name2": "notused",
+ "vnf-type": "VRR",
+ "service-id": "VRRaaS",
+ "regional-resource-zone": "notusedforMobility",
+ "prov-status": "PREPROV",
+ "operational-status": "",
+ "license-key": "novalue",
+ "equipment-role": "VRR",
+ "orchestration-status": "Created",
+ "heat-stack-id": "1234",
+ "mso-catalog-key": "msokey",
+ "ipv4-oam-address": "135.60.77.25",
+ "ipv4-loopback0-address": "12.60.77.25",
+ "nm-lan-v6-address": "2001:1890:1F8:2075::1:4",
+ "management-v6-address": "2001:1890:1F8:2075::1:5",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1505337418754",
+ "model-invariant-id": "96129eb9-f0de-4e05-8af2-73146473f766",
+ "model-version-id": "5761e0a7-c6df-4d8a-9ebd-b8f445054dec",
+ "widget-model-id": "78789",
+ "widget-model-version": "7",
+ "nf-function": "nf-function in ASDC",
+ "nf-role": "nf-role in ASDC",
+ "nf-naming-code": "code in ASDC",
+ "selflink": "pathToController"
+ },
+ "related-to": [
+ {
+ "id": "1689710648",
+ "node-type": "service-instance",
+ "url": "/aai/v11/business/customers/customer/customer-9887-jc689q/service-subscriptions/service-subscription/VRR/service-instances/service-instance/SI-9887-jc689q"
+ },
+ {
+ "id": "1689706552",
+ "node-type": "vserver",
+ "url": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-id-9887-jc689q/cloudRegion-id-9887-jc689q/tenants/tenant/tenant-id-9887-jc689q/vservers/vserver/vserver-id-3-9887-jc689q"
+ }
+ ]
+ }
+]}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/catalog.json b/onap-enabler-be/src/main/resources/catalog.json
new file mode 100644
index 0000000..ae4d684
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/catalog.json
@@ -0,0 +1,174 @@
+{
+ "services": {
+ "0346aa9f-57b7-458a-9681-daf5b19d52b0": {
+ "uuid": "0346aa9f-57b7-458a-9681-daf5b19d52b0",
+ "name": "The Worst Service",
+ "version": "1.0",
+ "toscaModelURL": "sampleTosca.csar",
+ "category": "Bad Services",
+ "lifecycleState": "NOT_CERTIFIED_CHECKOUT",
+ "lastUpdaterUserId": "example@example.org",
+ "lastUpdaterFullName": "Example User",
+ "distributionStatus": "DISTRIBUTION_REJECTED",
+ "artifacts": [],
+ "resources": []
+ },
+ "1346aa9f-57b7-458a-9681-daf5b19d52b1": {
+ "uuid": "1346aa9f-57b7-458a-9681-daf5b19d52b1",
+ "name": "The Worst Service",
+ "version": "1.1",
+ "toscaModelURL": "sampleTosca.csar",
+ "category": "Bad Services",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "example@example.org",
+ "lastUpdaterFullName": "Example User",
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": [],
+ "resources": []
+ },
+ "3346aa9f-57b7-458a-9681-daf5b19d52b3": {
+ "uuid": "3346aa9f-57b7-458a-9681-daf5b19d52b3",
+ "name": "Bland Service",
+ "version": "1.9",
+ "toscaModelURL": "sampleTosca.csar",
+ "category": "Neutral Services",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "example@example.org",
+ "lastUpdaterFullName": "Example User",
+ "distributionStatus": "DISTRIBUTION_NOT_APPROVED",
+ "artifacts": [],
+ "resources": []
+ },
+ "2346aa9f-57b7-458a-9681-daf5b19d52b2": {
+ "uuid": "2346aa9f-57b7-458a-9681-daf5b19d52b2",
+ "name": "The Best Service",
+ "version": "1.3",
+ "toscaModelURL": "sampleTosca.csar",
+ "category": "Good Services",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "example@example.org",
+ "lastUpdaterFullName": "Example User",
+ "distributionStatus": "DISTRIBUTION_APPROVED",
+ "artifacts": [
+ {
+ "artifactUUID": "0cf78c81-1246-45e7-a190-eaa309ee5680",
+ "generatedFromUUID": "3cf78c81-1246-45e7-a190-eaa309ee5680",
+ "artifactName": "The Worst Artifact",
+ "artifactType": "HEAT",
+ "artifactDescription": "This is the worst artifact",
+ "artifactURL": "http://www.openecomp.org/",
+ "artifactTimeout": "60",
+ "artifactChecksum": "A worthy checksum",
+ "artifactVersion": "0.1"
+ },
+ {
+ "artifactUUID": "1cf78c81-1246-45e7-a190-eaa309ee5681",
+ "generatedFromUUID": "3cf78c81-1246-45e7-a190-eaa309ee5680",
+ "artifactName": "The Worst Artifact",
+ "artifactType": "HEAT",
+ "artifactDescription": "This is the worst artifact",
+ "artifactURL": "http://www.openecomp.org/",
+ "artifactTimeout": "60",
+ "artifactChecksum": "A worthy checksum",
+ "artifactVersion": "0.1"
+ },
+ {
+ "artifactUUID": "2cf78c81-1246-45e7-a190-eaa309ee5682",
+ "generatedFromUUID": "3cf78c81-1246-45e7-a190-eaa309ee5680",
+ "artifactName": "The Worst Artifact",
+ "artifactType": "HEAT",
+ "artifactDescription": "This is the worst artifact",
+ "artifactURL": "http://www.openecomp.org/",
+ "artifactTimeout": "60",
+ "artifactChecksum": "A worthy checksum",
+ "artifactVersion": "0.1"
+ }
+ ],
+ "resources": []
+ }
+ },
+ "resources": {
+ "2f92b5b0-10ff-4cf4-9531-88546fe88a42": {
+ "uuid": "2f92b5b0-10ff-4cf4-9531-88546fe88a42",
+ "invariantUUID": "df92b5b0-10ff-4cf4-9531-88546fe88a4d",
+ "name": "The Worst Resource",
+ "version": "0.1",
+ "toscaModelURL": "sampleTosca.csar",
+ "toscaModel": "http://www.openecomp.org/",
+ "toscaResourceName": "The Worst Resource (TOSCA)",
+ "category": "Bad Resources",
+ "subCategory": "Really Bad Resources",
+ "resourceType": "VF",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "example@example.org",
+ "lastUpdaterFullName": "Example User",
+ "artifacts": [
+ {
+ "artifactUUID": "0cf78c81-1246-45e7-a190-eaa309ee5680",
+ "generatedFromUUID": "3cf78c81-1246-45e7-a190-eaa309ee5680",
+ "artifactName": "The Worst Artifact",
+ "artifactType": "HEAT",
+ "artifactDescription": "This is the worst artifact",
+ "artifactURL": "http://www.openecomp.org/",
+ "artifactTimeout": "60",
+ "artifactChecksum": "A worthy checksum",
+ "artifactVersion": "0.1"
+ },
+ {
+ "artifactUUID": "1cf78c81-1246-45e7-a190-eaa309ee5681",
+ "generatedFromUUID": "3cf78c81-1246-45e7-a190-eaa309ee5680",
+ "artifactName": "The Worst Artifact",
+ "artifactType": "HEAT",
+ "artifactDescription": "This is the worst artifact",
+ "artifactURL": "http://www.openecomp.org/",
+ "artifactTimeout": "60",
+ "artifactChecksum": "A worthy checksum",
+ "artifactVersion": "0.1"
+ },
+ {
+ "artifactUUID": "2cf78c81-1246-45e7-a190-eaa309ee5682",
+ "generatedFromUUID": "3cf78c81-1246-45e7-a190-eaa309ee5680",
+ "artifactName": "The Worst Artifact",
+ "artifactType": "HEAT",
+ "artifactDescription": "This is the worst artifact",
+ "artifactURL": "http://www.openecomp.org/",
+ "artifactTimeout": "60",
+ "artifactChecksum": "A worthy checksum",
+ "artifactVersion": "0.1"
+ }
+ ]
+ },
+ "0f92b5b0-10ff-4cf4-9531-88546fe88a40": {
+ "uuid": "0f92b5b0-10ff-4cf4-9531-88546fe88a40",
+ "invariantUUID": "df92b5b0-10ff-4cf4-9531-88546fe88a4d",
+ "name": "The Worst Resource",
+ "version": "0.1",
+ "toscaModelURL": "sampleTosca.csar",
+ "toscaModel": "http://www.openecomp.org/",
+ "toscaResourceName": "The Worst Resource (TOSCA)",
+ "category": "Bad Resources",
+ "subCategory": "Really Bad Resources",
+ "resourceType": "VF",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "example@example.org",
+ "lastUpdaterFullName": "Example User",
+ "artifacts": []
+ },
+ "1f92b5b0-10ff-4cf4-9531-88546fe88a41": {
+ "uuid": "1f92b5b0-10ff-4cf4-9531-88546fe88a41",
+ "invariantUUID": "df92b5b0-10ff-4cf4-9531-88546fe88a4d",
+ "name": "The Worst Resource",
+ "version": "0.1",
+ "toscaModelURL": "sampleTosca.csar",
+ "toscaModel": "http://www.openecomp.org/",
+ "toscaResourceName": "The Worst Resource (TOSCA)",
+ "category": "Bad Resources",
+ "subCategory": "Really Bad Resources",
+ "resourceType": "VF",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "example@example.org",
+ "lastUpdaterFullName": "Example User",
+ "artifacts": []
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/json/mso/cloudConfiguration b/onap-enabler-be/src/main/resources/json/mso/cloudConfiguration
new file mode 100644
index 0000000..eb62779
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/cloudConfiguration
@@ -0,0 +1,19 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "fields communicating the cloud configuration in a standard way",
+ "type": "object",
+ "properties": {
+ "nodeLocation": {
+ "description": "Location identifier for the node",
+ "type": "string"
+ },
+ "lcpCloudRegionId": {
+ "description": "LCP Node Location identifier",
+ "type": "string"
+ },
+ "tenantId": {
+ "description": "Openstack tenant id",
+ "type": "string"
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/json/mso/instanceIds b/onap-enabler-be/src/main/resources/json/mso/instanceIds
new file mode 100644
index 0000000..c20ea9a
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/instanceIds
@@ -0,0 +1,29 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "instanceIds that may be associated with a particular request",
+ "type": "object",
+ "properties": {
+ "networkInstanceId": {
+ "description": "UUID for the network instance (if any)",
+ "type": "string"
+ },
+ "serviceInstanceId": {
+ "description": "UUID for the service instance",
+ "type": "string"
+ },
+ "vfModuleInstanceId": {
+ "description": "UUID for the vfModule instance (if any)",
+ "type": "string"
+ },
+ "vnfInstanceId": {
+ "description": "UUID for the vnf instance (if any)",
+ "type": "string"
+ },
+ "volumeGroupInstanceId": {
+ "description": "UUID for the volume group instance (if any)",
+ "type": "string"
+ }
+ }
+}
+
+
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/json/mso/modelInfo b/onap-enabler-be/src/main/resources/json/mso/modelInfo
new file mode 100644
index 0000000..56d268c
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/modelInfo
@@ -0,0 +1,42 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "fields describing the SDC entity being operated on by the request",
+ "type": "object",
+ "properties": {
+ "modelCustomizationName": {
+ "description": "reference to the customized set of parameters associated with a model in a given service context",
+ "type": "string"
+ },
+ "modelCustomizationId": {
+ "description": "reference to the customized set of parameters associated with a model in a given service context",
+ "type": "string"
+ },
+ "modelInvariantId": {
+ "description": "Invariant UUID for the model name, irrespective of the version, as defined in SDC--authoritative",
+ "type": "string",
+ "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
+ },
+ "modelVersionId": {
+ "description": "Version id for version",
+ "type": "string"
+ },
+ "modelName": {
+ "description": "name of the model as defined in SDC--not authoritative",
+ "type": "string"
+ },
+ "modelNameVersionId": {
+ "description": "UUID for the model name and version combination as defined in SDC--authoritative",
+ "type": "string",
+ "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
+ },
+ "modelType": {
+ "description": "short description of the entity being operated on",
+ "type": "string"
+ },
+ "modelVersion": {
+ "description": "the version of the model as defined in SDC--not authoritative",
+ "type": "string"
+ }
+ },
+ "required": ["modelType"]
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/json/mso/relatedInstance b/onap-enabler-be/src/main/resources/json/mso/relatedInstance
new file mode 100644
index 0000000..89554a5
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/relatedInstance
@@ -0,0 +1,16 @@
+{
+ "description": "modelInfo and optional instanceId and instanceName for a model related to the modelInfo being operated on",
+ "type": "object",
+ "properties": {
+ "instanceName": {
+ "description": "optional name for the instance Id of the related model",
+ "type": "string"
+ },
+ "instanceId": {
+ "description": "instance Id for the related model",
+ "type": "string"
+ },
+ "modelInfo": {}
+ },
+ "required": ["modelInfo"]
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/json/mso/relatedModel b/onap-enabler-be/src/main/resources/json/mso/relatedModel
new file mode 100644
index 0000000..a70a171
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/relatedModel
@@ -0,0 +1,15 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "modelInfo and optional instance id for a model related to the modelInfo being operated on",
+ "type": "object",
+ "properties": {
+ "instanceId": {
+ "description": "instance Id for the related model",
+ "type": "string"
+ },
+ "modelInfo": {}
+ },
+ "required": [ "modelInfo" ]
+}
+
+
diff --git a/onap-enabler-be/src/main/resources/json/mso/request b/onap-enabler-be/src/main/resources/json/mso/request
new file mode 100644
index 0000000..61f1040
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/request
@@ -0,0 +1,32 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "request structure",
+ "type": "object",
+ "properties": {
+ "finishTime": {
+ "description": "Date and time the request was finished in GMT with the following sample format: Wed, 15 Oct 2014 13:01:52 GMT",
+ "type": "string"
+ },
+ "instanceIds": {},
+ "requestDetails": {},
+ "requestId": {
+ "description": "UUID for the request generated by the instantiation service",
+ "type": "string",
+ "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
+ },
+ "requestScope": {
+ "description": "short description of the entity being operated on",
+ "type": "string"
+ },
+ "requestStatus": {},
+ "requestType": {
+ "description": "short description of the action being performed on the requestScope",
+ "type": "string"
+ },
+ "startTime": {
+ "description": "Date and time the request was created in GMT with the following sample format: Wed, 15 Oct 2014 13:01:52 GMT",
+ "type": "string"
+ }
+ },
+ "required": ["requestDetails", "requestId", "requestScope", "requestType", "startTime"]
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/json/mso/requestDetails b/onap-enabler-be/src/main/resources/json/mso/requestDetails
new file mode 100644
index 0000000..c0ef530
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/requestDetails
@@ -0,0 +1,13 @@
+{
+ "description": "aggregates the context, configuraiton and detailed parameters associated with the request into a single structure",
+ "properties": {
+ "cloudConfiguration": {},
+ "modelInfo": {},
+ "relatedModelList": {},
+ "requestInfo": {},
+ "requestParameters": {},
+ "subscriberInfo": {}
+ },
+ "type": "object"
+}
+
diff --git a/onap-enabler-be/src/main/resources/json/mso/requestError b/onap-enabler-be/src/main/resources/json/mso/requestError
new file mode 100644
index 0000000..497f671
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/requestError
@@ -0,0 +1,27 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "standard request error data structure",
+ "properties": {
+ "messageId": {
+ "description": "Unique message identifier of the format ABCnnnn where ABC is either SVC for Service Exceptions or POL for Policy Exception",
+ "type": "string"
+ },
+ "text": {
+ "description": "Message text, with replacement variables marked with %n, where n is an index into the list of <variables> elements, starting at 1",
+ "type": "string"
+ },
+ "url": {
+ "description": "Hyperlink to a detailed error resource e.g., an HTML page for browser user agents",
+ "type": "string"
+ },
+ "variables": {
+ "description": "List of zero or more strings that represent the contents of the variables used by the message text",
+ "type": "string"
+ }
+ },
+ "required": [
+ "messageId",
+ "text"
+ ],
+ "type": "object"
+}
diff --git a/onap-enabler-be/src/main/resources/json/mso/requestInfo b/onap-enabler-be/src/main/resources/json/mso/requestInfo
new file mode 100644
index 0000000..5fcf74c
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/requestInfo
@@ -0,0 +1,52 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "fields providing general context information for the request",
+ "properties": {
+ "billingAccountNumber": {
+ "description": "billing account associated with the model being operated on",
+ "type": "string"
+ },
+ "callbackUrl": {
+ "description": "client URL to use for asynchronous responses",
+ "type": "string"
+ },
+ "correlator": {
+ "description": "Optional correlationId for async callback requests",
+ "type": "string"
+ },
+ "instanceName": {
+ "description": "Client provided name for the instance being operated on by the operation (note: not guaranteed to be unique)",
+ "type": "string"
+ },
+ "orderNumber": {
+ "description": "reference to an order",
+ "type": "string"
+ },
+ "orderVersion": {
+ "description": "order version number",
+ "type": "number"
+ },
+ "productFamilyId": {
+ "description": "UUID for the product family associated with the model being operated on",
+ "type": "string"
+ },
+ "source": {
+ "description": "source of the request--not authoritative--actual source revealed via authentication",
+ "type": "string"
+ },
+ "suppressRollback": {
+ "description": "true or false boolean indicating whether rollbacks should be suppressed on failures",
+ "type": "boolean"
+ },
+ "responseValue": {
+ "description": "Is the user selected value based on the validResponses list provided to complete the manual task",
+ "type": "string"
+ },
+ "requestorId": {
+ "description": "The id of the person who initiated the completion request",
+ "type": "string"
+ }
+ },
+
+ "type": "object"
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/json/mso/requestParameters b/onap-enabler-be/src/main/resources/json/mso/requestParameters
new file mode 100644
index 0000000..010d787
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/requestParameters
@@ -0,0 +1,23 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "subscriptionServiceType": {
+ "type": "string"
+ },
+ "userParams": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "value": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/json/mso/requestReferences b/onap-enabler-be/src/main/resources/json/mso/requestReferences
new file mode 100644
index 0000000..30f6411
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/requestReferences
@@ -0,0 +1,18 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "provides the instanceId and requestId associated with the request",
+ "type": "object",
+ "properties": {
+ "instanceId": {
+ "description": "UUID for the service instance",
+ "type": "string",
+ "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
+ },
+ "requestId": {
+ "description": "UUID for the request",
+ "type": "string",
+ "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
+ }
+ },
+ "required": [ "instanceId", "requestId" ]
+}
diff --git a/onap-enabler-be/src/main/resources/json/mso/requestStatus b/onap-enabler-be/src/main/resources/json/mso/requestStatus
new file mode 100644
index 0000000..75b7215
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/requestStatus
@@ -0,0 +1,32 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "fields describing the status of a request",
+ "properties": {
+ "percentProgress": {
+ "description": "percentage complete estimate from 0 to 100",
+ "type": "number"
+ },
+ "requestState": {
+ "description": "short description of the instantiation state",
+ "type": "string"
+ },
+ "statusMessage": {
+ "description": "additional descriptive information about the status",
+ "type": "string"
+ },
+ "timestamp": {
+ "description": "GMT Datetime the requestStatus was created e.g.: Wed, 15 Oct 2014 13:01:52 GMT",
+ "type": "string"
+ },
+ "wasRolledBack": {
+ "description": "true or false boolean indicating whether the request was rolled back",
+ "type": "boolean"
+ }
+
+ },
+ "required": [
+ "requestState",
+ "timestamp"
+ ],
+ "type": "object"
+}
diff --git a/onap-enabler-be/src/main/resources/json/mso/response b/onap-enabler-be/src/main/resources/json/mso/response
new file mode 100644
index 0000000..fa37d2d
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/response
@@ -0,0 +1,13 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "response structure",
+ "type": "object",
+ "code": {
+ "description": "Return code",
+ "type": "string"
+ },
+ "message": {
+ "description": "Result message",
+ "type": "string"
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/json/mso/subscriberInfo b/onap-enabler-be/src/main/resources/json/mso/subscriberInfo
new file mode 100644
index 0000000..df78737
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/json/mso/subscriberInfo
@@ -0,0 +1,19 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "fields providing information about the subscriber associated with the request",
+ "type": "object",
+ "properties": {
+ "globalSubscriberId": {
+ "description": "global Customer Id understood by A&AI",
+ "type": "string"
+ },
+ "subscriberCommonSiteId": {
+ "description": "id representing the location of the subscriber",
+ "type": "string"
+ },
+ "subscriberName": {
+ "description": "name of the customer or subscriber",
+ "type": "string"
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/mso_complete_manual_task.json b/onap-enabler-be/src/main/resources/mso_complete_manual_task.json
new file mode 100644
index 0000000..af6c1e1
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/mso_complete_manual_task.json
@@ -0,0 +1,5 @@
+{
+ "taskRequestReference": {
+ "taskId": "daf4dd84-b77a-42da-a051-3239b7a9392c"
+ }
+}
diff --git a/onap-enabler-be/src/main/resources/mso_create_instance_response.json b/onap-enabler-be/src/main/resources/mso_create_instance_response.json
new file mode 100644
index 0000000..8b0341f
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/mso_create_instance_response.json
@@ -0,0 +1,6 @@
+{
+ "requestReferences": {
+ "instanceId": "ba00de9b-3c3e-4b0a-a1ad-0c5489e711fb",
+ "requestId": "311cc766-b673-4a50-b9c5-471f68914586"
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/mso_get_manual_task_by_request_id.json b/onap-enabler-be/src/main/resources/mso_get_manual_task_by_request_id.json
new file mode 100644
index 0000000..ae8d511
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/mso_get_manual_task_by_request_id.json
@@ -0,0 +1,23 @@
+{
+ "taskList":[
+ {
+ "taskId":"daf4dd84-b77a-42da-a051-3239b7a9392c",
+ "type":"fallout",
+ "nfRole":"vSCP",
+ "subscriptionServiceType":"Mobility",
+ "originalRequestId":"za1234d1-5a33-55df-13ab-12abad84e335",
+ "originalRequestorId":"ss835w",
+ "errorSource":"A&AI",
+ "errorCode":"404",
+ "errorMessage":"Failed in A&AI 404",
+ "buildingBlockName":"DoCreateVfModule",
+ "buildingBlockStep":"invokeA&AI:getTenant",
+ "validResponses":[
+ "rollback",
+ "abort",
+ "skip",
+ "retry"
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/mso_get_orchestration_requests.json b/onap-enabler-be/src/main/resources/mso_get_orchestration_requests.json
new file mode 100644
index 0000000..318945b
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/mso_get_orchestration_requests.json
@@ -0,0 +1,88 @@
+{
+ "requestList":[
+ {
+ "request":{
+ "requestId":"25272f7e-74c6-4afc-966a-4587f2c30bae",
+ "startTime":"Mon, 31 Jul 2017 23:25:30 GMT",
+ "requestScope":"vnf",
+ "requestType":"updateInstance",
+ "requestDetails":null,
+ "instanceReferences":{
+ "serviceInstanceId":null,
+ "serviceInstanceName":null,
+ "vnfInstanceId":null,
+ "vnfInstanceName":null,
+ "vfModuleInstanceId":null,
+ "vfModuleInstanceName":null,
+ "volumeGroupInstanceId":null,
+ "volumeGroupInstanceName":null,
+ "networkInstanceId":null,
+ "networkInstanceName":null,
+ "requestorId":"md5621"
+ },
+ "requestStatus":{
+ "requestState":"IN_PROGRESS",
+ "statusMessage":null,
+ "percentProgress":20,
+ "finishTime":null
+ }
+ }
+ },
+ {
+ "request":{
+ "requestId":"25272f7e-74c6-4afc-966a-4587f2c30bae",
+ "startTime":"Mon, 31 Jul 2017 23:25:30 GMT",
+ "requestScope":"service",
+ "requestType":"createInstance",
+ "requestDetails":null,
+ "instanceReferences":{
+ "serviceInstanceId":null,
+ "serviceInstanceName":null,
+ "vnfInstanceId":null,
+ "vnfInstanceName":null,
+ "vfModuleInstanceId":null,
+ "vfModuleInstanceName":null,
+ "volumeGroupInstanceId":null,
+ "volumeGroupInstanceName":null,
+ "networkInstanceId":null,
+ "networkInstanceName":null,
+ "requestorId":"md5621"
+ },
+ "requestStatus":{
+ "requestState":"IN_PROGRESS",
+ "statusMessage":null,
+ "percentProgress":20,
+ "finishTime":null
+ }
+ }
+ },
+ {
+ "request":{
+ "requestId":"9d6819e1-76e6-4e28-ad08-367632f41c7e",
+ "startTime":"Fri, 20 May 2016 19:07:57 GMT",
+ "requestScope":"vnf",
+ "requestType":"replaceInstance",
+ "requestDetails":null,
+ "instanceReferences":{
+ "serviceInstanceId":null,
+ "serviceInstanceName":null,
+ "vnfInstanceId":null,
+ "vnfInstanceName":null,
+ "vfModuleInstanceId":null,
+ "vfModuleInstanceName":null,
+ "volumeGroupInstanceId":null,
+ "volumeGroupInstanceName":null,
+ "networkInstanceId":null,
+ "networkInstanceName":null,
+ "requestorId":null
+ },
+ "requestStatus":{
+ "requestState":"FAILED",
+ "statusMessage":"Service request FAILED schema validation. No valid format for volume request is specified",
+ "percentProgress":100,
+ "finishTime":"Fri, 20 May 2016 19:07:57 GMT"
+ }
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/owning-entity-properties.JSON b/onap-enabler-be/src/main/resources/owning-entity-properties.JSON
new file mode 100644
index 0000000..12ee4cf
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/owning-entity-properties.JSON
@@ -0,0 +1,17 @@
+{
+ "owningEntityProperties" : {
+ "platform": {
+ "Platform-name": "Platform-name"
+ },
+ "project": {
+ "Project-name": "Project-name"
+ },
+ "lineOfBusiness": {
+ "Line-of-business-name": "Line-of-business-name"
+ },
+ "owningEntity": {
+ "Owning-entity-id": "Owning-entity-name"
+ }
+ }
+}
+
diff --git a/onap-enabler-be/src/main/resources/roles.json b/onap-enabler-be/src/main/resources/roles.json
new file mode 100644
index 0000000..db32392
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/roles.json
@@ -0,0 +1,8 @@
+{
+ "roles": [
+ "VID_Subscriber_serviceType1_Tenant1",
+ "VID_Subscriber_serviceType1_Tenant2",
+ "read_motorola_epost_tow",
+ "read_motorola_epost"
+ ]
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/sdcservices.json b/onap-enabler-be/src/main/resources/sdcservices.json
new file mode 100644
index 0000000..91c2cc2
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/sdcservices.json
@@ -0,0 +1,172 @@
+{
+ "services": [
+ {
+ "uuid": "6bce7302-70bd-4057-b48e-8d5b99e686ca",
+ "invariantUUID": "9aa04749-c02c-432d-a90c-18caa361c833",
+ "name": "vDBE_srv",
+ "version": "1.0",
+ "toscaModelURL": "./service-VdbeSrv-csar.zip",
+ "category": "Mobility",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
+ "uuid": "76f27dfe-33e5-472f-8e0b-acf524adc4f0",
+ "invariantUUID": "c3618e16-bb5b-433a-a6e0-565ca79d8b65",
+ "name": "4-27_vMME_Service",
+ "version": "1.0",
+ "toscaModelURL": "./service-MsoExampleService-csar.zip",
+ "category": "Mobility",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
+ "uuid": "f4d84bb4-a416-4b4e-997e-0059973630b9",
+ "invariantUUID": "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9",
+ "name": "ADIOD vMX vPE_BV Service 488",
+ "version": "1.0",
+ "toscaModelURL": "./service-vf-with-annotations.zip",
+ "category": "Mobility",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
+ "uuid": "48a52540-8772-4368-9cdb-1f124ea5c931",
+ "invariantUUID": "f430728a-4530-42be-a577-1206b9484cef",
+ "name": "4-27_vMME_Service",
+ "version": "1.0",
+ "toscaModelURL": "./service-vf-csar.zip",
+ "category": "Mobility",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
+ "uuid": "cb49608f-5a24-4789-b0f7-2595473cb997",
+ "invariantUUID": "0311f998-9268-4fd6-bbba-afff15087b72",
+ "name": "4-27_vMME_Service",
+ "version": "1.0",
+ "toscaModelURL": "./service-vl-csar.zip",
+ "category": "Mobility",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
+ "uuid": "73e1322a-8a9a-49dc-9558-b0c5c5770e4a",
+ "invariantUUID": "f430728a-4530-42be-a577-1206b9484cef",
+ "name": "4-27_vMME_Service",
+ "version": "1.0",
+ "toscaModelURL": "./pnf.zip",
+ "category": "Mobility",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
+ "uuid": "240376de-870e-48df-915a-31f140eedd2c",
+ "invariantUUID": "709d1be4-9a3f-4a29-8c4d-a20465e808a3",
+ "name": "Demo Service",
+ "version": "1.0",
+ "toscaModelURL": "./service-DemoService1-csar.csar",
+ "category": "Mobility",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
+ "uuid": "32671332-a7ee-4df6-9609-db50ce5eaee7",
+ "invariantUUID": "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9",
+ "name": "ADIOD vMX vPE_BV Service 488",
+ "version": "1.0",
+ "toscaModelURL": "./adiod.zip",
+ "category": "Mobility",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
+ "uuid": "55a48870-d99e-41a8-a3b4-a8d748333139",
+ "invariantUUID": "3d89efc0-19ca-4df7-9818-028e1fc6f708",
+ "name": "AMP PH SVC",
+ "version": "1.0",
+ "toscaModelURL": "./service-AmpPhSvc-csar.zip",
+ "category": "Mobility",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
+ "uuid": "2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd",
+ "invariantUUID": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
+ "name": "action-data",
+ "version": "1.0",
+ "toscaModelURL": "./2f80c596.zip",
+ "category": "Mobility",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
+ "uuid": "ee6d61be-4841-4f98-8f23-5de9da846ca7",
+ "invariantUUID": "b7d923c9-6175-41f1-91ba-4565c4953408",
+ "name": "Multiple pProbes",
+ "version": "1.0",
+ "toscaModelURL": "./service-Servicecontainermultiplepprobes-csar.zip",
+ "category": "Mobility",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ },
+ {
+ "uuid": "ee6d61be-4841-4f98-8f23-5de9da845544",
+ "invariantUUID": "b7d923c9-6175-41f1-91ba-4565c4955555",
+ "name": "ServiceContainerMultiplepProbes2",
+ "version": "2.0",
+ "toscaModelURL": "./service-ServicecontainerContainsPprobe.zip",
+ "category": "Network L1-3",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "rg276b",
+ "lastUpdaterFullName": null,
+ "distributionStatus": "DISTRIBUTED",
+ "artifacts": null,
+ "resources": null
+ }
+ ]
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/resources/test.csv b/onap-enabler-be/src/main/resources/test.csv
new file mode 100644
index 0000000..e402c1e
--- /dev/null
+++ b/onap-enabler-be/src/main/resources/test.csv
@@ -0,0 +1,5 @@
+ee6d61be-4841-4f98-8f23-5de9da846ca7,95c75a48-6f86-498f-b1a6-e9179a83d9c7,Update
+ee6d61be-4841-4f98-8f23-5de9da846ca7,95c75a48-6f86-498f-b1a6-e9179a83d9c7, VNF In Place Software Update
+418f32e5-484a-4073-8fa9-fab7d497459f,709d1be4-9a3f-4a29-8c4d-a20465e808a3, VNF In Place Software Update
+fa06db34-f8e3-42d9-8e51-a76816eb0f0d,0ebfb706-a846-4715-b0d0-fe0be09458d7, VNF In Place Software Update
+fa06db34-f8e3-42d9-8e51-a76816eb0f0d, 87447b67-29e3-4244-8038-990a8c70259a,Replace
\ No newline at end of file
diff --git a/onap-enabler-be/src/main/webapp/META-INF/MANIFEST.MF b/onap-enabler-be/src/main/webapp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..5e94951
--- /dev/null
+++ b/onap-enabler-be/src/main/webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/onap-enabler-be/src/main/webapp/WEB-INF/conf/dev.features.properties b/onap-enabler-be/src/main/webapp/WEB-INF/conf/dev.features.properties
new file mode 100644
index 0000000..d1f8ffa
--- /dev/null
+++ b/onap-enabler-be/src/main/webapp/WEB-INF/conf/dev.features.properties
@@ -0,0 +1,14 @@
+FLAG_ASYNC_INSTANTIATION = true
+FLAG_ASYNC_JOBS = true
+FLAG_REGION_ID_FROM_REMOTE = true
+CREATE_INSTANCE_TEST = false
+EMPTY_DRAWING_BOARD_TEST = false
+FLAG_ADVANCED_PORTS_FILTER = true
+FLAG_ADD_MSO_TESTAPI_FIELD = true
+FLAG_UNASSIGN_SERVICE = true
+FLAG_COLLECTION_RESOURCE_SUPPORT = true
+FLAG_NETWORK_TO_ASYNC_INSTANTIATION = true
+FLAG_SERVICE_MODEL_CACHE = true
+FLAG_SHOW_ASSIGNMENTS = true
+FLAG_SHOW_VERIFY_SERVICE=false
+FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD = false
diff --git a/onap-enabler-be/src/main/webapp/WEB-INF/conf/features.properties b/onap-enabler-be/src/main/webapp/WEB-INF/conf/features.properties
new file mode 100644
index 0000000..b9a640d
--- /dev/null
+++ b/onap-enabler-be/src/main/webapp/WEB-INF/conf/features.properties
@@ -0,0 +1,27 @@
+# features.properties
+# -------------------
+
+# This file is, generally, empty.
+
+# Configure `featureFlags.filename` in system.properties to use
+# one of the ready-made sets:
+
+# - featureFlags.filename = ci.features.properties
+# - featureFlags.filename = ist.features.properties
+# - featureFlags.filename = e2e.features.properties
+
+FLAG_ASYNC_INSTANTIATION = true
+FLAG_ASYNC_JOBS = false
+FLAG_REGION_ID_FROM_REMOTE = true
+CREATE_INSTANCE_TEST = false
+EMPTY_DRAWING_BOARD_TEST = false
+FLAG_ADVANCED_PORTS_FILTER = true
+FLAG_ADD_MSO_TESTAPI_FIELD = true
+FLAG_UNASSIGN_SERVICE = true
+FLAG_COLLECTION_RESOURCE_SUPPORT = true
+FLAG_NETWORK_TO_ASYNC_INSTANTIATION = true
+FLAG_SERVICE_MODEL_CACHE = true
+FLAG_SHOW_ASSIGNMENTS = true
+FLAG_SHOW_VERIFY_SERVICE=false
+FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD = false
+FLAG_PNP_INSTANTIATION = true
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java b/onap-enabler-be/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
new file mode 100644
index 0000000..45a4bcd
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.aai.util;
+
+import org.junit.Test;
+import org.onap.osam.aai.util.JettyObfuscationConversionCommandLineUtil;
+
+public class JettyObfuscationConversionCommandLineUtilTest {
+
+ private JettyObfuscationConversionCommandLineUtil createTestSubject() {
+ return new JettyObfuscationConversionCommandLineUtil();
+ }
+
+
+ @Test
+ public void testMain() throws Exception {
+ String[] args = new String[] { "" };
+
+ // default test
+ JettyObfuscationConversionCommandLineUtil.main(args);
+ }
+
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/ecomp/vid/selenium/FirstClass.java b/onap-enabler-be/src/test/java/org/onap/ecomp/vid/selenium/FirstClass.java
new file mode 100644
index 0000000..b1db197
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/ecomp/vid/selenium/FirstClass.java
@@ -0,0 +1,604 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.ecomp.vid.selenium;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.ie.InternetExplorerDriver;
+import org.openqa.selenium.support.ui.Select;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import org.apache.log4j.Logger;
+import org.testng.Assert;
+import org.testng.asserts.*;
+
+public class FirstClass {
+
+ WebElement loginButton;
+
+ /** The eg. */
+ String eg;
+
+ /** The login. */
+ WebElement login;
+
+ /** The pwd. */
+ WebElement pwd;
+
+ /** The log. */
+ Logger log;
+
+ /** The errormessage. */
+ WebElement errormessage;
+
+
+ /** The driver. */
+ WebDriver driver=new FirefoxDriver();
+
+
+
+ /** The config prop. */
+ private final Properties configProp = new Properties();
+
+
+ /**
+ * Instantiates a new first class.
+ */
+ private FirstClass() {
+ // TODO Auto-generated constructor stub
+ //
+ try{
+ // InputStream input =this.getClass().getClassLoader().getResourceAsStream("objectmap.properties");
+ //FileInputStream input1 = new FileInputStream("objectmap.properties");
+
+ InputStream input =new FileInputStream("objectconfig.properties");
+ System.out.println("Read all properties from file");
+ configProp.load(input);
+ System.out.println("Read all properties from file completed");
+ }
+ catch(IOException e) {
+
+ e.printStackTrace();
+ }
+ }
+
+
+ /*
+
+
+ @BeforeClass
+ public void setUp() {
+ System.out.println("*******************");
+ System.out.println("launching IE browser");
+ System.setProperty("webdriver.ie.driver", driverPath+"IEDriverServer.exe");
+ driver = new InternetExplorerDriver();
+ driver.findElement(By.className());
+ driver.manage().window().maximize();
+
+
+ login = driver.findElement(By.xpath("//input[@class='fn-ebz-text ng-pristine ng-valid']"));
+ pwd = driver.findElement(By.xpath("//input[@class='span3 ng-pristine ng-valid']"));
+ loginButton = driver.findElement(By.id("loginBtn"));
+ }
+
+
+ */
+ /**
+ * Sets the up.
+ */
+ // TODO Auto-generated method stub
+ @BeforeClass
+ public void setUp()
+ {
+
+
+ //WebDriver driver=new FirefoxDriver();
+
+ log = Logger.getLogger(FirstClass.class.getName());
+
+
+
+ // Get url
+ driver.get(configProp.getProperty("baseURL"));
+ driver.manage().window().maximize();
+
+
+ login = driver.findElement(By.xpath(configProp.getProperty("login")));
+
+ pwd = driver.findElement(By.xpath(configProp.getProperty("pwd")));
+ loginButton = driver.findElement(By.id(configProp.getProperty("loginButton")));
+ }
+
+
+ /**
+ * Empty username password.
+ */
+ @Test(priority=1)
+ public void emptyUsernamePassword()
+ {
+
+
+ //User Name and Password field is empty
+ log.info("-----VID-11 TC-8----Username and password empty");
+ loginButton.click();
+ errormessage=driver.findElement(By.xpath("//*[@id='errorInfo']/span"));
+ String errmsg= errormessage.getText();
+ //System.out.println("Error message is"+errmsg);
+ //String expected = "Invaild username or password, Please try again";
+
+ //Assert.assertEquals(errmsg,expected);
+
+ Boolean str = driver.getPageSource().contains("Invalid username or password, Please try again");
+ System.out.println(driver.getPageSource().contains("Invalid username or password, Please try again"));
+
+ if(str==true)
+ {
+ log.info("Error message validated");
+ log.info("VID-11 TC-8 PASSED");
+
+ }else
+ log.error("Failed validation");
+
+ }
+
+
+
+ /**
+ * Invalid user name.
+ */
+ @Test(priority=2)
+ public void invalidUserName()
+ {
+
+ log.info("-----VID-11 TC-6----Invalid Username and Valid Password");
+
+
+ login.sendKeys("xxx");
+ pwd.sendKeys("abc123");
+ loginButton.click();
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String errmsg= errormessage.getText();
+ String expected = "Invalid username or password, Please try again";
+ Assert.assertEquals(errmsg,expected);
+ //Boolean str1 = driver.getPageSource().contains("Invalid username or password, Please try again");
+ //System.out.print(str1);
+
+ log.info("VID-11 TC-6 PASSED");
+
+ }
+
+
+ /**
+ * Invalid password.
+ */
+ @Test(priority=3)
+ public void invalidPassword()
+ {
+ log.info("-----VID-11 TC-7----Valid Username and Invalid Password");
+ // Valid user name and Invalid password.
+ login.clear();
+ pwd.clear();
+ login.sendKeys("testuser");
+ pwd.sendKeys("xxx");
+ loginButton.click();
+ driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+
+
+ String errmsg= errormessage.getText();
+ String expected = "Invalid username or password, Please try again";
+ Assert.assertEquals(errmsg,expected);
+
+ //Boolean str2 = driver.getPageSource().contains("Invaild username or password, Please try again");
+ //System.out.print(str2);
+
+ log.info("VID-11 TC-7 PASSED");
+ }
+
+
+ /**
+ * Login successful.
+ */
+ @Test(priority=4)
+ public void loginSuccessful()
+ {
+ log.info("-----VID-11 TC-1----Valid Username and Valid Password");
+ //Login with valid user name and password.
+ login.clear();
+ login.sendKeys("su");
+ pwd.clear();
+ pwd.sendKeys("fusion");
+
+
+ loginButton.click();
+ driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+
+ try {
+ Thread.sleep(6000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances"));
+ log.info("VID-11 TC-1 PASSED");
+
+ }
+
+
+ /**
+ * Verify home page elements left pane.
+ */
+ @Test(priority=5)
+ public void verifyHomePageElementsLeftPane()
+
+ {
+
+
+ log.info("VID-10 TC 1 ");
+ //VID Home
+ log.info("VID 11 TC-2");
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[1]/a/span")).isDisplayed();
+ //Create New Service Instance
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[2]/a/span")).isDisplayed();
+
+ //Browse Service Type
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[3]/a/span")).isDisplayed();
+ //View Log
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[4]/a/span")).isDisplayed();
+
+ //Profile
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[5]/a/span")).isDisplayed();
+ //Admin
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[6]/a/span")).isDisplayed();
+ //Logout
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[7]/a/span")).isDisplayed();
+
+ //Infrastructure Subscriber Name
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[1]/div/label")).isDisplayed();
+ //Infrastructure Subscriber Name Select Drop down
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")).isDisplayed();
+ //Infrastructure Service Type
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[1]/div/label")).isDisplayed();
+ //Infrastructure Service Type Select Drop down
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select")).isDisplayed();
+ //Submit button
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button")).isDisplayed();
+
+ //Login Snippet Icon
+ driver.findElement(By.xpath(".//*[@class='icon-user-small login-snippet-icon']")).isDisplayed();
+
+
+ //String bodyText = driver.findElement(By.tagName("body")).getText();
+ //Assert.assertTrue("Text not found!", bodyText.contains("Search Existing Service Instances"));
+ //Assert.IsTrue(driver.getPageSource.Contains("Search Existing Service Instances"));
+
+ log.info("VID-12 TC-1");
+ Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances"));
+ Assert.assertTrue(driver.getPageSource().contains("Please search by the Subscriber name or Service Type from below:"));
+ log.info("VID-12 TC-1 PASSED");
+ log.info("VID-10 TC 1 PASSED");
+ log.info("VID-11 TC-2 PASSED");
+ }
+
+
+ /**
+ * Disabled submit button.
+ */
+ @Test(priority=6)
+ public void disabledSubmitButton()
+ {
+ log.info("VID-12 TC-13");
+ //Assert submit button disabled.
+ Assert.assertFalse(driver.findElement(By.xpath(configProp.getProperty("submitButton"))).isEnabled());
+ log.info("VID-12 TC-13 PASSED");
+
+ }
+
+ /**
+ * Default list box value.
+ */
+ @Test(priority=7)
+ public void defaultListBoxValue()
+ {
+ log.info("VID-12 TC-2");
+
+
+ //WebElement subscribername =driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"));
+
+ Select oSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown"))));
+ Select iSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown"))));
+
+
+ WebElement ielement=iSelect.getFirstSelectedOption();
+ WebElement oelement=oSelect.getFirstSelectedOption();
+ String defaultsubscribername=oelement.getText();
+ String defaultservicetype=ielement.getText();
+
+ Assert.assertEquals(defaultsubscribername,"Select Subscriber Name");
+ Assert.assertEquals(defaultservicetype,"Select Service Type");
+
+
+
+
+ //Verify Select Subscriber Name isDisplayed.
+ //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select/option[1]")).isSelected();
+
+ //Verify Select Service Type isDisplayed.
+ //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select/option[1]")).isSelected();
+
+
+ log.info("VID-12 TC-2 PASSED");
+
+ }
+
+
+
+ /**
+ * Select subscriber name drop down.
+ *
+ * @throws InterruptedException the interrupted exception
+ */
+ @Test(priority=8)
+ public void selectSubscriberNameDropDown() throws InterruptedException
+ {
+ log.info("------------------VID-10 TC-2,VID-12 TC-11, VID-12 TC-9, VID 12 TC-10,VID-12 TC-6, VID 12 TC-5--------------------");
+
+
+ driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown")));
+
+ driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown")));
+ Thread.sleep(5000);
+
+ //Infrastructure Subscriber Name
+ Select oSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown"))));
+
+ List <WebElement> elementCount = oSelect.getOptions();
+ log.info("Select Element Count of Service Name");
+ System.out.println(elementCount.size());
+
+
+ //Verifying getInfrastructureSubscribersList
+ log.info("VID-29 TC-1");
+ Assert.assertTrue(elementCount.size()>0);
+ log.info("VID-29 TC-1 PASSED");
+
+ oSelect.selectByIndex(2);
+ String selectedOption = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown")))).getFirstSelectedOption().getText();
+
+ System.out.println("Service Name selected is " +selectedOption);
+ log.info("VID-10 TC-2 PASSED");
+
+ //Submit button is clicked
+ driver.findElement(By.xpath(configProp.getProperty("submitButton"))).click();
+
+
+ //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:"
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed();
+ //Assert.assertTrue(driver.getPageSource().contains("Selected Subscriber's Service Instance Details:"))
+
+
+ //Verify whether the page header is displayed "Global Customer ID"
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/thead/tr/th[2]/div")).isDisplayed();
+ Assert.assertTrue(driver.getPageSource().contains("Global Customer ID"));
+ Assert.assertTrue(driver.getPageSource().contains("Subscriber Name"));
+ Assert.assertTrue(driver.getPageSource().contains("Service Type"));
+ Assert.assertTrue(driver.getPageSource().contains("Service Instance ID"));
+
+ log.info("VID-12 TC-5 PASSED");
+ log.info("VID-12 TC-11 PASSED");
+
+ WebElement serviceinstancetable =driver.findElement(By.xpath("//table[@class='tablesorter tablesorter-default ng-isolate-scope']"));
+
+ List<WebElement> rows_table = serviceinstancetable.findElements(By.tagName("tr"));
+ //To calculate no of rows In table.
+ int rows_count = rows_table.size();
+
+ //Loop will execute till the last row of table.
+ for (int row=0; row<rows_count; row++){
+ //To locate columns(cells) of that specific row.
+ List<WebElement> Columns_row = rows_table.get(row).findElements(By.tagName("td"));
+ //To calculate no of columns(cells) In that specific row.
+ int columns_count = Columns_row.size();
+ //System.out.println("Number of cells In Row "+row+" are "+columns_count);
+
+ //Loop will execute till the last cell of that specific row.
+ for (int column=0; column<columns_count; column++){
+ //To retrieve text from that specific cell.
+ String celtext = Columns_row.get(column).getText();
+ //System.out.println("Cell Value Of row number "+row+" and column number "+column+" Is "+celtext);
+
+
+
+ //log.info("Testing Get column and row value");
+ List <WebElement> exx= rows_table.get(1).findElements(By.tagName("td"));
+ eg=Columns_row.get(2).getText();
+ // System.out.println("Cell value of row 1 and column 2 is" +eg);
+ }
+ }
+
+
+
+
+ //Verify View/Edit isDisplayed and Click
+
+ driver.findElement(By.xpath("//a[@alt='View/Edit']")).isDisplayed();
+
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/tbody/tr[1]/td[1]/div/a")).click();
+
+ log.info("User clicked View/Edit");
+
+ //Verify the Subscriber Name displayed.
+ String header= driver.findElement(By.xpath("//h1[@class='heading1 ng-binding']")).getText();
+ //System.out.println(header);
+
+
+ if(header.contains(eg))
+ {
+ System.out.println("Header contains the subscriber name");
+ }else
+ System.out.println("Header does not contain the subscriber name");
+
+
+
+ Assert.assertTrue(driver.getPageSource().contains("PerfTest Subscriber00020021"));
+ log.info("VID-12 TC-6 PASSED");
+
+
+
+ driver.navigate().back();
+ //Cancel button isDisplayed
+ driver.findElement(By.xpath("//button[@class='button button--small button--primary']")).isDisplayed();
+ log.info("VID-12 TC-9 PASSED");
+
+ //Cancel button is clicked
+ driver.findElement(By.xpath("//button[@class='button button--small button--primary']")).click();
+ log.info("Cancel button is clicked");
+
+ //Verifying VID Home page is displayed
+ Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances"));
+ log.info("VID-12 TC-10 PASSED");
+
+ }
+
+
+ /**
+ * Refresh subscriber name.
+ */
+ @Test(priority=9)
+ public void refreshSubscriberName()
+ {
+ log.info("VID-10 TC-4");
+
+
+ driver.findElement(By.xpath(configProp.getProperty("refreshButtonSubscriberName"))).isDisplayed();
+
+ log.info("VID-10 TC-4 PASSED");
+
+
+ }
+
+
+ /**
+ * Select subscriber type drop down.
+ *
+ * @throws InterruptedException the interrupted exception
+ */
+ @Test(priority=9)
+ public void selectSubscriberTypeDropDown() throws InterruptedException
+ {
+ Thread.sleep(5000);
+ log.info("------------------VID-10 TC-3, VID-12 TC-12,--------------------");
+ //Infrastructure Subscriber Type
+ Select iSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown"))));
+
+ List <WebElement> ielementCount = iSelect.getOptions();
+ log.info("Select Element Count of Service type");
+ System.out.println(ielementCount.size());
+ iSelect.selectByIndex(1);
+
+ log.info("VID-10 TC-3 PASSED");
+
+
+ //Submit button is clicked
+ driver.findElement(By.xpath(configProp.getProperty("submitButton"))).click();
+
+ //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:"
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed();
+ //Assert.assertTrue(driver.getPageSource().contains("Selected Subscriber's Service Instance Details:"))
+ log.info("Page Header: Selected Subscriber's Service Instance Details");
+
+
+ //Verify whether the page header is displayed "Global Customer ID"
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/thead/tr/th[2]/div")).isDisplayed();
+
+ //Assert.assertTrue(driver.getPageSource().contains("Global Customer ID"));
+ log.info("Table is displayed");
+
+ log.info("VID-12 TC-12 PASSED");
+
+ }
+
+
+
+ /**
+ * Logout under profile.
+ */
+ @Test(priority=10)
+ public void logoutUnderProfile()
+ {
+
+ log.info("-----------VID-11 TC-5---------------------");
+ //driver.findElement(By.partialLinkText("Click here to login")).click();
+ //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+
+
+ driver.findElement(By.xpath(".//*[@class='icon-user-small login-snippet-icon']")).click();
+ driver.findElement(By.xpath(".//*[@id='reg-logout-div']/a")).click();
+ //Validate that the user has logged out of VID. Displays "Portal"
+ Assert.assertTrue(driver.getPageSource().contains("Portal"));
+
+ log.info("VID-11 TC-5 PASSED");
+
+ }
+
+
+
+ /**
+ * Tear down.
+ */
+ @AfterClass
+ public void tearDown()
+ {
+ driver.close();
+
+ }
+
+
+
+ }
+
+
+
+
diff --git a/onap-enabler-be/src/test/java/org/onap/ecomp/vid/selenium/LogOutLeftPane.java b/onap-enabler-be/src/test/java/org/onap/ecomp/vid/selenium/LogOutLeftPane.java
new file mode 100644
index 0000000..1511c2d
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/ecomp/vid/selenium/LogOutLeftPane.java
@@ -0,0 +1,240 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.ecomp.vid.selenium;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.log4j.Logger;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.support.ui.Select;
+import org.testng.Assert;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+@Test(enabled=false)
+public class LogOutLeftPane {
+
+ WebElement loginButton;
+
+ /** The login. */
+ WebElement login;
+
+ /** The pwd. */
+ WebElement pwd;
+
+ /** The log. */
+ Logger log;
+
+ /** The errormessage. */
+ WebElement errormessage;
+
+ /** The driver. */
+ WebDriver driver=new FirefoxDriver();
+
+
+ /** The config prop. */
+ private final Properties configProp = new Properties();
+
+
+ /**
+ * Instantiates a new log out left pane.
+ */
+ private LogOutLeftPane() {
+ // TODO Auto-generated constructor stub
+ //
+ try{
+ // InputStream input =this.getClass().getClassLoader().getResourceAsStream("objectmap.properties");
+ //FileInputStream input1 = new FileInputStream("objectmap.properties");
+
+ InputStream input =new FileInputStream("objectconfig.properties");
+ System.out.println("Read all properties from file");
+ configProp.load(input);
+ System.out.println("Read all properties from file completed");
+ }
+ catch(IOException e) {
+
+ e.printStackTrace();
+ }
+ }
+
+
+
+
+ /**
+ * Do before test.
+ */
+ // TODO Auto-generated method stub
+ @BeforeTest
+ public void doBeforeTest()
+ {
+ //WebDriver driver=new FirefoxDriver();
+
+ log = Logger.getLogger(LogOutLeftPane.class.getName());
+
+
+
+ // Get url
+ driver.get("http://vid.onap.org:9080/vid/login_external.htm");
+ driver.manage().window().maximize();
+
+
+ login = driver.findElement(By.xpath("//input[@class='fn-ebz-text ng-pristine ng-valid']"));
+ pwd = driver.findElement(By.xpath("//input[@class='span3 ng-pristine ng-valid']"));
+ loginButton = driver.findElement(By.id("loginBtn"));
+ }
+
+
+ /**
+ * Expand collapse panel.
+ *
+ * @throws InterruptedException the interrupted exception
+ */
+ @Test(priority=1)
+ public void expandCollapsePanel() throws InterruptedException
+ {
+
+
+
+ login.clear();
+ login.sendKeys("su");
+ pwd.clear();
+ pwd.sendKeys("fusion");
+ //driver.findElement(By.partialLinkText("Click here to login")).click();
+ //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+
+ loginButton.click();
+ driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+
+
+ log.info("Clicking Profile link from left pane");
+ Thread.sleep(3000);
+ System.out.println("properties file details --->"+configProp.getProperty("profilelink"));
+ driver.findElement(By.xpath(configProp.getProperty("profilelink"))).click();
+ Thread.sleep(3000);
+
+ //Verify whether the sub panel is displayed
+ //To verify the following :Search import from webphone and Self
+ driver.findElement(By.xpath(".//*[@id='panel4']")).isDisplayed();
+ log.info("Expand and collapse passed for Profile link");
+
+ //For Admin
+ //Verify expand and collapse working for ADMIN
+ log.info("Clicking Admin link from left pane");
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[6]/a/span")).click();
+ //To verify the following: Roles, Roles Functions, Usages
+ driver.findElement(By.xpath(".//*[@id='panel5']")).isDisplayed();
+
+
+ log.info("Expand and collapse passed for ADMIN link");
+
+ log.info("VID-11 TC-3 PASSED");
+
+ }
+
+
+ /**
+ * Drop down list.
+ *
+ * @throws InterruptedException the interrupted exception
+ */
+ @Test(priority=2)
+ public void dropDownList() throws InterruptedException
+ {
+ //VID-12 TC-3
+ log.info("VID-12 TC-3");
+ //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"));
+
+ //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select"));
+ Thread.sleep(5000);
+
+ //Infrastructure Subscriber Name
+ Select oSelect = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")));
+ Select iSelect = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select")));
+
+ List <WebElement> elementCount = oSelect.getOptions();
+ log.info("Subscriber Name Drop Down");
+ System.out.println(elementCount.size());
+ oSelect.selectByIndex(1);
+ log.info("Subscriber name selected");
+ //String selectedOption = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"))).getFirstSelectedOption().getText();
+
+
+ List <WebElement> count = iSelect.getOptions();
+ log.info("Subscriber type drop down");
+ System.out.println(count.size());
+ oSelect.selectByIndex(1);
+ log.info("Subscriber type selected");
+
+
+
+ //Submit button is clicked
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button")).click();
+
+
+ //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:"
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed();
+ log.info("VID-12 TC-3 PASSED");
+ }
+
+
+
+
+ /**
+ * Logout left pane.
+ */
+ @Test(priority=3)
+ public void logoutLeftPane()
+ {
+ //To Verify if the logout link redirects to Login page when clicked.
+
+
+ /*log.info("----------------VID-11 TC-4----------------");
+ login.clear();
+ login.sendKeys("testuser");
+ pwd.clear();
+ pwd.sendKeys("abc123");
+ //driver.findElement(By.partialLinkText("Click here to login")).click();
+ //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+
+ loginButton.click();
+ driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);*/
+ log.info("----------------VID-11 TC-4----------------");
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[7]/a")).click();
+ //Validate that the user has logged out of VID. Displays "Portal"
+ Assert.assertTrue(driver.getPageSource().contains("Portal"));
+
+ log.info("VID 11 TC-4 PASSED");
+
+ driver.close();
+
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java b/onap-enabler-be/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java
new file mode 100644
index 0000000..09a0b43
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java
@@ -0,0 +1,166 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.fusion.core;
+
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.AnnotationConfigWebContextLoader;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.testng.annotations.Test;
+import org.onap.portalsdk.core.conf.AppConfig;
+import org.onap.portalsdk.core.objectcache.AbstractCacheManager;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.portalsdk.core.util.CacheManager;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@WebAppConfiguration
+@ContextConfiguration(loader = AnnotationConfigWebContextLoader.class, classes = {MockAppConfig.class})
+@ActiveProfiles(value="test")
+@Test(enabled=false)
+public class MockApplicationContextTestSuite {
+
+ @Autowired
+ public WebApplicationContext wac;
+
+ /** The mock mvc. */
+ private MockMvc mockMvc;
+
+ /**
+ * Setup.
+ */
+ @Before
+ public void setup() {
+ if(mockMvc == null) {
+ this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
+
+ }
+ }
+
+ /**
+ * Gets the bean.
+ *
+ * @param name the name
+ * @return the bean
+ */
+ public Object getBean(String name) {
+ return this.wac.getBean(name);
+ }
+
+
+ /**
+ * Gets the mock mvc.
+ *
+ * @return the mock mvc
+ */
+ public MockMvc getMockMvc() {
+ return mockMvc;
+ }
+
+ /**
+ * Sets the mock mvc.
+ *
+ * @param mockMvc the new mock mvc
+ */
+ public void setMockMvc(MockMvc mockMvc) {
+ this.mockMvc = mockMvc;
+ }
+
+ /**
+ * Gets the web application context.
+ *
+ * @return the web application context
+ */
+ public WebApplicationContext getWebApplicationContext() {
+ return wac;
+ }
+
+
+
+
+}
+
+
+ @Configuration
+ @ComponentScan(basePackages = "org.onap",
+ excludeFilters = {
+ // the following source configurations should not be scanned; instead of using Exclusion filter, we can use the @Profile annotation to exclude them
+ // see AppConfig class
+ //@ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.onap.portalsdk.core.*AppConfig*")//,
+ //@ComponentScan.Filter(type = FilterType.REGEX, pattern = org.onap.*.*AppConfig*")
+ }
+ )
+ @Profile("test")
+ class MockAppConfig extends AppConfig {
+
+ @Bean
+ public SystemProperties systemProperties(){
+ return new MockSystemProperties();
+ }
+
+ @Bean
+ public AbstractCacheManager cacheManager() {
+ return new CacheManager() {
+
+ public void configure() throws IOException {
+
+ }
+ };
+ }
+
+ protected String[] tileDefinitions() {
+ return new String[] {"classpath:/WEB-INF/fusion/defs/definitions.xml", "classpath:/WEB-INF/defs/definitions.xml"};
+ }
+
+ @Override
+ public void addInterceptors(InterceptorRegistry registry) {
+ //registry.addInterceptor(new SessionTimeoutInterceptor()).excludePathPatterns(getExcludeUrlPathsForSessionTimeout());
+ //registry.addInterceptor(resourceInterceptor());
+ }
+
+ public static class MockSystemProperties extends SystemProperties {
+
+ public MockSystemProperties() {
+ }
+
+ }
+
+ }
+
+
+
+
diff --git a/onap-enabler-be/src/test/java/org/onap/fusionapp/controller/NetMapTest.java b/onap-enabler-be/src/test/java/org/onap/fusionapp/controller/NetMapTest.java
new file mode 100644
index 0000000..98a715f
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/fusionapp/controller/NetMapTest.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.fusionapp.controller;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.test.web.servlet.ResultActions;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+
+import org.onap.fusion.core.MockApplicationContextTestSuite;
+
+
+public class NetMapTest extends MockApplicationContextTestSuite {
+
+// @Test
+ public void testGetNetMap() throws Exception {
+ ResultActions ra =getMockMvc().perform(MockMvcRequestBuilders.get("/net_map"));
+ //Assert.assertEquals(UrlAccessRestrictedException.class,ra.andReturn().getResolvedException().getClass());
+ Assert.assertEquals("net_map_int",ra.andReturn().getModelAndView().getModel().get("frame_int"));
+ }
+
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java b/onap-enabler-be/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java
new file mode 100644
index 0000000..c88348f
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.fusionapp.service;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import org.onap.fusion.core.MockApplicationContextTestSuite;
+import org.onap.portalsdk.core.domain.Profile;
+import org.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.service.ProfileService;
+import org.onap.portalsdk.core.service.UserProfileService;
+
+
+
+public class ProfileServiceTest extends MockApplicationContextTestSuite {
+
+ @Autowired
+ ProfileService service;
+
+ /** The user profile service. */
+ @Autowired
+ UserProfileService userProfileService;
+
+ /**
+ * Test find all.
+ */
+ //@Test
+ public void testFindAll() {
+ try {
+ List<Profile> profiles = service.findAll();
+ Assert.assertTrue(profiles.size() > 0);
+
+ }
+ catch (Exception e) {
+ // TODO: handle exception
+ }
+ }
+
+ /**
+ * Test find all active.
+ */
+// @Test
+ public void testFindAllActive() {
+
+ List<User> users = userProfileService.findAllActive();
+ List<User> activeUsers = userProfileService.findAllActive();
+ Assert.assertTrue(users.size() - activeUsers.size() >= 0);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/RelatedToTest.java b/onap-enabler-be/src/test/java/org/onap/osam/RelatedToTest.java
new file mode 100644
index 0000000..d205abb
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/RelatedToTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam;
+
+import java.util.Map;
+
+import org.junit.Test;
+
+
+public class RelatedToTest {
+
+ private RelatedTo createTestSubject() {
+ return new RelatedTo();
+ }
+
+
+ @Test
+ public void testGetAdditionalProperties() throws Exception {
+ RelatedTo testSubject;
+ Map<String, Object> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAdditionalProperties();
+ }
+
+
+ @Test
+ public void testSetAdditionalProperty() throws Exception {
+ RelatedTo testSubject;
+ String name = "";
+ Object value = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAdditionalProperty(name, value);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/AaiClientTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/AaiClientTest.java
new file mode 100644
index 0000000..0a3536a
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/AaiClientTest.java
@@ -0,0 +1,469 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableList;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.commons.lang3.reflect.FieldUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.mockito.Mockito;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.osam.aai.model.AaiNodeQueryResponse;
+import org.onap.osam.aai.model.ResourceType;
+import org.onap.osam.aai.util.AAIRestInterface;
+import org.onap.osam.aai.util.HttpsAuthClient;
+import org.onap.osam.aai.util.ServletRequestHelper;
+import org.onap.osam.aai.util.SystemPropertyHelper;
+import org.onap.osam.controllers.LocalWebConfig;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.model.Subscriber;
+import org.onap.osam.model.SubscriberList;
+import org.onap.osam.model.probes.ExternalComponentStatus;
+import org.onap.osam.model.probes.HttpRequestMetadata;
+import org.onap.osam.model.probes.StatusMetadata;
+import org.onap.osam.testUtils.TestUtils;
+import org.springframework.http.HttpMethod;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import sun.security.provider.certpath.SunCertPathBuilderException;
+import sun.security.validator.ValidatorException;
+
+import javax.crypto.BadPaddingException;
+import javax.net.ssl.SSLHandshakeException;
+import javax.servlet.ServletContext;
+import javax.ws.rs.ProcessingException;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.core.Response;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.security.cert.CertificateException;
+import java.util.ArrayList;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalToIgnoringCase;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.*;
+
+@ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class})
+@WebAppConfiguration
+public class AaiClientTest {
+
+ private AaiClient aaiClientMock;
+ private ServletContext servletContext;
+
+ @BeforeMethod
+ public void initMocks(){
+ aaiClientMock = mock(AaiClient.class);
+ aaiClientMock.logger = mock(EELFLoggerDelegate.class);
+ servletContext = mock(ServletContext.class);
+
+ when(servletContext.getRealPath(any(String.class))).thenReturn("");
+
+ when(aaiClientMock.doAaiGet(any(String.class),any(Boolean.class))).thenReturn(null);
+ }
+
+ @DataProvider
+ public static Object[][] logicalLinkData() {
+ return new Object[][] {
+ {"", "network/logical-links/logical-link/"},
+ {"link", "network/logical-links/logical-link/link"}
+ };
+ }
+
+ @Test(dataProvider = "logicalLinkData")
+ public void getLogicalLink_Link_Is_Empty(String link, String expectedUrl) {
+
+ when(aaiClientMock.getLogicalLink(any(String.class))).thenCallRealMethod();
+ aaiClientMock.getLogicalLink(link);
+ Mockito.verify(aaiClientMock).doAaiGet(argThat(equalToIgnoringCase(expectedUrl)),any(Boolean.class));
+ }
+
+ @DataProvider
+ public static Object[][] subscribersResults() {
+ return new Object[][] {
+ {new SubscriberList(new ArrayList<Subscriber>() {{ add(new Subscriber()); add(new Subscriber()); }}), true},
+ {new SubscriberList(new ArrayList<Subscriber>() {{ add(new Subscriber()); }}), true},
+ {new SubscriberList(new ArrayList<Subscriber>()), false}
+ };
+ }
+
+ @Test(dataProvider = "subscribersResults")
+ public void testProbeAaiGetAllSubscribers_returnsTwoToZeroSubscribers_ResultsAsExpected(SubscriberList subscribers, boolean isAvailable){
+ ExternalComponentStatus expectedStatus = new ExternalComponentStatus(ExternalComponentStatus.Component.AAI,isAvailable, new HttpRequestMetadata(
+ HttpMethod.GET,
+ 200,
+ "url",
+ "rawData",
+ isAvailable ? "OK" : "No subscriber received",
+ 0
+ ));
+ Mockito.when(aaiClientMock.getAllSubscribers(true)).thenReturn(
+ new AaiResponseWithRequestInfo<>(
+ HttpMethod.GET, "url", new AaiResponse<>(subscribers, null, 200),
+ "rawData"));
+ Mockito.when(aaiClientMock.probeAaiGetAllSubscribers()).thenCallRealMethod();
+ ExternalComponentStatus result = aaiClientMock.probeAaiGetAllSubscribers();
+ assertThat(statusDataReflected(result),is(statusDataReflected(expectedStatus)));
+ assertThat(requestMetadataReflected(result.getMetadata()),is(requestMetadataReflected(expectedStatus.getMetadata())));
+ }
+
+ //serialize fields except of fields we cannot know ahead of time
+ private static String requestMetadataReflected(StatusMetadata metadata) {
+ return new ReflectionToStringBuilder(metadata, ToStringStyle.SHORT_PREFIX_STYLE)
+ .setExcludeFieldNames("duration")
+ .toString();
+ }
+
+ private static String statusDataReflected(ExternalComponentStatus status) {
+ return new ReflectionToStringBuilder(status, ToStringStyle.SHORT_PREFIX_STYLE)
+ .setExcludeFieldNames("metadata")
+ .toString();
+ }
+
+ @DataProvider
+ public static Object[][] rawData() {
+ return new Object[][]{
+ {"errorMessage", }, {""}, {null}
+ };
+ }
+
+ @Test(dataProvider = "rawData")
+ public void testProbeAaiGetFullSubscribersWithNullResponse_returnsNotAvailableWithErrorRawData(String rawData){
+ Mockito.when(aaiClientMock.getAllSubscribers(true)).thenReturn(
+ new AaiResponseWithRequestInfo<>(HttpMethod.GET, "url", null,
+ rawData));
+ ExternalComponentStatus result = callProbeAaiGetAllSubscribersAndAssertNotAvailable();
+ assertThat(result.getMetadata(), instanceOf(HttpRequestMetadata.class));
+ assertEquals(((HttpRequestMetadata) result.getMetadata()).getRawData(), rawData);
+ }
+
+ @DataProvider
+ public static Object[][] exceptions() {
+ return new Object[][] {
+ {"NullPointerException", "errorMessage",
+ new ExceptionWithRequestInfo(HttpMethod.GET, "url",
+ "errorMessage", null, new NullPointerException())},
+ {"RuntimeException", null,
+ new ExceptionWithRequestInfo(HttpMethod.GET, "url",
+ null, null, new RuntimeException())},
+ {"RuntimeException", null,
+ new RuntimeException()},
+ };
+ }
+
+ @Test(dataProvider = "exceptions")
+ public void testProbeAaiGetFullSubscribersWithNullResponse_returnsNotAvailableWithErrorRawData(String description, String expectedRawData, Exception exception){
+ Mockito.when(aaiClientMock.getAllSubscribers(true)).thenThrow(exception);
+ ExternalComponentStatus result = callProbeAaiGetAllSubscribersAndAssertNotAvailable();
+ if (exception instanceof ExceptionWithRequestInfo) {
+ assertThat(result.getMetadata(), instanceOf(HttpRequestMetadata.class));
+ assertEquals(((HttpRequestMetadata) result.getMetadata()).getRawData(), expectedRawData);
+ }
+ assertThat(result.getMetadata().getDescription(), containsString(description));
+ }
+
+ private ExternalComponentStatus callProbeAaiGetAllSubscribersAndAssertNotAvailable() {
+ Mockito.when(aaiClientMock.probeAaiGetAllSubscribers()).thenCallRealMethod();
+ ExternalComponentStatus result = aaiClientMock.probeAaiGetAllSubscribers();
+ assertFalse(result.isAvailable());
+ return result;
+ }
+
+
+ @Test
+ public void getTenants_Arguments_Are_Null_Or_Empty() {
+
+ when(aaiClientMock.getTenants(any(String.class), any(String.class))).thenCallRealMethod();
+
+ AaiResponse response = aaiClientMock.getTenants("", "");
+
+ assertEquals(response.getErrorMessage(), "{\"statusText\":\" Failed to retrieve LCP Region & Tenants from A&AI, Subscriber ID or Service Type is missing.\"}");
+
+
+ response = aaiClientMock.getTenants(null, null);
+
+ assertEquals(response.getErrorMessage(), "{\"statusText\":\" Failed to retrieve LCP Region & Tenants from A&AI, Subscriber ID or Service Type is missing.\"}");
+ }
+
+ @Test
+ public void getTenants_Arguments_Are_Valid_But_Tenants_Not_Exist() {
+
+ when(aaiClientMock.getTenants(any(String.class), any(String.class))).thenCallRealMethod();
+
+ Response generalEmptyResponse = mock(Response.class);
+ when(aaiClientMock.doAaiGet(any(String.class),any(Boolean.class))).thenReturn(generalEmptyResponse);
+
+ AaiResponse response = aaiClientMock.getTenants("subscriberId", "serviceType");
+
+ assertEquals(response.getErrorMessage(), "{\"statusText\":\" A&AI has no LCP Region & Tenants associated to subscriber 'subscriberId' and service type 'serviceType'\"}");
+
+ }
+
+ @Test
+ public void getTenants_Arguments_Are_Valid_Get_The_Tenanats() {
+
+ when(aaiClientMock.getTenants(any(String.class), any(String.class))).thenCallRealMethod();
+
+
+ Response generalEmptyResponse = mock(Response.class);
+
+ when(generalEmptyResponse.readEntity(String.class)).thenReturn(tenantResponseRaw);
+ when(generalEmptyResponse.getStatus()).thenReturn(200);
+ when(generalEmptyResponse.getStatusInfo()).thenReturn(new Response.StatusType() {
+ @Override
+ public int getStatusCode() {
+ return 200;
+ }
+
+ @Override
+ public Response.Status.Family getFamily() {
+ return Response.Status.Family.SUCCESSFUL;
+ }
+
+ @Override
+ public String getReasonPhrase() {
+ return null;
+ }
+ });
+
+
+ when(aaiClientMock.doAaiGet(any(String.class),any(Boolean.class))).thenReturn(generalEmptyResponse);
+
+ AaiResponse<GetTenantsResponse[]> response = aaiClientMock.getTenants("subscriberId", "serviceType");
+
+ Assert.assertTrue(response.t.length> 0);
+ }
+
+ final String tenantResponseRaw ="" +
+ "{" +
+ "\"service-type\": \"VIRTUAL USP\"," +
+ "\"resource-version\": \"1494001841964\"," +
+ "\"relationship-list\": {" +
+ "\"relationship\": [{" +
+ "\"related-to\": \"tenant\"," +
+ "\"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/092eb9e8e4b7412e8787dd091bc58e86\"," +
+ "\"relationship-data\": [{" +
+ "\"relationship-key\": \"cloud-region.cloud-owner\"," +
+ "\"relationship-value\": \"att-aic\"" +
+ "}," +
+ "{" +
+ "\"relationship-key\": \"cloud-region.cloud-region-id\"," +
+ "\"relationship-value\": \"AAIAIC25\"" +
+ "}," +
+ "{" +
+ "\"relationship-key\": \"tenant.tenant-id\"," +
+ "\"relationship-value\": \"092eb9e8e4b7412e8787dd091bc58e86\"" +
+ "}" +
+ "]," +
+ "\"related-to-property\": [{" +
+ "\"property-key\": \"tenant.tenant-name\"," +
+ "\"property-value\": \"USP-SIP-IC-24335-T-01\"" +
+ "}]" +
+ "}]" +
+ "}" +
+ "}";
+
+ @DataProvider
+ public static Object[][] resourceTypesProvider() {
+ return new Object[][] {
+ {"service-instance", ResourceType.SERVICE_INSTANCE},
+ {"generic-vnf", ResourceType.GENERIC_VNF},
+ {"vf-module", ResourceType.VF_MODULE}
+ };
+ }
+
+ @Test(dataProvider = "resourceTypesProvider")
+ public void aaiNodeQueryResponseDeserializationTest(String resourceType, ResourceType expectedResourceType) throws IOException {
+ String link = "/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Nimbus/service-instances/service-instance/7131d483-b450-406f-8e30-0c650645fc67";
+ String json =
+ "{\"result-data\": [{" +
+ "\"resource-type\": \""+resourceType+"\"," +
+ "\"resource-link\": \""+ link+ "\"" +
+ "}]}";
+
+ AaiNodeQueryResponse nodeQueryResponse = new ObjectMapper().readValue(json, AaiNodeQueryResponse.class);
+ assertThat(nodeQueryResponse.resultData.get(0).resourceLink, equalTo(link));
+ assertThat(nodeQueryResponse.resultData.get(0).resourceType, is(expectedResourceType));
+ }
+
+ @Test
+ public void aaiNodeQueryEmptyResponseDeserializationTest() throws IOException{
+ String json = "{}";
+ AaiNodeQueryResponse nodeQueryResponse = new ObjectMapper().readValue(json, AaiNodeQueryResponse.class);
+ assertNull(nodeQueryResponse.resultData);
+ }
+
+ @DataProvider
+ public static Object[][] nameAndResourceTypeProvider() {
+ return new Object[][] {
+ {"SRIOV_SVC", ResourceType.SERVICE_INSTANCE, "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:SRIOV_SVC"},
+ {"b1707vidnf", ResourceType.GENERIC_VNF, "search/nodes-query?search-node-type=generic-vnf&filter=vnf-name:EQUALS:b1707vidnf"},
+ {"connectivity_test", ResourceType.VF_MODULE, "search/nodes-query?search-node-type=vf-module&filter=vf-module-name:EQUALS:connectivity_test"},
+ {"MjVg1234", ResourceType.VOLUME_GROUP, "search/nodes-query?search-node-type=volume-group&filter=volume-group-name:EQUALS:MjVg1234"}
+ };
+ }
+
+ @Test(dataProvider = "nameAndResourceTypeProvider")
+ public void whenSearchNodeTypeByName_callRightAaiPath(String name, ResourceType type, String expectedUrl) {
+ when(aaiClientMock.searchNodeTypeByName(any(String.class), any(ResourceType.class))).thenCallRealMethod();
+ aaiClientMock.searchNodeTypeByName(name, type);
+ Mockito.verify(aaiClientMock).doAaiGet(eq(expectedUrl), eq(false));
+ }
+
+ @DataProvider
+ public static Object[][] aaiClientInternalExceptions() {
+ return Stream.<Pair<Class<? extends Throwable>, UncheckedBiConsumer<HttpsAuthClient, Client>>>of(
+
+ // Exception out of httpsAuthClientMock
+ Pair.of(CertificateException.class, (httpsAuthClientMock, javaxClientMock) -> {
+ final CertificateException e0 = new CertificateException("No X509TrustManager implementation available");
+ SSLHandshakeException e = new SSLHandshakeException(e0.toString());
+ e.initCause(e0);
+
+ when(httpsAuthClientMock.getClient(any())).thenThrow(e);
+ }),
+
+ Pair.of(StringIndexOutOfBoundsException.class, mockExceptionOnClientProvider(new StringIndexOutOfBoundsException(4))),
+
+ Pair.of(NullPointerException.class, mockExceptionOnClientProvider(new NullPointerException("null"))),
+
+ Pair.of(FileNotFoundException.class, mockExceptionOnClientProvider(new FileNotFoundException("vid/WEB-INF/cert/aai-client-cert.p12"))),
+
+ Pair.of(BadPaddingException.class, mockExceptionOnClientProvider(
+ new IOException("keystore password was incorrect", new BadPaddingException("Given final block not properly padded")))
+ ),
+ Pair.of(GenericUncheckedException.class, mockExceptionOnClientProvider(new GenericUncheckedException("basa"))),
+
+ Pair.of(NullPointerException.class, (httpsAuthClientMock, javaxClientMock) ->
+ when(httpsAuthClientMock.getClient(any())).thenReturn(null)),
+
+
+ // Exception out of javax's Client
+ Pair.of(SSLHandshakeException.class, (httpsAuthClientMock, javaxClientMock) -> {
+ when(javaxClientMock.target(anyString())).thenThrow(
+ new ProcessingException(new SSLHandshakeException("Received fatal alert: certificate_expired"))
+ );
+ }),
+
+ Pair.of(SunCertPathBuilderException.class, (httpsAuthClientMock, javaxClientMock) -> {
+ SunCertPathBuilderException e0 = new SunCertPathBuilderException("unable to find valid certification path to requested target");
+ when(javaxClientMock.target(anyString())).thenThrow(
+ new ProcessingException(new ValidatorException("PKIX path building failed: " + e0.toString(), e0))
+ );
+ }),
+
+ Pair.of(GenericUncheckedException.class, (httpsAuthClientMock, javaxClientMock) ->
+ when(javaxClientMock.target(anyString())).thenThrow(new GenericUncheckedException("basa")))
+
+ ).flatMap(l -> Stream.of(
+ // double each case to propagateExceptions = true/false, to verify that "don't propagate" really still work
+ ImmutableList.of(l.getLeft(), l.getRight(), true).toArray(),
+ ImmutableList.of(l.getLeft(), l.getRight(), false).toArray()
+ )).collect(Collectors.toList()).toArray(new Object[][]{});
+ }
+
+ private static UncheckedBiConsumer<HttpsAuthClient, Client> mockExceptionOnClientProvider(Exception e) {
+ return (httpsAuthClientMock, javaxClientMock) ->
+ when(httpsAuthClientMock.getClient(any())).thenThrow(e);
+ }
+
+ @Test(dataProvider = "aaiClientInternalExceptions")
+ public void propagateExceptions_internalsThrowException_ExceptionRethrown(Class<? extends Throwable> expectedType, BiConsumer<HttpsAuthClient, Client> setupMocks, boolean propagateExceptions) throws Exception {
+
+ // prepare mocks
+ HttpsAuthClient httpsAuthClientMock = mock(HttpsAuthClient.class);
+ TestUtils.JavaxRsClientMocks mocks = new TestUtils.JavaxRsClientMocks();
+ Client javaxClientMock = mocks.getFakeClient();
+ Response responseMock = mocks.getFakeResponse();
+
+ // prepare real AAIRestInterface and AaiClient, and wire mocks
+ AAIRestInterface aaiRestInterface = new AAIRestInterface(httpsAuthClientMock, new ServletRequestHelper(), new SystemPropertyHelper());
+ final AaiClient aaiClient = new AaiClient(aaiRestInterface, null);
+ when(httpsAuthClientMock.getClient(any())).thenReturn(javaxClientMock);
+
+ // define atomic method under test, including reset of "aaiRestInterface.client"
+ final Function<Boolean, Response> doAaiGet = (propagateExceptions1) -> {
+ try {
+ FieldUtils.writeField(aaiRestInterface, "client", null, true);
+ return aaiClient.doAaiGet("uri", false, propagateExceptions1).getResponse();
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ };
+
+ // verify setup again
+ assertThat("mocks setup should make doAaiGet return our responseMock", doAaiGet.apply(true), is(sameInstance(responseMock)));
+
+
+ /// TEST:
+ setupMocks.accept(httpsAuthClientMock, javaxClientMock);
+
+ try {
+ final Response response = doAaiGet.apply(propagateExceptions);
+ } catch (Exception e) {
+ if (propagateExceptions) {
+ assertThat("root cause incorrect for " + ExceptionUtils.getStackTrace(e), ExceptionUtils.getRootCause(e), instanceOf(expectedType));
+ return; // ok, done
+ } else {
+ // Verify that "don't propagate" really still work
+ Assert.fail("calling doAaiGet when propagateExceptions is false must result with no exception", e);
+ }
+ }
+
+ // If no exception caught
+ // We're asserting that the legacy behaviour is still in place. Hopefully
+ // one day we will remove the non-propagateExceptions case
+ assertFalse(propagateExceptions, "calling doAaiGet when propagateExceptions is 'true' must result with an exception (in this test)");
+ }
+
+ @FunctionalInterface
+ public interface UncheckedBiConsumer<T, U> extends BiConsumer<T, U> {
+ @Override
+ default void accept(T t, U u) {
+ try {
+ acceptThrows(t, u);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ void acceptThrows(T t, U u) throws Exception;
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/AaiGetVnfResponseTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/AaiGetVnfResponseTest.java
new file mode 100644
index 0000000..78509b5
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/AaiGetVnfResponseTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import java.util.Map;
+
+import org.junit.Test;
+
+public class AaiGetVnfResponseTest {
+
+ private AaiGetVnfResponse createTestSubject() {
+ return new AaiGetVnfResponse();
+ }
+
+ @Test
+ public void testGetAdditionalProperties() throws Exception {
+ AaiGetVnfResponse testSubject;
+ Map<String, Object> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAdditionalProperties();
+ }
+
+ @Test
+ public void testSetAdditionalProperty() throws Exception {
+ AaiGetVnfResponse testSubject;
+ String name = "";
+ Object value = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAdditionalProperty(name, value);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/OperationalEnvironmentTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/OperationalEnvironmentTest.java
new file mode 100644
index 0000000..b358eb8
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/OperationalEnvironmentTest.java
@@ -0,0 +1,211 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import org.junit.Test;
+import org.onap.osam.aai.model.RelationshipList;
+
+public class OperationalEnvironmentTest {
+
+ private OperationalEnvironment createTestSubject() {
+ return new OperationalEnvironment();
+ }
+
+ @Test
+ public void testGetOperationalEnvironmentId() throws Exception {
+ OperationalEnvironment testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getOperationalEnvironmentId();
+ }
+
+ @Test
+ public void testSetOperationalEnvironmentId() throws Exception {
+ OperationalEnvironment testSubject;
+ String operationalEnvironmentId = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setOperationalEnvironmentId(operationalEnvironmentId);
+ }
+
+ @Test
+ public void testGetOperationalEnvironmentName() throws Exception {
+ OperationalEnvironment testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getOperationalEnvironmentName();
+ }
+
+ @Test
+ public void testSetOperationalEnvironmentName() throws Exception {
+ OperationalEnvironment testSubject;
+ String operationalEnvironmentName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setOperationalEnvironmentName(operationalEnvironmentName);
+ }
+
+ @Test
+ public void testGetOperationalEnvironmentType() throws Exception {
+ OperationalEnvironment testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getOperationalEnvironmentType();
+ }
+
+ @Test
+ public void testSetOperationalEnvironmentType() throws Exception {
+ OperationalEnvironment testSubject;
+ String operationalEnvironmentType = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setOperationalEnvironmentType(operationalEnvironmentType);
+ }
+
+ @Test
+ public void testGetOperationalEnvironmentStatus() throws Exception {
+ OperationalEnvironment testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getOperationalEnvironmentStatus();
+ }
+
+ @Test
+ public void testSetOperationalEnvironmentStatus() throws Exception {
+ OperationalEnvironment testSubject;
+ String operationalEnvironmentStatus = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setOperationalEnvironmentStatus(operationalEnvironmentStatus);
+ }
+
+ @Test
+ public void testGetTenantContext() throws Exception {
+ OperationalEnvironment testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getTenantContext();
+ }
+
+ @Test
+ public void testSetTenantContext() throws Exception {
+ OperationalEnvironment testSubject;
+ String tenantContext = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setTenantContext(tenantContext);
+ }
+
+ @Test
+ public void testGetWorkloadContext() throws Exception {
+ OperationalEnvironment testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getWorkloadContext();
+ }
+
+ @Test
+ public void testSetWorkloadContext() throws Exception {
+ OperationalEnvironment testSubject;
+ String workloadContext = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setWorkloadContext(workloadContext);
+ }
+
+ @Test
+ public void testGetResourceVersion() throws Exception {
+ OperationalEnvironment testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getResourceVersion();
+ }
+
+ @Test
+ public void testSetResourceVersion() throws Exception {
+ OperationalEnvironment testSubject;
+ String resourceVersion = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setResourceVersion(resourceVersion);
+ }
+
+ @Test
+ public void testGetRelationshipList() throws Exception {
+ OperationalEnvironment testSubject;
+ RelationshipList result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRelationshipList();
+ }
+
+ @Test
+ public void testSetRelationshipList() throws Exception {
+ OperationalEnvironment testSubject;
+ RelationshipList relationshipList = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setRelationshipList(relationshipList);
+ }
+
+ @Test
+ public void testOperationalEnvironment() throws Exception {
+ OperationalEnvironment testSubject;
+ String operationalEnvironmentId = "";
+ String operationalEnvironmentName = "";
+ String operationalEnvironmentType = "";
+ String operationalEnvironmentStatus = "";
+ String tenantContext = "";
+ String workloadContext = "";
+ String resourceVersion = "";
+ RelationshipList relationshipList = null;
+
+ // default test
+ testSubject = new OperationalEnvironment(operationalEnvironmentId, operationalEnvironmentName,
+ operationalEnvironmentType, operationalEnvironmentStatus, tenantContext, workloadContext,
+ resourceVersion, relationshipList);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/ServicePropertiesTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/ServicePropertiesTest.java
new file mode 100644
index 0000000..b651049
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/ServicePropertiesTest.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import java.util.Map;
+
+import org.junit.Test;
+import org.onap.osam.aai.model.ServiceProperties;
+
+public class ServicePropertiesTest {
+
+ private ServiceProperties createTestSubject() {
+ return new ServiceProperties();
+ }
+
+ @Test
+ public void testGetAdditionalProperties() throws Exception {
+ ServiceProperties testSubject;
+ Map<String, Object> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAdditionalProperties();
+ }
+
+ @Test
+ public void testSetAdditionalProperty() throws Exception {
+ ServiceProperties testSubject;
+ String name = "";
+ Object value = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAdditionalProperty(name, value);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/SubscriberAaiResponseTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/SubscriberAaiResponseTest.java
new file mode 100644
index 0000000..8adf9c2
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/SubscriberAaiResponseTest.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import org.junit.Test;
+import org.onap.osam.model.SubscriberList;
+
+public class SubscriberAaiResponseTest {
+
+ private SubscriberAaiResponse createTestSubject() {
+ return new SubscriberAaiResponse(new SubscriberList(), "", 0);
+ }
+
+
+ @Test
+ public void testGetSubscriberList() throws Exception {
+ SubscriberAaiResponse testSubject;
+ SubscriberList result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getSubscriberList();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/SubscriberFilteredResultsTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/SubscriberFilteredResultsTest.java
new file mode 100644
index 0000000..e7cf380
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/SubscriberFilteredResultsTest.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import java.util.ArrayList;
+
+import org.junit.Test;
+import org.onap.osam.model.SubscriberList;
+import org.onap.osam.roles.EcompRole;
+import org.onap.osam.roles.Role;
+import org.onap.osam.roles.RoleValidator;
+
+public class SubscriberFilteredResultsTest {
+
+ private SubscriberFilteredResults createTestSubject() {
+ ArrayList<Role> list = new ArrayList<Role>();
+ list.add(new Role(EcompRole.READ, "a", "a", "a"));
+ RoleValidator rl=new RoleValidator(list);
+ SubscriberList sl = new SubscriberList();
+ sl.customer = new ArrayList<org.onap.osam.model.Subscriber>();
+ sl.customer.add(new org.onap.osam.model.Subscriber());
+ return new SubscriberFilteredResults(rl, sl, "OK", 200);
+ }
+
+ @Test
+ public void testGetSubscriberList() throws Exception {
+ SubscriberFilteredResults testSubject;
+ SubscriberListWithFilterData result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getSubscriberList();
+ }
+
+ @Test
+ public void testSetSubscriberList() throws Exception {
+ SubscriberFilteredResults testSubject;
+ SubscriberListWithFilterData subscriberList = null;
+
+ // default test
+ testSubject = createTestSubject();
+ //testSubject.setSubscriberList(subscriberList);
+ testSubject.getSubscriberList();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/SubscriberWithFilterTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/SubscriberWithFilterTest.java
new file mode 100644
index 0000000..5b6ddcc
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/SubscriberWithFilterTest.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import org.junit.Test;
+
+public class SubscriberWithFilterTest {
+
+ private SubscriberWithFilter createTestSubject() {
+ return new SubscriberWithFilter();
+ }
+
+ @Test
+ public void testGetIsPermitted() throws Exception {
+ SubscriberWithFilter testSubject;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getIsPermitted();
+ }
+
+ @Test
+ public void testSetIsPermitted() throws Exception {
+ SubscriberWithFilter testSubject;
+ boolean isPermitted = false;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setIsPermitted(isPermitted);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/VnfResultTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/VnfResultTest.java
new file mode 100644
index 0000000..3f06e6c
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/VnfResultTest.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai;
+
+import java.util.Map;
+
+import org.junit.Test;
+import org.onap.osam.aai.model.VnfResult;
+
+public class VnfResultTest {
+
+ private VnfResult createTestSubject() {
+ return new VnfResult();
+ }
+
+ @Test
+ public void testGetAdditionalProperties() throws Exception {
+ VnfResult testSubject;
+ Map<String, Object> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAdditionalProperties();
+ }
+
+ @Test
+ public void testSetAdditionalProperty() throws Exception {
+ VnfResult testSubject;
+ String name = "";
+ Object value = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAdditionalProperty(name, value);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentListTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentListTest.java
new file mode 100644
index 0000000..4bc64ab
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentListTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetOperationalEnvironments;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+import org.junit.Test;
+
+public class OperationalEnvironmentListTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(OperationalEnvironmentList.class, hasValidGettersAndSetters());
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/AaiGetPnfResponseTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/AaiGetPnfResponseTest.java
new file mode 100644
index 0000000..c74fe37
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/AaiGetPnfResponseTest.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.StringContains.containsString;
+import static org.hamcrest.core.IsEqual.equalTo;
+
+public class AaiGetPnfResponseTest {
+
+ private AaiGetPnfResponse aaiGetPnfResponse;
+
+ @Before
+ public void setUp(){
+ aaiGetPnfResponse = new AaiGetPnfResponse();
+ aaiGetPnfResponse.results = new ArrayList<>();
+ aaiGetPnfResponse.setAdditionalProperty("key1", "value1");
+ aaiGetPnfResponse.setAdditionalProperty("key2", "value2");
+ }
+
+ @Test
+ public void shouldHaveValidGettersAndSetters() throws IOException {
+ String result = new ObjectMapper().writeValueAsString(aaiGetPnfResponse);
+ assertThat(result, containsString("key1"));
+ assertThat(result, containsString("value2"));
+ assertThat(result, containsString("key2"));
+ assertThat(result, containsString("value2"));
+ }
+
+ @Test
+ public void shouldHaveValidToString(){
+ assertThat(aaiGetPnfResponse.toString(),
+ equalTo("AaiGetPnfResponse{results=[], additionalProperties={key1=value1, key2=value2}}"));
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/AaiGetPnfs/PnfTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/AaiGetPnfs/PnfTest.java
new file mode 100644
index 0000000..ec25225
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/AaiGetPnfs/PnfTest.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model.AaiGetPnfs;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class PnfTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(Pnf.class, hasValidGettersAndSetters());
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/AaiRelationResponseTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/AaiRelationResponseTest.java
new file mode 100644
index 0000000..d139936
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/AaiRelationResponseTest.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class AaiRelationResponseTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(AaiRelationResponse.class, hasValidGettersAndSetters());
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/GetServiceModelsByDistributionStatusResponseTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/GetServiceModelsByDistributionStatusResponseTest.java
new file mode 100644
index 0000000..a0b4ac2
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/GetServiceModelsByDistributionStatusResponseTest.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class GetServiceModelsByDistributionStatusResponseTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(GetServiceModelsByDistributionStatusResponse.class, hasValidGettersAndSetters());
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/LogicalLinkResponseTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/LogicalLinkResponseTest.java
new file mode 100644
index 0000000..607ea78
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/LogicalLinkResponseTest.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class LogicalLinkResponseTest {
+
+ private LogicalLinkResponse createTestSubject() {
+ return new LogicalLinkResponse();
+ }
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(LogicalLinkResponse.class, hasValidGettersAndSetters());
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ModelTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ModelTest.java
new file mode 100644
index 0000000..13d6ea2
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ModelTest.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class ModelTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(Model.class, hasValidGettersAndSetters());
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ModelVerTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ModelVerTest.java
new file mode 100644
index 0000000..d0944c1
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ModelVerTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class ModelVerTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(ModelVer.class, hasValidGettersAndSetters());
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ModelVersTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ModelVersTest.java
new file mode 100644
index 0000000..3d32f87
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ModelVersTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class ModelVersTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(ModelVers.class, hasValidGettersAndSetters());
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/OwningEntityTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/OwningEntityTest.java
new file mode 100644
index 0000000..a38bdc6
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/OwningEntityTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class OwningEntityTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(OwningEntity.class, hasValidGettersAndSetters());
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/PnfPropertiesTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/PnfPropertiesTest.java
new file mode 100644
index 0000000..80989ef
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/PnfPropertiesTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.StringContains.containsString;
+
+public class PnfPropertiesTest {
+
+ private PnfProperties pnfProperties;
+
+ @Before
+ public void setUp(){
+ pnfProperties = new PnfProperties();
+ pnfProperties.setAdditionalProperty("key1", "value1");
+ pnfProperties.setAdditionalProperty("key2", "value2");
+ }
+
+ @Test
+ public void shouldHaveValidGettersAndSetters() throws IOException {
+ String result = new ObjectMapper().writeValueAsString(pnfProperties);
+ assertThat(result, containsString("key1"));
+ assertThat(result, containsString("value2"));
+ assertThat(result, containsString("key2"));
+ assertThat(result, containsString("value2"));
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/PnfResultTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/PnfResultTest.java
new file mode 100644
index 0000000..027c47e
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/PnfResultTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import java.io.IOException;
+
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.StringContains.containsString;
+
+public class PnfResultTest {
+
+ private PnfResult pnfResult;
+
+ @Before
+ public void setUp(){
+ pnfResult = new PnfResult();
+ pnfResult.setAdditionalProperty("key1", "value1");
+ pnfResult.setAdditionalProperty("key2", "value2");
+ }
+
+ @Test
+ public void shouldHaveValidGettersAndSetters() throws IOException {
+ String result = new ObjectMapper().writeValueAsString(pnfResult);
+ assertThat(result, containsString("key1"));
+ assertThat(result, containsString("value2"));
+ assertThat(result, containsString("key2"));
+ assertThat(result, containsString("value2"));
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ProjectResponseTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ProjectResponseTest.java
new file mode 100644
index 0000000..85719b7
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ProjectResponseTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class ProjectResponseTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(ProjectResponse.class, hasValidGettersAndSetters());
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ProjectTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ProjectTest.java
new file mode 100644
index 0000000..15d5ad4
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ProjectTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class ProjectTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(Project.class, hasValidGettersAndSetters());
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/RelatedToPropertyTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/RelatedToPropertyTest.java
new file mode 100644
index 0000000..9f7358c
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/RelatedToPropertyTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class RelatedToPropertyTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(RelatedToProperty.class, hasValidGettersAndSetters());
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/RelationshipDataTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/RelationshipDataTest.java
new file mode 100644
index 0000000..401e2f5
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/RelationshipDataTest.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+
+public class RelationshipDataTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters(){
+ assertThat(RelationshipData.class, hasValidGettersAndSetters());
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/RelationshipTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/RelationshipTest.java
new file mode 100644
index 0000000..6ec55e5
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/RelationshipTest.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+
+public class RelationshipTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(Relationship.class, hasValidGettersAndSetters());
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ResultTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ResultTest.java
new file mode 100644
index 0000000..f5e8a24
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ResultTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class ResultTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(Result.class, hasValidGettersAndSetters());
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ServiceRelationshipsTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ServiceRelationshipsTest.java
new file mode 100644
index 0000000..3b3f616
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/model/ServiceRelationshipsTest.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.model;
+
+import org.junit.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+
+public class ServiceRelationshipsTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(ServiceRelationships.class, hasValidGettersAndSetters());
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/util/AAIRestInterfaceTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/util/AAIRestInterfaceTest.java
new file mode 100644
index 0000000..ce038c3
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/util/AAIRestInterfaceTest.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+public class AAIRestInterfaceTest {
+
+ /*
+ TO BE IMPLEMENTED
+
+ private AAIRestInterface createTestSubject() {
+ return new AAIRestInterface("");
+ }
+
+ @Test
+ public void testEncodeURL() throws Exception {
+ AAIRestInterface testSubject;
+ String nodeKey = "";
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.encodeURL(nodeKey);
+ }
+
+ @Test
+ public void testSetRestSrvrBaseURL() throws Exception {
+ AAIRestInterface testSubject;
+ String baseURL = "";
+
+ // test 1
+ testSubject = createTestSubject();
+ baseURL = null;
+ testSubject.SetRestSrvrBaseURL(baseURL);
+
+ // test 2
+ testSubject = createTestSubject();
+ baseURL = "";
+ testSubject.SetRestSrvrBaseURL(baseURL);
+ }
+
+ @Test
+ public void testGetRestSrvrBaseURL() throws Exception {
+ AAIRestInterface testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRestSrvrBaseURL();
+ }
+
+
+ @Test
+ public void testRestPut() throws Exception {
+ AAIRestInterface testSubject;
+ String fromAppId = "";
+ String transId = "";
+ String path = "";
+ String payload = "";
+ boolean xml = false;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.RestPut(fromAppId, transId, path, payload, xml);
+ }
+
+ @Test
+ public void testRestPost() throws Exception {
+ AAIRestInterface testSubject;
+ String fromAppId = "";
+ String transId = "";
+ String path = "";
+ String payload = "";
+ boolean xml = false;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.RestPost(fromAppId, transId, path, payload, xml);
+ }*/
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/util/CustomJacksonJaxBJsonProviderTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/util/CustomJacksonJaxBJsonProviderTest.java
new file mode 100644
index 0000000..6b1029e
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/util/CustomJacksonJaxBJsonProviderTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationConfig;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.SerializationConfig;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CustomJacksonJaxBJsonProviderTest {
+
+ private CustomJacksonJaxBJsonProvider createTestSubject() {
+ return new CustomJacksonJaxBJsonProvider();
+ }
+
+ @Test
+ public void testMapperHasCorrectConfig() throws Exception {
+ CustomJacksonJaxBJsonProvider testSubject = createTestSubject();
+ DeserializationConfig deserializationConfig = testSubject.getMapper().getDeserializationConfig();
+ SerializationConfig serializationConfig = testSubject.getMapper().getSerializationConfig();
+
+ Assert.assertFalse(serializationConfig.hasSerializationFeatures(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS.getMask()));
+ Assert.assertFalse(serializationConfig.hasSerializationFeatures(SerializationFeature.INDENT_OUTPUT.getMask()));
+ Assert.assertFalse(serializationConfig.hasSerializationFeatures(SerializationFeature.WRAP_ROOT_VALUE.getMask()));
+ Assert.assertFalse(serializationConfig.hasSerializationFeatures(SerializationFeature.CLOSE_CLOSEABLE.getMask()));
+
+ Assert.assertFalse(deserializationConfig.hasDeserializationFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES.getMask()));
+ Assert.assertFalse(deserializationConfig.hasDeserializationFeatures(DeserializationFeature.UNWRAP_ROOT_VALUE.getMask()));
+
+ Assert.assertEquals(serializationConfig.getSerializationInclusion(), JsonInclude.Include.NON_NULL);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/util/HttpsAuthClientTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/util/HttpsAuthClientTest.java
new file mode 100644
index 0000000..9883e11
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/util/HttpsAuthClientTest.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import javax.net.ssl.SSLContext;
+
+import static org.mockito.Mockito.verify;
+
+@RunWith(MockitoJUnitRunner.class)
+public class HttpsAuthClientTest {
+ @Mock
+ private SystemPropertyHelper systemPropertyHelper;
+ @Mock
+ private SSLContextProvider sslContextProvider;
+ @Mock
+ private SSLContext sslContext;
+
+ public static final String CERT_FILE_PATH = "any_path";
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/util/ParametrizedAAIRestInterfaceTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/util/ParametrizedAAIRestInterfaceTest.java
new file mode 100644
index 0000000..b33aacf
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/util/ParametrizedAAIRestInterfaceTest.java
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.osam.aai.exceptions.InvalidPropertyException;
+import org.testng.Assert;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Optional;
+import java.util.UUID;
+
+import static javax.ws.rs.core.Response.Status.NO_CONTENT;
+import static javax.ws.rs.core.Response.Status.OK;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(Parameterized.class)
+public class ParametrizedAAIRestInterfaceTest {
+
+ private static final String PATH = "path";
+ private static final String HTTP_LOCALHOST = "http://localhost/";
+ @Mock
+ private Client client;
+ @Mock
+ private WebTarget webTarget;
+ @Mock
+ private Invocation.Builder builder;
+ @Mock
+ private ServletRequestHelper servletRequestHelper;
+ @Mock
+ private HttpsAuthClient httpsAuthClient;
+ @Mock
+ private HttpServletRequest httpServletRequest;
+ @Mock
+ private Response response;
+ @Mock
+ private SystemPropertyHelper systemPropertyHelper;
+
+ private AAIRestInterface testSubject;
+ private Response.Status status;
+
+ @Parameterized.Parameters
+ public static Collection<Object> data() {
+ return Arrays.asList(OK, NO_CONTENT);
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ mockSystemProperties();
+ testSubject = createTestSubject();
+ when(client.target(HTTP_LOCALHOST+PATH)).thenReturn(webTarget);
+ when(webTarget.request()).thenReturn(builder);
+ when(builder.accept(Mockito.anyString())).thenReturn(builder);
+ when(builder.header(Mockito.anyString(), Mockito.anyString())).thenReturn(builder);
+ when(servletRequestHelper.extractOrGenerateRequestId()).thenReturn(UUID.randomUUID().toString());
+ }
+
+ public ParametrizedAAIRestInterfaceTest(Response.Status status) {
+ this.status = status;
+ }
+
+ private AAIRestInterface createTestSubject() {
+ return new AAIRestInterface(Optional.of(client), httpsAuthClient, servletRequestHelper, systemPropertyHelper);
+ }
+
+ @Test
+ public void testRestDeleteWithValidResponse() throws Exception {
+ // given
+ String methodName = "Delete";
+
+ // when
+ when(builder.delete()).thenReturn(response);
+ when(response.getStatusInfo()).thenReturn(status);
+ boolean finalResponse = testSubject.Delete("", "", PATH);
+
+ // then
+ verify(builder).delete();
+ Assert.assertTrue(finalResponse);
+ }
+
+ private void mockSystemProperties() throws UnsupportedEncodingException, InvalidPropertyException {
+ when(systemPropertyHelper.getAAIServerUrl()).thenReturn(Optional.of(HTTP_LOCALHOST));
+ when(systemPropertyHelper.getAAIUseClientCert()).thenReturn(Optional.of("cert"));
+ when(systemPropertyHelper.getAAIVIDPasswd()).thenReturn(Optional.of("passwd"));
+ when(systemPropertyHelper.getAAIVIDUsername()).thenReturn(Optional.of("user"));
+ when(systemPropertyHelper.getEncodedCredentials()).thenReturn("someCredentials");
+ when(systemPropertyHelper.getFullServicePath(Mockito.anyString())).thenReturn("http://localhost/path");
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/aai/util/SingleAAIRestInterfaceTest.java b/onap-enabler-be/src/test/java/org/onap/osam/aai/util/SingleAAIRestInterfaceTest.java
new file mode 100644
index 0000000..5ec9b9e
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/aai/util/SingleAAIRestInterfaceTest.java
@@ -0,0 +1,310 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.aai.util;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.osam.aai.exceptions.InvalidPropertyException;
+import org.testng.Assert;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.UnsupportedEncodingException;
+import java.util.Optional;
+import java.util.UUID;
+
+import static javax.ws.rs.core.Response.Status.*;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SingleAAIRestInterfaceTest {
+
+ private static final String PATH = "path";
+ private static final String HTTP_LOCALHOST = "http://localhost/";
+ @Mock
+ private Client client;
+ @Mock
+ private WebTarget webTarget;
+ @Mock
+ private Invocation.Builder builder;
+ @Mock
+ private ServletRequestHelper servletRequestHelper;
+ @Mock
+ private HttpsAuthClient httpsAuthClient;
+ @Mock
+ private HttpServletRequest httpServletRequest;
+ @Mock
+ private Response response;
+ @Mock
+ private SystemPropertyHelper systemPropertyHelper;
+
+ private AAIRestInterface testSubject;
+
+ @Before
+ public void setUp() throws Exception {
+ mockSystemProperties();
+ testSubject = createTestSubject();
+ when(client.target(HTTP_LOCALHOST+PATH)).thenReturn(webTarget);
+ when(webTarget.request()).thenReturn(builder);
+ when(builder.accept(Mockito.anyString())).thenReturn(builder);
+ when(builder.header(Mockito.anyString(), Mockito.anyString())).thenReturn(builder);
+ when(servletRequestHelper.extractOrGenerateRequestId()).thenReturn(UUID.randomUUID().toString());
+ }
+
+ private AAIRestInterface createTestSubject() {
+ return new AAIRestInterface(Optional.of(client), httpsAuthClient, servletRequestHelper, systemPropertyHelper);
+ }
+
+ @Test
+ public void testEncodeURL() throws Exception {
+ String nodeKey = "some unusual uri";
+ Assert.assertEquals(testSubject.encodeURL(nodeKey), "some%20unusual%20uri");
+ }
+
+ @Test
+ public void testSetRestSrvrBaseURLWithNullValue() throws Exception {
+ testSubject.SetRestSrvrBaseURL(null);
+ }
+
+ @Test
+ public void testSetRestSrvrBaseURL() throws Exception {
+ String baseUrl = "anything";
+ testSubject.SetRestSrvrBaseURL(baseUrl);
+ Assert.assertEquals(testSubject.getRestSrvrBaseURL(), baseUrl);
+ }
+
+ @Test
+ public void testRestJsonPutWithResponse200() throws Exception {
+ // given
+ String methodName = "RestPut";
+ String payload = "{\"id\": 1}";
+ Entity<String> entity = Entity.entity(payload, MediaType.APPLICATION_JSON);
+
+ // when
+ when(builder.put(Mockito.any(Entity.class))).thenReturn(response);
+ when(response.getStatusInfo()).thenReturn(OK);
+ Response finalResponse = testSubject.RestPut("", PATH, payload, false);
+
+ // then
+ verify(builder).put(entity);
+ Assert.assertEquals(response, finalResponse);
+ }
+
+ @Test
+ public void testFailedRestJsonPut() throws Exception {
+ // given
+ String methodName = "RestPut";
+ String payload = "{\"id\": 1}";
+ Entity<String> entity = Entity.entity(payload, MediaType.APPLICATION_JSON);
+
+ // when
+ when(builder.put(Mockito.any(Entity.class))).thenThrow(new RuntimeException());
+ Response finalResponse = testSubject.RestPut("", PATH, payload, false);
+
+ // then
+ verify(builder).put(entity);
+ Assert.assertEquals(finalResponse, null);
+ }
+
+ @Test
+ public void testRestJsonPutWithResponse400() throws Exception {
+ // given
+ String methodName = "RestPut";
+ String payload = "{\"id\": 1}";
+ Entity<String> entity = Entity.entity(payload, MediaType.APPLICATION_JSON);
+
+ // when
+ when(builder.put(Mockito.any(Entity.class))).thenReturn(response);
+ when(response.getStatusInfo()).thenReturn(BAD_REQUEST);
+ when(response.getStatus()).thenReturn(BAD_REQUEST.getStatusCode());
+ Response finalResponse = testSubject.RestPut("", PATH, payload, false);
+
+ // then
+ verify(builder).put(entity);
+ Assert.assertEquals(response, finalResponse);
+ }
+
+ @Test
+ public void testRestPostWithResponse200() throws Exception {
+ // given
+ String methodName = "RestPost";
+ String payload = "{\"id\": 1}";
+ Entity<String> entity = Entity.entity(payload, MediaType.APPLICATION_JSON);
+
+ // when
+ when(builder.post(Mockito.any(Entity.class))).thenReturn(response);
+ when(response.getStatusInfo()).thenReturn(OK);
+ Response finalResponse = testSubject.RestPost("", PATH, payload, false);
+
+ // then
+ verify(builder).post(entity);
+ Assert.assertEquals(response, finalResponse);
+ }
+
+ @Test
+ public void testRestPostWithResponse400() throws Exception {
+ // given
+ String methodName = "RestPost";
+ String payload = "{\"id\": 1}";
+ Entity<String> entity = Entity.entity(payload, MediaType.APPLICATION_JSON);
+
+ // when
+ when(builder.post(Mockito.any(Entity.class))).thenReturn(response);
+ when(response.getStatusInfo()).thenReturn(BAD_REQUEST);
+ when(response.getStatus()).thenReturn(BAD_REQUEST.getStatusCode());
+ Response finalResponse = testSubject.RestPost("", PATH, payload, false);
+
+ // then
+ verify(builder).post(entity);
+ Assert.assertEquals(response, finalResponse);
+ }
+
+ @Test
+ public void testFailedRestPost() throws Exception {
+ // given
+ String methodName = "RestPost";
+ String payload = "{\"id\": 1}";
+ Entity<String> entity = Entity.entity(payload, MediaType.APPLICATION_JSON);
+
+ // when
+ when(builder.post(Mockito.any(Entity.class))).thenThrow(new RuntimeException());
+ Response finalResponse = testSubject.RestPost("", PATH, payload, false);
+
+ // then
+ verify(builder).post(entity);
+ Assert.assertEquals(finalResponse, null);
+ }
+
+ @Test
+ public void testRestDeleteWithResponse400() throws Exception {
+ // given
+ String methodName = "Delete";
+
+ // when
+ when(builder.delete()).thenReturn(response);
+ when(response.getStatusInfo()).thenReturn(BAD_REQUEST);
+ String reason = "Any reason";
+ when(response.readEntity(String.class)).thenReturn(reason);
+ when(response.getStatus()).thenReturn(BAD_REQUEST.getStatusCode());
+ boolean finalResponse = testSubject.Delete("", "", PATH);
+
+ // then
+ verify(builder).delete();
+ Assert.assertFalse(finalResponse);
+ }
+
+ @Test
+ public void testRestDeleteWithResponse404() throws Exception {
+ // given
+ String methodName = "Delete";
+
+ // when
+ when(builder.delete()).thenReturn(response);
+ when(response.getStatusInfo()).thenReturn(NOT_FOUND);
+ String reason = "Any reason";
+ when(response.readEntity(String.class)).thenReturn(reason);
+ when(response.getStatus()).thenReturn(NOT_FOUND.getStatusCode());
+ boolean finalResponse = testSubject.Delete("", "", PATH);
+
+ // then
+ verify(builder).delete();
+ Assert.assertFalse(finalResponse);
+ }
+
+ @Test
+ public void testFailedRestDelete() throws Exception {
+ // given
+ String methodName = "Delete";
+
+ // when
+ when(builder.delete()).thenThrow(new RuntimeException());
+ boolean finalResponse = testSubject.Delete("", "", PATH);
+
+ // then
+ verify(builder).delete();
+ Assert.assertFalse(finalResponse);
+ }
+
+ @Test
+ public void testRestJsonGetWithResponse200() throws Exception {
+ // given
+ String methodName = "RestGet";
+
+ // when
+ when(builder.get()).thenReturn(response);
+ when(response.getStatusInfo()).thenReturn(OK);
+ Response finalResponse = testSubject.RestGet("", "", PATH, false).getResponse();
+
+ // then
+ Assert.assertEquals(response, finalResponse);
+ }
+
+ @Test
+ public void testRestJsonGetWithResponse400() throws Exception {
+ // given
+ String methodName = "RestGet";
+
+ // when
+ when(builder.get()).thenReturn(response);
+ when(response.getStatusInfo()).thenReturn(BAD_REQUEST);
+ when(response.getStatus()).thenReturn(BAD_REQUEST.getStatusCode());
+ Response finalResponse = testSubject.RestGet("", "", PATH, false).getResponse();
+
+ // then
+ Assert.assertEquals(response, finalResponse);
+ }
+
+ @Test
+ public void testFailedRestGet() throws Exception {
+ // given
+ String methodName = "RestGet";
+
+ // when
+ when(builder.get()).thenThrow(new RuntimeException());
+ Response finalResponse = testSubject.RestGet("", "", PATH, false).getResponse();
+
+ // then
+ Assert.assertEquals(finalResponse, null);
+ }
+
+ private void mockSystemProperties() throws UnsupportedEncodingException, InvalidPropertyException {
+ when(systemPropertyHelper.getAAIServerUrl()).thenReturn(Optional.of(HTTP_LOCALHOST));
+ when(systemPropertyHelper.getAAIUseClientCert()).thenReturn(Optional.of("cert"));
+ when(systemPropertyHelper.getAAIVIDPasswd()).thenReturn(Optional.of("passwd"));
+ when(systemPropertyHelper.getAAIVIDUsername()).thenReturn(Optional.of("user"));
+ when(systemPropertyHelper.getEncodedCredentials()).thenReturn("someCredentials");
+ when(systemPropertyHelper.getFullServicePath(Mockito.anyString())).thenReturn("http://localhost/path");
+ when(systemPropertyHelper.getServiceBasePath(Mockito.anyString())).thenReturn("http://localhost/path");
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/bl/AaiServiceTest.java b/onap-enabler-be/src/test/java/org/onap/osam/bl/AaiServiceTest.java
new file mode 100644
index 0000000..ce5d632
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/bl/AaiServiceTest.java
@@ -0,0 +1,176 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.bl;
+
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.osam.aai.AaiClientInterface;
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.aai.model.*;
+import org.onap.osam.aai.model.AaiGetPnfs.Pnf;
+import org.onap.osam.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.osam.roles.Role;
+import org.onap.osam.roles.RoleValidator;
+import org.onap.osam.services.AaiServiceImpl;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.hamcrest.Matchers.arrayWithSize;
+import static org.hamcrest.Matchers.equalTo;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class AaiServiceTest {
+
+ @InjectMocks
+ private AaiServiceImpl aaiService;
+
+ @Mock
+ private AaiClientInterface aaiClientInterface;
+
+
+
+ @BeforeMethod
+ public void initMocks(){
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testGetSpecificPnf(){
+ Pnf pnf = new Pnf();
+ pnf.setPnfId("11111");
+ AaiResponse<Pnf> aaiResponse = new AaiResponse<>(pnf, "aaaa", 200);
+ Mockito.doReturn(aaiResponse).when(aaiClientInterface).getSpecificPnf(Mockito.anyString());
+ AaiResponse<Pnf> specificPnf = aaiService.getSpecificPnf("1345667");
+ assertNotNull(specificPnf);
+ pnf = specificPnf.getT();
+ assertNotNull(pnf);
+ assertEquals("11111",pnf.getPnfId());
+ assertEquals("aaaa",specificPnf.getErrorMessage());
+ assertEquals(200,specificPnf.getHttpCode());
+ }
+
+ @Test
+ public void testPnfByRegion(){
+ AaiGetPnfResponse aaiGetPnfResponse = new AaiGetPnfResponse();
+ AaiResponse<AaiGetPnfResponse> aaiResponse = new AaiResponse<>(aaiGetPnfResponse, "", 200);
+ Mockito.doReturn(aaiResponse).when(aaiClientInterface).getPNFData(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
+ AaiResponse<AaiGetPnfResponse> aaiGetPnfResponseWrapper = aaiService.getPNFData("1345667", "1345667", "1345667", "1345667", "1345667", "1345667", "1345667");
+ assertNotNull(aaiGetPnfResponseWrapper);
+ aaiGetPnfResponse = aaiGetPnfResponseWrapper.getT();
+ assertNotNull(aaiGetPnfResponse);
+ }
+
+ @Test
+ public void testGetAssociatedPnfs(){
+ ServiceRelationships serviceRelationships = createServiceRelationships();
+ AaiResponse<ServiceRelationships> aaiResponse = new AaiResponse<>(serviceRelationships, null, 200);
+ Mockito.doReturn(aaiResponse).when(aaiClientInterface).getServiceInstance(Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
+
+ LogicalLinkResponse logicalLinkResponse = createLogicalLinkResponse();
+ AaiResponse<LogicalLinkResponse> aaiResponse1 = new AaiResponse<>(logicalLinkResponse, null, 200);
+ Mockito.doReturn(aaiResponse1).when(aaiClientInterface).getLogicalLink("SANITY6758cce9%3ALAG1992%7CSANITY6785cce9%3ALAG1961");
+
+ List<String> pnfList = aaiService.getServiceInstanceAssociatedPnfs("123", "456", "789");
+ assertNotNull(pnfList);
+ assertEquals(1, pnfList.size());
+ assertEquals("SANITY6785cce9", pnfList.get(0));
+ }
+
+ private ServiceRelationships createServiceRelationships() {
+ ServiceRelationships serviceRelationships = new ServiceRelationships();
+ serviceRelationships.setServiceInstanceName("test service");
+
+ RelationshipData logicalLinksRelationshipData = new RelationshipData();
+ logicalLinksRelationshipData.setRelationshipKey("logical-link.link-name");
+ logicalLinksRelationshipData.setRelationshipValue("SANITY6758cce9:LAG1992|SANITY6785cce9:LAG1961");
+
+ Relationship logicalLinksRelationship = new Relationship();
+ logicalLinksRelationship.setRelatedTo("logical-link");
+ logicalLinksRelationship.setRelationDataList(Arrays.asList(logicalLinksRelationshipData));
+
+ RelationshipList logicalLinksRelationshipsList = new RelationshipList();
+ logicalLinksRelationshipsList.setRelationship(Arrays.asList(logicalLinksRelationship));
+
+ serviceRelationships.setRelationshipList(logicalLinksRelationshipsList);
+ return serviceRelationships;
+ }
+
+ private LogicalLinkResponse createLogicalLinkResponse() {
+ LogicalLinkResponse logicalLinkResponse = new LogicalLinkResponse();
+ logicalLinkResponse.setLinkName("SANITY6758cce9:LAG1992|SANITY6785cce9:LAG1961");
+
+ RelationshipData lagInterfaceRelationshipData = new RelationshipData();
+ lagInterfaceRelationshipData.setRelationshipKey("pnf.pnf-name");
+ lagInterfaceRelationshipData.setRelationshipValue("SANITY6785cce9");
+
+ Relationship lagInterfaceRelationship = new Relationship();
+ lagInterfaceRelationship.setRelatedTo("lag-interface");
+ lagInterfaceRelationship.setRelationDataList(Arrays.asList(lagInterfaceRelationshipData));
+
+ RelationshipList lagInterfaceRelationshipsList = new RelationshipList();
+ lagInterfaceRelationshipsList.setRelationship(Arrays.asList(lagInterfaceRelationship));
+
+ logicalLinkResponse.setRelationshipList(lagInterfaceRelationshipsList);
+
+ return logicalLinkResponse;
+ }
+
+ @DataProvider
+ public static Object[][] getTenantsData() {
+ return new Object[][] {
+ {"customer1", "serviceType1", "tenant1", "customer1", "serviceType1", "tenant1", "id-1", true},
+ {"customer1", "serviceType1", "TeNant1", "customer1", "serviceType1", "tenant1", "id-1", true},
+ {"customer1", "serviceType1", "TENANT1", "customer1", "serviceType1", "tenant1", "id-1", true},
+ {"customer1", "serviceType1", "tenant2", "customer1", "serviceType1", "tenant1", "tenant2", false},
+ {"customer1", "serviceType1", null, "customer1", "serviceType1", "tenant1", "tenant2", true},
+ {"customer2", "serviceType1", "tenant1", "customer1", "serviceType1", "tenant1", "id-1", false},
+ {"customer1", "serviceType2", "tenant1", "customer1", "serviceType1", "tenant1", "id-1", false},
+ {"customer2", "serviceType1", null, "customer1", "serviceType1", "tenant1", "id-1", false},
+ {"customer1", "serviceType2", null, "customer1", "serviceType1", "tenant1", "id-1", false},
+ };
+ }
+
+ @Test(dataProvider = "getTenantsData")
+ public void testGetTenants(String userGlobalCustomerId, String userServiceType, String userTenantName, String serviceGlobalCustomerId,
+ String serviceServiceType, String serviceTenantName, String serviceTenantId, boolean expectedIsPermitted) {
+ GetTenantsResponse[] getTenantsResponses = new GetTenantsResponse[] {new GetTenantsResponse(null, null, serviceTenantName, serviceTenantId, expectedIsPermitted)};
+ AaiResponse<GetTenantsResponse[]> aaiResponse = new AaiResponse<>(getTenantsResponses, null, 200);
+ Mockito.doReturn(aaiResponse).when(aaiClientInterface).getTenants(serviceGlobalCustomerId, serviceServiceType);
+ Role role = new Role(null, userGlobalCustomerId, userServiceType, userTenantName);
+ RoleValidator roleValidator = new RoleValidator(Collections.singletonList(role));
+ AaiResponse<GetTenantsResponse[]> actualTenants = aaiService.getTenants(serviceGlobalCustomerId, serviceServiceType, roleValidator);
+
+ assertThat(actualTenants.getT(), arrayWithSize(1));
+ assertThat(actualTenants.getT()[0].tenantName, equalTo(serviceTenantName));
+ //assertThat(actualTenants.getT()[0].isPermitted, equalTo(expectedIsPermitted));
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/client/HttpBasicClientTest.java b/onap-enabler-be/src/test/java/org/onap/osam/client/HttpBasicClientTest.java
new file mode 100644
index 0000000..3b29cf3
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/client/HttpBasicClientTest.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.client;
+
+import org.junit.Test;
+
+public class HttpBasicClientTest {
+
+ private HttpBasicClient createTestSubject() {
+ return new HttpBasicClient();
+ }
+
+ @Test
+ public void testGetClient() throws Exception {
+ // default test
+ HttpBasicClient.getClient();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/client/HttpsBasicClientTest.java b/onap-enabler-be/src/test/java/org/onap/osam/client/HttpsBasicClientTest.java
new file mode 100644
index 0000000..048dd8b
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/client/HttpsBasicClientTest.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.client;
+
+import org.junit.Test;
+
+public class HttpsBasicClientTest {
+
+ private HttpsBasicClient createTestSubject() {
+ return new HttpsBasicClient();
+ }
+
+ @Test
+ public void testGetClient() throws Exception {
+
+ // default test
+ HttpsBasicClient.getClient();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/client/SyncRestClientForHttpServerTest.java b/onap-enabler-be/src/test/java/org/onap/osam/client/SyncRestClientForHttpServerTest.java
new file mode 100644
index 0000000..28e899e
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/client/SyncRestClientForHttpServerTest.java
@@ -0,0 +1,270 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.client;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableMap;
+import com.xebialabs.restito.semantics.Condition;
+import com.xebialabs.restito.server.StubServer;
+import io.joshworks.restclient.http.HttpResponse;
+import io.joshworks.restclient.http.JsonNode;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import com.xebialabs.restito.semantics.Action;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.AfterMethod;
+import org.glassfish.grizzly.http.Method;
+import org.testng.annotations.Test;
+
+import java.util.Collections;
+import java.util.Map;
+
+import static com.xebialabs.restito.builder.verify.VerifyHttp.verifyHttp;
+import static com.xebialabs.restito.builder.stub.StubHttp.whenHttp;
+import static com.xebialabs.restito.semantics.Action.stringContent;
+import static com.xebialabs.restito.semantics.Action.contentType;
+import static com.xebialabs.restito.semantics.Action.status;
+import static com.xebialabs.restito.semantics.Action.ok;
+import static org.testng.Assert.assertEquals;
+
+public class SyncRestClientForHttpServerTest {
+
+ private static final SyncRestClientModel.TestModel testObject = new SyncRestClientModel.TestModel(1, "test");
+ private static final String NOT_EXISTING_OBJECT = "NOT EXISTING OBJECT";
+
+ private StubServer stubServer;
+ private ObjectMapper objectMapper = new ObjectMapper();
+ private SyncRestClient syncRestClient;
+
+ @BeforeMethod
+ public void setUp() {
+ stubServer = new StubServer();
+ stubServer.run();
+ syncRestClient = new SyncRestClient();
+ }
+
+ @AfterMethod
+ public void tearDown() {
+ stubServer.stop();
+ syncRestClient.destroy();
+ }
+
+ @Test
+ public void testJsonResponseFromGet() throws JsonProcessingException {
+ // given
+ stubGetCall();
+ String url = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient
+ .get(url, Collections.emptyMap(), Collections.emptyMap());
+ // then
+ verifyHttp(stubServer).once(Condition.method(Method.GET), Condition.url(url));
+ assertEquals(jsonNodeHttpResponse.getStatus(), 200);
+ assertEquals(jsonNodeHttpResponse.getBody().getObject().get("key"), 1);
+ assertEquals(jsonNodeHttpResponse.getBody().getObject().get("value"), "test");
+ }
+
+ @Test
+ public void testObjectResponseFromGet() throws JsonProcessingException {
+ // given
+ stubGetCall();
+ String url = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<SyncRestClientModel.TestModel> testModelHttpResponse = syncRestClient
+ .get(url, Collections.emptyMap(), Collections.emptyMap(), SyncRestClientModel.TestModel.class);
+ // then
+ verifyHttp(stubServer).once(Condition.method(Method.GET), Condition.url(url));
+ assertEquals(testModelHttpResponse.getStatus(), 200);
+ assertEquals(testModelHttpResponse.getBody().getKey(), 1);
+ assertEquals(testModelHttpResponse.getBody().getValue(), "test");
+ }
+
+ @Test
+ public void testJsonResponseFromPost() throws JsonProcessingException {
+ // given
+ stubPostCall();
+ String url = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient.post(url, Collections.emptyMap(), testObject);
+ // then
+ verifyHttp(stubServer).once(Condition.method(Method.POST), Condition.url(url));
+ assertEquals(jsonNodeHttpResponse.getStatus(), 200);
+ assertEquals(jsonNodeHttpResponse.getBody().getObject().get("key"), 1);
+ assertEquals(jsonNodeHttpResponse.getBody().getObject().get("value"), "test");
+ }
+
+ @Test
+ public void test404JsonResponseFromPost() throws JsonProcessingException {
+ // given
+ stubPostCall();
+ String url = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient
+ .post(url, Collections.emptyMap(), NOT_EXISTING_OBJECT);
+ // then
+ assertEquals(jsonNodeHttpResponse.getStatus(), 404);
+ assertEquals(jsonNodeHttpResponse.getStatusText(), "Not Found");
+ }
+
+ @Test
+ public void testHeadersWerePassedToPost() throws JsonProcessingException {
+ // given
+ stubPostCall();
+ Map headers = ImmutableMap.<String, String>builder().put("Authorization", "Basic anyHash").build();
+ String url = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient.post(url, headers, testObject);
+ // then
+ verifyHttp(stubServer).once(Condition.withHeader("Authorization"));
+ assertEquals(jsonNodeHttpResponse.getStatus(), 200);
+ }
+
+ @Test(expectedExceptions = {Exception.class})
+ public void testFailedJsonResponseFromPost() throws JsonProcessingException {
+ // given
+ stubPostCall();
+ String url = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ stubServer.stop();
+ syncRestClient.post(url, Collections.emptyMap(), testObject);
+ }
+
+ @Test
+ public void testObjectResponseFromPost() throws JsonProcessingException {
+ // given
+ stubPostCall();
+ String url = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<SyncRestClientModel.TestModel> objectHttpResponse = syncRestClient
+ .post(url, Collections.emptyMap(), testObject, SyncRestClientModel.TestModel.class);
+ // then
+ verifyHttp(stubServer).once(Condition.method(Method.POST), Condition.url(url));
+ assertEquals(objectHttpResponse.getStatus(), 200);
+ assertEquals(objectHttpResponse.getBody().getKey(), 1);
+ assertEquals(objectHttpResponse.getBody().getValue(), "test");
+ }
+
+ @Test
+ public void testJsonResponseFromPut() throws JsonProcessingException {
+ // given
+ stubPutCall();
+ String url = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient.put(url, Collections.emptyMap(), testObject);
+ // then
+ verifyHttp(stubServer).once(Condition.method(Method.PUT), Condition.url(url));
+ assertEquals(jsonNodeHttpResponse.getStatus(), 201);
+ assertEquals(jsonNodeHttpResponse.getBody().getObject().get("key"), 1);
+ assertEquals(jsonNodeHttpResponse.getBody().getObject().get("value"), "test");
+ }
+
+ @Test
+ public void testObjectResponseFromPut() throws JsonProcessingException {
+ // given
+ stubPutCall();
+ String url = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<SyncRestClientModel.TestModel> modelHttpResponse = syncRestClient
+ .put(url, Collections.emptyMap(), testObject, SyncRestClientModel.TestModel.class);
+ // then
+ verifyHttp(stubServer).once(Condition.method(Method.PUT), Condition.url(url));
+ assertEquals(modelHttpResponse.getStatus(), 201);
+ assertEquals(modelHttpResponse.getBody().getKey(), 1);
+ assertEquals(modelHttpResponse.getBody().getValue(), "test");
+ }
+
+ @Test
+ public void testJsonResponseFromDelete() throws JsonProcessingException {
+ // given
+ stubDeleteCall();
+ String url = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient.delete(url, Collections.emptyMap());
+ // then
+ verifyHttp(stubServer).once(Condition.method(Method.DELETE), Condition.url(url));
+ assertEquals(jsonNodeHttpResponse.getStatus(), 200);
+ assertEquals(jsonNodeHttpResponse.getBody().getObject().get("key"), 1);
+ assertEquals(jsonNodeHttpResponse.getBody().getObject().get("value"), "test");
+ }
+
+ @Test
+ public void testObjectResponseFromDelete() throws JsonProcessingException {
+ // given
+ stubDeleteCall();
+ String url = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<SyncRestClientModel.TestModel> modelHttpResponse = syncRestClient
+ .delete(url, Collections.emptyMap(), SyncRestClientModel.TestModel.class);
+ // then
+ verifyHttp(stubServer).once(Condition.method(Method.DELETE), Condition.url(url));
+ assertEquals(modelHttpResponse.getStatus(), 200);
+ assertEquals(modelHttpResponse.getBody().getKey(), 1);
+ assertEquals(modelHttpResponse.getBody().getValue(), "test");
+ }
+
+ @Test
+ public void testRedirectToHttp() throws JsonProcessingException {
+ // given
+ stubGetCall();
+ String secured_url = "https://0.0.0.0:" + stubServer.getPort() + "/test";
+ String available_url = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient
+ .get(secured_url, Collections.emptyMap(), Collections.emptyMap());
+ // then
+ verifyHttp(stubServer).once(Condition.method(Method.GET), Condition.url(available_url),
+ Condition.not(Condition.url(secured_url)));
+ assertEquals(jsonNodeHttpResponse.getStatus(), 200);
+ }
+
+ private void stubGetCall() throws JsonProcessingException {
+ whenHttp(stubServer)
+ .match(Condition.get("/test"))
+ .then(ok(), jsonContent(), contentType("application/json"));
+ }
+
+ private void stubDeleteCall() throws JsonProcessingException {
+ whenHttp(stubServer)
+ .match(Condition.delete("/test"))
+ .then(ok(), jsonContent(), contentType("application/json"));
+ }
+
+ private void stubPostCall() throws JsonProcessingException {
+ whenHttp(stubServer)
+ .match(Condition.post("/test"),
+ Condition.withPostBodyContaining(objectMapper.writeValueAsString(testObject)))
+ .then(ok(), jsonContent(), contentType("application/json"));
+ }
+
+ private void stubPutCall() throws JsonProcessingException {
+ whenHttp(stubServer)
+ .match(Condition.put("/test"),
+ Condition.withPostBodyContaining(objectMapper.writeValueAsString(testObject)))
+ .then(status(HttpStatus.CREATED_201), jsonContent(), contentType("application/json"));
+ }
+
+ private Action jsonContent() throws JsonProcessingException {
+ return stringContent(objectMapper.writeValueAsString(testObject));
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/client/SyncRestClientForHttpsServerTest.java b/onap-enabler-be/src/test/java/org/onap/osam/client/SyncRestClientForHttpsServerTest.java
new file mode 100644
index 0000000..9450f27
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/client/SyncRestClientForHttpsServerTest.java
@@ -0,0 +1,140 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.client;
+
+import io.joshworks.restclient.http.HttpResponse;
+import io.joshworks.restclient.http.JsonNode;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.conn.ssl.SSLContextBuilder;
+import com.xebialabs.restito.semantics.Condition;
+import com.xebialabs.restito.server.StubServer;
+import com.xebialabs.restito.semantics.Action;
+import org.apache.http.config.RegistryBuilder;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.AfterMethod;
+import org.glassfish.grizzly.http.Method;
+import org.apache.http.config.Registry;
+import org.testng.annotations.Test;
+
+import java.security.GeneralSecurityException;
+import javax.net.ssl.SSLContext;
+import java.util.Collections;
+
+import static com.xebialabs.restito.builder.verify.VerifyHttp.verifyHttp;
+import static com.xebialabs.restito.builder.stub.StubHttp.whenHttp;
+import static com.xebialabs.restito.semantics.Action.stringContent;
+import static com.xebialabs.restito.semantics.Action.contentType;
+import static org.apache.http.client.config.RequestConfig.custom;
+import static com.xebialabs.restito.semantics.Action.ok;
+import static org.testng.Assert.assertEquals;
+
+public class SyncRestClientForHttpsServerTest {
+
+ private static final SyncRestClientModel.TestModel testObject = new SyncRestClientModel.TestModel(1, "test");
+ private static final String[] SUPPORTED_PROTOCOLS = {"TLSv1", "TLSv1.2"};
+ private StubServer stubServer;
+ private ObjectMapper objectMapper = new ObjectMapper();
+
+ private SyncRestClient syncRestClient;
+
+ @BeforeMethod
+ public void setUp() throws GeneralSecurityException {
+ stubServer = new StubServer();
+ stubServer.secured().run();
+ syncRestClient = new SyncRestClient(createNaiveHttpClient());
+ }
+
+ @AfterMethod
+ public void tearDown() {
+ stubServer.stop();
+ }
+
+ @Test
+ public void testJsonResponseFromGet() throws JsonProcessingException {
+ // given
+ stubGetCall();
+ String securedUrl = "https://0.0.0.0:" + stubServer.getPort() + "/test";
+ String notSecuredUrl = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient
+ .get(securedUrl, Collections.emptyMap(), Collections.emptyMap());
+ // then
+ verifyHttp(stubServer)
+ .once(Condition.method(Method.GET), Condition.url(securedUrl), Condition.not(Condition.url(notSecuredUrl)));
+ assertEquals(jsonNodeHttpResponse.getStatus(), 200);
+ assertEquals(jsonNodeHttpResponse.getBody().getObject().get("key"), 1);
+ assertEquals(jsonNodeHttpResponse.getBody().getObject().get("value"), "test");
+ }
+
+ @Test
+ public void testObjectResponseFromGet() throws JsonProcessingException {
+ // given
+ stubServer.run();
+ stubGetCall();
+ String securedUrl = "https://0.0.0.0:" + stubServer.getPort() + "/test";
+ String notSecuredUrl = "http://0.0.0.0:" + stubServer.getPort() + "/test";
+ // when
+ HttpResponse<SyncRestClientModel.TestModel> testModelHttpResponse = syncRestClient
+ .get(securedUrl, Collections.emptyMap(), Collections.emptyMap(), SyncRestClientModel.TestModel.class);
+ // then
+ verifyHttp(stubServer)
+ .once(Condition.method(Method.GET), Condition.url(securedUrl), Condition.not(Condition.url(notSecuredUrl)));
+ assertEquals(testModelHttpResponse.getStatus(), 200);
+ assertEquals(testModelHttpResponse.getBody().getKey(), 1);
+ assertEquals(testModelHttpResponse.getBody().getValue(), "test");
+ }
+
+ private Action jsonContent() throws JsonProcessingException {
+ return stringContent(objectMapper.writeValueAsString(testObject));
+ }
+
+ private void stubGetCall() throws JsonProcessingException {
+ whenHttp(stubServer)
+ .match(Condition.get("/test"))
+ .then(ok(), jsonContent(), contentType("application/json"));
+ }
+
+ private CloseableHttpClient createNaiveHttpClient() throws GeneralSecurityException {
+ final SSLContext context = new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy())
+ .build();
+
+ final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(context, SUPPORTED_PROTOCOLS,
+ null, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+ Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
+ .register("https", socketFactory)
+ .build();
+
+ return HttpClientBuilder.create()
+ .setDefaultRequestConfig(custom().setConnectionRequestTimeout(10000).build())
+ .setConnectionManager(new PoolingHttpClientConnectionManager(registry))
+ .setSSLSocketFactory(socketFactory).build();
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/client/SyncRestClientModel.java b/onap-enabler-be/src/test/java/org/onap/osam/client/SyncRestClientModel.java
new file mode 100644
index 0000000..94f5ac2
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/client/SyncRestClientModel.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.client;
+
+class SyncRestClientModel {
+
+ static class TestModel{
+
+ public TestModel() {
+ // needed by the object mappers
+ }
+
+ public TestModel(long key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ private long key;
+ private String value;
+
+ public void setKey(long key) {
+ this.key = key;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public long getKey() {
+ return key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/config/DataSourceConfig.java b/onap-enabler-be/src/test/java/org/onap/osam/config/DataSourceConfig.java
new file mode 100644
index 0000000..46f2b0e
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/config/DataSourceConfig.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.config;
+
+
+import org.hibernate.SessionFactory;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.portalsdk.core.service.DataAccessServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.jdbc.datasource.DriverManagerDataSource;
+import org.springframework.orm.hibernate4.HibernateTransactionManager;
+import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import javax.sql.DataSource;
+import java.util.Properties;
+
+@Configuration
+@EnableTransactionManagement
+public class DataSourceConfig {
+
+ @Bean
+ @Autowired
+ public LocalSessionFactoryBean sessionFactory(DataSource dataSource) {
+ LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
+ sessionFactory.setDataSource(dataSource);
+ //I used this class org.openecomp.portalsdk.core.conf.HibernateConfiguration to learn how to config the session factory
+ // and use the following url for actual h2 properties
+ //https://github.com/levi-putna/Hibernate-H2-Example/blob/master/hibernate-h2-example/src/hibernate.cfg.xml
+ Properties properties = getH2Properties();
+
+ properties.put("hibernate.default_schema", "PUBLIC");
+ properties.put("connection.pool_size", 10);
+ properties.put("cache.provider_class", "org.hibernate.cache.internal.NoCacheProvider");
+ properties.put("hibernate.show_sql", false);
+ properties.put("hbm2ddl.auto", "create");
+ properties.put("hibernate.hbm2ddl.auto", "create");
+
+ sessionFactory.setHibernateProperties(properties);
+ sessionFactory.setPackagesToScan("org.onap");
+ return sessionFactory;
+ }
+
+ @Bean
+ public DataSource getDataSource() {
+ DriverManagerDataSource dataSource = new DriverManagerDataSource();
+ dataSource.setDriverClassName("org.h2.Driver");
+ dataSource.setUrl("jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1");
+ dataSource.setUsername("sa");
+ dataSource.setPassword("");
+ return dataSource;
+ }
+
+ public Properties getH2Properties() {
+ Properties properties = new Properties();
+ properties.put("dialect", "org.hibernate.dialect.H2Dialect");
+ return properties;
+ }
+
+ public Properties getSqliteProperties() {
+ Properties properties = new Properties();
+ properties.put("connection.driver_class", "org.sqlite.JDBC");
+ properties.put("connection.url", "jdbc:sqlite:memory:myDb");
+ properties.put("connection.username", "sa");
+ properties.put("connection.password", "sa");
+ properties.put("dialect", "com.enigmabridge.hibernate.dialect.SQLiteDialect");
+ return properties;
+ }
+
+ @Bean
+ public DataAccessService dataAccessService() {
+ return new DataAccessServiceImpl();
+ }
+
+ @Bean
+ @Autowired
+ public PlatformTransactionManager transactionManager(SessionFactory sessionFactory) {
+ return new HibernateTransactionManager(sessionFactory);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/config/JobAdapterConfig.java b/onap-enabler-be/src/test/java/org/onap/osam/config/JobAdapterConfig.java
new file mode 100644
index 0000000..754b114
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/config/JobAdapterConfig.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.config;
+
+
+import org.hibernate.SessionFactory;
+import org.onap.osam.job.JobAdapter;
+import org.onap.osam.job.JobsBrokerService;
+import org.onap.osam.job.impl.JobAdapterImpl;
+import org.onap.osam.job.impl.JobsBrokerServiceInDatabaseImpl;
+import org.onap.osam.properties.VidProperties;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@Configuration
+@EnableTransactionManagement
+public class JobAdapterConfig {
+
+ @Bean
+ public JobAdapter jobAdapter() {
+ return new JobAdapterImpl();
+ }
+
+ @Bean
+ public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory) {
+ int maxOpenedInstantiationRequestsToMso = Integer.parseInt(SystemProperties.getProperty(VidProperties.MSO_MAX_OPENED_INSTANTIATION_REQUESTS));
+ int pollingIntervalSeconds = Integer.parseInt(SystemProperties.getProperty(VidProperties.MSO_ASYNC_POLLING_INTERVAL_SECONDS));
+
+ return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, maxOpenedInstantiationRequestsToMso, pollingIntervalSeconds);
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/config/JobCommandsConfigWithMockedMso.java b/onap-enabler-be/src/test/java/org/onap/osam/config/JobCommandsConfigWithMockedMso.java
new file mode 100644
index 0000000..8f88b1e
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/config/JobCommandsConfigWithMockedMso.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.config;
+
+import org.hibernate.SessionFactory;
+import org.mockito.Mockito;
+import org.onap.osam.services.IAsyncInstantiationBusinessLogic;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.osam.aai.AaiClientInterface;
+import org.onap.osam.aai.util.HttpsAuthClient;
+import org.onap.osam.aai.util.SSLContextProvider;
+import org.onap.osam.aai.util.SystemPropertyHelper;
+import org.onap.osam.job.JobAdapter;
+import org.onap.osam.job.JobsBrokerService;
+import org.onap.osam.job.command.InProgressStatusCommand;
+import org.onap.osam.job.command.JobCommandFactory;
+import org.onap.osam.job.command.ServiceInstantiationCommand;
+import org.onap.osam.job.impl.JobAdapterImpl;
+import org.onap.osam.job.impl.JobWorker;
+import org.onap.osam.job.impl.JobsBrokerServiceInDatabaseImpl;
+import org.onap.osam.mso.RestMsoImplementation;
+import org.onap.osam.services.AsyncInstantiationBusinessLogicImpl;
+import org.onap.osam.services.IAuditService;
+import org.onap.osam.services.AuditServiceImpl;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Scope;
+
+@Configuration
+public class JobCommandsConfigWithMockedMso {
+
+ @Bean
+ public RestMsoImplementation restMso() {
+ return Mockito.mock(RestMsoImplementation.class);
+ }
+
+ @Bean
+ public JobsBrokerService jobsBrokerService(DataAccessService dataAccessService, SessionFactory sessionFactory) {
+ return new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0);
+ }
+
+ @Bean
+ public HttpsAuthClient httpsAuthClientFactory(){
+ return new HttpsAuthClient("some random path", new SystemPropertyHelper(), new SSLContextProvider());
+ }
+
+ @Bean
+ public JobAdapter jobAdapter() {
+ return new JobAdapterImpl();
+ }
+
+ @Bean
+ public JobCommandFactory jobCommandFactory(ApplicationContext applicationContext) {
+ return new JobCommandFactory(applicationContext);
+ }
+
+ @Bean
+ public JobWorker jobWorker(JobsBrokerService jobsBrokerService, JobCommandFactory jobCommandFactory) {
+ JobWorker jobWorker = new JobWorker();
+ jobWorker.setJobsBrokerService(jobsBrokerService);
+ jobWorker.setJobCommandFactory(jobCommandFactory);
+ return jobWorker;
+ }
+
+ @Bean
+ public IAsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic(DataAccessService dataAccessService,
+ JobAdapter jobAdapter,
+ JobsBrokerService jobsBrokerService,
+ SessionFactory sessionFactory,
+ AaiClientInterface aaiClient) {
+ return new AsyncInstantiationBusinessLogicImpl(dataAccessService, jobAdapter, jobsBrokerService, sessionFactory, aaiClient);
+ }
+
+ @Bean
+ @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+ public ServiceInstantiationCommand serviceInstantiationCommand() {
+ return new ServiceInstantiationCommand();
+ }
+
+ @Bean
+ @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+ public InProgressStatusCommand inProgressStatusCommand() {
+ return new InProgressStatusCommand();
+ }
+
+ @Bean
+ public IAuditService auditService() {
+ return new AuditServiceImpl();
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/config/MockedAaiClientAndFeatureManagerConfig.java b/onap-enabler-be/src/test/java/org/onap/osam/config/MockedAaiClientAndFeatureManagerConfig.java
new file mode 100644
index 0000000..c1a0f68
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/config/MockedAaiClientAndFeatureManagerConfig.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.config;
+
+import org.mockito.Mockito;
+import org.onap.osam.aai.AaiClientInterface;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.togglz.core.manager.FeatureManager;
+
+@Configuration
+public class MockedAaiClientAndFeatureManagerConfig {
+
+ @Bean
+ public FeatureManager featureManager() {
+ return Mockito.mock(FeatureManager.class);
+ }
+
+ @Bean
+ public AaiClientInterface aaiClient() {
+ return Mockito.mock(AaiClientInterface.class);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controller/ClientCredentialsFilterTest.java b/onap-enabler-be/src/test/java/org/onap/osam/controller/ClientCredentialsFilterTest.java
new file mode 100644
index 0000000..6ef2fcc
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controller/ClientCredentialsFilterTest.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controller;
+
+
+import org.junit.Assert;
+import org.mockito.Mockito;
+import org.onap.osam.filters.ClientCredentialsFilter;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+import static org.mockito.Matchers.any;
+
+
+@Test
+public class ClientCredentialsFilterTest {
+
+ @DataProvider
+ public static Object[][] authorizedData() {
+ return new Object[][] {
+ {"Basic 123==", null},
+ {null, null},
+ {null, ""},
+ {"Basic 123==", ""},
+ {"Basic 123==", "Basic 123=="}
+ };
+ }
+
+ @DataProvider
+ public static Object[][] notAuthorizedData() {
+ return new Object[][] {
+ {null, "Basic 123=="},
+ {"", "Basic 123=="},
+ {"not null but not as expected", "Basic 123=="},
+ {"basic 123==", "Basic 123=="}
+ };
+ }
+
+ @DataProvider
+ public static Object[][] clientVerified() {
+ return new Object[][] {
+ {true},
+ {false}
+ };
+ }
+
+ @Test(dataProvider = "authorizedData")
+ public void givenAuthorizationHeader_Authorized(String actualAuth, String expectedAuth){
+ ClientCredentialsFilter filter = new ClientCredentialsFilter();
+ Assert.assertTrue(filter.verifyClientCredentials(actualAuth, expectedAuth));
+ }
+
+ @Test(dataProvider = "notAuthorizedData")
+ public void givenAuthorizationHeader_NotAuthorized(String actualAuth, String expectedAuth){
+ ClientCredentialsFilter filter = new ClientCredentialsFilter();
+ Assert.assertFalse(filter.verifyClientCredentials(actualAuth, expectedAuth));
+ }
+
+ //@Test(dataProvider = "clientVerified")
+ public void notAuthorized_return401(Boolean clientVerified) throws IOException, ServletException {
+ ClientCredentialsFilter filter = Mockito.mock(ClientCredentialsFilter.class);
+ HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
+ HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+ FilterChain chain = Mockito.mock(FilterChain.class);
+
+
+ Mockito.when(filter.verifyClientCredentials(any(String.class),any(String.class))).thenReturn(clientVerified);
+ Mockito.doNothing().when(response).sendError(401);
+
+ Mockito.doCallRealMethod().when(filter).doFilter(request,response,chain);
+ filter.doFilter(request,response,chain);
+
+ if (clientVerified)
+ {
+ Mockito.verify(chain).doFilter(request,response);
+
+ }
+ else {
+ Mockito.verify(response).sendError(401);
+ }
+
+ }
+
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controller/LocalWebConfig.java b/onap-enabler-be/src/test/java/org/onap/osam/controller/LocalWebConfig.java
new file mode 100644
index 0000000..97fe380
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controller/LocalWebConfig.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controller;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.osam.aai.AaiClient;
+import org.onap.osam.aai.AaiClientInterface;
+import org.onap.osam.aai.model.PortDetailsTranslator;
+import org.onap.osam.aai.util.AAIRestInterface;
+import org.onap.osam.aai.util.HttpsAuthClient;
+import org.onap.osam.aai.util.SSLContextProvider;
+import org.onap.osam.aai.util.ServletRequestHelper;
+import org.onap.osam.aai.util.SystemPropertyHelper;
+import org.onap.osam.services.AaiServiceImpl;
+import org.onap.osam.services.IAaiService;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.servlet.ServletContext;
+import java.io.File;
+
+@Configuration
+public class LocalWebConfig {
+
+ @Bean
+ public ObjectMapper getObjectMapper() {
+ return new ObjectMapper();
+ }
+
+
+ @Bean
+ public IAaiService getAaiService() {
+ return new AaiServiceImpl();
+ }
+
+ @Bean
+ public SSLContextProvider sslContextProvider() {
+ return new SSLContextProvider();
+ }
+
+ @Bean
+ public SystemPropertyHelper systemPropertyHelper() {
+ return new SystemPropertyHelper();
+ }
+
+ @Bean
+ public ServletRequestHelper servletRequestHelper() {
+ return new ServletRequestHelper();
+ }
+
+ @Bean
+ public HttpsAuthClient httpsAuthClientFactory(ServletContext servletContext, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider) {
+ final String certFilePath = new File(servletContext.getRealPath("/WEB-INF/cert/")).getAbsolutePath();
+ return new HttpsAuthClient(certFilePath, systemPropertyHelper, sslContextProvider);
+ }
+
+ @Bean(name = "aaiRestInterface")
+ public AAIRestInterface aaiRestInterface(HttpsAuthClient httpsAuthClientFactory, ServletRequestHelper servletRequestHelper, SystemPropertyHelper systemPropertyHelper) {
+ return new AAIRestInterface(httpsAuthClientFactory, servletRequestHelper, systemPropertyHelper);
+ }
+
+ @Bean
+ public AaiClientInterface getAaiClientInterface(@Qualifier("aaiRestInterface")AAIRestInterface aaiRestInterface, PortDetailsTranslator portDetailsTranslator) {
+ return new AaiClient(aaiRestInterface, portDetailsTranslator);
+ }
+
+ @Bean
+ public PortDetailsTranslator portDetailsTranslator(){
+ return new PortDetailsTranslator();
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controller/MsoControllerTest.java b/onap-enabler-be/src/test/java/org/onap/osam/controller/MsoControllerTest.java
new file mode 100644
index 0000000..141a78b
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controller/MsoControllerTest.java
@@ -0,0 +1,130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controller;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.controllers.MsoConfig;
+import org.onap.osam.controllers.MsoController;
+import org.onap.osam.domain.mso.RequestInfo;
+import org.onap.osam.factories.MsoRequestFactory;
+import org.onap.osam.mso.rest.Request;
+import org.onap.osam.mso.rest.RequestDetails;
+import org.onap.osam.mso.rest.Task;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+
+@WebAppConfiguration
+@ContextConfiguration(classes = {SystemProperties.class, MsoConfig.class})
+public class MsoControllerTest extends AbstractTestNGSpringContextTests {
+
+ @Autowired
+ MsoRequestFactory msoRequestFactory;
+
+ @Test(enabled = false)
+ public void testInstanceCreationNew() throws Exception {
+
+ RequestDetails requestDetails = msoRequestFactory.createMsoRequest("msoRequest.json");
+ MsoController msoController = new MsoController(null);
+ //TODO: make ths test to really test something
+ //ResponseEntity<String> responseEntityNew = msoController.createSvcInstanceNew(null, requestDetails);
+ ResponseEntity<String> responseEntity = msoController.createSvcInstance(null, requestDetails);
+ //Assert.assertEquals(responseEntityNew, responseEntity);
+
+ }
+
+ @Test(enabled = false)
+ public void testInstanceCreationLocalWithRest() throws Exception {
+
+ RequestDetails requestDetails = msoRequestFactory.createMsoRequest("msoRequest.json");
+ MsoController msoController = new MsoController(null);
+ ResponseEntity<String> responseEntityNew = msoController.createSvcInstance(null, requestDetails);
+ //TODO: make ths test to really test something
+// ResponseEntity<String> responseEntityRest = msoController.createSvcInstanceNewRest(null, requestDetails);
+//
+// Assert.assertEquals(responseEntityNew.getBody(), responseEntityRest.getBody());
+
+ }
+
+ @Test(enabled = false)
+ public void testInstanceCreation() throws Exception {
+
+ RequestDetails requestDetails = msoRequestFactory.createMsoRequest("msoRequest.json");
+ MsoController msoController = new MsoController(null);
+ ResponseEntity<String> responseEntity = msoController.createSvcInstance(null, requestDetails);
+
+
+ Assert.assertEquals(responseEntity.getBody(), "{ \"status\": 200, \"entity\": {\n" +
+ " \"requestReferences\": {\n" +
+ " \"instanceId\": \"ba00de9b-3c3e-4b0a-a1ad-0c5489e711fb\",\n" +
+ " \"requestId\": \"311cc766-b673-4a50-b9c5-471f68914586\"\n" +
+ " }\n" +
+ "}}");
+
+ }
+
+ @Test(enabled = false)
+ public void testGetOrchestrationRequestsForDashboard() throws Exception {
+ MsoController msoController = new MsoController(null);
+ List<Request> orchestrationRequestsForDashboard = msoController.getOrchestrationRequestsForDashboard();
+
+ Assert.assertEquals(orchestrationRequestsForDashboard.size(), 2);
+ }
+
+ @Test(enabled = false)
+ public void testGetManualTasksByRequestId() throws Exception {
+ MsoController msoController = new MsoController(null);
+ List<Task> orchestrationRequestsForDashboard = msoController.getManualTasksByRequestId("za1234d1-5a33-55df-13ab-12abad84e335");
+
+ Assert. assertEquals(orchestrationRequestsForDashboard.get(0).getTaskId(), "daf4dd84-b77a-42da-a051-3239b7a9392c");
+ }
+
+
+ public void testCompleteManualTask() throws Exception { // TODO not done yet
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setResponseValue("rollback");
+ requestInfo.setRequestorId("abc");
+ requestInfo.setSource("VID");
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setRequestInfo(requestInfo);
+ MsoController msoController = new MsoController(null);
+ ResponseEntity<String> responseEntity = msoController.manualTaskComplete("daf4dd84-b77a-42da-a051-3239b7a9392c", requestDetails);
+ String assertString = "{ \\\"status\\\": 200, \\\"entity\\\": {\\n\" +\n" +
+ " \" \\\"taskRequestReference\\\": {\\n\" +\n" +
+ " \" \\\"taskId\\\": \\\"daf4dd84-b77a-42da-a051-3239b7a9392c\\\"\\n\" +\n" +
+ " \" }\\n\" +\n" +
+ " \"}\\n\" +\n" +
+ " \"}";
+ Assert.assertEquals(responseEntity.getBody(), StringEscapeUtils.unescapeJava(assertString));
+ }
+
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controller/PromiseEcompRequestIdFilterTest.java b/onap-enabler-be/src/test/java/org/onap/osam/controller/PromiseEcompRequestIdFilterTest.java
new file mode 100644
index 0000000..2c43cf4
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controller/PromiseEcompRequestIdFilterTest.java
@@ -0,0 +1,184 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controller;
+
+import com.google.common.collect.ImmutableMap;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+import org.mockito.stubbing.Answer;
+import org.onap.portalsdk.core.web.support.UserUtils;
+import org.onap.osam.filters.PromiseEcompRequestIdFilter;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.testng.annotations.Test;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.*;
+import java.util.function.Function;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.argThat;
+import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID;
+
+@Test
+public class PromiseEcompRequestIdFilterTest {
+
+ private final String anotherHeader = "ANDREI_RUBLEV";
+ private final String anotherValue = "foo value";
+ private final String mixedCaseHeader = "x-ecomp-REQUESTID";
+
+ @Test
+ public void givenRequestIdHeader_headerValueNotChanged() throws IOException, ServletException {
+
+ final String someTxId = "863850e2-8545-4efd-94b8-afba5f52b3d5";
+
+ final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of(
+ anotherHeader, anotherValue,
+ ECOMP_REQUEST_ID, someTxId
+ );
+
+ buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, specificTxId(someTxId));
+ }
+
+ @Test
+ public void givenMixedCaseRequestIdHeader_headerValueNotChanged() throws IOException, ServletException {
+
+ final String someTxId = "729bbd8d-b0c2-4809-a794-dcccd9cda2c0";
+
+ final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of(
+ mixedCaseHeader, someTxId,
+ anotherHeader, anotherValue
+ );
+
+ buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, specificTxId(someTxId));
+ }
+
+ @Test
+ public void givenNoRequestIdHeader_headerValueWasGenerated() throws IOException, ServletException {
+
+ final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of(
+ anotherHeader, anotherValue
+ );
+
+ buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, UserUtils::getRequestId);
+ }
+
+
+ private void buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(
+ ImmutableMap<String, String> originalRequestHeaders,
+ Function<HttpServletRequest, String> txIdExtractor
+ ) throws IOException, ServletException {
+ HttpServletRequest servletRequest = createMockedHttpServletRequest(originalRequestHeaders);
+ HttpServletResponse servletResponse = createMockedHttpServletResponse();
+
+ final FilterChain capturingFilterChain = Mockito.mock(FilterChain.class);
+
+ //////////////////
+ //
+ // doFilter() is the function under test
+ //
+ new PromiseEcompRequestIdFilter().doFilter(servletRequest, servletResponse, capturingFilterChain);
+ //
+ //////////////////
+
+ final ServletRequest capturedServletRequest = extractCapturedServletRequest(capturingFilterChain);
+ final ServletResponse capturedServletResponse = extractCapturedServletResponse(capturingFilterChain);
+ final String expectedTxId = txIdExtractor.apply((HttpServletRequest) capturedServletRequest);
+
+ assertRequestObjectHeaders(capturedServletRequest, expectedTxId);
+ assertResponseObjectHeaders(capturedServletResponse, expectedTxId);
+ }
+
+
+ private void assertRequestObjectHeaders(ServletRequest request, String expectedTxId) {
+ final HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+
+ assertThat(Collections.list(httpServletRequest.getHeaderNames()),
+ containsInAnyOrder(equalToIgnoringCase(ECOMP_REQUEST_ID), equalToIgnoringCase(anotherHeader)));
+
+ assertThat(httpServletRequest.getHeader(anotherHeader), is(anotherValue));
+
+ assertThat(httpServletRequest.getHeader(ECOMP_REQUEST_ID), is(expectedTxId));
+ assertThat(httpServletRequest.getHeader(mixedCaseHeader), is(expectedTxId));
+
+ assertThat(UserUtils.getRequestId(httpServletRequest), is(expectedTxId));
+ assertThat(UserUtils.getRequestId(httpServletRequest), is(not(emptyOrNullString())));
+ }
+
+ private void assertResponseObjectHeaders(ServletResponse response, String txId) {
+ final String REQUEST_ID_HEADER_NAME_IN_RESPONSE = mixedCaseHeader + "-echo";
+ final HttpServletResponse httpServletResponse = (HttpServletResponse) response;
+
+ assertThat("header " + REQUEST_ID_HEADER_NAME_IN_RESPONSE.toLowerCase() + " in response must be provided",
+ httpServletResponse.getHeader(REQUEST_ID_HEADER_NAME_IN_RESPONSE), is(txId));
+ }
+
+
+
+ private HttpServletRequest createMockedHttpServletRequest(Map<String, String> requestHeaders) {
+ HttpServletRequest servletRequest = Mockito.mock(HttpServletRequest.class);
+ requestHeaders.forEach((k, v) -> {
+ Mockito.when(servletRequest.getHeader(argThat(equalToIgnoringCase(k)))).thenReturn(v);
+ Mockito.when(servletRequest.getHeaders(argThat(equalToIgnoringCase(k)))).then(returnEnumerationAnswer(v));
+ });
+ Mockito.when(servletRequest.getHeaderNames()).then(returnEnumerationAnswer(requestHeaders.keySet()));
+ return servletRequest;
+ }
+
+ private HttpServletResponse createMockedHttpServletResponse() {
+ return new MockHttpServletResponse();
+ }
+
+ private static Answer<Enumeration<String>> returnEnumerationAnswer(String ... items) {
+ return returnEnumerationAnswer(Arrays.asList(items));
+ }
+
+ private static Answer<Enumeration<String>> returnEnumerationAnswer(Collection<String> items) {
+ return invocation -> Collections.enumeration(items);
+ }
+
+ private Function<HttpServletRequest, String> specificTxId(String someTxId) {
+ return r -> someTxId;
+ }
+
+ private ServletRequest extractCapturedServletRequest(FilterChain capturingFilterChain) throws IOException, ServletException {
+ ArgumentCaptor<ServletRequest> captor = ArgumentCaptor.forClass(ServletRequest.class);
+ Mockito.verify(capturingFilterChain).doFilter(captor.capture(), any());
+ return captor.getValue();
+ }
+
+ private ServletResponse extractCapturedServletResponse(FilterChain capturingFilterChain) throws IOException, ServletException {
+ ArgumentCaptor<ServletResponse> captor = ArgumentCaptor.forClass(ServletResponse.class);
+ Mockito.verify(capturingFilterChain).doFilter(any(), captor.capture());
+ return captor.getValue();
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controllers/AaiControllerTest.java b/onap-enabler-be/src/test/java/org/onap/osam/controllers/AaiControllerTest.java
new file mode 100644
index 0000000..442a5e4
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controllers/AaiControllerTest.java
@@ -0,0 +1,459 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Test;
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.osam.model.VersionByInvariantIdsRequest;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.servlet.ModelAndView;
+import java.util.*;
+
+public class AaiControllerTest {
+
+ private AaiController createTestSubject() {
+ return new AaiController();
+ }
+
+ @Test
+ public void testWelcome() throws Exception {
+ AaiController testSubject;
+ HttpServletRequest request = null;
+ ModelAndView result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.welcome(request);
+ }
+
+ @Test
+ public void testGetTargetProvStatus() throws Exception {
+ AaiController testSubject;
+ ResponseEntity<String> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getTargetProvStatus();
+ }
+
+ @Test
+ public void testViewEditGetTenantsFromServiceType() throws Exception {
+ AaiController testSubject;
+ HttpServletRequest request = null;
+ String globalCustomerId = "";
+ String serviceType = "";
+ ResponseEntity<String> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.viewEditGetTenantsFromServiceType(request, globalCustomerId, serviceType);
+ }
+
+
+
+
+
+ /*@Test
+ public void testGetAicZones() throws Exception {
+ AaiController testSubject;
+ HttpServletRequest request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getAicZones(request);
+ } catch (Exception e) {
+ }
+ }*/
+
+ @Test
+ public void testGetAicZoneForPnf() throws Exception {
+ AaiController testSubject;
+ String globalCustomerId = "";
+ String serviceType = "";
+ String serviceId = "";
+ HttpServletRequest request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getAicZoneForPnf(globalCustomerId, serviceType, serviceId, request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetUserID() throws Exception {
+ AaiController testSubject;
+ HttpServletRequest request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getUserID(request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDoGetServices() throws Exception {
+ AaiController testSubject;
+ HttpServletRequest request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.doGetServices(request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetVersionByInvariantId() throws Exception {
+ AaiController testSubject;
+ HttpServletRequest request = null;
+ VersionByInvariantIdsRequest versions = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getVersionByInvariantId(request, versions);
+ } catch (Exception e) {
+ }
+ }
+
+ // @Test
+ // public void testAaiResponseToResponseEntity() throws Exception {
+ // AaiController testSubject;AaiResponse aaiResponseData = null;
+ // ResponseEntity<String> result;
+ //
+ // // default test
+ // }
+
+ @Test
+ public void testDoGetServiceInstance() throws Exception {
+ AaiController testSubject;
+ String serviceInstanceId = "";
+ String serviceInstanceType = "";
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.doGetServiceInstance(serviceInstanceId, serviceInstanceType);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDoGetServices_1() throws Exception {
+ AaiController testSubject;
+ String globalCustomerId = "";
+ String serviceSubscriptionId = "";
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.doGetServices(globalCustomerId, serviceSubscriptionId);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDoGetSubscriberList() throws Exception {
+ AaiController testSubject;
+ HttpServletRequest request = null;
+ String fullSet = "";
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.doGetSubscriberList(request, fullSet);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetOperationalEnvironments() throws Exception {
+ AaiController testSubject;
+ String operationalEnvironmentType = "";
+ String operationalEnvironmentStatus = "";
+ AaiResponse<OperationalEnvironmentList> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getOperationalEnvironments(operationalEnvironmentType, operationalEnvironmentStatus);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetFullSubscriberList() throws Exception {
+ AaiController testSubject;
+ HttpServletRequest request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getFullSubscriberList(request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetVnfDataByGlobalIdAndServiceType() throws Exception {
+ AaiController testSubject;
+ HttpServletRequest request = null;
+ String globalCustomerId = "";
+ String serviceType = "";
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getVnfDataByGlobalIdAndServiceType(request, globalCustomerId, serviceType);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDoRefreshSubscriberList() throws Exception {
+ AaiController testSubject;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.doRefreshSubscriberList();
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDoRefreshFullSubscriberList() throws Exception {
+ AaiController testSubject;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.doRefreshFullSubscriberList();
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetSubscriberDetails() throws Exception {
+ AaiController testSubject;
+ HttpServletRequest request = null;
+ String subscriberId = "";
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.GetSubscriberDetails(request, subscriberId);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testSearchServiceInstances() throws Exception {
+ AaiController testSubject;
+ HttpServletRequest request = null;
+ String subscriberId = "";
+ String instanceIdentifier = "";
+ List<String> projects = null;
+ List<String> owningEntities = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.SearchServiceInstances(request, subscriberId, instanceIdentifier, projects,
+ owningEntities);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testViewEditGetComponentList() throws Exception {
+ AaiController testSubject;
+ String namedQueryId = "";
+ String globalCustomerId = "";
+ String serviceType = "";
+ String serviceInstance = "";
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.viewEditGetComponentList(namedQueryId, globalCustomerId, serviceType, serviceInstance);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetVnfData() throws Exception {
+ AaiController testSubject;
+ String globalCustomerId = "";
+ String serviceType = "";
+ String serviceInstanceId = "";
+ AaiResponse<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getVnfData(globalCustomerId, serviceType, serviceInstanceId);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testViewEditGetComponentList_1() throws Exception {
+ AaiController testSubject;
+ String namedQueryId = "";
+ String globalCustomerId = "";
+ String serviceType = "";
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.viewEditGetComponentList(namedQueryId, globalCustomerId, serviceType);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetNodeTemplateInstances() throws Exception {
+ AaiController testSubject;
+ String globalCustomerId = "";
+ String serviceType = "";
+ String modelVersionId = "";
+ String modelInvariantId = "";
+ String cloudRegion = "";
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId,
+ modelInvariantId, cloudRegion);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetByUri() throws Exception {
+ AaiController testSubject;
+ HttpServletRequest request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getByUri(request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetSpecificConfiguration() throws Exception {
+ AaiController testSubject;
+ String configurationId = "";
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getSpecificConfiguration(configurationId);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetServiceInstanceAssociatedPnfs() throws Exception {
+ AaiController testSubject;
+ String globalCustomerId = "";
+ String serviceType = "";
+ String serviceInstanceId = "";
+ List<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getServiceInstanceAssociatedPnfs(globalCustomerId, serviceType, serviceInstanceId);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetSpecificPnf() throws Exception {
+ AaiController testSubject;
+ String pnfId = "";
+ ResponseEntity result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getSpecificPnf(pnfId);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetPnfInstances() throws Exception {
+ AaiController testSubject;
+ String globalCustomerId = "";
+ String serviceType = "";
+ String modelVersionId = "";
+ String modelInvariantId = "";
+ String cloudRegion = "";
+ String equipVendor = "";
+ String equipModel = "";
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getPnfInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId,
+ cloudRegion, equipVendor, equipModel);
+ } catch (Exception e) {
+ }
+
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controllers/HealthCheckControllerTest.java b/onap-enabler-be/src/test/java/org/onap/osam/controllers/HealthCheckControllerTest.java
new file mode 100644
index 0000000..45edaa5
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controllers/HealthCheckControllerTest.java
@@ -0,0 +1,79 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import org.apache.log4j.BasicConfigurator;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.osam.controllers.PodDemoController.HealthStatus;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+
+public class HealthCheckControllerTest {
+
+ private PodDemoController testSubject;
+ private MockMvc mockMvc;
+
+ @Before
+ public void setUp() {
+ testSubject = new PodDemoController();
+ BasicConfigurator.configure();
+ mockMvc = MockMvcBuilders.standaloneSetup(testSubject).build();
+ }
+
+ @Test
+ public void testGetProfileCount() throws Exception {
+ String driver = "";
+ String URL = "";
+ String username = "";
+ String password = "";
+ int result;
+
+ // default test
+ result = testSubject.getProfileCount(driver, URL, username, password);
+ }
+
+ @Test
+ public void testGethealthCheckStatusforIDNS() throws Exception {
+ HealthStatus result;
+
+ // default test
+ result = testSubject.gethealthCheckStatusforIDNS();
+ }
+
+ @Test
+ public void testCommitInfoEndpoint() throws Exception {
+ mockMvc.perform(get("/commitInfo")
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.commitId").value("123987"))
+ .andExpect(jsonPath("$.commitMessageShort").value("Test short commit message"))
+ .andExpect(jsonPath("$.commitTime").value("1999-09-12T13:48:55+0200"));
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controllers/LocalWebConfig.java b/onap-enabler-be/src/test/java/org/onap/osam/controllers/LocalWebConfig.java
new file mode 100644
index 0000000..538846b
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controllers/LocalWebConfig.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.osam.aai.AaiClient;
+import org.onap.osam.aai.AaiClientInterface;
+import org.onap.osam.services.IAaiService;
+import org.onap.osam.services.AaiServiceImpl;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class LocalWebConfig {
+
+ @Bean
+ public ObjectMapper getObjectMapper() {
+ return new ObjectMapper();
+ }
+
+
+ @Bean
+ public IAaiService getAaiService() {
+ return new AaiServiceImpl();
+ }
+
+ @Bean
+ public AaiClientInterface getAaiClientInterface() {
+ return new AaiClient(null,null);
+ }
+
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controllers/LoggerControllerTest.java b/onap-enabler-be/src/test/java/org/onap/osam/controllers/LoggerControllerTest.java
new file mode 100644
index 0000000..ab6fb4a
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controllers/LoggerControllerTest.java
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import javax.ws.rs.NotAuthorizedException;
+
+import org.junit.Test;
+
+
+public class LoggerControllerTest {
+
+ private LoggerController createTestSubject() {
+ return new LoggerController();
+ }
+
+ /*@Test
+ public void testGetLog() throws Exception {
+ LoggerController testSubject;
+ String loggerName = "";
+ HttpServletRequest request = null;
+ Integer limit = 0;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getLog(loggerName, request, limit);
+ }*/
+
+
+ @Test
+ public void testNotAuthorizedHandler() throws Exception {
+ LoggerController testSubject;
+ NotAuthorizedException e = null;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.notAuthorizedHandler(e);
+ }
+
+ /*@Test
+ public void testIoExceptionHandler() throws Exception {
+ LoggerController testSubject;
+ Exception e = null;
+ ExceptionResponse result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.ioExceptionHandler(e);
+ }*/
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controllers/MsoControllerNewTest.java b/onap-enabler-be/src/test/java/org/onap/osam/controllers/MsoControllerNewTest.java
new file mode 100644
index 0000000..87a0fc5
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controllers/MsoControllerNewTest.java
@@ -0,0 +1,411 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Test;
+import org.onap.osam.mso.MsoBusinessLogicImpl;
+import org.onap.osam.mso.rest.RequestDetails;
+import org.onap.osam.mso.rest.RequestDetailsWrapper;
+import org.springframework.http.ResponseEntity;
+
+public class MsoControllerNewTest {
+
+ private MsoController createTestSubject() {
+ try {
+ return new MsoController(new MsoBusinessLogicImpl(null,null));
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCreateSvcInstance() throws Exception {
+ MsoController testSubject;
+ HttpServletRequest request = null;
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.createSvcInstance(request, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testCreateVnf() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ HttpServletRequest request = null;
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.createVnf(serviceInstanceId, request, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testCreateNwInstance() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ HttpServletRequest request = null;
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.createNwInstance(serviceInstanceId, request, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testCreateVolumeGroupInstance() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ String vnfInstanceId = "";
+ HttpServletRequest request = null;
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.createVolumeGroupInstance(serviceInstanceId, vnfInstanceId, request, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testCreateVfModuleInstance() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ String vnfInstanceId = "";
+ HttpServletRequest request = null;
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.createVfModuleInstance(serviceInstanceId, vnfInstanceId, request, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testCreateConfigurationInstance() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ HttpServletRequest request = null;
+ RequestDetailsWrapper mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.createConfigurationInstance(serviceInstanceId, request, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDeleteSvcInstance() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ HttpServletRequest request = null;
+ RequestDetails mso_request = null;
+ String result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.deleteSvcInstance(serviceInstanceId, request, mso_request, "");
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDeleteVnf() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ String vnfInstanceId = "";
+ HttpServletRequest request = null;
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.deleteVnf(serviceInstanceId, vnfInstanceId, request, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDeleteConfiguration() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ String configurationId = "";
+ RequestDetailsWrapper mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.deleteConfiguration(serviceInstanceId, configurationId, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testActivateConfiguration() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ String configurationId = "";
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.activateConfiguration(serviceInstanceId, configurationId, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDeactivateConfiguration() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ String configurationId = "";
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.deactivateConfiguration(serviceInstanceId, configurationId, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDisablePortOnConfiguration() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ String configurationId = "";
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.disablePortOnConfiguration(serviceInstanceId, configurationId, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testEnablePortOnConfiguration() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ String configurationId = "";
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.enablePortOnConfiguration(serviceInstanceId, configurationId, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDeleteVfModule() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ String vnfInstanceId = "";
+ String vfModuleId = "";
+ HttpServletRequest request = null;
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.deleteVfModule(serviceInstanceId, vnfInstanceId, vfModuleId, request, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDeleteVolumeGroupInstance() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ String vnfInstanceId = "";
+ String volumeGroupId = "";
+ HttpServletRequest request = null;
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.deleteVolumeGroupInstance(serviceInstanceId, vnfInstanceId, volumeGroupId, request,
+ mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDeleteNwInstance() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ String networkInstanceId = "";
+ HttpServletRequest request = null;
+ RequestDetails mso_request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.deleteNwInstance(serviceInstanceId, networkInstanceId, request, mso_request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetOrchestrationRequest() throws Exception {
+ MsoController testSubject;
+ String requestId = "";
+ HttpServletRequest request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getOrchestrationRequest(requestId, request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetOrchestrationRequests() throws Exception {
+ MsoController testSubject;
+ String filterString = "";
+ HttpServletRequest request = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getOrchestrationRequests(filterString, request);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testActivateServiceInstance() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ RequestDetails requestDetails = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.activateServiceInstance(serviceInstanceId, requestDetails);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDeactivateServiceInstance() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ RequestDetails requestDetails = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.deactivateServiceInstance(serviceInstanceId, requestDetails);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testManualTaskComplete() throws Exception {
+ MsoController testSubject;
+ String taskId = "";
+ RequestDetails requestDetails = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.manualTaskComplete(taskId, requestDetails);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testRemoveRelationshipFromServiceInstance() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ RequestDetails requestDetails = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.removeRelationshipFromServiceInstance(serviceInstanceId, requestDetails);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testAddRelationshipToServiceInstance() throws Exception {
+ MsoController testSubject;
+ String serviceInstanceId = "";
+ RequestDetails requestDetails = null;
+ ResponseEntity<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.addRelationshipToServiceInstance(serviceInstanceId, requestDetails);
+ } catch (Exception e) {
+ }
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controllers/MsoControllerTest.java b/onap-enabler-be/src/test/java/org/onap/osam/controllers/MsoControllerTest.java
new file mode 100644
index 0000000..b25e095
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controllers/MsoControllerTest.java
@@ -0,0 +1,128 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.domain.mso.RequestInfo;
+import org.onap.osam.factories.MsoRequestFactory;
+import org.onap.osam.mso.rest.Request;
+import org.onap.osam.mso.rest.RequestDetails;
+import org.onap.osam.mso.rest.Task;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+
+@WebAppConfiguration
+@ContextConfiguration(classes = {SystemProperties.class, MsoConfig.class})
+public class MsoControllerTest extends AbstractTestNGSpringContextTests {
+
+ @Autowired
+ MsoRequestFactory msoRequestFactory;
+
+ @Test(enabled = false)
+ public void testInstanceCreationNew() throws Exception {
+
+ RequestDetails requestDetails = msoRequestFactory.createMsoRequest("msoRequest.json");
+ MsoController msoController = new MsoController(null);
+ //TODO: make ths test to really test something
+ //ResponseEntity<String> responseEntityNew = msoController.createSvcInstanceNew(null, requestDetails);
+ ResponseEntity<String> responseEntity = msoController.createSvcInstance(null, requestDetails);
+ //Assert.assertEquals(responseEntityNew, responseEntity);
+
+ }
+
+ @Test(enabled = false)
+ public void testInstanceCreationLocalWithRest() throws Exception {
+
+ RequestDetails requestDetails = msoRequestFactory.createMsoRequest("msoRequest.json");
+ MsoController msoController = new MsoController(null);
+ ResponseEntity<String> responseEntityNew = msoController.createSvcInstance(null, requestDetails);
+ //TODO: make ths test to really test something
+// ResponseEntity<String> responseEntityRest = msoController.createSvcInstanceNewRest(null, requestDetails);
+//
+// Assert.assertEquals(responseEntityNew.getBody(), responseEntityRest.getBody());
+
+ }
+
+ @Test(enabled = false)
+ public void testInstanceCreation() throws Exception {
+
+ RequestDetails requestDetails = msoRequestFactory.createMsoRequest("msoRequest.json");
+ MsoController msoController = new MsoController(null);
+ ResponseEntity<String> responseEntity = msoController.createSvcInstance(null, requestDetails);
+
+
+ Assert.assertEquals(responseEntity.getBody(), "{ \"status\": 200, \"entity\": {\n" +
+ " \"requestReferences\": {\n" +
+ " \"instanceId\": \"ba00de9b-3c3e-4b0a-a1ad-0c5489e711fb\",\n" +
+ " \"requestId\": \"311cc766-b673-4a50-b9c5-471f68914586\"\n" +
+ " }\n" +
+ "}}");
+
+ }
+
+ @Test(enabled = false)
+ public void testGetOrchestrationRequestsForDashboard() throws Exception {
+ MsoController msoController = new MsoController(null);
+ List<Request> orchestrationRequestsForDashboard = msoController.getOrchestrationRequestsForDashboard();
+
+ Assert.assertEquals(orchestrationRequestsForDashboard.size(), 2);
+ }
+
+ @Test(enabled = false)
+ public void testGetManualTasksByRequestId() throws Exception {
+ MsoController msoController = new MsoController(null);
+ List<Task> orchestrationRequestsForDashboard = msoController.getManualTasksByRequestId("za1234d1-5a33-55df-13ab-12abad84e335");
+
+ Assert. assertEquals(orchestrationRequestsForDashboard.get(0).getTaskId(), "daf4dd84-b77a-42da-a051-3239b7a9392c");
+ }
+
+
+ public void testCompleteManualTask() throws Exception { // TODO not done yet
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setResponseValue("rollback");
+ requestInfo.setRequestorId("abc");
+ requestInfo.setSource("VID");
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setRequestInfo(requestInfo);
+ MsoController msoController = new MsoController(null);
+ ResponseEntity<String> responseEntity = msoController.manualTaskComplete("daf4dd84-b77a-42da-a051-3239b7a9392c", requestDetails);
+ String assertString = "{ \\\"status\\\": 200, \\\"entity\\\": {\\n\" +\n" +
+ " \" \\\"taskRequestReference\\\": {\\n\" +\n" +
+ " \" \\\"taskId\\\": \\\"daf4dd84-b77a-42da-a051-3239b7a9392c\\\"\\n\" +\n" +
+ " \" }\\n\" +\n" +
+ " \"}\\n\" +\n" +
+ " \"}";
+ Assert.assertEquals(responseEntity.getBody(), StringEscapeUtils.unescapeJava(assertString));
+ }
+
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controllers/PromiseEcompRequestIdFilterTest.java b/onap-enabler-be/src/test/java/org/onap/osam/controllers/PromiseEcompRequestIdFilterTest.java
new file mode 100644
index 0000000..2b64031
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controllers/PromiseEcompRequestIdFilterTest.java
@@ -0,0 +1,184 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+import com.google.common.collect.ImmutableMap;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+import org.mockito.stubbing.Answer;
+import org.onap.portalsdk.core.web.support.UserUtils;
+import org.onap.osam.filters.PromiseEcompRequestIdFilter;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.testng.annotations.Test;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.*;
+import java.util.function.Function;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.argThat;
+import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID;
+
+@Test
+public class PromiseEcompRequestIdFilterTest {
+
+ private final String anotherHeader = "ANDREI_RUBLEV";
+ private final String anotherValue = "foo value";
+ private final String mixedCaseHeader = "x-ecomp-REQUESTID";
+
+ @Test
+ public void givenRequestIdHeader_headerValueNotChanged() throws IOException, ServletException {
+
+ final String someTxId = "863850e2-8545-4efd-94b8-afba5f52b3d5";
+
+ final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of(
+ anotherHeader, anotherValue,
+ ECOMP_REQUEST_ID, someTxId
+ );
+
+ buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, specificTxId(someTxId));
+ }
+
+ @Test
+ public void givenMixedCaseRequestIdHeader_headerValueNotChanged() throws IOException, ServletException {
+
+ final String someTxId = "729bbd8d-b0c2-4809-a794-dcccd9cda2c0";
+
+ final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of(
+ mixedCaseHeader, someTxId,
+ anotherHeader, anotherValue
+ );
+
+ buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, specificTxId(someTxId));
+ }
+
+ @Test
+ public void givenNoRequestIdHeader_headerValueWasGenerated() throws IOException, ServletException {
+
+ final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of(
+ anotherHeader, anotherValue
+ );
+
+ buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, UserUtils::getRequestId);
+ }
+
+
+ private void buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(
+ ImmutableMap<String, String> originalRequestHeaders,
+ Function<HttpServletRequest, String> txIdExtractor
+ ) throws IOException, ServletException {
+ HttpServletRequest servletRequest = createMockedHttpServletRequest(originalRequestHeaders);
+ HttpServletResponse servletResponse = createMockedHttpServletResponse();
+
+ final FilterChain capturingFilterChain = Mockito.mock(FilterChain.class);
+
+ //////////////////
+ //
+ // doFilter() is the function under test
+ //
+ new PromiseEcompRequestIdFilter().doFilter(servletRequest, servletResponse, capturingFilterChain);
+ //
+ //////////////////
+
+ final ServletRequest capturedServletRequest = extractCapturedServletRequest(capturingFilterChain);
+ final ServletResponse capturedServletResponse = extractCapturedServletResponse(capturingFilterChain);
+ final String expectedTxId = txIdExtractor.apply((HttpServletRequest) capturedServletRequest);
+
+ assertRequestObjectHeaders(capturedServletRequest, expectedTxId);
+ assertResponseObjectHeaders(capturedServletResponse, expectedTxId);
+ }
+
+
+ private void assertRequestObjectHeaders(ServletRequest request, String expectedTxId) {
+ final HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+
+ assertThat(Collections.list(httpServletRequest.getHeaderNames()),
+ containsInAnyOrder(equalToIgnoringCase(ECOMP_REQUEST_ID), equalToIgnoringCase(anotherHeader)));
+
+ assertThat(httpServletRequest.getHeader(anotherHeader), is(anotherValue));
+
+ assertThat(httpServletRequest.getHeader(ECOMP_REQUEST_ID), is(expectedTxId));
+ assertThat(httpServletRequest.getHeader(mixedCaseHeader), is(expectedTxId));
+
+ assertThat(UserUtils.getRequestId(httpServletRequest), is(expectedTxId));
+ assertThat(UserUtils.getRequestId(httpServletRequest), is(not(emptyOrNullString())));
+ }
+
+ private void assertResponseObjectHeaders(ServletResponse response, String txId) {
+ final String REQUEST_ID_HEADER_NAME_IN_RESPONSE = mixedCaseHeader + "-echo";
+ final HttpServletResponse httpServletResponse = (HttpServletResponse) response;
+
+ assertThat("header " + REQUEST_ID_HEADER_NAME_IN_RESPONSE.toLowerCase() + " in response must be provided",
+ httpServletResponse.getHeader(REQUEST_ID_HEADER_NAME_IN_RESPONSE), is(txId));
+ }
+
+
+
+ private HttpServletRequest createMockedHttpServletRequest(Map<String, String> requestHeaders) {
+ HttpServletRequest servletRequest = Mockito.mock(HttpServletRequest.class);
+ requestHeaders.forEach((k, v) -> {
+ Mockito.when(servletRequest.getHeader(argThat(equalToIgnoringCase(k)))).thenReturn(v);
+ Mockito.when(servletRequest.getHeaders(argThat(equalToIgnoringCase(k)))).then(returnEnumerationAnswer(v));
+ });
+ Mockito.when(servletRequest.getHeaderNames()).then(returnEnumerationAnswer(requestHeaders.keySet()));
+ return servletRequest;
+ }
+
+ private HttpServletResponse createMockedHttpServletResponse() {
+ return new MockHttpServletResponse();
+ }
+
+ private static Answer<Enumeration<String>> returnEnumerationAnswer(String ... items) {
+ return returnEnumerationAnswer(Arrays.asList(items));
+ }
+
+ private static Answer<Enumeration<String>> returnEnumerationAnswer(Collection<String> items) {
+ return invocation -> Collections.enumeration(items);
+ }
+
+ private Function<HttpServletRequest, String> specificTxId(String someTxId) {
+ return r -> someTxId;
+ }
+
+ private ServletRequest extractCapturedServletRequest(FilterChain capturingFilterChain) throws IOException, ServletException {
+ ArgumentCaptor<ServletRequest> captor = ArgumentCaptor.forClass(ServletRequest.class);
+ Mockito.verify(capturingFilterChain).doFilter(captor.capture(), any());
+ return captor.getValue();
+ }
+
+ private ServletResponse extractCapturedServletResponse(FilterChain capturingFilterChain) throws IOException, ServletException {
+ ArgumentCaptor<ServletResponse> captor = ArgumentCaptor.forClass(ServletResponse.class);
+ Mockito.verify(capturingFilterChain).doFilter(any(), captor.capture());
+ return captor.getValue();
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controllers/VidControllerTest.java b/onap-enabler-be/src/test/java/org/onap/osam/controllers/VidControllerTest.java
new file mode 100644
index 0000000..4b02752
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controllers/VidControllerTest.java
@@ -0,0 +1,211 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+
+//import com.fasterxml.jackson.databind.ObjectMapper;
+//import net.javacrumbs.jsonunit.JsonAssert;
+//import org.apache.commons.io.IOUtils;
+//import org.onap.vid.asdc.AsdcCatalogException;
+//import org.onap.vid.asdc.AsdcClient;
+//import org.onap.vid.asdc.parser.ToscaParserImpl2;
+//import org.onap.vid.model.*;
+//import org.onap.portalsdk.core.util.SystemProperties;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.mock.web.MockServletContext;
+//import org.springframework.test.context.ContextConfiguration;
+//import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+//import org.springframework.test.context.web.WebAppConfiguration;
+//import org.testng.Assert;
+//import org.testng.annotations.Test;
+//
+//import static org.onap.vid.testUtils.TestUtils.assertJsonStringEqualsIgnoreNulls;
+//
+//import java.io.IOException;
+//import java.io.InputStream;
+//import java.nio.file.Path;
+//import java.util.Map;
+//import java.util.UUID;
+//
+////import org.junit.Assert;
+////import org.junit.Ignore;
+////import org.junit.Test;
+////import org.junit.runner.RunWith;
+////import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+//
+//@ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class})
+////@RunWith(SpringJUnit4ClassRunner.class)
+//@WebAppConfiguration
+//
+//public class VidControllerTest extends AbstractTestNGSpringContextTests {
+//
+// @Autowired
+// MockServletContext context;
+// @Autowired
+// private AsdcClient asdcClient;
+// private ToscaParserImpl2 p2 = new ToscaParserImpl2();
+// private ObjectMapper om = new ObjectMapper();
+//
+//
+// @Test
+// public void assertEqualsBetweenServices() throws Exception {
+// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) {
+// Service expectedService = mockHelper.getNewServiceModel().getService();
+// Service actualService = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getService();
+// assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(expectedService), om.writeValueAsString(actualService));
+// }
+// }
+//
+//// @Test
+//// public void assertEqualBetweenObjects() throws Exception {
+//// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) {
+//// final Path csarPath = getCsarPath(mockHelper.getUuid());
+//// System.out.println("Comparing for csar " + csarPath);
+//// ServiceModel actualServiceModel = p2.makeServiceModel(csarPath, getServiceByUuid(mockHelper.getUuid()));
+//// assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(mockHelper.getNewServiceModel()), om.writeValueAsString(actualServiceModel));
+//// }
+//// }
+//
+//// @Test
+//// public void assertEqualsBetweenNetworkNodes() throws Exception {
+//// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) {
+//// Map<String, Network> expectedNetworksMap = mockHelper.getNewServiceModel().getNetworks();
+//// Map<String, Network> actualNetworksMap = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getNetworks();
+//// for (Map.Entry<String, Network> entry : expectedNetworksMap.entrySet()) {
+//// Network expectedNetwork = entry.getValue();
+//// Network actualNetwork = actualNetworksMap.get(entry.getKey());
+//// Assert.assertEquals(expectedNetwork.getModelCustomizationName(), actualNetwork.getModelCustomizationName());
+//// verifyBaseNodeProperties(expectedNetwork, actualNetwork);
+//// compareProperties(expectedNetwork.getProperties(), actualNetwork.getProperties());
+//// }
+//// }
+//// }
+//
+// //Because we are not supporting the old flow, the JSON are different by definition.
+// @Test
+// public void assertEqualsBetweenVnfsOfTosca() throws Exception {
+// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) {
+// Map<String, VNF> expectedVnfsMap = mockHelper.getNewServiceModel().getVnfs();
+// Map<String, VNF> actualVnfsMap = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVnfs();
+// for (Map.Entry<String, VNF> entry : expectedVnfsMap.entrySet()) {
+// VNF expectedVnf = entry.getValue();
+// VNF actualVnf = actualVnfsMap.get(entry.getKey());
+// //need to uncomment these after 1806 merge
+// //verifyBaseNodeProperties(expectedVnf, actualVnf);
+// Assert.assertEquals(expectedVnf.getModelCustomizationName(), actualVnf.getModelCustomizationName());
+// //compareProperties(expectedVnf.getProperties(), actualVnf.getProperties());
+// //assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(expectedVnf), om.writeValueAsString(actualVnf));
+// }
+// }
+// }
+//
+// @Test
+// public void assertEqualsBetweenVolumeGroups() throws Exception {
+// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) {
+// Map<String, VolumeGroup> actualVolumeGroups = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVolumeGroups();
+// Map<String, VolumeGroup> expectedVolumeGroups = mockHelper.getNewServiceModel().getVolumeGroups();
+// JsonAssert.assertJsonEquals(actualVolumeGroups, expectedVolumeGroups);
+// }
+// }
+//
+// @Test
+// public void assertEqualsBetweenVfModules() throws Exception {
+// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) {
+// Map<String, VfModule> actualVfModules = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getVfModules();
+// Map<String, VfModule> expectedVfModules = mockHelper.getNewServiceModel().getVfModules();
+// //need to uncomment after 1906 merge
+// //JsonAssert.assertJsonEquals(actualVfModules, expectedVfModules);
+// }
+// }
+//
+// /*@Test
+// public void assertEqualsBetweenPolicyConfigurationNodes() throws Exception {
+// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) {
+// Map<String, PortMirroringConfig> actualConfigurations = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getConfigurations();
+// Map<String, PortMirroringConfig> expectedConfigurations = mockHelper.getNewServiceModel().getConfigurations();
+// JsonAssert.assertJsonEquals(actualConfigurations, expectedConfigurations);
+// }
+// }*/
+//
+// @Test
+// public void assertEqualsBetweenServiceProxyNodes() throws Exception {
+// for (ToscaParserMockHelper mockHelper : getExpectedServiceModel()) {
+// Map<String, ServiceProxy> actualServiceProxies = p2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid())).getServiceProxies();
+// Map<String, ServiceProxy> expectedServiceProxies = mockHelper.getNewServiceModel().getServiceProxies();
+// JsonAssert.assertJsonEquals(actualServiceProxies, expectedServiceProxies);
+// }
+// }
+//
+// private void verifyBaseNodeProperties(Node expectedNode, Node actualNode) {
+// Assert.assertEquals(expectedNode.getName(), actualNode.getName());
+// Assert.assertEquals(expectedNode.getCustomizationUuid(), actualNode.getCustomizationUuid());
+// Assert.assertEquals(expectedNode.getDescription(), actualNode.getDescription());
+// Assert.assertEquals(expectedNode.getInvariantUuid(), actualNode.getInvariantUuid());
+// Assert.assertEquals(expectedNode.getUuid(), actualNode.getUuid());
+// Assert.assertEquals(expectedNode.getVersion(), actualNode.getVersion());
+// }
+//
+// private void compareProperties(Map<String, String> expectedProperties, Map<String, String> actualProperties) {
+// for (Map.Entry<String, String> property : expectedProperties.entrySet()) {
+// String expectedValue = property.getValue();
+// String key = property.getKey();
+// String actualValue = actualProperties.get(key);
+// Assert.assertEquals(expectedValue, actualValue);
+// }
+// }
+//
+// private ToscaParserMockHelper[] getExpectedServiceModel() throws IOException {
+// ToscaParserMockHelper[] mockHelpers = {
+// new ToscaParserMockHelper(Constants.vlUuid, Constants.vlFilePath),
+// new ToscaParserMockHelper(Constants.vfUuid, Constants.vfFilePath),
+// new ToscaParserMockHelper(Constants.configurationUuid, Constants.configurationFilePath),
+// };
+// for (ToscaParserMockHelper mockHelper : mockHelpers) {
+// InputStream jsonFile = VidControllerTest.class.getClassLoader().getResourceAsStream(mockHelper.getFilePath());
+// String expectedJsonAsString = IOUtils.toString(jsonFile);
+// NewServiceModel newServiceModel1 = om.readValue(expectedJsonAsString, NewServiceModel.class);
+// mockHelper.setNewServiceModel(newServiceModel1);
+// }
+// return mockHelpers;
+// }
+//
+// private Path getCsarPath(String uuid) throws AsdcCatalogException {
+// return asdcClient.getServiceToscaModel(UUID.fromString(uuid));
+// }
+//
+// private org.onap.vid.asdc.beans.Service getServiceByUuid(String uuid) throws AsdcCatalogException {
+// return asdcClient.getService(UUID.fromString(uuid));
+// }
+//
+// public class Constants {
+// public static final String configurationUuid = "ee6d61be-4841-4f98-8f23-5de9da846ca7";
+// public static final String configurationFilePath = "policy-configuration-csar.JSON";
+// static final String vfUuid = "48a52540-8772-4368-9cdb-1f124ea5c931";
+// static final String vlUuid = "cb49608f-5a24-4789-b0f7-2595473cb997";
+// // public static final String PNFUuid = "68101369-6f08-4e99-9a28-fa6327d344f3";
+// static final String vfFilePath = "vf-csar.JSON";
+// static final String vlFilePath = "vl-csar.JSON";
+//// public static final String PNFFilePath = "/Users/Oren/Git/Att/vid_internal/vid-app-common/src/main/resources/pnf.csar";
+//
+// }
+//
+//}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/controllers/ViewEditSubControllerTest.java b/onap-enabler-be/src/test/java/org/onap/osam/controllers/ViewEditSubControllerTest.java
new file mode 100644
index 0000000..3067eef
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/controllers/ViewEditSubControllerTest.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.controllers;
+//package org.onap.vid.controller;
+//
+//import javax.servlet.http.HttpServletRequest;
+//
+//import org.junit.Test;
+//import org.springframework.web.servlet.ModelAndView;
+//
+//public class ViewEditSubControllerTest {
+//
+// private ViewEditSubController createTestSubject() {
+// return new ViewEditSubController();
+// }
+//
+// @Test
+// public void testWelcome() throws Exception {
+// ViewEditSubController testSubject;
+// HttpServletRequest request = null;
+// ModelAndView result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.welcome(request);
+// }
+//
+//
+// @Test
+// public void testGetViewName() throws Exception {
+// ViewEditSubController testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.getViewName();
+// }
+//
+// @Test
+// public void testSetViewName() throws Exception {
+// ViewEditSubController testSubject;
+// String viewName = "";
+//
+// // default test
+// testSubject = createTestSubject();
+// testSubject.setViewName(viewName);
+// }
+//}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/dao/FnAppDoaImplTest.java b/onap-enabler-be/src/test/java/org/onap/osam/dao/FnAppDoaImplTest.java
new file mode 100644
index 0000000..c958a2f
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/dao/FnAppDoaImplTest.java
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.dao;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FnAppDoaImplTest {
+
+ private FnAppDoaImpl createTestSubject() {
+ return new FnAppDoaImpl();
+ }
+
+ @Test
+ public void testGetConnection() throws Exception {
+ String driver2 = "";
+ String url = "";
+ String username = "";
+ String password = "";
+ Connection result;
+
+ // test 1
+ url = null;
+ username = null;
+ password = null;
+ result = FnAppDoaImpl.getConnection(driver2, url, username);
+ Assert.assertEquals(null, result);
+
+ // test 2
+ url = "";
+ username = null;
+ password = null;
+ result = FnAppDoaImpl.getConnection(driver2, url, username);
+ Assert.assertEquals(null, result);
+
+ // test 3
+ username = null;
+ url = null;
+ password = null;
+ result = FnAppDoaImpl.getConnection(driver2, url, username);
+ Assert.assertEquals(null, result);
+
+ // test 4
+ username = "";
+ url = null;
+ password = null;
+ result = FnAppDoaImpl.getConnection(driver2, url, username);
+ Assert.assertEquals(null, result);
+
+ // test 5
+ password = null;
+ url = null;
+ username = null;
+ result = FnAppDoaImpl.getConnection(driver2, url, username);
+ Assert.assertEquals(null, result);
+
+ // test 6
+ password = "";
+ url = null;
+ username = null;
+ result = FnAppDoaImpl.getConnection(driver2, url, username);
+ Assert.assertEquals(null, result);
+ }
+
+ @Test
+ public void testCleanup() throws Exception {
+ ResultSet rs = null;
+ PreparedStatement st = null;
+
+ // test 1
+ rs = null;
+ FnAppDoaImpl.cleanup(rs, st, null);
+
+ // test 2
+ st = null;
+ FnAppDoaImpl.cleanup(rs, st, null);
+
+ // test 3
+ FnAppDoaImpl.cleanup(rs, st, null);
+ }
+
+ @Test
+ public void testGetProfileCount() throws Exception {
+ FnAppDoaImpl testSubject;
+ String driver = "";
+ String URL = "";
+ String username = "";
+ String password = "";
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getProfileCount(driver, URL, username, password);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/factories/MsoRequestFactoryTest.java b/onap-enabler-be/src/test/java/org/onap/osam/factories/MsoRequestFactoryTest.java
new file mode 100644
index 0000000..60e7d2b
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/factories/MsoRequestFactoryTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.factories;
+
+import org.junit.Test;
+
+public class MsoRequestFactoryTest {
+
+ private MsoRequestFactory createTestSubject() {
+ return new MsoRequestFactory();
+ }
+
+ @Test
+ public void testCreateMsoRequest() throws Exception {
+ MsoRequestFactory testSubject;
+ String path = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.createMsoRequest(path);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/integrationTest/AaiIntegrationTest.java b/onap-enabler-be/src/test/java/org/onap/osam/integrationTest/AaiIntegrationTest.java
new file mode 100644
index 0000000..16b4f1c
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/integrationTest/AaiIntegrationTest.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.integrationTest;
+
+import org.onap.osam.aai.AaiClientInterface;
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.aai.model.GetServiceModelsByDistributionStatusResponse;
+import org.onap.osam.aai.model.Result;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+@ContextConfiguration(classes = {SystemProperties.class})
+
+
+@WebAppConfiguration
+public class AaiIntegrationTest extends AbstractTestNGSpringContextTests {
+
+
+ @Autowired
+ AaiClientInterface aaiClient;
+
+ @Test(enabled = false)
+ public void testGetServiceModelsFromAai() {
+ AaiResponse<GetServiceModelsByDistributionStatusResponse> serviceModelsByDistributionStatusResponse = aaiClient.getServiceModelsByDistributionStatus();
+ GetServiceModelsByDistributionStatusResponse response = serviceModelsByDistributionStatusResponse.getT();
+ for(Result result: response.getResults()){
+ Assert.assertNotNull(result.getModel().getModelInvariantId());
+ Assert.assertNotNull(result.getModel().getModelVers().getModelVer().get(0).getModelVersionId());
+ Assert.assertNotNull(result.getModel().getModelVers().getModelVer().get(0).getModelName());
+ Assert.assertNotNull(result.getModel().getModelVers().getModelVer().get(0).getModelVersion());
+ }
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/job/command/JobCommandFactoryTest.java b/onap-enabler-be/src/test/java/org/onap/osam/job/command/JobCommandFactoryTest.java
new file mode 100644
index 0000000..9c82b45
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/job/command/JobCommandFactoryTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job.command;
+
+import com.google.common.collect.ImmutableMap;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.osam.job.Job;
+import org.onap.osam.job.JobCommand;
+import org.onap.osam.job.JobType;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class JobCommandFactoryTest {
+
+ private JobCommandFactory jobCommandFactory;
+
+ @Mock
+ private Job job;
+
+ @Mock
+ private JobCommand mockCommand;
+
+ @BeforeMethod
+ public void initMocks() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @BeforeMethod
+ public void setUp() {
+ jobCommandFactory = new JobCommandFactory(any -> mockCommand);
+ }
+
+ @DataProvider
+ public Object[][] jobTypes() {
+ return Arrays.stream(
+ JobType.values()
+ ).map(v -> new Object[]{v}).collect(Collectors.toList()).toArray(new Object[][]{});
+
+ }
+
+ @Test(dataProvider = "jobTypes")
+ public void givenJob_createCommandCallsTheInitAndReturnsTheInstance(JobType jobType) {
+
+ final UUID uuid = UUID.randomUUID();
+ final Map<String, Object> data = ImmutableMap.of("foo", "bar");
+
+ when(job.getType()).thenReturn(jobType);
+ when(job.getUuid()).thenReturn(uuid);
+ when(job.getData()).thenReturn(data);
+
+ final JobCommand command = jobCommandFactory.toCommand(job);
+
+ verify(mockCommand).init(uuid, data);
+
+ assertThat(command, equalTo(mockCommand));
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/job/impl/JobWorkerTest.java b/onap-enabler-be/src/test/java/org/onap/osam/job/impl/JobWorkerTest.java
new file mode 100644
index 0000000..0c4dc2d
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/job/impl/JobWorkerTest.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.job.impl;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.commons.lang3.RandomUtils;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.hamcrest.Matcher;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.osam.job.*;
+import org.onap.osam.job.command.HttpCallCommand;
+import org.onap.osam.job.command.JobCommandFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+import java.util.UUID;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class JobWorkerTest {
+
+ @InjectMocks
+ private JobWorker jobWorker = new JobWorker();
+
+ @Mock
+ private JobCommandFactory jobCommandFactory;
+
+ private final JobCommand jobCommand = mock(JobCommand.class);
+ private Job jobUnderTest;
+ private JobAdapter.AsyncJobRequest originalData;
+ private JobType originalType;
+
+ @BeforeMethod
+ public void initMocks() {
+ MockitoAnnotations.initMocks(this);
+
+ when(jobCommandFactory.toCommand(any())).thenReturn(jobCommand);
+
+ originalData = new JobAdapter.AsyncJobRequest() {
+ public final Map datum = ImmutableMap.of("some", "data");
+ public final String foobar = "aux";
+ };
+
+ originalType = JobType.ServiceInstantiation;
+ jobUnderTest = new JobAdapterImpl().createJob(
+ originalType,
+ originalData,
+ UUID.randomUUID(),
+ "my user id",
+ RandomUtils.nextInt()
+ );
+ }
+
+ @Test
+ public void executeJobAndStepToNext_givenNull_onlyStatusModified() {
+
+ assertNextJobAfterExecuteJob(null, new String[]{"status"}, allOf(
+ hasProperty("status", is(Job.JobStatus.STOPPED)),
+ hasProperty("data", hasEntry("request", originalData)),
+ hasProperty("type", is(originalType)))
+ );
+ }
+
+ @Test
+ public void executeJobAndStepToNext_givenNextJob_jobDataIsModified() {
+
+ final Job.JobStatus nextStatus = Job.JobStatus.IN_PROGRESS;
+
+ final UUID jobUuid = UUID.randomUUID();
+ final NextCommand nextCommand = new NextCommand(nextStatus, new HttpCallCommand("my strange url", jobUuid));
+
+ String[] excludedFields = {"status", "data", "type"};
+
+ assertNextJobAfterExecuteJob(nextCommand, excludedFields, allOf(
+ hasProperty("status", is(nextStatus)),
+ hasProperty("data", is(nextCommand.getCommand().getData())),
+ hasProperty("type", is(nextCommand.getCommand().getType())))
+ );
+ }
+
+ private void assertNextJobAfterExecuteJob(NextCommand nextCommand, String[] excludedFields, Matcher<Job> jobMatcher) {
+ when(jobCommand.call()).thenReturn(nextCommand);
+
+ String jobBefore = new ReflectionToStringBuilder(jobUnderTest, ToStringStyle.SHORT_PREFIX_STYLE).setExcludeFieldNames(excludedFields).toString();
+
+ ////// FUNCTION UNDER TEST /////
+ Job nextJob = jobWorker.executeJobAndGetNext(jobUnderTest);
+ ////////////////////////////////
+
+ String jobAfter = new ReflectionToStringBuilder(nextJob, ToStringStyle.SHORT_PREFIX_STYLE).setExcludeFieldNames(excludedFields).toString();
+
+ assertThat(nextJob, jobMatcher);
+ assertThat(jobAfter, equalTo(jobBefore));
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/logging/VidLoggerAspectTest.java b/onap-enabler-be/src/test/java/org/onap/osam/logging/VidLoggerAspectTest.java
new file mode 100644
index 0000000..c10ef96
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/logging/VidLoggerAspectTest.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.logging;
+
+import org.junit.Test;
+
+
+public class VidLoggerAspectTest {
+
+ private VidLoggerAspect createTestSubject() {
+ return new VidLoggerAspect();
+ }
+
+ @Test
+ public void testVidControllers() throws Exception {
+ VidLoggerAspect testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.vidControllers();
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/model/CategoryParameterOptionTest.java b/onap-enabler-be/src/test/java/org/onap/osam/model/CategoryParameterOptionTest.java
new file mode 100644
index 0000000..1e3b6d5
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/model/CategoryParameterOptionTest.java
@@ -0,0 +1,211 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CategoryParameterOptionTest {
+
+ private CategoryParameterOption createTestSubject() {
+ return new CategoryParameterOption();
+ }
+
+ @Test
+ public void testGetId() throws Exception {
+ CategoryParameterOption testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getId();
+ }
+
+ @Test
+ public void testSetId() throws Exception {
+ CategoryParameterOption testSubject;
+ Long id = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setId(id);
+ }
+
+ @Test
+ public void testGetAppId() throws Exception {
+ CategoryParameterOption testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAppId();
+ }
+
+ @Test
+ public void testSetAppId() throws Exception {
+ CategoryParameterOption testSubject;
+ String appId = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAppId(appId);
+ }
+
+ @Test
+ public void testGetName() throws Exception {
+ CategoryParameterOption testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getName();
+ }
+
+ @Test
+ public void testSetName() throws Exception {
+ CategoryParameterOption testSubject;
+ String name = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setName(name);
+ }
+
+ @Test
+ public void testGetCategoryParameter() throws Exception {
+ CategoryParameterOption testSubject;
+ CategoryParameter result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCategoryParameter();
+ }
+
+ @Test
+ public void testSetCategoryParameter() throws Exception {
+ CategoryParameterOption testSubject;
+ CategoryParameter categoryParameter = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setCategoryParameter(categoryParameter);
+ }
+
+ @Test
+ public void testGetCreated() throws Exception {
+ CategoryParameterOption testSubject;
+ Date result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCreated();
+ }
+
+ @Test
+ public void testGetModified() throws Exception {
+ CategoryParameterOption testSubject;
+ Date result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getModified();
+ }
+
+ @Test
+ public void testGetCreatedId() throws Exception {
+ CategoryParameterOption testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCreatedId();
+ }
+
+ @Test
+ public void testGetModifiedId() throws Exception {
+ CategoryParameterOption testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getModifiedId();
+ }
+
+ @Test
+ public void testGetAuditUserId() throws Exception {
+ CategoryParameterOption testSubject;
+ Serializable result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAuditUserId();
+ }
+
+ @Test
+ public void testGetRowNum() throws Exception {
+ CategoryParameterOption testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRowNum();
+ }
+
+ @Test
+ public void testGetAuditTrail() throws Exception {
+ CategoryParameterOption testSubject;
+ Set result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAuditTrail();
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ CategoryParameterOption testSubject;
+ Object o = null;
+ boolean result;
+
+ // test 1
+ testSubject = createTestSubject();
+ o = null;
+ result = testSubject.equals(o);
+ Assert.assertEquals(false, result);
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ CategoryParameterOption testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.hashCode();
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/model/CategoryParameterTest.java b/onap-enabler-be/src/test/java/org/onap/osam/model/CategoryParameterTest.java
new file mode 100644
index 0000000..3b57f06
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/model/CategoryParameterTest.java
@@ -0,0 +1,207 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Set;
+
+import org.junit.Test;
+
+public class CategoryParameterTest {
+
+ private CategoryParameter createTestSubject() {
+ return new CategoryParameter();
+ }
+
+ @Test
+ public void testGetFamily() throws Exception {
+ CategoryParameter testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getFamily();
+ }
+
+ @Test
+ public void testSetFamily() throws Exception {
+ CategoryParameter testSubject;
+ String family = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setFamily(family);
+ }
+
+ @Test
+ public void testGetId() throws Exception {
+ CategoryParameter testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getId();
+ }
+
+ @Test
+ public void testGetCreated() throws Exception {
+ CategoryParameter testSubject;
+ Date result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCreated();
+ }
+
+ @Test
+ public void testGetModified() throws Exception {
+ CategoryParameter testSubject;
+ Date result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getModified();
+ }
+
+ @Test
+ public void testGetCreatedId() throws Exception {
+ CategoryParameter testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCreatedId();
+ }
+
+ @Test
+ public void testGetModifiedId() throws Exception {
+ CategoryParameter testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getModifiedId();
+ }
+
+ @Test
+ public void testGetName() throws Exception {
+ CategoryParameter testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getName();
+ }
+
+ @Test
+ public void testSetName() throws Exception {
+ CategoryParameter testSubject;
+ String name = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setName(name);
+ }
+
+ @Test
+ public void testGetAuditUserId() throws Exception {
+ CategoryParameter testSubject;
+ Serializable result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAuditUserId();
+ }
+
+ @Test
+ public void testGetRowNum() throws Exception {
+ CategoryParameter testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRowNum();
+ }
+
+ @Test
+ public void testGetAuditTrail() throws Exception {
+ CategoryParameter testSubject;
+ Set result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAuditTrail();
+ }
+
+ @Test
+ public void testGetOptions() throws Exception {
+ CategoryParameter testSubject;
+ Set<CategoryParameterOption> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getOptions();
+ }
+
+ @Test
+ public void testSetOptions() throws Exception {
+ CategoryParameter testSubject;
+ Set<CategoryParameterOption> options = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setOptions(options);
+ }
+
+ @Test
+ public void testAddOption() throws Exception {
+ CategoryParameter testSubject;
+ CategoryParameterOption option = null;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.addOption(option);
+ }
+
+ @Test
+ public void testIsIdSupported() throws Exception {
+ CategoryParameter testSubject;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isIdSupported();
+ }
+
+ @Test
+ public void testSetIdSupported() throws Exception {
+ CategoryParameter testSubject;
+ boolean idSupported = false;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setIdSupported(idSupported);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/model/ExceptionResponseTest.java b/onap-enabler-be/src/test/java/org/onap/osam/model/ExceptionResponseTest.java
new file mode 100644
index 0000000..68e2ae1
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/model/ExceptionResponseTest.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import org.junit.Test;
+
+public class ExceptionResponseTest {
+
+ private ExceptionResponse createTestSubject() {
+ return new ExceptionResponse();
+ }
+
+ @Test
+ public void testGetException() throws Exception {
+ ExceptionResponse testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getException();
+ }
+
+ @Test
+ public void testSetException() throws Exception {
+ ExceptionResponse testSubject;
+ String exception = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setException(exception);
+ }
+
+ @Test
+ public void testGetMessage() throws Exception {
+ ExceptionResponse testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getMessage();
+ }
+
+ @Test
+ public void testSetMessage() throws Exception {
+ ExceptionResponse testSubject;
+ String message = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setMessage(message);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/model/ListOfErrorsResponseTest.java b/onap-enabler-be/src/test/java/org/onap/osam/model/ListOfErrorsResponseTest.java
new file mode 100644
index 0000000..0fcd266
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/model/ListOfErrorsResponseTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.util.List;
+
+import org.junit.Test;
+
+public class ListOfErrorsResponseTest {
+
+ private ListOfErrorsResponse createTestSubject() {
+ return new ListOfErrorsResponse();
+ }
+
+ @Test
+ public void testGetErrors() throws Exception {
+ ListOfErrorsResponse testSubject;
+ List<String> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getErrors();
+ }
+
+ @Test
+ public void testSetErrors() throws Exception {
+ ListOfErrorsResponse testSubject;
+ List<String> errors = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setErrors(errors);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/model/ModelUtilTest.java b/onap-enabler-be/src/test/java/org/onap/osam/model/ModelUtilTest.java
new file mode 100644
index 0000000..0c7fcb1
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/model/ModelUtilTest.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class ModelUtilTest {
+
+ private ModelUtil createTestSubject() {
+ return new ModelUtil();
+ }
+
+
+ @Test
+ public void testGetTags() throws Exception {
+ String[] namespaces;
+ String constantValue = "test";
+ String[] result;
+
+ // test 1
+ namespaces = null;
+ result = ModelUtil.getTags(namespaces, constantValue);
+ Assert.assertNull(result);
+
+ // test 2
+ namespaces = new String[] { "" };
+ result = ModelUtil.getTags(namespaces, constantValue);
+ Assert.assertArrayEquals(new String[] { constantValue }, result);
+ }
+
+
+ @Test
+ public void testIsType() throws Exception {
+ String type = "a";
+ String[] tags;
+ boolean result;
+
+ // test 1
+ tags = null;
+ result = ModelUtil.isType(type, tags);
+ Assert.assertEquals(false, result);
+
+ // test 2
+ tags = new String[] { "a" };
+ result = ModelUtil.isType(type, tags);
+ Assert.assertEquals(true, result);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/model/RequestReferencesContainerTest.java b/onap-enabler-be/src/test/java/org/onap/osam/model/RequestReferencesContainerTest.java
new file mode 100644
index 0000000..83611c5
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/model/RequestReferencesContainerTest.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.util.Map;
+
+import org.junit.Test;
+import org.onap.osam.domain.mso.RequestReferences;
+
+public class RequestReferencesContainerTest {
+
+ private RequestReferencesContainer createTestSubject() {
+ return new RequestReferencesContainer(new RequestReferences());
+ }
+
+ @Test
+ public void testGetAdditionalProperties() throws Exception {
+ RequestReferencesContainer testSubject;
+ Map<String, Object> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAdditionalProperties();
+ }
+
+ @Test
+ public void testSetAdditionalProperty() throws Exception {
+ RequestReferencesContainer testSubject;
+ String name = "";
+ Object value = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAdditionalProperty(name, value);
+ }
+
+ @Test
+ public void testGetRequestReferences() throws Exception {
+ RequestReferencesContainer testSubject;
+ RequestReferences result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRequestReferences();
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ RequestReferencesContainer testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/model/ResultTest.java b/onap-enabler-be/src/test/java/org/onap/osam/model/ResultTest.java
new file mode 100644
index 0000000..9b1f3f4
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/model/ResultTest.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import org.junit.Test;
+
+public class ResultTest {
+
+ private Result createTestSubject() {
+ return new Result("");
+ }
+
+ @Test
+ public void testGetResult() throws Exception {
+ Result testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getResult();
+ }
+
+ @Test
+ public void testSetResult() throws Exception {
+ Result testSubject;
+ String result = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setResult(result);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/model/ServiceInstanceSearchResultTest.java b/onap-enabler-be/src/test/java/org/onap/osam/model/ServiceInstanceSearchResultTest.java
new file mode 100644
index 0000000..bfb3e4b
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/model/ServiceInstanceSearchResultTest.java
@@ -0,0 +1,204 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import org.junit.Test;
+
+public class ServiceInstanceSearchResultTest {
+
+ private ServiceInstanceSearchResult createTestSubject() {
+ return new ServiceInstanceSearchResult();
+ }
+
+ @Test
+ public void testGetServiceInstanceId() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getServiceInstanceId();
+ }
+
+ @Test
+ public void testSetServiceInstanceId() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String serviceInstanceId = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setServiceInstanceId(serviceInstanceId);
+ }
+
+ @Test
+ public void testGetGlobalCustomerId() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getGlobalCustomerId();
+ }
+
+ @Test
+ public void testSetGlobalCustomerId() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String globalCustomerId = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setGlobalCustomerId(globalCustomerId);
+ }
+
+ @Test
+ public void testGetServiceType() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getServiceType();
+ }
+
+ @Test
+ public void testSetServiceType() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String serviceType = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setServiceType(serviceType);
+ }
+
+ @Test
+ public void testGetServiceInstanceName() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getServiceInstanceName();
+ }
+
+ @Test
+ public void testSetServiceInstanceName() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String serviceInstanceName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setServiceInstanceName(serviceInstanceName);
+ }
+
+ @Test
+ public void testGetSubscriberName() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getSubscriberName();
+ }
+
+ @Test
+ public void testSetSubscriberName() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String subscriberName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setSubscriberName(subscriberName);
+ }
+
+ @Test
+ public void testGetAaiModelInvariantId() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAaiModelInvariantId();
+ }
+
+ @Test
+ public void testSetAaiModelInvariantId() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String aaiModelInvariantId = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAaiModelInvariantId(aaiModelInvariantId);
+ }
+
+ @Test
+ public void testGetAaiModelVersionId() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAaiModelVersionId();
+ }
+
+ @Test
+ public void testSetAaiModelVersionId() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ String aaiModelVersionId = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAaiModelVersionId(aaiModelVersionId);
+ }
+
+ @Test
+ public void testGetIsPermitted() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getIsPermitted();
+ }
+
+ @Test
+ public void testSetIsPermitted() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ boolean isPermitted = false;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setIsPermitted(isPermitted);
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ ServiceInstanceSearchResult testSubject;
+ Object other = null;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.equals(other);
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/model/VNFDaoTest.java b/onap-enabler-be/src/test/java/org/onap/osam/model/VNFDaoTest.java
new file mode 100644
index 0000000..1182a0f
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/model/VNFDaoTest.java
@@ -0,0 +1,176 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Set;
+
+import org.junit.Test;
+
+public class VNFDaoTest {
+
+ private VNFDao createTestSubject() {
+ return new VNFDao();
+ }
+
+ @Test
+ public void testGetId() throws Exception {
+ VNFDao testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getId();
+ }
+
+ @Test
+ public void testGetCreated() throws Exception {
+ VNFDao testSubject;
+ Date result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCreated();
+ }
+
+ @Test
+ public void testGetModified() throws Exception {
+ VNFDao testSubject;
+ Date result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getModified();
+ }
+
+ @Test
+ public void testGetCreatedId() throws Exception {
+ VNFDao testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCreatedId();
+ }
+
+ @Test
+ public void testGetModifiedId() throws Exception {
+ VNFDao testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getModifiedId();
+ }
+
+ @Test
+ public void testGetAuditUserId() throws Exception {
+ VNFDao testSubject;
+ Serializable result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAuditUserId();
+ }
+
+ @Test
+ public void testGetRowNum() throws Exception {
+ VNFDao testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRowNum();
+ }
+
+ @Test
+ public void testGetAuditTrail() throws Exception {
+ VNFDao testSubject;
+ Set result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAuditTrail();
+ }
+
+ @Test
+ public void testGetVnfUUID() throws Exception {
+ VNFDao testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getVnfUUID();
+ }
+
+ @Test
+ public void testGetVnfInvariantUUID() throws Exception {
+ VNFDao testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getVnfInvariantUUID();
+ }
+
+ @Test
+ public void testSetVnfUUID() throws Exception {
+ VNFDao testSubject;
+ String vnfUUID = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setVnfUUID(vnfUUID);
+ }
+
+ @Test
+ public void testSetVnfInvariantUUID() throws Exception {
+ VNFDao testSubject;
+ String vnfInvariantUUID = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setVnfInvariantUUID(vnfInvariantUUID);
+ }
+
+ @Test
+ public void testGetWorkflows() throws Exception {
+ VNFDao testSubject;
+ Set<VidWorkflow> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getWorkflows();
+ }
+
+ @Test
+ public void testSetWorkflows() throws Exception {
+ VNFDao testSubject;
+ Set<VidWorkflow> workflows = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setWorkflows(workflows);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/model/VidWorkflowTest.java b/onap-enabler-be/src/test/java/org/onap/osam/model/VidWorkflowTest.java
new file mode 100644
index 0000000..6a85cd4
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/model/VidWorkflowTest.java
@@ -0,0 +1,136 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Set;
+
+import org.junit.Test;
+
+public class VidWorkflowTest {
+
+ private VidWorkflow createTestSubject() {
+ return new VidWorkflow();
+ }
+
+ @Test
+ public void testGetId() throws Exception {
+ VidWorkflow testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getId();
+ }
+
+ @Test
+ public void testGetCreated() throws Exception {
+ VidWorkflow testSubject;
+ Date result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCreated();
+ }
+
+ @Test
+ public void testGetModified() throws Exception {
+ VidWorkflow testSubject;
+ Date result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getModified();
+ }
+
+ @Test
+ public void testGetCreatedId() throws Exception {
+ VidWorkflow testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCreatedId();
+ }
+
+ @Test
+ public void testGetModifiedId() throws Exception {
+ VidWorkflow testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getModifiedId();
+ }
+
+ @Test
+ public void testGetAuditUserId() throws Exception {
+ VidWorkflow testSubject;
+ Serializable result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAuditUserId();
+ }
+
+ @Test
+ public void testGetRowNum() throws Exception {
+ VidWorkflow testSubject;
+ Long result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRowNum();
+ }
+
+ @Test
+ public void testGetAuditTrail() throws Exception {
+ VidWorkflow testSubject;
+ Set result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAuditTrail();
+ }
+
+ @Test
+ public void testGetWokflowName() throws Exception {
+ VidWorkflow testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getWokflowName();
+ }
+
+ @Test
+ public void testSetWokflowName() throws Exception {
+ VidWorkflow testSubject;
+ String wokflowName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setWokflowName(wokflowName);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/model/WorkflowTest.java b/onap-enabler-be/src/test/java/org/onap/osam/model/WorkflowTest.java
new file mode 100644
index 0000000..10a66c5
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/model/WorkflowTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.util.Collection;
+
+import org.junit.Test;
+
+public class WorkflowTest {
+
+ private Workflow createTestSubject() {
+ return new Workflow();
+ }
+
+ @Test
+ public void testGetId() throws Exception {
+ Workflow testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getId();
+ }
+
+ @Test
+ public void testGetWorkflowName() throws Exception {
+ Workflow testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getWorkflowName();
+ }
+
+ @Test
+ public void testGetVnfNames() throws Exception {
+ Workflow testSubject;
+ Collection<String> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getVnfNames();
+ }
+
+ @Test
+ public void testSetId() throws Exception {
+ Workflow testSubject;
+ int id = 0;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setId(id);
+ }
+
+ @Test
+ public void testSetWorkflowName() throws Exception {
+ Workflow testSubject;
+ String workflowName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setWorkflowName(workflowName);
+ }
+
+ @Test
+ public void testSetVnfName() throws Exception {
+ Workflow testSubject;
+ Collection<String> vnfNames = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setVnfName(vnfNames);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/model/oeModel.java b/onap-enabler-be/src/test/java/org/onap/osam/model/oeModel.java
new file mode 100644
index 0000000..46757b3
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/model/oeModel.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.model;
+
+import java.util.List;
+import java.util.Map;
+
+public class oeModel {
+ public Map<String,List<Map<String,String>>> categoryParameters;
+}
+
+
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoBusinessLogicImplTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoBusinessLogicImplTest.java
new file mode 100644
index 0000000..743d218
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoBusinessLogicImplTest.java
@@ -0,0 +1,195 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.controllers.MsoController;
+import org.onap.osam.mso.rest.RequestDetails;
+import org.onap.osam.mso.rest.RequestDetailsWrapper;
+import org.onap.osam.properties.Features;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.testng.Assert;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import org.togglz.core.manager.FeatureManager;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.osam.controllers.MsoController.SVC_INSTANCE_ID;
+import static org.onap.osam.mso.MsoBusinessLogicImpl.validateEndpointPath;
+
+@ContextConfiguration(classes = {SystemProperties.class})
+@WebAppConfiguration
+public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
+
+ private static final String SERVICE_INSTANCE_ID = "1";
+ private static final String VNF_INSTANCE_ID = "1";
+ private static final String EXPECTED_SCALE_OUT_PATH = "/serviceInstantiation/v7/serviceInstances/1/vnfs/1/vfModules/scaleOut";
+ private static final Path PATH_TO_NOT_PROCESSED_SCALE_OUT_REQUEST = Paths.get("src", "test", "resources", "payload_jsons", "scaleOutVfModulePayload.json");
+ private static final Path PATH_TO_FINAL_SCALE_OUT_REQUEST = Paths.get("src", "test", "resources", "payload_jsons", "scaleOutVfModulePayloadToMso.json");
+ private static final ObjectMapper OBJECT_MAPPER=new ObjectMapper();
+
+ @InjectMocks
+ private MsoBusinessLogicImpl msoBusinessLogic;
+
+ @Mock
+ private FeatureManager featureManagerMock;
+
+ @Mock
+ private MsoInterface msoInterfaceMock;
+
+
+ @BeforeTest
+ public void initMocks() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void validateEndpointPath_endPointIsNotEmptyAndVaild_returnProperty() {
+ System.setProperty("TestEnv", "123");
+ String foundEndPoint = validateEndpointPath("TestEnv");
+ Assert.assertEquals("123", foundEndPoint);
+ }
+
+ @Test(expectedExceptions = RuntimeException.class)
+ public void validateEndpointPath_endPointIsNull_throwRuntimeException() {
+ validateEndpointPath("NotExists");
+ }
+
+ @Test(expectedExceptions = RuntimeException.class)
+ public void validateEndpointPath_endPointIsNotEmptyButDoesntExists_throwRuntimeException() {
+ System.setProperty("EmptyEndPoint", "");
+ validateEndpointPath("EmptyEndPoint");
+ }
+
+
+ //@Test(dataProvider = "unAssignOrDeleteParams")
+ public void deleteSvcInstance_verifyEndPointPathConstructing_unAssignFeatureOffOrUnAssignFlagIsFalse(boolean isAssignFlag, String status) {
+ Mockito.reset(msoInterfaceMock);
+ String endpoint = validateEndpointPath(isAssignFlag ? MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE : MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ RequestDetails requestDetails = new RequestDetails();
+
+ when(featureManagerMock.isActive(Features.FLAG_UNASSIGN_SERVICE)).thenReturn(isAssignFlag);
+
+ msoBusinessLogic.deleteSvcInstance(requestDetails, "tempId", status);
+
+ verify(msoInterfaceMock).deleteSvcInstance(requestDetails, endpoint + "/tempId");
+ }
+
+ @DataProvider
+ public Object[][] unAssignOrDeleteParams() {
+ return new Object[][]{
+ {Boolean.FALSE, "active"},
+ {Boolean.FALSE, "created"},
+ {Boolean.TRUE, "Active"},
+ {Boolean.TRUE, "unexpected-status"},
+ };
+ }
+
+ //@Test(dataProvider = "unAssignStatus")
+ public void deleteSvcInstance_verifyEndPointPathConstructing_unAssignFeatureOnAndUnAssignFlagIsTrue(String status) {
+ Mockito.reset(msoInterfaceMock);
+ // in the test Features.FLAG_UNASSIGN_SERVICE is active so the endpoint should be MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE
+ String endpoint = validateEndpointPath(MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE);
+ RequestDetails requestDetails = new RequestDetails();
+
+ when(featureManagerMock.isActive(Features.FLAG_UNASSIGN_SERVICE)).thenReturn(true);
+
+ msoBusinessLogic.deleteSvcInstance(requestDetails, "tempId", status);
+
+ verify(msoInterfaceMock).unassignSvcInstance(requestDetails, endpoint + "/tempId/unassign");
+ }
+
+ @DataProvider
+ public Object[][] unAssignStatus() {
+ return new Object[][]{
+ {"Created"},
+ {"Pendingdelete"},
+ {"pending-Delete"},
+ {"Assigned"}
+ };
+ }
+
+ @Test
+ public void deleteVnf_verifyEndPointPathConstructing() {
+ String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE);
+ RequestDetails requestDetails = new RequestDetails();
+
+ String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, "serviceInstanceTempId");
+
+ msoBusinessLogic.deleteVnf(requestDetails, "serviceInstanceTempId", "vnfInstanceTempId");
+ verify(msoInterfaceMock).deleteVnf(requestDetails, vnf_endpoint + "/vnfInstanceTempId");
+ }
+
+ @Test
+ public void deleteVfModule_verifyEndPointPathConstructing() {
+ String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
+ RequestDetails requestDetails = new RequestDetails();
+
+ String vf__modules_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, "serviceInstanceTempId").replaceFirst(MsoController.VNF_INSTANCE_ID, "vnfInstanceTempId");
+
+ msoBusinessLogic.deleteVfModule(requestDetails, "serviceInstanceTempId", "vnfInstanceTempId", "vfModuleTempId");
+ verify(msoInterfaceMock).deleteVfModule(requestDetails, vf__modules_endpoint + "/vfModuleTempId");
+ }
+
+
+ //@Test - fails after code cutting - TBD later
+ public void shouldSendProperScaleOutRequest() throws IOException {
+ ArgumentCaptor<RequestDetailsWrapper> requestDetailsWrapperArgumentCaptor = ArgumentCaptor.forClass(RequestDetailsWrapper.class);
+ RequestDetails requestDetails = getScaleOutRequest();
+ RequestDetailsWrapper expectedRequestWrapper = getExpectedRequestWrapper();
+
+ msoBusinessLogic.scaleOutVfModuleInstance(requestDetails, SERVICE_INSTANCE_ID, VNF_INSTANCE_ID);
+
+ verify(msoInterfaceMock).scaleOutVFModuleInstance(requestDetailsWrapperArgumentCaptor.capture(), eq(EXPECTED_SCALE_OUT_PATH));
+ RequestDetailsWrapper actual = requestDetailsWrapperArgumentCaptor.getAllValues().get(0);
+
+ assertThat(expectedRequestWrapper.requestDetails).isEqualTo(actual.requestDetails);
+ }
+
+ private RequestDetails getScaleOutRequest() throws IOException {
+ return OBJECT_MAPPER.readValue(PATH_TO_NOT_PROCESSED_SCALE_OUT_REQUEST.toFile(), RequestDetails.class);
+ }
+
+ private RequestDetailsWrapper getExpectedRequestWrapper() throws IOException {
+ return OBJECT_MAPPER.readValue(PATH_TO_FINAL_SCALE_OUT_REQUEST.toFile(), new TypeReference<RequestDetailsWrapper>() {
+ });
+ }
+}
+
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoBusinessLogicTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoBusinessLogicTest.java
new file mode 100644
index 0000000..b1347d0
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoBusinessLogicTest.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.osam.mso.rest.RequestDetails;
+import org.onap.osam.mso.rest.RequestDetailsWrapper;
+import org.testng.annotations.Test;
+
+import java.net.URL;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+@RunWith(MockitoJUnitRunner.class)
+public class MsoBusinessLogicTest {
+
+ @InjectMocks
+ private MsoBusinessLogicImpl msoBusinessLogic;
+
+ @Mock
+ private MsoInterface msoClient;
+
+ @Test
+ public void testCreateInstance() throws Exception {
+ String instanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
+ final RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
+ requestDetailsWrapper.requestDetails = setRequestDetails("mso_request_create_configuration.json");
+ Mockito.doReturn(getOkResponse(instanceId)).when(msoClient).createConfigurationInstance(requestDetailsWrapper, "/serviceInstances/v6/3f93c7cb-2fd0-4557-9514-e189b7b04f9d/configurations");
+ final MsoResponseWrapper msoResponseWrapper = msoBusinessLogic.createConfigurationInstance(requestDetailsWrapper, instanceId);
+
+ assertNotNull(msoResponseWrapper);
+ assertEquals(202, msoResponseWrapper.getStatus());
+ }
+
+ private MsoResponseWrapper getOkResponse(String instanceId){
+ MsoResponseWrapper responseWrapper = new MsoResponseWrapper();
+ String entity = " \"body\": {\n" +
+ " \"requestReferences\": {\n" +
+ " \"instanceId\": \""+instanceId+"\",\n" +
+ " \"requestId\": \"b6dc9806-b094-42f7-9386-a48de8218ce8\"\n" +
+ " }";
+ responseWrapper.setEntity(entity);
+ responseWrapper.setStatus(202);
+ return responseWrapper;
+ }
+
+ private RequestDetails setRequestDetails(String bodyFileName)throws Exception {
+ final URL resource = this.getClass().getResource("/payload_jsons/" + bodyFileName);
+ ObjectMapper mapper = new ObjectMapper();
+ RequestDetails requestDetails = mapper.readValue(resource, RequestDetails.class);
+ return requestDetails;
+
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoResponseWrapper2Test.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoResponseWrapper2Test.java
new file mode 100644
index 0000000..4ec0f98
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoResponseWrapper2Test.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import org.junit.Test;
+
+public class MsoResponseWrapper2Test {
+
+ private MsoResponseWrapper2 createTestSubject() {
+ return new MsoResponseWrapper2(new RestObject());
+ }
+
+ @Test
+ public void testGetStatus() throws Exception {
+ MsoResponseWrapper2 testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getStatus();
+ }
+
+ @Test
+ public void testGetResponse() throws Exception {
+ MsoResponseWrapper2 testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getResponse();
+ }
+
+ @Test
+ public void testGetEntity() throws Exception {
+ MsoResponseWrapper2 testSubject;
+ Object result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getEntity();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoResponseWrapperTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoResponseWrapperTest.java
new file mode 100644
index 0000000..9124d5f
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoResponseWrapperTest.java
@@ -0,0 +1,92 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import org.junit.Test;
+
+public class MsoResponseWrapperTest {
+
+ private MsoResponseWrapper createTestSubject() {
+ return new MsoResponseWrapper();
+ }
+
+ @Test
+ public void testGetEntity() throws Exception {
+ MsoResponseWrapper testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getEntity();
+ }
+
+ @Test
+ public void testGetStatus() throws Exception {
+ MsoResponseWrapper testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getStatus();
+ }
+
+ @Test
+ public void testSetStatus() throws Exception {
+ MsoResponseWrapper testSubject;
+ int v = 0;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setStatus(v);
+ }
+
+ @Test
+ public void testSetEntity() throws Exception {
+ MsoResponseWrapper testSubject;
+ String v = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setEntity(v);
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ MsoResponseWrapper testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+
+ @Test
+ public void testGetResponse() throws Exception {
+ MsoResponseWrapper testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getResponse();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoUtilTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoUtilTest.java
new file mode 100644
index 0000000..93230e6
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/MsoUtilTest.java
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MsoUtilTest {
+
+ private MsoUtil createTestSubject() {
+ return new MsoUtil();
+ }
+
+ @Test
+ public void testWrapResponse() throws Exception {
+ String body = "";
+ int statusCode = 0;
+ MsoResponseWrapper result;
+
+ // default test
+ result = MsoUtil.wrapResponse(body, statusCode);
+ }
+
+
+ @Test
+ public void testWrapResponse_2() throws Exception {
+ RestObject<String> rs = null;
+ MsoResponseWrapper result;
+
+ // test 1
+ result = MsoUtil.wrapResponse(rs);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertPojoToString() throws Exception {
+ String result;
+
+ // test 1
+ result = MsoUtil.convertPojoToString(null);
+ Assert.assertEquals("", result);
+ }
+
+ @Test
+ public void testMain() throws Exception {
+ String[] args = new String[] { "" };
+
+ // default test
+ MsoUtil.main(args);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/RestMsoImplementationTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/RestMsoImplementationTest.java
new file mode 100644
index 0000000..03f8446
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/RestMsoImplementationTest.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import org.junit.Test;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+
+public class RestMsoImplementationTest {
+
+ private RestMsoImplementation createTestSubject() {
+ return new RestMsoImplementation();
+ }
+
+ @Test
+ public void testInitMsoClient() throws Exception {
+ RestMsoImplementation testSubject;
+ MultivaluedHashMap<String, Object> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.initMsoClient();
+ } catch (Exception e) {
+ }
+ }
+
+
+ @Test
+ public void testGetForObject() throws Exception {
+ RestMsoImplementation testSubject;
+ String sourceID = "";
+ String path = "";
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ testSubject.GetForObject(sourceID, path, null);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ RestMsoImplementation testSubject;
+ String sourceID = "";
+ String path = "";
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ testSubject.Delete(null, null, sourceID, path, null);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testPostForObject() throws Exception {
+ RestMsoImplementation testSubject;
+ Object requestDetails = null;
+ String sourceID = "";
+ String path = "";
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ testSubject.PostForObject(requestDetails, sourceID, path, null);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+
+
+ @Test
+ public void testPrepareClient() throws Exception {
+ RestMsoImplementation testSubject;
+ String path = "";
+ String methodName = "";
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ testSubject.prepareClient(path, methodName);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+
+
+
+ // @Test
+ // public void testInitMsoClient() throws Exception {
+ // RestMsoImplementation testSubject;
+ //
+ // // default test
+ // testSubject = createTestSubject();
+ // testSubject.initMsoClient();
+ // }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/RestObjectTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/RestObjectTest.java
new file mode 100644
index 0000000..60420d2
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/RestObjectTest.java
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso;
+
+import org.junit.Test;
+
+public class RestObjectTest {
+
+ private RestObject createTestSubject() {
+ return new RestObject();
+ }
+
+ @Test
+ public void testSet() throws Exception {
+ RestObject testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.set(null);
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ RestObject testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.get();
+ }
+
+ @Test
+ public void testSetStatusCode() throws Exception {
+ RestObject testSubject;
+ int v = 0;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setStatusCode(v);
+ }
+
+ @Test
+ public void testGetStatusCode() throws Exception {
+ RestObject testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getStatusCode();
+ }
+
+ @Test
+ public void testGetRaw() throws Exception {
+ RestObject testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRaw();
+ }
+
+ @Test
+ public void testSetRaw() throws Exception {
+ RestObject testSubject;
+ String rawT = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setRaw(rawT);
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ RestObject testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/AsyncRequestStatusTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/AsyncRequestStatusTest.java
new file mode 100644
index 0000000..3d94f03
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/AsyncRequestStatusTest.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import org.junit.Test;
+
+
+public class AsyncRequestStatusTest {
+
+ private AsyncRequestStatus createTestSubject() {
+ return new AsyncRequestStatus();
+ }
+
+
+ @Test
+ public void testToString() throws Exception {
+ AsyncRequestStatus testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+
+
+ @Test
+ public void testHashCode() throws Exception {
+ AsyncRequestStatus testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.hashCode();
+ }
+
+
+ @Test
+ public void testEquals() throws Exception {
+ AsyncRequestStatus testSubject;
+ Object other = null;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.equals(other);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/MsoRestClientNewTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/MsoRestClientNewTest.java
new file mode 100644
index 0000000..16024bb
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/MsoRestClientNewTest.java
@@ -0,0 +1,471 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.osam.mso.rest;
+
+import com.xebialabs.restito.server.StubServer;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.client.SyncRestClient;
+import org.onap.osam.controllers.MsoController;
+import org.onap.osam.mso.MsoInterface;
+import org.onap.osam.mso.MsoProperties;
+import org.onap.osam.mso.MsoResponseWrapper;
+import org.onap.osam.mso.MsoResponseWrapperInterface;
+import org.onap.osam.mso.RestObject;
+import org.springframework.test.context.ContextConfiguration;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Properties;
+import java.util.UUID;
+
+import static org.onap.osam.controllers.MsoController.SVC_INSTANCE_ID;
+import static org.onap.osam.controllers.MsoController.VNF_INSTANCE_ID;
+
+@ContextConfiguration(classes = {SystemProperties.class})
+public class MsoRestClientNewTest {
+
+ private static StubServer server;
+ private static StubServer securedServer;
+ private static Properties props = new Properties();
+ private static String msoCreateServiceInstanceJson;
+ private static String msoScaleOutVfModule;
+ private final static String CREATE_INSTANCE_RESPONSE_STR =
+ "{\"requestReferences\":{\"instanceId\":\"baa13544-0e95-4644-9565-9a198a29a294\","
+ + "\"requestId\":\"a42a1a35-3d63-4629-bbe0-4989fa7414cb\"}}";
+ private final static String SERVICE_INSTANCE_ID = "12345";
+ private static final String SAMPLE_VNF_INSTANCE_ID = "111";
+ private static final String SAMPLE_VNF_MODULE_ID = "987";
+ private static final String SAMPLE_NETWORK_INSTANCE_ID = "666";
+ private static final String SAMPLE_CONFIGURATION_ID = "997";
+ private static final String SAMPLE_REQUEST_ID = "7777";
+
+
+ @BeforeClass
+ public static void start() throws IOException {
+ server = new StubServer().run();
+ securedServer = new StubServer().secured().run();
+
+ Path resourceDirectory =
+ Paths.get("src", "test", "resources", "WEB-INF", "conf", "system.properties");
+ try (InputStream is = Files.newInputStream(resourceDirectory)) {
+ props.load(is);
+ }
+
+ Path msoServiceInstantiationJsonFilePath =
+ Paths.get("src", "test", "resources", "payload_jsons", "mso_service_instantiation.json");
+
+ Path scaleOutJsonFilePath = Paths.get("src", "test", "resources", "payload_jsons", "scaleOutVfModulePayloadToMso.json");
+ msoCreateServiceInstanceJson =
+ String.join("\n", Files.readAllLines(msoServiceInstantiationJsonFilePath));
+ msoScaleOutVfModule = String.join("\n", Files.readAllLines(scaleOutJsonFilePath));
+
+ }
+
+ @AfterClass
+ public static void stop() {
+ server.stop();
+ securedServer.stop();
+ }
+
+
+ private String baseUrl() {
+ return String.format("http://localhost:%d", server.getPort());
+ }
+
+ @Test
+ public void testCreateSvcInstance() throws Exception {
+ String endpoint = props.getProperty(MsoProperties.MSO_REST_API_CONFIGURATIONS);
+ endpoint = endpoint.replace(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+ try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ endpoint,
+ HttpStatus.ACCEPTED_202,
+ CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::createSvcInstance);
+ }
+ }
+
+ @Test
+ public void testCreateVnf() throws Exception {
+ String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VNF_INSTANCE);
+ endpoint = endpoint.replace(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+ try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ endpoint,
+ HttpStatus.ACCEPTED_202,
+ CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+
+ closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::createVnf);
+ }
+ }
+
+ @Test
+ public void testCreateNwInstance() throws Exception {
+ String endpoint = props.getProperty(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
+ String nw_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+ try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ nw_endpoint,
+ HttpStatus.ACCEPTED_202,
+ CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::createNwInstance);
+ }
+ }
+
+ @Test
+ public void testCreateVolumeGroupInstance() throws Exception {
+ String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
+ String vnf_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+ vnf_endpoint = vnf_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
+ try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ vnf_endpoint,
+ HttpStatus.ACCEPTED_202,
+ CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::createVolumeGroupInstance);
+ }
+ }
+
+ @Test
+ public void testCreateVfModuleInstance() throws Exception {
+ String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
+ String partial_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+ String vf_module_endpoint =
+ partial_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
+
+
+ try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ vf_module_endpoint,
+ HttpStatus.ACCEPTED_202,
+ CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::createVfModuleInstance);
+ }
+ }
+
+ @Test
+ public void testCreateConfigurationInstance() throws Exception {
+ MsoRestClientNew testSubject;
+ RequestDetailsWrapper requestDetails = null;
+ String endpoint = "";
+ MsoResponseWrapper result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.createConfigurationInstance(requestDetails, endpoint);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDeleteSvcInstance() throws Exception {
+ String endpoint = props.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+
+
+ try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ endpoint,
+ HttpStatus.NO_CONTENT_204,
+ CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executeDelete(msoCreateServiceInstanceJson, msoRestClient()::deleteSvcInstance);
+ }
+ }
+
+ @Test
+ public void testDeleteVnf() throws Exception {
+ String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VNF_INSTANCE);
+ endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+
+ try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ endpoint,
+ HttpStatus.NO_CONTENT_204,
+ CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executeDelete(msoCreateServiceInstanceJson, msoRestClient()::deleteVnf);
+ }
+ }
+
+ @Test
+ public void testDeleteVfModule() throws Exception {
+ String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
+ String part_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+ String vf_modules_endpoint = part_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
+ String delete_vf_endpoint = vf_modules_endpoint + '/' + SAMPLE_VNF_MODULE_ID;
+
+ try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ delete_vf_endpoint,
+ HttpStatus.NO_CONTENT_204,
+ CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executeDelete(msoCreateServiceInstanceJson, msoRestClient()::deleteVfModule);
+ }
+ }
+
+ @Test
+ public void testDeleteVolumeGroupInstance() throws Exception {
+ String endpoint = props.getProperty(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
+ String svc_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+ String vnf_endpoint = svc_endpoint.replaceFirst(MsoController.VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
+ String delete_volume_group_endpoint = vnf_endpoint + "/" + SAMPLE_VNF_MODULE_ID;
+
+ try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ delete_volume_group_endpoint,
+ HttpStatus.NO_CONTENT_204,
+ CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executeDelete(msoCreateServiceInstanceJson, msoRestClient()::deleteVolumeGroupInstance);
+ }
+ }
+
+ @Test
+ public void testDeleteNwInstance() throws Exception {
+ String endpoint = props.getProperty(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
+ String svc_endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+ String delete_nw_endpoint = svc_endpoint + "/" + SAMPLE_NETWORK_INSTANCE_ID;
+
+ try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ delete_nw_endpoint,
+ HttpStatus.NO_CONTENT_204,
+ CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executeDelete(msoCreateServiceInstanceJson, msoRestClient()::deleteNwInstance);
+ }
+ }
+
+ @Test
+ public void testGetOrchestrationRequest() {
+ String p = props.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ);
+ String path = p + "/" + SAMPLE_REQUEST_ID;
+
+ try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ path,
+ HttpStatus.OK_200,
+ CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executeGet(msoRestClient()::getOrchestrationRequest);
+ }
+ }
+
+ @Test
+ public void testGetManualTasks() {
+ String p = props.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ);
+ String path = p + "/" + UUID.randomUUID();
+
+ try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ path,
+ HttpStatus.OK_200,
+ CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executeGet(msoRestClient()::getManualTasks);
+ }
+ }
+
+ @Test
+ public void testGetOrchestrationRequestsForDashboard() throws Exception {
+ MsoRestClientNew testSubject;
+ String t = "";
+ String sourceId = "";
+ String endpoint = "";
+ RestObject restObject = null;
+ MsoResponseWrapper result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getOrchestrationRequestsForDashboard(t, sourceId, endpoint, restObject);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetManualTasksByRequestId() throws Exception {
+ MsoRestClientNew testSubject;
+ String t = "";
+ String sourceId = "";
+ String endpoint = "";
+ RestObject restObject = null;
+ MsoResponseWrapper result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getManualTasksByRequestId(t, sourceId, endpoint, restObject);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testCompleteManualTask() throws Exception {
+ MsoRestClientNew testSubject;
+ RequestDetails requestDetails = null;
+ String t = "";
+ String sourceId = "";
+ String endpoint = "";
+ RestObject restObject = null;
+ MsoResponseWrapper result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.completeManualTask(requestDetails, t, sourceId, endpoint, restObject);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testDeleteConfiguration() throws Exception {
+ MsoRestClientNew testSubject;
+ RequestDetailsWrapper requestDetails = null;
+ String pmc_endpoint = "";
+ MsoResponseWrapper result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.deleteConfiguration(requestDetails, pmc_endpoint);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testSetConfigurationActiveStatus() throws Exception {
+ String endpoint = "/serviceInstances/v5/<service_instance_id>/configurations/<configuration_id>";
+ endpoint = endpoint.replace(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+ endpoint = endpoint.replace(MsoController.CONFIGURATION_ID, SAMPLE_CONFIGURATION_ID);
+ endpoint = endpoint + "/activate";
+
+ try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ endpoint,
+ HttpStatus.ACCEPTED_202,
+ CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::setConfigurationActiveStatus);
+ }
+ }
+
+ @Test
+ public void testSetPortOnConfigurationStatus() throws Exception {
+ MsoRestClientNew testSubject;
+ RequestDetails request = null;
+ String path = "";
+ MsoResponseWrapper result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.setPortOnConfigurationStatus(request, path);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testChangeManagementUpdate() throws Exception {
+ MsoRestClientNew testSubject;
+ RequestDetailsWrapper requestDetails = null;
+ String endpoint = "";
+ MsoResponseWrapperInterface result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.changeManagementUpdate(requestDetails, endpoint);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testSetServiceInstanceStatus() throws Exception {
+ MsoRestClientNew testSubject;
+ RequestDetails requestDetails = null;
+ String t = "";
+ String sourceId = "";
+ String endpoint = "";
+ RestObject<String> restObject = null;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ testSubject.setServiceInstanceStatus(requestDetails, t, sourceId, endpoint, restObject);
+ } catch (Exception e) {
+ }
+ }
+
+ @Test
+ public void testRemoveRelationshipFromServiceInstance() throws Exception {
+ String serviceEndpoint = props.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String removeRelationshipsPath = serviceEndpoint + "/" + SERVICE_INSTANCE_ID + "/removeRelationships";
+
+ try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ removeRelationshipsPath,
+ HttpStatus.ACCEPTED_202,
+ CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executePost(msoCreateServiceInstanceJson, msoRestClient()::removeRelationshipFromServiceInstance);
+ }
+ }
+
+ @Test
+ public void testAddRelationshipToServiceInstance() throws Exception {
+ MsoRestClientNew testSubject;
+ RequestDetails requestDetails = null;
+ String addRelationshipsPath = "";
+ MsoResponseWrapper result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.addRelationshipToServiceInstance(requestDetails, addRelationshipsPath);
+ } catch (Exception e) {
+ }
+ }
+ @Test
+ public void testScaleOutVfModule() throws IOException {
+ String serviceEndpoint = props.getProperty(MsoProperties.MSO_REST_API_VF_MODULE_SCALE_OUT);
+ String partial_endpoint = serviceEndpoint.replaceFirst(SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
+ String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, SAMPLE_VNF_INSTANCE_ID);
+ try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
+ server,
+ vf_module_endpoint,
+ HttpStatus.ACCEPTED_202,
+ CREATE_INSTANCE_RESPONSE_STR, CREATE_INSTANCE_RESPONSE_STR)) {
+ closure.executePostCall(msoScaleOutVfModule, msoRestClient()::scaleOutVFModuleInstance);
+ }
+
+ }
+
+ private MsoRestClientNew msoRestClient() {
+ return new MsoRestClientNew(new SyncRestClient(MsoInterface.objectMapper()), baseUrl());
+ }
+
+ private MsoRestClientNew createTestSubject() {
+ return new MsoRestClientNew(null, "");
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/MsoRestClientTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/MsoRestClientTest.java
new file mode 100644
index 0000000..ffe65cc
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/MsoRestClientTest.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.osam.mso.rest;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.onap.osam.client.SyncRestClient;
+import org.onap.osam.domain.mso.CloudConfiguration;
+import org.onap.osam.domain.mso.ModelInfo;
+import org.onap.osam.domain.mso.RequestInfo;
+import org.onap.osam.domain.mso.RequestParameters;
+import org.onap.osam.mso.MsoBusinessLogic;
+import org.onap.osam.mso.MsoBusinessLogicImpl;
+import org.onap.osam.controllers.LocalWebConfig;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.testng.annotations.Test;
+
+
+@ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class})
+@WebAppConfiguration
+public class MsoRestClientTest {
+
+
+ private MsoBusinessLogic msoBusinessLogic = new MsoBusinessLogicImpl(new MsoRestClientNew(new SyncRestClient(), ""), null);
+ private ObjectMapper om = new ObjectMapper();
+
+ @Test
+ public void createInPlaceMsoRequest() {
+ String result = null;
+ try {
+ RequestDetails requestDetails = generateMockMsoRequest();
+ result = om.writeValueAsString(msoBusinessLogic.generateInPlaceMsoRequest(requestDetails));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (result == null) {
+ Assert.fail("Failed to create mso request");
+ }
+ JSONObject jsonObj = new JSONObject(result);
+ Assert.assertNotNull(jsonObj.getJSONObject("requestDetails"));
+ }
+
+ private RequestDetails generateMockMsoRequest() {
+ RequestDetails requestDetails = new RequestDetails();
+ //requestDetails.setVnfInstanceId("vnf-instance-id");
+ //requestDetails.setVnfName("vnf-name");
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setTenantId("tenant-id");
+ cloudConfiguration.setLcpCloudRegionId("lcp-region");
+ requestDetails.setCloudConfiguration(cloudConfiguration);
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelInvariantId("model-invarient-id");
+ modelInfo.setModelCustomizationName("modelCustomizationName");
+ requestDetails.setModelInfo(modelInfo);
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setRequestorId("ok883e");
+ requestInfo.setSource("VID");
+ requestDetails.setRequestInfo(requestInfo);
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setSubscriptionServiceType("subscriber-service-type");
+ requestParameters.setAdditionalProperty("a", 1);
+ requestParameters.setAdditionalProperty("b", 2);
+ requestParameters.setAdditionalProperty("c", 3);
+ requestParameters.setAdditionalProperty("d", 4);
+ String payload = "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}";
+ requestParameters.setAdditionalProperty("payload", payload);
+
+ requestDetails.setRequestParameters(requestParameters);
+ return requestDetails;
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/MsoRestClientTestUtil.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/MsoRestClientTestUtil.java
new file mode 100644
index 0000000..1066be4
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/MsoRestClientTestUtil.java
@@ -0,0 +1,146 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import static com.xebialabs.restito.builder.stub.StubHttp.whenHttp;
+import static com.xebialabs.restito.builder.verify.VerifyHttp.verifyHttp;
+import static com.xebialabs.restito.semantics.Action.contentType;
+import static com.xebialabs.restito.semantics.Action.status;
+import static com.xebialabs.restito.semantics.Action.stringContent;
+import static com.xebialabs.restito.semantics.Condition.delete;
+import static com.xebialabs.restito.semantics.Condition.get;
+import static com.xebialabs.restito.semantics.Condition.method;
+import static com.xebialabs.restito.semantics.Condition.post;
+import static com.xebialabs.restito.semantics.Condition.uri;
+import static com.xebialabs.restito.semantics.Condition.withHeader;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.xebialabs.restito.semantics.Action;
+import com.xebialabs.restito.server.StubServer;
+import java.io.IOException;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
+import org.glassfish.grizzly.http.Method;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.osam.mso.MsoResponseWrapper;
+
+class MsoRestClientTestUtil implements AutoCloseable {
+ private final StubServer server;
+ private final String endpoint;
+ private final String responsePayload;
+ private final HttpStatus expectedStatus;
+ private final String expectedResponseStr;
+
+ MsoRestClientTestUtil(StubServer server, String endpoint, HttpStatus expectedStatus,
+ String responsePayload,
+ String expectedResponseStr) {
+ this.server = server;
+ this.endpoint = endpoint;
+ this.responsePayload = responsePayload;
+ this.expectedStatus = expectedStatus;
+ this.expectedResponseStr = expectedResponseStr;
+ }
+
+ void executePost(String jsonPayload, BiFunction<RequestDetails, String, MsoResponseWrapper> func) throws IOException {
+ whenHttp(server)
+ .match(post(endpoint))
+ .then(status(expectedStatus), jsonContent(responsePayload), contentType(MediaType.APPLICATION_JSON));
+
+ RequestDetails sampleRequestDetails =
+ new ObjectMapper().readValue(jsonPayload, RequestDetails.class);
+
+ MsoResponseWrapper response = func.apply(sampleRequestDetails, endpoint);
+ JSONObject actualJson = new JSONObject(response.getEntity());
+
+ Assert.assertEquals(expectedStatus.getStatusCode(), response.getStatus());
+ Assert.assertEquals(expectedResponseStr, actualJson.toString());
+ verifyServer(server, endpoint, Method.POST);
+
+ }
+ void executePostCall(String jsonPayload, BiFunction<RequestDetailsWrapper, String, MsoResponseWrapper> func) throws IOException {
+ whenHttp(server)
+ .match(post(endpoint))
+ .then(status(expectedStatus), jsonContent(responsePayload), contentType(MediaType.APPLICATION_JSON));
+
+ RequestDetailsWrapper sampleRequestDetails =
+ new ObjectMapper().readValue(jsonPayload, RequestDetailsWrapper.class);
+
+ MsoResponseWrapper response = func.apply(sampleRequestDetails, endpoint);
+ JSONObject actualJson = new JSONObject(response.getEntity());
+
+ Assert.assertEquals(expectedStatus.getStatusCode(), response.getStatus());
+ Assert.assertEquals(expectedResponseStr, actualJson.toString());
+ verifyServer(server, endpoint, Method.POST);
+ }
+
+ void executeDelete(String jsonPayload, BiFunction<RequestDetails, String, MsoResponseWrapper> func)
+ throws IOException {
+ whenHttp(server)
+ .match(delete(endpoint))
+ .then(status(expectedStatus), jsonContent(responsePayload), contentType(MediaType.APPLICATION_JSON));
+
+ RequestDetails sampleRequestDetails =
+ new ObjectMapper().readValue(jsonPayload, RequestDetails.class);
+ MsoResponseWrapper response = func.apply(sampleRequestDetails, endpoint);
+
+ Assert.assertEquals(expectedStatus.getStatusCode(), response.getStatus());
+ verifyServer(server, endpoint, Method.DELETE);
+ }
+
+ void executeGet(Function<String, MsoResponseWrapper> func) {
+ whenHttp(server)
+ .match(get(endpoint))
+ .then(status(expectedStatus), jsonContent(responsePayload), contentType(MediaType.APPLICATION_JSON));
+
+ MsoResponseWrapper response = func.apply(endpoint);
+
+ Assert.assertEquals(expectedStatus.getStatusCode(), response.getStatus());
+ verifyServer(server, endpoint, Method.GET);
+ }
+
+ private void verifyServer(StubServer server, String endpoint, Method httpMethod) {
+ verifyHttp(server).once(
+ method(httpMethod),
+ uri(endpoint),
+ withHeader(HttpHeaders.AUTHORIZATION),
+ withHeader(HttpHeaders.ACCEPT),
+ withHeader(HttpHeaders.CONTENT_TYPE),
+ withHeader(MsoRestClientNew.X_FROM_APP_ID),
+ withHeader(SystemProperties.ECOMP_REQUEST_ID));
+ }
+
+ private Action jsonContent(String str) {
+ return stringContent(str);
+ }
+
+ @Override
+ public void close() {
+ }
+}
+
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/OutgoingRequestIdTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/OutgoingRequestIdTest.java
new file mode 100644
index 0000000..5c42a31
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/OutgoingRequestIdTest.java
@@ -0,0 +1,212 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.commons.lang3.reflect.FieldUtils;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.InjectMocks;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.osam.aai.util.AAIRestInterface;
+import org.onap.osam.filters.PromiseEcompRequestIdFilter;
+import org.onap.osam.mso.RestMsoImplementation;
+import org.onap.osam.mso.RestObject;
+import org.onap.osam.testUtils.TestUtils;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.MultivaluedMap;
+import java.util.Set;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.equalToIgnoringCase;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasToString;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.matchesPattern;
+
+
+public class OutgoingRequestIdTest {
+
+
+ @InjectMocks
+ private RestMsoImplementation restMsoImplementation;
+
+ @InjectMocks
+ private AAIRestInterface aaiRestInterface;
+
+
+ @Captor
+ private ArgumentCaptor<MultivaluedMap<String, Object>> multivaluedMapArgumentCaptor;
+
+ @BeforeClass
+ public void initMocks() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @BeforeMethod
+ private void putRequestInSpringContext() {
+ RequestContextHolder.setRequestAttributes(new ServletRequestAttributes((HttpServletRequest) PromiseEcompRequestIdFilter.wrapIfNeeded(new MockHttpServletRequest())));
+ }
+
+ @DataProvider
+ public Object[][] msoMethods() {
+ return Stream.<ThrowingConsumer<RestMsoImplementation>>of(
+
+ client -> client.Get(new Object(), "whatever source id", "/any path", new RestObject<>()),
+ client -> client.GetForObject("whatever source id", "/any path", Object.class),
+ client -> client.Post(new Object(), "some payload", "whatever source id", "/any path", new RestObject<>()),
+ client -> client.PostForObject("some payload", "whatever source id", "/any path", Object.class),
+ client -> client.Put(Object.class, new RequestDetailsWrapper(), "whatever source id", "/any path", new RestObject<>())
+
+ ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{});
+ }
+
+ @Test(dataProvider = "msoMethods")
+ public void mso(Consumer<RestMsoImplementation> f) throws Exception {
+ final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(restMsoImplementation);
+
+ f.accept(restMsoImplementation);
+
+ verifyRequestIdHeaderWasAdded(mocks.getFakeBuilder());
+ }
+
+ @DataProvider
+ public Object[][] aaiMethods() {
+ return Stream.<ThrowingConsumer<AAIRestInterface>>of(
+
+ client -> client.RestGet("from app id", "some transId", "/any path", false),
+ client -> client.Delete("whatever source id", "some transId", "/any path"),
+ client -> client.RestPost("from app id", "/any path", "some payload", false),
+ client -> client.RestPut("from app id", "/any path", "some payload", false)
+
+ ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{});
+ }
+
+ //@Test(dataProvider = "aaiMethods")
+ public void aai(Consumer<AAIRestInterface> f) throws Exception {
+ final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(aaiRestInterface);
+
+ f.accept(aaiRestInterface);
+
+ verifyRequestIdHeaderWasAdded(mocks.getFakeBuilder());
+ }
+
+// @Test(dataProvider = "schedulerMethods")
+// public void scheduler(Consumer<AAIRestInterface> f) throws Exception {
+//
+// This test os not feasible in the wat acheduler is implemented today,
+// as Scheduler's client is rewritten in every call.
+//
+// :-(
+//
+// }
+
+ private void verifyRequestIdHeaderWasAdded(Invocation.Builder fakeBuilder) {
+ final String requestIdHeader = "x-ecomp-requestid";
+ final String uuidRegex = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
+
+ // Checks that the builder was called with either one of header("x-ecomp-requestid", uuid)
+ // or the plural brother: headers(Map.of("x-ecomp-requestid", Set.of(uuid))
+
+ Object requestId;
+ // The 'verify()' will capture the request id. If no match -- AssertionError will
+ // catch for a second chance -- another 'verify()'.
+ try {
+ ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class);
+ Mockito.verify(fakeBuilder)
+ .header(
+ Matchers.argThat(equalToIgnoringCase(requestIdHeader)),
+ argumentCaptor.capture()
+ );
+ requestId = argumentCaptor.getValue();
+
+ } catch (AssertionError e) {
+ Mockito.verify(fakeBuilder).headers(multivaluedMapArgumentCaptor.capture());
+
+ final MultivaluedMap<String, Object> headersMap = multivaluedMapArgumentCaptor.getValue();
+ final String thisRequestIdHeader = getFromSetCaseInsensitive(headersMap.keySet(), requestIdHeader);
+
+ assertThat(headersMap.keySet(), hasItem(thisRequestIdHeader));
+ requestId = headersMap.getFirst(thisRequestIdHeader);
+ }
+
+ assertThat("header '" + requestIdHeader + "' should be a uuid", requestId,
+ allOf(instanceOf(String.class), hasToString(matchesPattern(uuidRegex))));
+ }
+
+ private String getFromSetCaseInsensitive(Set<String> set, String key) {
+ return set.stream()
+ .filter(anotherString -> anotherString.equalsIgnoreCase(key))
+ .findFirst()
+ .orElse(key);
+ }
+
+ private TestUtils.JavaxRsClientMocks setAndGetMocksInsideRestImpl(Class<?> clazz) throws IllegalAccessException {
+ TestUtils.JavaxRsClientMocks mocks = new TestUtils.JavaxRsClientMocks();
+ Client fakeClient = mocks.getFakeClient();
+
+ FieldUtils.writeStaticField(clazz, "client", fakeClient, true);
+
+ return mocks;
+ }
+
+ private TestUtils.JavaxRsClientMocks setAndGetMocksInsideRestImpl(Object instance) throws IllegalAccessException {
+ TestUtils.JavaxRsClientMocks mocks = new TestUtils.JavaxRsClientMocks();
+ Client fakeClient = mocks.getFakeClient();
+
+ FieldUtils.writeField(instance, "client", fakeClient, true);
+
+ return mocks;
+ }
+
+ @FunctionalInterface
+ public interface ThrowingConsumer<T> extends Consumer<T> {
+ @Override
+ default void accept(T t) {
+ try {
+ acceptThrows(t);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ void acceptThrows(T t) throws Exception;
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RelatedInstanceTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RelatedInstanceTest.java
new file mode 100644
index 0000000..63f4bca
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RelatedInstanceTest.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import java.util.Map;
+
+import org.junit.Test;
+import org.onap.osam.domain.mso.ModelInfo;
+
+
+public class RelatedInstanceTest {
+
+ private RelatedInstance createTestSubject() {
+ return new RelatedInstance();
+ }
+
+
+ @Test
+ public void testGetModelInfo() throws Exception {
+ RelatedInstance testSubject;
+ ModelInfo result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getModelInfo();
+ }
+
+
+ @Test
+ public void testSetModelInfo() throws Exception {
+ RelatedInstance testSubject;
+ ModelInfo modelInfo = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setModelInfo(modelInfo);
+ }
+
+
+ @Test
+ public void testToString() throws Exception {
+ RelatedInstance testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+
+
+ @Test
+ public void testGetAdditionalProperties() throws Exception {
+ RelatedInstance testSubject;
+ Map<String, Object> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAdditionalProperties();
+ }
+
+
+ @Test
+ public void testSetAdditionalProperty() throws Exception {
+ RelatedInstance testSubject;
+ String name = "";
+ Object value = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAdditionalProperty(name, value);
+ }
+
+
+ @Test
+ public void testHashCode() throws Exception {
+ RelatedInstance testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.hashCode();
+ }
+
+
+ @Test
+ public void testEquals() throws Exception {
+ RelatedInstance testSubject;
+ Object other = null;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.equals(other);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RelatedModelTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RelatedModelTest.java
new file mode 100644
index 0000000..545d76a
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RelatedModelTest.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import java.util.Map;
+
+import org.junit.Test;
+import org.onap.osam.domain.mso.ModelInfo;
+
+
+public class RelatedModelTest {
+
+ private RelatedModel createTestSubject() {
+ return new RelatedModel();
+ }
+
+
+ @Test
+ public void testGetModelInfo() throws Exception {
+ RelatedModel testSubject;
+ ModelInfo result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getModelInfo();
+ }
+
+
+ @Test
+ public void testSetModelInfo() throws Exception {
+ RelatedModel testSubject;
+ ModelInfo modelInfo = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setModelInfo(modelInfo);
+ }
+
+
+ @Test
+ public void testToString() throws Exception {
+ RelatedModel testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+
+
+ @Test
+ public void testGetAdditionalProperties() throws Exception {
+ RelatedModel testSubject;
+ Map<String, Object> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAdditionalProperties();
+ }
+
+
+ @Test
+ public void testSetAdditionalProperty() throws Exception {
+ RelatedModel testSubject;
+ String name = "";
+ Object value = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAdditionalProperty(name, value);
+ }
+
+
+ @Test
+ public void testHashCode() throws Exception {
+ RelatedModel testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.hashCode();
+ }
+
+
+ @Test
+ public void testEquals() throws Exception {
+ RelatedModel testSubject;
+ Object other = null;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.equals(other);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RequestDetailsTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RequestDetailsTest.java
new file mode 100644
index 0000000..696b2d5
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RequestDetailsTest.java
@@ -0,0 +1,204 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.onap.osam.domain.mso.*;
+
+
+public class RequestDetailsTest {
+
+ private RequestDetails createTestSubject() {
+ return new RequestDetails();
+ }
+
+
+ @Test
+ public void testGetCloudConfiguration() throws Exception {
+ RequestDetails testSubject;
+ CloudConfiguration result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCloudConfiguration();
+ }
+
+
+ @Test
+ public void testSetCloudConfiguration() throws Exception {
+ RequestDetails testSubject;
+ CloudConfiguration cloudConfiguration = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setCloudConfiguration(cloudConfiguration);
+ }
+
+
+ @Test
+ public void testGetModelInfo() throws Exception {
+ RequestDetails testSubject;
+ ModelInfo result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getModelInfo();
+ }
+
+
+ @Test
+ public void testSetModelInfo() throws Exception {
+ RequestDetails testSubject;
+ ModelInfo modelInfo = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setModelInfo(modelInfo);
+ }
+
+
+ @Test
+ public void testGetRelatedInstanceList() throws Exception {
+ RequestDetails testSubject;
+ List<RelatedInstanceWrapper> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRelatedInstanceList();
+ }
+
+
+ @Test
+ public void testSetRelatedInstanceList() throws Exception {
+ RequestDetails testSubject;
+ List<RelatedInstanceWrapper> relatedInstanceList = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setRelatedInstanceList(relatedInstanceList);
+ }
+
+
+ @Test
+ public void testGetRequestInfo() throws Exception {
+ RequestDetails testSubject;
+ RequestInfo result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRequestInfo();
+ }
+
+
+ @Test
+ public void testSetRequestInfo() throws Exception {
+ RequestDetails testSubject;
+ RequestInfo requestInfo = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setRequestInfo(requestInfo);
+ }
+
+
+ @Test
+ public void testGetSubscriberInfo() throws Exception {
+ RequestDetails testSubject;
+ SubscriberInfo result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getSubscriberInfo();
+ }
+
+
+ @Test
+ public void testSetSubscriberInfo() throws Exception {
+ RequestDetails testSubject;
+ SubscriberInfo subscriberInfo = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setSubscriberInfo(subscriberInfo);
+ }
+
+
+ @Test
+ public void testToString() throws Exception {
+ RequestDetails testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+
+
+ @Test
+ public void testGetAdditionalProperties() throws Exception {
+ RequestDetails testSubject;
+ Map<String, Object> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAdditionalProperties();
+ }
+
+
+ @Test
+ public void testSetAdditionalProperty() throws Exception {
+ RequestDetails testSubject;
+ String name = "";
+ Object value = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAdditionalProperty(name, value);
+ }
+
+
+ @Test
+ public void testHashCode() throws Exception {
+ RequestDetails testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.hashCode();
+ }
+
+
+ @Test
+ public void testEquals() throws Exception {
+ RequestDetails testSubject;
+ Object other = null;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.equals(other);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RequestListTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RequestListTest.java
new file mode 100644
index 0000000..0a1c109
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RequestListTest.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class RequestListTest {
+
+ private RequestList createTestSubject() {
+ return new RequestList();
+ }
+
+ @Test
+ public void testGetRequestList() throws Exception {
+ RequestList testSubject;
+ List<RequestWrapper> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRequestList();
+ }
+
+ @Test
+ public void testSetRequestList() throws Exception {
+ RequestList testSubject;
+ List<RequestWrapper> l = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setRequestList(l);
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ RequestList testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+
+ @Test
+ public void testGetAdditionalProperties() throws Exception {
+ RequestList testSubject;
+ Map<String, Object> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAdditionalProperties();
+ }
+
+ @Test
+ public void testSetAdditionalProperty() throws Exception {
+ RequestList testSubject;
+ String name = "";
+ Object value = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAdditionalProperty(name, value);
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ RequestList testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.hashCode();
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ RequestList testSubject;
+ Object other = null;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.equals(other);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RequestTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RequestTest.java
new file mode 100644
index 0000000..65b2433
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RequestTest.java
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import org.junit.Test;
+import org.onap.osam.domain.mso.InstanceIds;
+import org.onap.osam.domain.mso.RequestStatus;
+
+public class RequestTest {
+
+ private Request createTestSubject() {
+ return new Request();
+ }
+
+ @Test
+ public void testGetInstanceIds() throws Exception {
+ Request testSubject;
+ InstanceIds result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getInstanceIds();
+ }
+
+ @Test
+ public void testSetInstanceIds() throws Exception {
+ Request testSubject;
+ InstanceIds instanceIds = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setInstanceIds(instanceIds);
+ }
+
+ @Test
+ public void testGetRequestDetails() throws Exception {
+ Request testSubject;
+ RequestDetails result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRequestDetails();
+ }
+
+ @Test
+ public void testSetRequestDetails() throws Exception {
+ Request testSubject;
+ RequestDetails requestDetails = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setRequestDetails(requestDetails);
+ }
+
+ @Test
+ public void testGetRequestStatus() throws Exception {
+ Request testSubject;
+ RequestStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRequestStatus();
+ }
+
+ @Test
+ public void testSetRequestStatus() throws Exception {
+ Request testSubject;
+ RequestStatus requestStatus = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setRequestStatus(requestStatus);
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ Request testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ Request testSubject;
+ Object other = null;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.equals(other);
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ Request testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.hashCode();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RequestWrapperTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RequestWrapperTest.java
new file mode 100644
index 0000000..b75a308
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/RequestWrapperTest.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import org.junit.Test;
+
+public class RequestWrapperTest {
+
+ private RequestWrapper createTestSubject() {
+ return new RequestWrapper();
+ }
+
+ @Test
+ public void testGetRequest() throws Exception {
+ RequestWrapper testSubject;
+ Request result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getRequest();
+ }
+
+ @Test
+ public void testSetRequest() throws Exception {
+ RequestWrapper testSubject;
+ Request request = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setRequest(request);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/ResponseTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/ResponseTest.java
new file mode 100644
index 0000000..36f1cb8
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/ResponseTest.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import org.junit.Test;
+
+public class ResponseTest {
+
+ private Response createTestSubject() {
+ return new Response();
+ }
+
+ @Test
+ public void testGetStatus() throws Exception {
+ Response testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getStatus();
+ }
+
+ @Test
+ public void testSetStatus() throws Exception {
+ Response testSubject;
+ int status = 0;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setStatus(status);
+ }
+
+ @Test
+ public void testGetEntity() throws Exception {
+ Response testSubject;
+ RequestList result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getEntity();
+ }
+
+ @Test
+ public void testSetEntity() throws Exception {
+ Response testSubject;
+ RequestList entity = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setEntity(entity);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/TaskListTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/TaskListTest.java
new file mode 100644
index 0000000..92858b1
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/TaskListTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import java.util.List;
+
+import org.junit.Test;
+
+public class TaskListTest {
+
+ private TaskList createTestSubject() {
+ return new TaskList();
+ }
+
+ @Test
+ public void testGetTaskList() throws Exception {
+ TaskList testSubject;
+ List<Task> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getTaskList();
+ }
+
+ @Test
+ public void testSetTaskList() throws Exception {
+ TaskList testSubject;
+ List<Task> taskList = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setTaskList(taskList);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/TaskTest.java b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/TaskTest.java
new file mode 100644
index 0000000..71533c7
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/mso/rest/TaskTest.java
@@ -0,0 +1,274 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.mso.rest;
+
+import java.util.List;
+
+import org.junit.Test;
+
+public class TaskTest {
+
+ private Task createTestSubject() {
+ return new Task();
+ }
+
+ @Test
+ public void testGetTaskId() throws Exception {
+ Task testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getTaskId();
+ }
+
+ @Test
+ public void testSetTaskId() throws Exception {
+ Task testSubject;
+ String taskId = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setTaskId(taskId);
+ }
+
+ @Test
+ public void testGetType() throws Exception {
+ Task testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getType();
+ }
+
+ @Test
+ public void testSetType() throws Exception {
+ Task testSubject;
+ String type = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setType(type);
+ }
+
+ @Test
+ public void testGetNfRole() throws Exception {
+ Task testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getNfRole();
+ }
+
+ @Test
+ public void testSetNfRole() throws Exception {
+ Task testSubject;
+ String nfRole = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setNfRole(nfRole);
+ }
+
+ @Test
+ public void testGetSubscriptionServiceType() throws Exception {
+ Task testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getSubscriptionServiceType();
+ }
+
+ @Test
+ public void testSetSubscriptionServiceType() throws Exception {
+ Task testSubject;
+ String subscriptionServiceType = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setSubscriptionServiceType(subscriptionServiceType);
+ }
+
+ @Test
+ public void testGetOriginalRequestId() throws Exception {
+ Task testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getOriginalRequestId();
+ }
+
+ @Test
+ public void testSetOriginalRequestId() throws Exception {
+ Task testSubject;
+ String originalRequestId = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setOriginalRequestId(originalRequestId);
+ }
+
+ @Test
+ public void testGetOriginalRequestorId() throws Exception {
+ Task testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getOriginalRequestorId();
+ }
+
+ @Test
+ public void testSetOriginalRequestorId() throws Exception {
+ Task testSubject;
+ String originalRequestorId = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setOriginalRequestorId(originalRequestorId);
+ }
+
+ @Test
+ public void testGetErrorSource() throws Exception {
+ Task testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getErrorSource();
+ }
+
+ @Test
+ public void testSetErrorSource() throws Exception {
+ Task testSubject;
+ String errorSource = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setErrorSource(errorSource);
+ }
+
+ @Test
+ public void testGetErrorCode() throws Exception {
+ Task testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getErrorCode();
+ }
+
+ @Test
+ public void testSetErrorCode() throws Exception {
+ Task testSubject;
+ String errorCode = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setErrorCode(errorCode);
+ }
+
+ @Test
+ public void testGetErrorMessage() throws Exception {
+ Task testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getErrorMessage();
+ }
+
+ @Test
+ public void testSetErrorMessage() throws Exception {
+ Task testSubject;
+ String errorMessage = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setErrorMessage(errorMessage);
+ }
+
+ @Test
+ public void testGetBuildingBlockName() throws Exception {
+ Task testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getBuildingBlockName();
+ }
+
+ @Test
+ public void testSetBuildingBlockName() throws Exception {
+ Task testSubject;
+ String buildingBlockName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setBuildingBlockName(buildingBlockName);
+ }
+
+ @Test
+ public void testGetBuildingBlockStep() throws Exception {
+ Task testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getBuildingBlockStep();
+ }
+
+ @Test
+ public void testSetBuildingBlockStep() throws Exception {
+ Task testSubject;
+ String buildingBlockStep = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setBuildingBlockStep(buildingBlockStep);
+ }
+
+ @Test
+ public void testGetValidResponses() throws Exception {
+ Task testSubject;
+ List<String> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getValidResponses();
+ }
+
+ @Test
+ public void testSetValidResponses() throws Exception {
+ Task testSubject;
+ List<String> validResponses = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setValidResponses(validResponses);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyResponseWrapperTest.java b/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyResponseWrapperTest.java
new file mode 100644
index 0000000..55a8201
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyResponseWrapperTest.java
@@ -0,0 +1,92 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+import org.junit.Test;
+
+public class PolicyResponseWrapperTest {
+
+ private PolicyResponseWrapper createTestSubject() {
+ return new PolicyResponseWrapper();
+ }
+
+ @Test
+ public void testGetEntity() throws Exception {
+ PolicyResponseWrapper testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getEntity();
+ }
+
+ @Test
+ public void testGetStatus() throws Exception {
+ PolicyResponseWrapper testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getStatus();
+ }
+
+ @Test
+ public void testSetStatus() throws Exception {
+ PolicyResponseWrapper testSubject;
+ int v = 0;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setStatus(v);
+ }
+
+ @Test
+ public void testSetEntity() throws Exception {
+ PolicyResponseWrapper testSubject;
+ String v = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setEntity(v);
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ PolicyResponseWrapper testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+
+ @Test
+ public void testGetResponse() throws Exception {
+ PolicyResponseWrapper testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getResponse();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyRestIntTest.java b/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyRestIntTest.java
new file mode 100644
index 0000000..20a7da4
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyRestIntTest.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+import org.junit.Test;
+import org.onap.osam.policy.rest.RequestDetails;
+
+public class PolicyRestIntTest {
+
+ private PolicyRestInt createTestSubject() {
+ return new PolicyRestInt();
+ }
+
+ @Test
+ public void testLogRequest() throws Exception {
+ PolicyRestInt testSubject;
+ RequestDetails r = null;
+
+ // test 1
+ testSubject = createTestSubject();
+ r = null;
+ testSubject.logRequest(r);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyRestInterfaceFactoryTest.java b/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyRestInterfaceFactoryTest.java
new file mode 100644
index 0000000..6f25540
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyRestInterfaceFactoryTest.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+import org.junit.Test;
+
+public class PolicyRestInterfaceFactoryTest {
+
+ private PolicyRestInterfaceFactory createTestSubject() {
+ return new PolicyRestInterfaceFactory();
+ }
+
+ @Test
+ public void testGetInstance() throws Exception {
+ PolicyRestInterfaceIfc result;
+
+ // default test
+ result = PolicyRestInterfaceFactory.getInstance();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyRestInterfaceTest.java b/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyRestInterfaceTest.java
new file mode 100644
index 0000000..7b61e5d
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyRestInterfaceTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+import org.junit.Test;
+import org.onap.osam.policy.rest.RequestDetails;
+
+public class PolicyRestInterfaceTest {
+
+ private PolicyRestInterface createTestSubject() {
+ return new PolicyRestInterface();
+ }
+
+ @Test
+ public void testLogRequest() throws Exception {
+ PolicyRestInterface testSubject;
+ RequestDetails r = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.logRequest(r);
+ }
+
+ /*@Test
+ public void testInitRestClient() throws Exception {
+ PolicyRestInterface testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.initRestClient();
+ }*/
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyUtilTest.java b/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyUtilTest.java
new file mode 100644
index 0000000..3379e9b
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/policy/PolicyUtilTest.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PolicyUtilTest {
+
+ private PolicyUtil createTestSubject() {
+ return new PolicyUtil();
+ }
+
+ @Test
+ public void testWrapResponse() throws Exception {
+ String body = "";
+ int statusCode = 0;
+ PolicyResponseWrapper result;
+
+ // default test
+ result = PolicyUtil.wrapResponse(body, statusCode);
+ }
+
+
+ @Test
+ public void testWrapResponse_2() throws Exception {
+ RestObject<String> rs = null;
+ PolicyResponseWrapper result;
+
+ // test 1
+ rs = null;
+ result = PolicyUtil.wrapResponse(rs);
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void testConvertPojoToString() throws Exception {
+ String result;
+
+ // test 1
+ result = PolicyUtil.convertPojoToString(null);
+ Assert.assertEquals("", result);
+ }
+
+ @Test
+ public void testMain() throws Exception {
+ String[] args = new String[] { "" };
+
+ // default test
+ PolicyUtil.main(args);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/policy/RestObjectTest.java b/onap-enabler-be/src/test/java/org/onap/osam/policy/RestObjectTest.java
new file mode 100644
index 0000000..3d91f18
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/policy/RestObjectTest.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy;
+
+import org.junit.Test;
+
+public class RestObjectTest {
+
+ private RestObject createTestSubject() {
+ return new RestObject();
+ }
+
+ @Test
+ public void testSet() throws Exception {
+ RestObject testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.set(null);
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ RestObject testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.get();
+ }
+
+ @Test
+ public void testSetStatusCode() throws Exception {
+ RestObject testSubject;
+ int v = 0;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setStatusCode(v);
+ }
+
+ @Test
+ public void testGetStatusCode() throws Exception {
+ RestObject testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getStatusCode();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/policy/rest/RequestDetailsTest.java b/onap-enabler-be/src/test/java/org/onap/osam/policy/rest/RequestDetailsTest.java
new file mode 100644
index 0000000..78a8995
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/policy/rest/RequestDetailsTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.policy.rest;
+
+import org.junit.Test;
+
+
+public class RequestDetailsTest {
+
+ private RequestDetails createTestSubject() {
+ return new RequestDetails();
+ }
+
+
+ @Test
+ public void testGetPolicyName() throws Exception {
+ RequestDetails testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getPolicyName();
+ }
+
+
+ @Test
+ public void testSetPolicyName() throws Exception {
+ RequestDetails testSubject;
+ String policyName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setPolicyName(policyName);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/properties/VidPropertiesTest.java b/onap-enabler-be/src/test/java/org/onap/osam/properties/VidPropertiesTest.java
new file mode 100644
index 0000000..a0c726e
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/properties/VidPropertiesTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.properties;
+
+import org.junit.Test;
+
+
+public class VidPropertiesTest {
+
+ private VidProperties createTestSubject() {
+ return new VidProperties();
+ }
+
+
+ @Test
+ public void testGetAsdcModelNamespace() throws Exception {
+ String result;
+
+ // default test
+ result = VidProperties.getAsdcModelNamespace();
+ }
+
+
+ @Test
+ public void testGetPropertyWithDefault() throws Exception {
+ String propName = "";
+ String defaultValue = "";
+ String result;
+
+ // default test
+ result = VidProperties.getPropertyWithDefault(propName, defaultValue);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/roles/RoleProviderTest.java b/onap-enabler-be/src/test/java/org/onap/osam/roles/RoleProviderTest.java
new file mode 100644
index 0000000..2272381
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/roles/RoleProviderTest.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.roles;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Test;
+
+
+public class RoleProviderTest {
+
+ private RoleProvider createTestSubject() {
+ return new RoleProvider();
+ }
+
+
+ @Test
+ public void testExtractRoleFromSession() throws Exception {
+ HttpServletRequest request = null;
+ List<String> result;
+
+ // default test
+ result = RoleProvider.extractRoleFromSession(request);
+ }
+
+
+// @Test
+// public void testGetUserRoles() throws Exception {
+// RoleProvider testSubject;
+// HttpServletRequest request = null;
+// List<Role> result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.getUserRoles(request);
+// }
+
+
+ @Test
+ public void testSplitRole() throws Exception {
+ RoleProvider testSubject;
+ String roleAsString = "";
+ String[] result;
+
+ // default test
+ testSubject = createTestSubject();
+ //TODO:fix result = testSubject.splitRole(roleAsString);
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/roles/RoleTest.java b/onap-enabler-be/src/test/java/org/onap/osam/roles/RoleTest.java
new file mode 100644
index 0000000..0d29853
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/roles/RoleTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.roles;
+
+import org.junit.Test;
+
+public class RoleTest {
+
+ private Role createTestSubject() {
+ return new Role(EcompRole.READ, "", "", "");
+ }
+
+ @Test
+ public void testGetEcompRole() throws Exception {
+ Role testSubject;
+ EcompRole result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getEcompRole();
+ }
+
+ @Test
+ public void testGetSubscribeName() throws Exception {
+ Role testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getSubscribeName();
+ }
+
+ @Test
+ public void testSetSubscribeName() throws Exception {
+ Role testSubject;
+ String subscribeName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setSubscribeName(subscribeName);
+ }
+
+ @Test
+ public void testGetServiceType() throws Exception {
+ Role testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getServiceType();
+ }
+
+ @Test
+ public void testGetTenant() throws Exception {
+ Role testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getTenant();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/roles/RoleValidatorTest.java b/onap-enabler-be/src/test/java/org/onap/osam/roles/RoleValidatorTest.java
new file mode 100644
index 0000000..401af85
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/roles/RoleValidatorTest.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.roles;
+
+import org.junit.Test;
+import org.onap.osam.mso.rest.RequestDetails;
+
+public class RoleValidatorTest {
+
+ private RoleValidator createTestSubject() {
+ return new RoleValidator(null);
+ }
+
+ @Test
+ public void testIsMsoRequestValid() throws Exception {
+ RoleValidator testSubject;
+ RequestDetails mso_request = null;
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isMsoRequestValid(mso_request);
+ }
+
+ @Test
+ public void testIsServicePermitted() throws Exception {
+ RoleValidator testSubject;
+ String subscriberName = "";
+ String serviceType = "";
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isServicePermitted(subscriberName, serviceType);
+ }
+
+ @Test
+ public void testIsSubscriberPermitted() throws Exception {
+ RoleValidator testSubject;
+ String subscriberName = "";
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isSubscriberPermitted(subscriberName);
+ }
+
+ @Test
+ public void testIsTenantPermitted() throws Exception {
+ RoleValidator testSubject;
+ String globalCustomerId = "";
+ String serviceType = "";
+ String tenantName = "";
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isTenantPermitted(globalCustomerId, serviceType, tenantName);
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjectTest.java b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjectTest.java
new file mode 100644
index 0000000..41438e6
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjectTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.scheduler;
+
+import org.junit.Test;
+
+public class RestObjectTest {
+
+ private RestObject createTestSubject() {
+ return new RestObject();
+ }
+
+ @Test
+ public void testSet() throws Exception {
+ RestObject testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.set(null);
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ RestObject testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.get();
+ }
+
+ @Test
+ public void testSetStatusCode() throws Exception {
+ RestObject testSubject;
+ int v = 0;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setStatusCode(v);
+ }
+
+ @Test
+ public void testGetStatusCode() throws Exception {
+ RestObject testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getStatusCode();
+ }
+
+ @Test
+ public void testSetUUID() throws Exception {
+ RestObject testSubject;
+ String uuid = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setUUID(uuid);
+ }
+
+ @Test
+ public void testGetUUID() throws Exception {
+ RestObject testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getUUID();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjects/GetTimeSlotsRestObjectTest.java b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjects/GetTimeSlotsRestObjectTest.java
new file mode 100644
index 0000000..f40a0e4
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjects/GetTimeSlotsRestObjectTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+//package org.onap.vid.scheduler.RestObjects;
+//
+//import org.junit.Test;
+//
+//
+//public class GetTimeSlotsRestObjectTest {
+//
+// private GetTimeSlotsRestObject createTestSubject() {
+// return new GetTimeSlotsRestObject();
+// }
+//
+//
+// @Test
+// public void testSetUUID() throws Exception {
+// GetTimeSlotsRestObject testSubject;
+// String uuid = "";
+//
+// // default test
+// testSubject = createTestSubject();
+// testSubject.setUUID(uuid);
+// }
+//
+//
+// @Test
+// public void testGetUUID() throws Exception {
+// GetTimeSlotsRestObject testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.getUUID();
+// }
+//}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjects/PostCreateNewVnfRestObjectTest.java b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjects/PostCreateNewVnfRestObjectTest.java
new file mode 100644
index 0000000..24b472a
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjects/PostCreateNewVnfRestObjectTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+//package org.onap.vid.scheduler.RestObjects;
+//
+//import org.junit.Test;
+//
+//
+//public class PostCreateNewVnfRestObjectTest {
+//
+// private PostCreateNewVnfRestObject createTestSubject() {
+// return new PostCreateNewVnfRestObject();
+// }
+//
+//
+// @Test
+// public void testSetUUID() throws Exception {
+// PostCreateNewVnfRestObject testSubject;
+// String uuid = "";
+//
+// // default test
+// testSubject = createTestSubject();
+// testSubject.setUUID(uuid);
+// }
+//
+//
+// @Test
+// public void testGetUUID() throws Exception {
+// PostCreateNewVnfRestObject testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.getUUID();
+// }
+//}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjects/PostSubmitVnfChangeRestObjectTest.java b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjects/PostSubmitVnfChangeRestObjectTest.java
new file mode 100644
index 0000000..04c3200
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjects/PostSubmitVnfChangeRestObjectTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+//package org.onap.vid.scheduler.RestObjects;
+//
+//import org.junit.Test;
+//
+//
+//public class PostSubmitVnfChangeRestObjectTest {
+//
+// private PostSubmitVnfChangeRestObject createTestSubject() {
+// return new PostSubmitVnfChangeRestObject();
+// }
+//
+//
+// @Test
+// public void testSetUUID() throws Exception {
+// PostSubmitVnfChangeRestObject testSubject;
+// String uuid = "";
+//
+// // default test
+// testSubject = createTestSubject();
+// testSubject.setUUID(uuid);
+// }
+//
+//
+// @Test
+// public void testGetUUID() throws Exception {
+// PostSubmitVnfChangeRestObject testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.getUUID();
+// }
+//}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjects/RestObjectTest.java b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjects/RestObjectTest.java
new file mode 100644
index 0000000..4faa297
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/RestObjects/RestObjectTest.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.scheduler.RestObjects;
+
+import org.junit.Test;
+
+
+public class RestObjectTest {
+
+ private RestObject createTestSubject() {
+ return new RestObject();
+ }
+
+
+ @Test
+ public void testSet() throws Exception {
+ RestObject testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.set(null);
+ }
+
+
+ @Test
+ public void testGet() throws Exception {
+ RestObject testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.get();
+ }
+
+
+ @Test
+ public void testSetStatusCode() throws Exception {
+ RestObject testSubject;
+ int v = 0;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setStatusCode(v);
+ }
+
+
+ @Test
+ public void testGetStatusCode() throws Exception {
+ RestObject testSubject;
+ int result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getStatusCode();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/scheduler/SchedulerResponseWrappers/PostCreateNewVnfWrapperTest.java b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/SchedulerResponseWrappers/PostCreateNewVnfWrapperTest.java
new file mode 100644
index 0000000..20bd458
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/SchedulerResponseWrappers/PostCreateNewVnfWrapperTest.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+//package org.onap.vid.scheduler.SchedulerResponseWrappers;
+//
+//import org.junit.Test;
+//
+//
+//public class PostCreateNewVnfWrapperTest {
+//
+// private PostCreateNewVnfWrapper createTestSubject() {
+// return new PostCreateNewVnfWrapper();
+// }
+//
+//
+// @Test
+// public void testGetUuid() throws Exception {
+// PostCreateNewVnfWrapper testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.getUuid();
+// }
+//
+//
+// @Test
+// public void testSetUuid() throws Exception {
+// PostCreateNewVnfWrapper testSubject;
+// String v = "";
+//
+// // default test
+// testSubject = createTestSubject();
+// testSubject.setUuid(v);
+// }
+//
+//
+// @Test
+// public void testToString() throws Exception {
+// PostCreateNewVnfWrapper testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.toString();
+// }
+//
+//
+// @Test
+// public void testGetResponse() throws Exception {
+// PostCreateNewVnfWrapper testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.getResponse();
+// }
+//}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/scheduler/SchedulerResponseWrappers/PostSubmitVnfChangeTimeSlotsWrapperTest.java b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/SchedulerResponseWrappers/PostSubmitVnfChangeTimeSlotsWrapperTest.java
new file mode 100644
index 0000000..a8bfd3c
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/SchedulerResponseWrappers/PostSubmitVnfChangeTimeSlotsWrapperTest.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+//package org.onap.vid.scheduler.SchedulerResponseWrappers;
+//
+//import org.junit.Test;
+//
+//
+//public class PostSubmitVnfChangeTimeSlotsWrapperTest {
+//
+// private PostSubmitVnfChangeTimeSlotsWrapper createTestSubject() {
+// return new PostSubmitVnfChangeTimeSlotsWrapper();
+// }
+//
+//
+// @Test
+// public void testGetUuid() throws Exception {
+// PostSubmitVnfChangeTimeSlotsWrapper testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.getUuid();
+// }
+//
+//
+// @Test
+// public void testSetUuid() throws Exception {
+// PostSubmitVnfChangeTimeSlotsWrapper testSubject;
+// String v = "";
+//
+// // default test
+// testSubject = createTestSubject();
+// testSubject.setUuid(v);
+// }
+//
+//
+// @Test
+// public void testToString() throws Exception {
+// PostSubmitVnfChangeTimeSlotsWrapper testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.toString();
+// }
+//
+//
+// @Test
+// public void testGetResponse() throws Exception {
+// PostSubmitVnfChangeTimeSlotsWrapper testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.getResponse();
+// }
+//}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/scheduler/SchedulerResponseWrappers/SchedulerResponseWrapperTest.java b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/SchedulerResponseWrappers/SchedulerResponseWrapperTest.java
new file mode 100644
index 0000000..b68570a
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/SchedulerResponseWrappers/SchedulerResponseWrapperTest.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+//package org.onap.vid.scheduler.SchedulerResponseWrappers;
+//
+//import org.junit.Test;
+//
+//
+//public class SchedulerResponseWrapperTest {
+//
+// private SchedulerResponseWrapper createTestSubject() {
+// return new SchedulerResponseWrapper();
+// }
+//
+//
+// @Test
+// public void testGetEntity() throws Exception {
+// SchedulerResponseWrapper testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.getEntity();
+// }
+//
+//
+// @Test
+// public void testGetStatus() throws Exception {
+// SchedulerResponseWrapper testSubject;
+// int result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.getStatus();
+// }
+//
+//
+// @Test
+// public void testSetStatus() throws Exception {
+// SchedulerResponseWrapper testSubject;
+// int v = 0;
+//
+// // default test
+// testSubject = createTestSubject();
+// testSubject.setStatus(v);
+// }
+//
+//
+// @Test
+// public void testSetEntity() throws Exception {
+// SchedulerResponseWrapper testSubject;
+// String v = "";
+//
+// // default test
+// testSubject = createTestSubject();
+// testSubject.setEntity(v);
+// }
+//
+//
+// @Test
+// public void testToString() throws Exception {
+// SchedulerResponseWrapper testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.toString();
+// }
+//
+//
+// @Test
+// public void testGetResponse() throws Exception {
+// SchedulerResponseWrapper testSubject;
+// String result;
+//
+// // default test
+// testSubject = createTestSubject();
+// result = testSubject.getResponse();
+// }
+//}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/scheduler/SchedulerRestInterfaceTest.java b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/SchedulerRestInterfaceTest.java
new file mode 100644
index 0000000..23a4287
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/SchedulerRestInterfaceTest.java
@@ -0,0 +1,138 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+
+package org.onap.osam.scheduler;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.xebialabs.restito.semantics.Action;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.onap.osam.testUtils.StubServerUtil;
+import org.testng.annotations.AfterMethod;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+
+@RunWith(MockitoJUnitRunner.class)
+public class SchedulerRestInterfaceTest {
+
+ private static final String SAMPLE_USERNAME = "sample";
+ private static final String SAMPLE_PASSWORD = "paS$w0Rd";
+ private static final String SAMPLE_SCHEDULER_SERVER_URL = "http://localhost";
+ private static final String SAMPLE_SOURCE_ID = "AAI";
+ private static final JSONParser JSON_PARSER = new JSONParser();
+ private static final String RESPONSE_CONTENT = "\"schedules\": \"SAMPLE STRING\"";
+ private static final String ERROR_RESPONSE = "\"error\": \"Internal server error!\"";
+ private static Map<String, String> DUMMY_SYSTEM_PROPERTIES = new HashMap<String, String>() {{
+ put(SchedulerProperties.SCHEDULER_USER_NAME_VAL, SAMPLE_USERNAME);
+ put(SchedulerProperties.SCHEDULER_PASSWORD_VAL, SAMPLE_PASSWORD);
+ put(SchedulerProperties.SCHEDULER_SERVER_URL_VAL, SAMPLE_SCHEDULER_SERVER_URL);
+ }};
+ private static StubServerUtil serverUtil;
+ private static SchedulerRestInterface schedulerInterface = new SchedulerRestInterface((key) -> DUMMY_SYSTEM_PROPERTIES.get(key));
+
+ @BeforeClass
+ public static void setUpClass() {
+ serverUtil = new StubServerUtil();
+ serverUtil.runServer();
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ serverUtil.stopServer();
+ }
+
+
+ @AfterMethod
+ public void tearDown() {
+ serverUtil.stopServer();
+ }
+
+ @Test
+ public void testShouldGetOKWhenStringIsExpected() throws JsonProcessingException, ParseException {
+ prepareEnvForTest();
+ RestObject<String> sampleRestObj = new RestObject<>();
+ serverUtil.prepareGetCall("/test", RESPONSE_CONTENT, Action.ok());
+
+ schedulerInterface.Get("", SAMPLE_SOURCE_ID, "", sampleRestObj);
+
+ assertResponseHasExpectedBodyAndStatus(sampleRestObj, RESPONSE_CONTENT, 200);
+ }
+
+ @Test(expected = GenericUncheckedException.class)
+ public void shouldRaiseExceptionWhenErrorOccursDuringGet() throws JsonProcessingException {
+ prepareEnvForTest();
+ RestObject<String> sampleRestObj = new RestObject<>();
+
+ serverUtil.prepareGetCall("/test", ERROR_RESPONSE, Action.status(HttpStatus.INTERNAL_SERVER_ERROR_500));
+
+ schedulerInterface.Get("", SAMPLE_SOURCE_ID, "", sampleRestObj);
+ }
+
+ @Test
+ public void shouldDeleteResourceSuccessfully() throws JsonProcessingException, ParseException {
+ prepareEnvForTest();
+ RestObject<String> sampleRestObj = new RestObject<>();
+ serverUtil.prepareDeleteCall("/test", RESPONSE_CONTENT, Action.ok());
+
+ schedulerInterface.Delete("", SAMPLE_SOURCE_ID, "", sampleRestObj);
+
+ assertResponseHasExpectedBodyAndStatus(sampleRestObj, RESPONSE_CONTENT, 200);
+ }
+
+ @Test
+ public void shouldRaiseExceptionWhenErrorOccursDuringDelete() throws JsonProcessingException, ParseException {
+ prepareEnvForTest();
+ RestObject<String> sampleRestObj = new RestObject<>();
+ serverUtil.prepareDeleteCall("/test", ERROR_RESPONSE, Action.status(HttpStatus.INTERNAL_SERVER_ERROR_500));
+
+ schedulerInterface.Delete("", SAMPLE_SOURCE_ID, "", sampleRestObj);
+
+ assertResponseHasExpectedBodyAndStatus(sampleRestObj, ERROR_RESPONSE, 500);
+ }
+
+
+ private void assertResponseHasExpectedBodyAndStatus(RestObject<String> sampleRestObj, String expectedResponse, int expectedStatusCode) throws ParseException {
+ Object parsedResult = JSON_PARSER.parse(sampleRestObj.get());
+
+ assertThat(sampleRestObj.getStatusCode()).isEqualTo(expectedStatusCode);
+ assertThat(parsedResult).isInstanceOf(String.class).isEqualTo(expectedResponse);
+ assertThat(sampleRestObj.getUUID()).isNull();
+
+ }
+
+ private void prepareEnvForTest() {
+ String targetUrl = serverUtil.constructTargetUrl("http", "test");
+ DUMMY_SYSTEM_PROPERTIES.put(SchedulerProperties.SCHEDULER_SERVER_URL_VAL, targetUrl);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/scheduler/rest/RequestDetailsTest.java b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/rest/RequestDetailsTest.java
new file mode 100644
index 0000000..d82f1d9
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/scheduler/rest/RequestDetailsTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.scheduler.rest;
+
+import org.onap.osam.mso.rest.RequestDetails;
+
+
+public class RequestDetailsTest {
+
+ private RequestDetails createTestSubject() {
+ return new RequestDetails();
+ }
+
+
+ /*@Test
+ public void testGetDomain() throws Exception {
+ RequestDetails testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDomain();
+ }
+
+
+ @Test
+ public void testSetDomain() throws Exception {
+ RequestDetails testSubject;
+ String domain = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setDomain(domain);
+ }*/
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/selenium/FirstClass.java b/onap-enabler-be/src/test/java/org/onap/osam/selenium/FirstClass.java
new file mode 100644
index 0000000..188d27d
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/selenium/FirstClass.java
@@ -0,0 +1,597 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.selenium;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.support.ui.Select;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import org.apache.log4j.Logger;
+import org.testng.Assert;
+
+public class FirstClass {
+
+ WebElement loginButton;
+
+ /** The eg. */
+ String eg;
+
+ /** The login. */
+ WebElement login;
+
+ /** The pwd. */
+ WebElement pwd;
+
+ /** The log. */
+ Logger log;
+
+ /** The errormessage. */
+ WebElement errormessage;
+
+
+ /** The driver. */
+ WebDriver driver=new FirefoxDriver();
+
+
+
+ /** The config prop. */
+ private final Properties configProp = new Properties();
+
+
+ /**
+ * Instantiates a new first class.
+ */
+ private FirstClass() {
+ // TODO Auto-generated constructor stub
+ //
+ try{
+ // InputStream input =this.getClass().getClassLoader().getResourceAsStream("objectmap.properties");
+ //FileInputStream input1 = new FileInputStream("objectmap.properties");
+
+ InputStream input =new FileInputStream("objectconfig.properties");
+ System.out.println("Read all properties from file");
+ configProp.load(input);
+ System.out.println("Read all properties from file completed");
+ }
+ catch(IOException e) {
+
+ e.printStackTrace();
+ }
+ }
+
+
+ /*
+
+
+ @BeforeClass
+ public void setUp() {
+ System.out.println("*******************");
+ System.out.println("launching IE browser");
+ System.setProperty("webdriver.ie.driver", driverPath+"IEDriverServer.exe");
+ driver = new InternetExplorerDriver();
+ driver.findElement(By.className());
+ driver.manage().window().maximize();
+
+
+ login = driver.findElement(By.xpath("//input[@class='fn-ebz-text ng-pristine ng-valid']"));
+ pwd = driver.findElement(By.xpath("//input[@class='span3 ng-pristine ng-valid']"));
+ loginButton = driver.findElement(By.id("loginBtn"));
+ }
+
+
+ */
+ /**
+ * Sets the up.
+ */
+ // TODO Auto-generated method stub
+ @BeforeClass
+ public void setUp()
+ {
+
+
+ //WebDriver driver=new FirefoxDriver();
+
+ log = Logger.getLogger(FirstClass.class.getName());
+
+
+
+ // Get url
+ driver.get(configProp.getProperty("baseURL"));
+ driver.manage().window().maximize();
+
+
+ login = driver.findElement(By.xpath(configProp.getProperty("login")));
+
+ pwd = driver.findElement(By.xpath(configProp.getProperty("pwd")));
+ loginButton = driver.findElement(By.id(configProp.getProperty("loginButton")));
+ }
+
+
+ /**
+ * Empty username password.
+ */
+ @Test(priority=1)
+ public void emptyUsernamePassword()
+ {
+
+
+ //User Name and Password field is empty
+ log.info("-----VID-11 TC-8----Username and password empty");
+ loginButton.click();
+ errormessage=driver.findElement(By.xpath("//*[@id='errorInfo']/span"));
+ String errmsg= errormessage.getText();
+ //System.out.println("Error message is"+errmsg);
+ //String expected = "Invaild username or password, Please try again";
+
+ //Assert.assertEquals(errmsg,expected);
+
+ Boolean str = driver.getPageSource().contains("Invalid username or password, Please try again");
+ System.out.println(driver.getPageSource().contains("Invalid username or password, Please try again"));
+
+ if(str==true)
+ {
+ log.info("Error message validated");
+ log.info("VID-11 TC-8 PASSED");
+
+ }else
+ log.error("Failed validation");
+
+ }
+
+
+
+ /**
+ * Invalid user name.
+ */
+ @Test(priority=2)
+ public void invalidUserName()
+ {
+
+ log.info("-----VID-11 TC-6----Invalid Username and Valid Password");
+
+
+ login.sendKeys("xxx");
+ pwd.sendKeys("abc123");
+ loginButton.click();
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String errmsg= errormessage.getText();
+ String expected = "Invalid username or password, Please try again";
+ Assert.assertEquals(errmsg,expected);
+ //Boolean str1 = driver.getPageSource().contains("Invalid username or password, Please try again");
+ //System.out.print(str1);
+
+ log.info("VID-11 TC-6 PASSED");
+
+ }
+
+
+ /**
+ * Invalid password.
+ */
+ @Test(priority=3)
+ public void invalidPassword()
+ {
+ log.info("-----VID-11 TC-7----Valid Username and Invalid Password");
+ // Valid user name and Invalid password.
+ login.clear();
+ pwd.clear();
+ login.sendKeys("testuser");
+ pwd.sendKeys("xxx");
+ loginButton.click();
+ driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+
+
+ String errmsg= errormessage.getText();
+ String expected = "Invalid username or password, Please try again";
+ Assert.assertEquals(errmsg,expected);
+
+ //Boolean str2 = driver.getPageSource().contains("Invaild username or password, Please try again");
+ //System.out.print(str2);
+
+ log.info("VID-11 TC-7 PASSED");
+ }
+
+
+ /**
+ * Login successful.
+ */
+ @Test(priority=4)
+ public void loginSuccessful()
+ {
+ log.info("-----VID-11 TC-1----Valid Username and Valid Password");
+ //Login with valid user name and password.
+ login.clear();
+ login.sendKeys("su");
+ pwd.clear();
+ pwd.sendKeys("fusion");
+
+
+ loginButton.click();
+ driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+
+ try {
+ Thread.sleep(6000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances"));
+ log.info("VID-11 TC-1 PASSED");
+
+ }
+
+
+ /**
+ * Verify home page elements left pane.
+ */
+ @Test(priority=5)
+ public void verifyHomePageElementsLeftPane()
+
+ {
+
+
+ log.info("VID-10 TC 1 ");
+ //VID Home
+ log.info("VID 11 TC-2");
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[1]/a/span")).isDisplayed();
+ //Create New Service Instance
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[2]/a/span")).isDisplayed();
+
+ //Browse Service Type
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[3]/a/span")).isDisplayed();
+ //View Log
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[4]/a/span")).isDisplayed();
+
+ //Profile
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[5]/a/span")).isDisplayed();
+ //Admin
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[6]/a/span")).isDisplayed();
+ //Logout
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[7]/a/span")).isDisplayed();
+
+ //Infrastructure Subscriber Name
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[1]/div/label")).isDisplayed();
+ //Infrastructure Subscriber Name Select Drop down
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")).isDisplayed();
+ //Infrastructure Service Type
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[1]/div/label")).isDisplayed();
+ //Infrastructure Service Type Select Drop down
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select")).isDisplayed();
+ //Submit button
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button")).isDisplayed();
+
+ //Login Snippet Icon
+ driver.findElement(By.xpath(".//*[@class='icon-user-small login-snippet-icon']")).isDisplayed();
+
+
+ //String bodyText = driver.findElement(By.tagName("body")).getText();
+ //Assert.assertTrue("Text not found!", bodyText.contains("Search Existing Service Instances"));
+ //Assert.IsTrue(driver.getPageSource.Contains("Search Existing Service Instances"));
+
+ log.info("VID-12 TC-1");
+ Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances"));
+ Assert.assertTrue(driver.getPageSource().contains("Please search by the Subscriber name or Service Type from below:"));
+ log.info("VID-12 TC-1 PASSED");
+ log.info("VID-10 TC 1 PASSED");
+ log.info("VID-11 TC-2 PASSED");
+ }
+
+
+ /**
+ * Disabled submit button.
+ */
+ @Test(priority=6)
+ public void disabledSubmitButton()
+ {
+ log.info("VID-12 TC-13");
+ //Assert submit button disabled.
+ Assert.assertFalse(driver.findElement(By.xpath(configProp.getProperty("submitButton"))).isEnabled());
+ log.info("VID-12 TC-13 PASSED");
+
+ }
+
+ /**
+ * Default list box value.
+ */
+ @Test(priority=7)
+ public void defaultListBoxValue()
+ {
+ log.info("VID-12 TC-2");
+
+
+ //WebElement subscribername =driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"));
+
+ Select oSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown"))));
+ Select iSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown"))));
+
+
+ WebElement ielement=iSelect.getFirstSelectedOption();
+ WebElement oelement=oSelect.getFirstSelectedOption();
+ String defaultsubscribername=oelement.getText();
+ String defaultservicetype=ielement.getText();
+
+ Assert.assertEquals(defaultsubscribername,"Select Subscriber Name");
+ Assert.assertEquals(defaultservicetype,"Select Service Type");
+
+
+
+
+ //Verify Select Subscriber Name isDisplayed.
+ //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select/option[1]")).isSelected();
+
+ //Verify Select Service Type isDisplayed.
+ //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select/option[1]")).isSelected();
+
+
+ log.info("VID-12 TC-2 PASSED");
+
+ }
+
+
+
+ /**
+ * Select subscriber name drop down.
+ *
+ * @throws InterruptedException the interrupted exception
+ */
+ @Test(priority=8)
+ public void selectSubscriberNameDropDown() throws InterruptedException
+ {
+ log.info("------------------VID-10 TC-2,VID-12 TC-11, VID-12 TC-9, VID 12 TC-10,VID-12 TC-6, VID 12 TC-5--------------------");
+
+
+ driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown")));
+
+ driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown")));
+ Thread.sleep(5000);
+
+ //Infrastructure Subscriber Name
+ Select oSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown"))));
+
+ List <WebElement> elementCount = oSelect.getOptions();
+ log.info("Select Element Count of Service Name");
+ System.out.println(elementCount.size());
+
+
+ //Verifying getInfrastructureSubscribersList
+ log.info("VID-29 TC-1");
+ Assert.assertTrue(elementCount.size()>0);
+ log.info("VID-29 TC-1 PASSED");
+
+ oSelect.selectByIndex(2);
+ String selectedOption = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown")))).getFirstSelectedOption().getText();
+
+ System.out.println("Service Name selected is " +selectedOption);
+ log.info("VID-10 TC-2 PASSED");
+
+ //Submit button is clicked
+ driver.findElement(By.xpath(configProp.getProperty("submitButton"))).click();
+
+
+ //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:"
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed();
+ //Assert.assertTrue(driver.getPageSource().contains("Selected Subscriber's Service Instance Details:"))
+
+
+ //Verify whether the page header is displayed "Global Customer ID"
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/thead/tr/th[2]/div")).isDisplayed();
+ Assert.assertTrue(driver.getPageSource().contains("Global Customer ID"));
+ Assert.assertTrue(driver.getPageSource().contains("Subscriber Name"));
+ Assert.assertTrue(driver.getPageSource().contains("Service Type"));
+ Assert.assertTrue(driver.getPageSource().contains("Service Instance ID"));
+
+ log.info("VID-12 TC-5 PASSED");
+ log.info("VID-12 TC-11 PASSED");
+
+ WebElement serviceinstancetable =driver.findElement(By.xpath("//table[@class='tablesorter tablesorter-default ng-isolate-scope']"));
+
+ List<WebElement> rows_table = serviceinstancetable.findElements(By.tagName("tr"));
+ //To calculate no of rows In table.
+ int rows_count = rows_table.size();
+
+ //Loop will execute till the last row of table.
+ for (int row=0; row<rows_count; row++){
+ //To locate columns(cells) of that specific row.
+ List<WebElement> Columns_row = rows_table.get(row).findElements(By.tagName("td"));
+ //To calculate no of columns(cells) In that specific row.
+ int columns_count = Columns_row.size();
+ //System.out.println("Number of cells In Row "+row+" are "+columns_count);
+
+ //Loop will execute till the last cell of that specific row.
+ for (int column=0; column<columns_count; column++){
+ //To retrieve text from that specific cell.
+ String celtext = Columns_row.get(column).getText();
+ //System.out.println("Cell Value Of row number "+row+" and column number "+column+" Is "+celtext);
+
+
+
+ //log.info("Testing Get column and row value");
+ List <WebElement> exx= rows_table.get(1).findElements(By.tagName("td"));
+ eg=Columns_row.get(2).getText();
+ // System.out.println("Cell value of row 1 and column 2 is" +eg);
+ }
+ }
+
+
+
+
+ //Verify View/Edit isDisplayed and Click
+
+ driver.findElement(By.xpath("//a[@alt='View/Edit']")).isDisplayed();
+
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/tbody/tr[1]/td[1]/div/a")).click();
+
+ log.info("User clicked View/Edit");
+
+ //Verify the Subscriber Name displayed.
+ String header= driver.findElement(By.xpath("//h1[@class='heading1 ng-binding']")).getText();
+ //System.out.println(header);
+
+
+ if(header.contains(eg))
+ {
+ System.out.println("Header contains the subscriber name");
+ }else
+ System.out.println("Header does not contain the subscriber name");
+
+
+
+ Assert.assertTrue(driver.getPageSource().contains("PerfTest Subscriber00020021"));
+ log.info("VID-12 TC-6 PASSED");
+
+
+
+ driver.navigate().back();
+ //Cancel button isDisplayed
+ driver.findElement(By.xpath("//button[@class='button button--small button--primary']")).isDisplayed();
+ log.info("VID-12 TC-9 PASSED");
+
+ //Cancel button is clicked
+ driver.findElement(By.xpath("//button[@class='button button--small button--primary']")).click();
+ log.info("Cancel button is clicked");
+
+ //Verifying VID Home page is displayed
+ Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances"));
+ log.info("VID-12 TC-10 PASSED");
+
+ }
+
+
+ /**
+ * Refresh subscriber name.
+ */
+ @Test(priority=9)
+ public void refreshSubscriberName()
+ {
+ log.info("VID-10 TC-4");
+
+
+ driver.findElement(By.xpath(configProp.getProperty("refreshButtonSubscriberName"))).isDisplayed();
+
+ log.info("VID-10 TC-4 PASSED");
+
+
+ }
+
+
+ /**
+ * Select subscriber type drop down.
+ *
+ * @throws InterruptedException the interrupted exception
+ */
+ @Test(priority=9)
+ public void selectSubscriberTypeDropDown() throws InterruptedException
+ {
+ Thread.sleep(5000);
+ log.info("------------------VID-10 TC-3, VID-12 TC-12,--------------------");
+ //Infrastructure Subscriber Type
+ Select iSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown"))));
+
+ List <WebElement> ielementCount = iSelect.getOptions();
+ log.info("Select Element Count of Service type");
+ System.out.println(ielementCount.size());
+ iSelect.selectByIndex(1);
+
+ log.info("VID-10 TC-3 PASSED");
+
+
+ //Submit button is clicked
+ driver.findElement(By.xpath(configProp.getProperty("submitButton"))).click();
+
+ //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:"
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed();
+ //Assert.assertTrue(driver.getPageSource().contains("Selected Subscriber's Service Instance Details:"))
+ log.info("Page Header: Selected Subscriber's Service Instance Details");
+
+
+ //Verify whether the page header is displayed "Global Customer ID"
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/thead/tr/th[2]/div")).isDisplayed();
+
+ //Assert.assertTrue(driver.getPageSource().contains("Global Customer ID"));
+ log.info("Table is displayed");
+
+ log.info("VID-12 TC-12 PASSED");
+
+ }
+
+
+
+ /**
+ * Logout under profile.
+ */
+ @Test(priority=10)
+ public void logoutUnderProfile()
+ {
+
+ log.info("-----------VID-11 TC-5---------------------");
+ //driver.findElement(By.partialLinkText("Click here to login")).click();
+ //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+
+
+ driver.findElement(By.xpath(".//*[@class='icon-user-small login-snippet-icon']")).click();
+ driver.findElement(By.xpath(".//*[@id='reg-logout-div']/a")).click();
+ //Validate that the user has logged out of VID. Displays "Portal"
+ Assert.assertTrue(driver.getPageSource().contains("Portal"));
+
+ log.info("VID-11 TC-5 PASSED");
+
+ }
+
+
+
+ /**
+ * Tear down.
+ */
+ @AfterClass
+ public void tearDown()
+ {
+ driver.close();
+
+ }
+
+
+
+ }
+
+
+
+
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/selenium/LogOutLeftPane.java b/onap-enabler-be/src/test/java/org/onap/osam/selenium/LogOutLeftPane.java
new file mode 100644
index 0000000..ca5c618
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/selenium/LogOutLeftPane.java
@@ -0,0 +1,240 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.selenium;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.log4j.Logger;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.support.ui.Select;
+import org.testng.Assert;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+@Test(enabled=false)
+public class LogOutLeftPane {
+
+ WebElement loginButton;
+
+ /** The login. */
+ WebElement login;
+
+ /** The pwd. */
+ WebElement pwd;
+
+ /** The log. */
+ Logger log;
+
+ /** The errormessage. */
+ WebElement errormessage;
+
+ /** The driver. */
+ WebDriver driver=new FirefoxDriver();
+
+
+ /** The config prop. */
+ private final Properties configProp = new Properties();
+
+
+ /**
+ * Instantiates a new log out left pane.
+ */
+ private LogOutLeftPane() {
+ // TODO Auto-generated constructor stub
+ //
+ try{
+ // InputStream input =this.getClass().getClassLoader().getResourceAsStream("objectmap.properties");
+ //FileInputStream input1 = new FileInputStream("objectmap.properties");
+
+ InputStream input =new FileInputStream("objectconfig.properties");
+ System.out.println("Read all properties from file");
+ configProp.load(input);
+ System.out.println("Read all properties from file completed");
+ }
+ catch(IOException e) {
+
+ e.printStackTrace();
+ }
+ }
+
+
+
+
+ /**
+ * Do before test.
+ */
+ // TODO Auto-generated method stub
+ @BeforeTest
+ public void doBeforeTest()
+ {
+ //WebDriver driver=new FirefoxDriver();
+
+ log = Logger.getLogger(LogOutLeftPane.class.getName());
+
+
+
+ // Get url
+ driver.get("http://vid.onap.org:9080/vid/login_external.htm");
+ driver.manage().window().maximize();
+
+
+ login = driver.findElement(By.xpath("//input[@class='fn-ebz-text ng-pristine ng-valid']"));
+ pwd = driver.findElement(By.xpath("//input[@class='span3 ng-pristine ng-valid']"));
+ loginButton = driver.findElement(By.id("loginBtn"));
+ }
+
+
+ /**
+ * Expand collapse panel.
+ *
+ * @throws InterruptedException the interrupted exception
+ */
+ @Test(priority=1)
+ public void expandCollapsePanel() throws InterruptedException
+ {
+
+
+
+ login.clear();
+ login.sendKeys("su");
+ pwd.clear();
+ pwd.sendKeys("fusion");
+ //driver.findElement(By.partialLinkText("Click here to login")).click();
+ //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+
+ loginButton.click();
+ driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+
+
+ log.info("Clicking Profile link from left pane");
+ Thread.sleep(3000);
+ System.out.println("properties file details --->"+configProp.getProperty("profilelink"));
+ driver.findElement(By.xpath(configProp.getProperty("profilelink"))).click();
+ Thread.sleep(3000);
+
+ //Verify whether the sub panel is displayed
+ //To verify the following :Search import from webphone and Self
+ driver.findElement(By.xpath(".//*[@id='panel4']")).isDisplayed();
+ log.info("Expand and collapse passed for Profile link");
+
+ //For Admin
+ //Verify expand and collapse working for ADMIN
+ log.info("Clicking Admin link from left pane");
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[6]/a/span")).click();
+ //To verify the following: Roles, Roles Functions, Usages
+ driver.findElement(By.xpath(".//*[@id='panel5']")).isDisplayed();
+
+
+ log.info("Expand and collapse passed for ADMIN link");
+
+ log.info("VID-11 TC-3 PASSED");
+
+ }
+
+
+ /**
+ * Drop down list.
+ *
+ * @throws InterruptedException the interrupted exception
+ */
+ @Test(priority=2)
+ public void dropDownList() throws InterruptedException
+ {
+ //VID-12 TC-3
+ log.info("VID-12 TC-3");
+ //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"));
+
+ //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select"));
+ Thread.sleep(5000);
+
+ //Infrastructure Subscriber Name
+ Select oSelect = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")));
+ Select iSelect = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select")));
+
+ List <WebElement> elementCount = oSelect.getOptions();
+ log.info("Subscriber Name Drop Down");
+ System.out.println(elementCount.size());
+ oSelect.selectByIndex(1);
+ log.info("Subscriber name selected");
+ //String selectedOption = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"))).getFirstSelectedOption().getText();
+
+
+ List <WebElement> count = iSelect.getOptions();
+ log.info("Subscriber type drop down");
+ System.out.println(count.size());
+ oSelect.selectByIndex(1);
+ log.info("Subscriber type selected");
+
+
+
+ //Submit button is clicked
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button")).click();
+
+
+ //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:"
+ driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed();
+ log.info("VID-12 TC-3 PASSED");
+ }
+
+
+
+
+ /**
+ * Logout left pane.
+ */
+ @Test(priority=3)
+ public void logoutLeftPane()
+ {
+ //To Verify if the logout link redirects to Login page when clicked.
+
+
+ /*log.info("----------------VID-11 TC-4----------------");
+ login.clear();
+ login.sendKeys("testuser");
+ pwd.clear();
+ pwd.sendKeys("abc123");
+ //driver.findElement(By.partialLinkText("Click here to login")).click();
+ //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
+
+ loginButton.click();
+ driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);*/
+ log.info("----------------VID-11 TC-4----------------");
+ driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[7]/a")).click();
+ //Validate that the user has logged out of VID. Displays "Portal"
+ Assert.assertTrue(driver.getPageSource().contains("Portal"));
+
+ log.info("VID 11 TC-4 PASSED");
+
+ driver.close();
+
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/services/AaiServiceImplTest.java b/onap-enabler-be/src/test/java/org/onap/osam/services/AaiServiceImplTest.java
new file mode 100644
index 0000000..7034134
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/services/AaiServiceImplTest.java
@@ -0,0 +1,358 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.aai.SubscriberFilteredResults;
+import org.onap.osam.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.osam.aai.model.AaiGetPnfs.Pnf;
+import org.onap.osam.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.osam.model.SubscriberList;
+import org.onap.osam.roles.RoleValidator;
+
+public class AaiServiceImplTest {
+
+ private AaiServiceImpl createTestSubject() {
+ return new AaiServiceImpl();
+ }
+
+ @Test
+ public void testGetFullSubscriberList() throws Exception {
+ AaiServiceImpl testSubject;
+ RoleValidator roleValidator = null;
+ SubscriberFilteredResults result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getFullSubscriberList(roleValidator);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetOperationalEnvironments() throws Exception {
+ AaiServiceImpl testSubject;
+ String operationalEnvironmentType = "";
+ String operationalEnvironmentStatus = "";
+ AaiResponse<OperationalEnvironmentList> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getOperationalEnvironments(operationalEnvironmentType, operationalEnvironmentStatus);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetFullSubscriberList_1() throws Exception {
+ AaiServiceImpl testSubject;
+ AaiResponse<SubscriberList> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getFullSubscriberList();
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetSubscriberData() throws Exception {
+ AaiServiceImpl testSubject;
+ String subscriberId = "";
+ RoleValidator roleValidator = null;
+ AaiResponse result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getSubscriberData(subscriberId, roleValidator);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetServiceInstanceSearchResults() throws Exception {
+ AaiServiceImpl testSubject;
+ String subscriberId = "";
+ String instanceIdentifier = "";
+ RoleValidator roleValidator = null;
+ List<String> owningEntities = null;
+ List<String> projects = null;
+ AaiResponse result;
+
+ // test 1
+ testSubject = createTestSubject();
+ subscriberId = null;
+ instanceIdentifier = null;
+ result = testSubject.getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator,
+ owningEntities, projects);
+ Assert.assertNotEquals(null, result);
+
+ /*/ test 2
+ testSubject = createTestSubject();
+ subscriberId = "";
+ instanceIdentifier = null;
+ result = testSubject.getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator,
+ owningEntities, projects);
+ Assert.assertNotEquals(null, result);
+
+ // test 3
+ testSubject = createTestSubject();
+ instanceIdentifier = null;
+ subscriberId = null;
+ result = testSubject.getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator,
+ owningEntities, projects);
+ Assert.assertEquals(null, result);
+
+ // test 4
+ testSubject = createTestSubject();
+ instanceIdentifier = "";
+ subscriberId = null;
+ result = testSubject.getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator,
+ owningEntities, projects);
+ Assert.assertEquals(null, result);
+
+ // test 5
+ testSubject = createTestSubject();
+ owningEntities = null;
+ result = testSubject.getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator,
+ owningEntities, projects);
+ Assert.assertEquals(null, result);
+
+ // test 6
+ testSubject = createTestSubject();
+ projects = null;
+ result = testSubject.getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator,
+ owningEntities, projects);
+ Assert.assertEquals(null, result);*/
+ }
+
+ @Test
+ public void testGetVersionByInvariantId() throws Exception {
+ AaiServiceImpl testSubject;
+ List<String> modelInvariantId = null;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ testSubject.getVersionByInvariantId(modelInvariantId);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetSpecificPnf() throws Exception {
+ AaiServiceImpl testSubject;
+ String pnfId = "";
+ AaiResponse<Pnf> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getSpecificPnf(pnfId);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetPNFData() throws Exception {
+ AaiServiceImpl testSubject;
+ String globalCustomerId = "";
+ String serviceType = "";
+ String modelVersionId = "";
+ String modelInvariantId = "";
+ String cloudRegion = "";
+ String equipVendor = "";
+ String equipModel = "";
+ AaiResponse result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId,
+ cloudRegion, equipVendor, equipModel);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetServices() throws Exception {
+ AaiServiceImpl testSubject;
+ RoleValidator roleValidator = null;
+ AaiResponse result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getServices(roleValidator);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetTenants() throws Exception {
+ AaiServiceImpl testSubject;
+ String globalCustomerId = "";
+ String serviceType = "";
+ RoleValidator roleValidator = null;
+ AaiResponse<GetTenantsResponse[]> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getTenants(globalCustomerId, serviceType, roleValidator);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetVNFData() throws Exception {
+ AaiServiceImpl testSubject;
+ String globalSubscriberId = "";
+ String serviceType = "";
+ String serviceInstanceId = "";
+ AaiResponse result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getVNFData(globalSubscriberId, serviceType, serviceInstanceId);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetVNFData_1() throws Exception {
+ AaiServiceImpl testSubject;
+ String globalSubscriberId = "";
+ String serviceType = "";
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ testSubject.getVNFData(globalSubscriberId, serviceType);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetAaiZones() throws Exception {
+ AaiServiceImpl testSubject;
+ AaiResponse result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getAaiZones();
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetAicZoneForPnf() throws Exception {
+ AaiServiceImpl testSubject;
+ String globalCustomerId = "";
+ String serviceType = "";
+ String serviceId = "";
+ AaiResponse result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getAicZoneForPnf(globalCustomerId, serviceType, serviceId);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetNodeTemplateInstances() throws Exception {
+ AaiServiceImpl testSubject;
+ String globalCustomerId = "";
+ String serviceType = "";
+ String modelVersionId = "";
+ String modelInvariantId = "";
+ String cloudRegion = "";
+ AaiResponse result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId,
+ modelInvariantId, cloudRegion);
+ } catch (
+
+ Exception e) {
+ }
+ }
+
+ @Test
+ public void testGetServiceInstanceAssociatedPnfs() throws Exception {
+ AaiServiceImpl testSubject;
+ String globalCustomerId = "";
+ String serviceType = "";
+ String serviceInstanceId = "";
+ List<String> result;
+
+ // default test
+ try {
+ testSubject = createTestSubject();
+ result = testSubject.getServiceInstanceAssociatedPnfs(globalCustomerId, serviceType, serviceInstanceId);
+ } catch (
+
+ Exception e) {
+ }
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/services/AsyncInstantiationBaseTest.java b/onap-enabler-be/src/test/java/org/onap/osam/services/AsyncInstantiationBaseTest.java
new file mode 100644
index 0000000..b8118d2
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/services/AsyncInstantiationBaseTest.java
@@ -0,0 +1,213 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import com.google.common.collect.ImmutableMap;
+import jersey.repackaged.com.google.common.collect.ImmutableList;
+import org.onap.osam.aai.AaiClientInterface;
+import org.onap.osam.aai.AaiResponse;
+import org.onap.osam.aai.model.AaiNodeQueryResponse;
+import org.onap.osam.aai.model.ResourceType;
+import org.onap.osam.domain.mso.ModelInfo;
+import org.onap.osam.domain.mso.RequestStatus;
+import org.onap.osam.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.osam.model.serviceInstantiation.VfModule;
+import org.onap.osam.model.serviceInstantiation.Vnf;
+import org.onap.osam.mso.RestObject;
+import org.onap.osam.mso.rest.AsyncRequestStatus;
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+import org.togglz.core.manager.FeatureManager;
+
+import javax.inject.Inject;
+import java.util.*;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests {
+
+ public static final String OWNING_ENTITY_ID = "038d99af-0427-42c2-9d15-971b99b9b489";
+ public static final String PACKET_CORE = "PACKET CORE";
+ public static final String PROJECT_NAME = "{some project name}";
+ public static final String SUBSCRIBER_ID = "{some subscriber id}";
+ public static final String SUBSCRIBER_NAME = "{some subscriber name}";
+ public static final String PRODUCT_FAMILY_ID = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
+ public static final String INSTANCE_NAME = "vPE_Service";
+ public static final String SUBSCRIPTION_SERVICE_TYPE = "VMX";
+ public static final String LCP_CLOUD_REGION_ID = "mdt1";
+ public static final String A6CA3EE0394ADE9403F075DB23167E = "88a6ca3ee0394ade9403f075db23167e";
+ public static final String TENANT_NAME = "USP-SIP-IC-24335-T-01";
+ public static final String AIC_ZONE_ID = "NFT1";
+ public static final String AIC_ZONE_NAME = "NFTJSSSS-NFT1";
+
+ protected HashMap<String, String> instanceParamsMapWithoutParams;
+ protected HashMap<String, String> vfModuleInstanceParamsMapWithParamsToRemove;
+ protected HashMap<String, String> vnfInstanceParamsMapWithParamsToRemove;
+
+ @Inject
+ protected FeatureManager featureManager;
+
+ @Inject
+ protected AaiClientInterface aaiClient;
+
+ public ServiceInstantiation generateMockServiceInstantiationPayload(boolean isPause, Map<String, Vnf> vnfs, int bulkSize, boolean isUserProvidedNaming, String projectName, boolean rollbackOnFailure) {
+ ModelInfo modelInfo = createModelInfo();
+
+ List<Map<String,String>> instanceParams = createInstanceParams();
+
+ return new ServiceInstantiation (
+ modelInfo,
+ AsyncInstantiationBusinessLogicTest.OWNING_ENTITY_ID,
+ AsyncInstantiationBusinessLogicTest.PACKET_CORE,
+ projectName,
+ AsyncInstantiationBusinessLogicTest.SUBSCRIBER_ID,
+ AsyncInstantiationBusinessLogicTest.SUBSCRIBER_NAME,
+ AsyncInstantiationBusinessLogicTest.PRODUCT_FAMILY_ID,
+ isUserProvidedNaming ? AsyncInstantiationBusinessLogicTest.INSTANCE_NAME : "" ,
+ isUserProvidedNaming,
+ AsyncInstantiationBusinessLogicTest.SUBSCRIPTION_SERVICE_TYPE,
+ AsyncInstantiationBusinessLogicTest.LCP_CLOUD_REGION_ID,
+ AsyncInstantiationBusinessLogicTest.A6CA3EE0394ADE9403F075DB23167E,
+ AsyncInstantiationBusinessLogicTest.TENANT_NAME,
+ AsyncInstantiationBusinessLogicTest.AIC_ZONE_ID,
+ AsyncInstantiationBusinessLogicTest.AIC_ZONE_NAME,
+ vnfs,
+ instanceParams,
+ isPause,
+ bulkSize,
+ rollbackOnFailure
+ );
+ }
+
+ private List<Map<String,String>> createInstanceParams() {
+ List<Map<String, String>> instanceParams = new ArrayList<>();
+ HashMap<String, String> map = new HashMap<>();
+ map.put("instanceParams_test1" , "some text");
+ map.put("instanceParams_test2" , "another text");
+ instanceParams.add(map);
+ return instanceParams;
+ }
+
+ private VfModule createVfModule(String modelName, String modelVersionId, String modelCustomizationId,
+ List<Map<String, String>> instanceParams, String instanceName, String volumeGroupInstanceName) {
+ ModelInfo vfModuleInfo = new ModelInfo();
+ vfModuleInfo.setModelType("vfModule");
+ vfModuleInfo.setModelName(modelName);
+ vfModuleInfo.setModelVersionId(modelVersionId);
+ vfModuleInfo.setModelCustomizationId(modelCustomizationId);
+ return new VfModule(vfModuleInfo , instanceName, volumeGroupInstanceName, instanceParams);
+ }
+
+ private ModelInfo createVnfModelInfo() {
+ ModelInfo vnfModelInfo = new ModelInfo();
+ vnfModelInfo.setModelType("vnf");
+ vnfModelInfo.setModelName("2016-73_MOW-AVPN-vPE-BV-L");
+ vnfModelInfo.setModelVersionId("7f40c192-f63c-463e-ba94-286933b895f8");
+ vnfModelInfo.setModelCustomizationName("2016-73_MOW-AVPN-vPE-BV-L 0");
+ vnfModelInfo.setModelCustomizationId("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ return vnfModelInfo;
+ }
+
+ private ModelInfo createModelInfo() {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelType("service");
+ modelInfo.setModelVersionId("3c40d244-808e-42ca-b09a-256d83d19d0a");
+ modelInfo.setModelVersion("10.0");
+ modelInfo.setModelInvariantId("5d48acb5-097d-4982-aeb2-f4a3bd87d31b");
+ modelInfo.setModelName("MOW AVPN vMX BV vPE 1 Service");
+ return modelInfo;
+ }
+
+ protected Map<String, Vnf> createVnfList(HashMap<String, String> vfModuleInstanceParamsMap, List vnfInstanceParams, boolean isUserProvidedNaming) {
+ Map<String, Vnf> vnfs = new HashMap<>();
+ ModelInfo vnfModelInfo = createVnfModelInfo();
+
+ Map<String, Map<String, VfModule>> vfModules = new HashMap<>();
+
+ List<Map<String, String>> instanceParams1 =ImmutableList.of((ImmutableMap.of("vmx_int_net_len", "24")));
+ VfModule vfModule1 = createVfModule("201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0", "4c75f813-fa91-45a4-89d0-790ff5f1ae79", "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f", instanceParams1, "vmxnjr001_AVPN_base_vPE_BV_base", null);
+ List<Map<String, String>> instanceParams2 = ImmutableList.of(vfModuleInstanceParamsMap);
+ VfModule vfModule2 = createVfModule("201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1", "56e2b103-637c-4d1a-adc8-3a7f4a6c3240", "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", instanceParams2, "vmxnjr001_AVPN_base_vRE_BV_expansion", "myVgName");
+
+ String vfModuleModelName = vfModule1.getModelInfo().getModelName();
+ vfModules.put(vfModuleModelName, new LinkedHashMap<>());
+
+ vfModules.get(vfModuleModelName).put(vfModule1.getInstanceName(),vfModule1);
+ vfModules.get(vfModuleModelName).put(vfModule2.getInstanceName(), vfModule2);
+
+ Vnf vnf = new Vnf(vnfModelInfo, "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", "vmxnjr001", isUserProvidedNaming,
+ "platformName", "mdt1", "88a6ca3ee0394ade9403f075db23167e", vnfInstanceParams,"lineOfBusinessName" ,vfModules);
+
+ vnfs.put(vnf.getInstanceName(), vnf);
+ return vnfs;
+ }
+
+ protected void createInstanceParamsMaps() {
+ instanceParamsMapWithoutParams = new HashMap<>();
+ instanceParamsMapWithoutParams.put("availability_zone_0" , "mtpocdv-kvm-az01");
+ instanceParamsMapWithoutParams.put("vre_a_volume_size_0" , "100");
+
+ vfModuleInstanceParamsMapWithParamsToRemove = new HashMap<>();
+ vfModuleInstanceParamsMapWithParamsToRemove.put(IAsyncInstantiationBusinessLogic.PARAMS_TO_IGNORE.get(0), "should be removed");
+ vfModuleInstanceParamsMapWithParamsToRemove.put("availability_zone_0" , "mtpocdv-kvm-az01");
+ vfModuleInstanceParamsMapWithParamsToRemove.put("vre_a_volume_size_0" , "100");
+
+ vnfInstanceParamsMapWithParamsToRemove = new HashMap<>();
+ vnfInstanceParamsMapWithParamsToRemove.put(IAsyncInstantiationBusinessLogic.PARAMS_TO_IGNORE.get(1), "should be removed");
+ }
+
+ protected AsyncRequestStatus asyncRequestStatusResponse(String msoStatus) {
+ AsyncRequestStatus asyncRequestStatus = new AsyncRequestStatus(new AsyncRequestStatus.Request(new RequestStatus()));
+ asyncRequestStatus.request.requestStatus.setRequestState(msoStatus);
+ asyncRequestStatus.request.requestId = UUID.randomUUID().toString();
+ return asyncRequestStatus;
+ }
+
+ protected RestObject<AsyncRequestStatus> asyncRequestStatusResponseAsRestObject(String msoStatus) {
+ return asyncRequestStatusResponseAsRestObject(msoStatus, 200);
+ }
+
+ protected RestObject<AsyncRequestStatus> asyncRequestStatusResponseAsRestObject(String msoStatus, int httpStatusCode) {
+ RestObject<AsyncRequestStatus> restObject = new RestObject<>();
+ restObject.set(asyncRequestStatusResponse(msoStatus));
+ restObject.setStatusCode(httpStatusCode);
+ return restObject;
+ }
+
+ protected void mockAaiClientAnyNameFree() {
+ when(aaiClient.searchNodeTypeByName(any(), any())).thenReturn(aaiNodeQueryResponseNameFree());
+ }
+
+ protected AaiResponse<AaiNodeQueryResponse> aaiNodeQueryResponseNameFree() {
+ return new AaiResponse<>(new AaiNodeQueryResponse(null),"", 200);
+ }
+
+ protected AaiResponse<AaiNodeQueryResponse> aaiNodeQueryBadResponse() {
+ return new AaiResponse<>(null,"", 404);
+ }
+
+ protected AaiResponse<AaiNodeQueryResponse> aaiNodeQueryResponseNameUsed(ResourceType type) {
+ AaiNodeQueryResponse mockAaiNodeQuery = new AaiNodeQueryResponse(ImmutableList.of(new AaiNodeQueryResponse.ResultData(type, "/some/mocked/link")));
+ return new AaiResponse<>(mockAaiNodeQuery,"", 200);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/services/AsyncInstantiationBusinessLogicTest.java b/onap-enabler-be/src/test/java/org/onap/osam/services/AsyncInstantiationBusinessLogicTest.java
new file mode 100644
index 0000000..0072018
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/services/AsyncInstantiationBusinessLogicTest.java
@@ -0,0 +1,845 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import org.onap.osam.config.DataSourceConfig;
+import org.onap.osam.config.MockedAaiClientAndFeatureManagerConfig;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.test.context.ContextConfiguration;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.mockito.Matchers.any;
+
+@ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, MockedAaiClientAndFeatureManagerConfig.class})
+public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseTest {
+/*
+TO BE FIXED
+ @Inject
+ private DataAccessService dataAccessService;
+
+ @Mock
+ private JobAdapter jobAdapter;
+
+ @Mock
+ private JobsBrokerService jobsBrokerService;
+
+
+
+ @Autowired
+ private SessionFactory sessionFactory;
+
+ private IAsyncInstantiationBusinessLogic asyncInstantiationBL;
+
+ private int serviceCount = 0;
+
+ private static final String UPDATE_SERVICE_INFO_EXCEPTION_MESSAGE =
+ "Failed to retrieve job with uuid .* from ServiceInfo table. Instances found: .*";
+
+ private static final String DELETE_SERVICE_INFO_STATUS_EXCEPTION_MESSAGE =
+ "Service status does not allow deletion from the queue";
+
+ @BeforeClass
+ void initServicesInfoService() {
+ MockitoAnnotations.initMocks(this);
+ asyncInstantiationBL = new AsyncInstantiationBusinessLogicImpl(dataAccessService, jobAdapter, jobsBrokerService, sessionFactory, aaiClient);
+ createInstanceParamsMaps();
+ }
+
+ @BeforeMethod
+ void defineMocks() {
+ mockAaiClientAnyNameFree();
+ }
+
+ @BeforeMethod
+ void resetServiceCount() {
+ serviceCount = 0;
+ }
+
+ @AfterMethod
+ void clearDb() {
+ dataAccessService.deleteDomainObjects(JobDaoImpl.class, "1=1", getPropsMap());
+ dataAccessService.deleteDomainObjects(ServiceInfo.class, "1=1", getPropsMap());
+ dataAccessService.deleteDomainObjects(JobAuditStatus.class, "1=1", getPropsMap());
+ dataAccessService.deleteDomainObjects(NameCounter.class, "1=1", getPropsMap());
+ }
+
+
+ private void createNewTestServicesInfoForFilter(String userId) {
+ LocalDateTime createdDate, modifiedDate;
+ LocalDateTime NOW = LocalDateTime.now();
+ UUID uuid;
+
+ // Old job
+ uuid = UUID.randomUUID();
+ addNewJob(uuid);
+ createdDate = NOW.minusYears(1);
+ addNewServiceInfo(uuid, userId, "Old", createdDate, createdDate, COMPLETED, false);
+
+ uuid = UUID.randomUUID();
+ addNewJob(uuid);
+ createdDate = NOW.minusDays(20);
+ modifiedDate = NOW.minusDays(19);
+ addNewServiceInfo(uuid, userId, "Hidden", createdDate, modifiedDate, PAUSE, true);
+
+ createNewTestServicesInfo(String.valueOf(userId));
+ }
+
+ private void createNewTestServicesInfo(String userId) {
+
+ LocalDateTime createdDate, modifiedDate;
+ LocalDateTime NOW = LocalDateTime.now();
+ UUID uuid;
+
+ uuid = UUID.randomUUID();
+ addNewJob(uuid);
+
+ createdDate = NOW.minusDays(40);
+ addNewServiceInfo(uuid, userId, "service instance 5", createdDate, createdDate, COMPLETED, false);
+ addNewServiceInfo(uuid, userId, "service instance 6", createdDate, createdDate, STOPPED, false);
+
+ uuid = UUID.randomUUID();
+ addNewJob(uuid);
+
+ createdDate = NOW.minusDays(20);
+ modifiedDate = NOW.minusDays(10);
+ addNewServiceInfo(uuid, userId, "service instance 4", createdDate, modifiedDate, STOPPED, false);
+ addNewServiceInfo(uuid, userId, "service instance 2", createdDate, modifiedDate, COMPLETED, false);
+ addNewServiceInfo(uuid, userId, "service instance 3", createdDate, modifiedDate, PAUSE, false);
+
+ modifiedDate = NOW.minusDays(19);
+ addNewServiceInfo(uuid, userId, "service instance 1", createdDate, modifiedDate, FAILED, false);
+
+
+ // Job to a different user
+ uuid = UUID.randomUUID();
+ addNewJob(uuid);
+
+ createdDate = NOW.minusMonths(2);
+ addNewServiceInfo(uuid, "2221", "service instance 7", createdDate, createdDate, COMPLETED, false);
+
+ }
+
+ private UUID createServicesInfoWithDefaultValues(Job.JobStatus status) {
+
+ LocalDateTime NOW = LocalDateTime.now();
+ UUID uuid;
+
+ uuid = UUID.randomUUID();
+ addNewJob(uuid, status);
+
+ addNewServiceInfo(uuid, null, "service instance 1", NOW, NOW, status, false);
+
+ return uuid;
+
+ }
+
+ private List<ServiceInfo> getFullList() {
+ List<ServiceInfo> expectedOrderServiceInfo = dataAccessService.getList(ServiceInfo.class, getPropsMap());
+ assertThat("Failed to retrieve all predefined services", expectedOrderServiceInfo.size(), equalTo(serviceCount));
+ expectedOrderServiceInfo.sort(new ServiceInfoComparator());
+ return expectedOrderServiceInfo;
+ }
+
+ private static Date toDate(LocalDateTime localDateTime) {
+ return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
+ }
+
+ private LocalDateTime fromDate(Date date) {
+ return Instant.ofEpochMilli(date.getTime())
+ .atZone(ZoneId.systemDefault())
+ .toLocalDateTime();
+ }
+
+ private void addNewServiceInfo(UUID uuid, String userId, String serviceName, LocalDateTime createDate, LocalDateTime statusModifiedDate, Job.JobStatus status, boolean isHidden) {
+ ServiceInfo serviceInfo = new ServiceInfo();
+ serviceInfo.setJobId(uuid);
+ serviceInfo.setUserId(userId);
+ serviceInfo.setServiceInstanceName(serviceName);
+ serviceInfo.setStatusModifiedDate(toDate(statusModifiedDate));
+ serviceInfo.setJobStatus(status);
+ serviceInfo.setPause(false);
+ serviceInfo.setOwningEntityId("1234");
+ serviceInfo.setCreatedBulkDate(toDate(createDate));
+
+ serviceInfo.setHidden(isHidden);
+ dataAccessService.saveDomainObject(serviceInfo, getPropsMap());
+ setCreateDateToServiceInfo(uuid, createDate);
+ serviceCount++;
+
+ }
+
+ private void setCreateDateToServiceInfo(UUID jobUuid, LocalDateTime createDate) {
+ List<ServiceInfo> serviceInfoList = dataAccessService.getList(ServiceInfo.class, getPropsMap());
+ DaoUtils.tryWithSessionAndTransaction(sessionFactory, session -> {
+ serviceInfoList.stream()
+ .filter(serviceInfo -> jobUuid.equals(serviceInfo.getJobId()))
+ .forEach(serviceInfo -> {
+ serviceInfo.setCreated(toDate(createDate));
+ session.saveOrUpdate(serviceInfo);
+ });
+ return 1;
+ });
+ }
+
+ private void addNewJob(UUID uuid) {
+ addNewJob(uuid, null);
+ }
+
+ private void addNewJob(UUID uuid, Job.JobStatus status) {
+ JobDaoImpl jobDao = new JobDaoImpl();
+ jobDao.setUuid(uuid);
+ jobDao.setStatus(status);
+ dataAccessService.saveDomainObject(jobDao, getPropsMap());
+ }
+
+ @Test
+ public void testServiceInfoAreOrderedAsExpected() {
+ int userId = 2222;
+ createNewTestServicesInfo(String.valueOf(userId));
+ List<ServiceInfo> expectedOrderServiceInfo = getFullList();
+ List<ServiceInfo> serviceInfoListResult = asyncInstantiationBL.getAllServicesInfo();
+ assertThat("Services aren't ordered as expected", serviceInfoListResult, equalTo(expectedOrderServiceInfo));
+ }
+
+ @Test
+ public void testServiceInfoAreFilteredAsExpected() {
+ int userId = 2222;
+ createNewTestServicesInfoForFilter(String.valueOf(userId));
+ List<ServiceInfo> expectedOrderServiceInfo = getFullList();
+
+ List<ServiceInfo> expectedFilterByUser = expectedOrderServiceInfo.stream().filter(x ->
+ !x.getServiceInstanceName().equals("Old") && !x.getServiceInstanceName().equals("Hidden")
+
+ ).collect(Collectors.toList());
+
+
+ List<ServiceInfo> serviceInfoFilteredByUser = asyncInstantiationBL.getAllServicesInfo();
+ assertThat("Services aren't ordered filtered as expected", serviceInfoFilteredByUser, equalTo(expectedFilterByUser));
+ }
+
+ @Test(dataProvider = "pauseAndInstanceParams", enabled = false) //Test is irrelevant with unique names feature
+ public void createServiceInstantiationMsoRequest(Boolean isPause, HashMap<String, String> vfModuleInstanceParamsMap, List vnfInstanceParams) throws Exception {
+ ServiceInstantiation serviceInstantiationPayload = generateMockServiceInstantiationPayload(isPause, createVnfList(vfModuleInstanceParamsMap, vnfInstanceParams, true));
+ final URL resource = this.getClass().getResource("/payload_jsons/bulk_service_request.json");
+ RequestDetailsWrapper<ServiceInstantiationRequestDetails> result =
+ asyncInstantiationBL.generateServiceInstantiationRequest(null, serviceInstantiationPayload, "az2016");
+ String expected = IOUtils.toString(resource, "UTF-8");
+ MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
+ }
+
+ @Test(dataProvider = "pauseAndInstanceParams")
+ public void createServiceInstantiationMsoRequestUniqueName(Boolean isPause, HashMap<String, String> vfModuleInstanceParamsMap, List vnfInstanceParams) throws Exception {
+ Mockito.reset(aaiClient);
+ mockAaiClientAnyNameFree();
+ ServiceInstantiation serviceInstantiationPayload = generateMockServiceInstantiationPayload(isPause, createVnfList(vfModuleInstanceParamsMap, vnfInstanceParams, true));
+ final URL resource = this.getClass().getResource("/payload_jsons/bulk_service_request_unique_names.json");
+ List<UUID> uuids = new ArrayList<>();
+ for (int i = 0; i < 2; i++) {
+ UUID currentUuid = createJobAndServiceInfo();
+ uuids.add(currentUuid);
+ RequestDetailsWrapper<ServiceInstantiationRequestDetails> result =
+ asyncInstantiationBL.generateServiceInstantiationRequest(currentUuid, serviceInstantiationPayload, "az2016");
+ String unique = String.format("00%s", i + 1);
+ String expected = IOUtils.toString(resource, "UTF-8")
+ .replace("{SERVICE_UNIQENESS}", unique)
+ .replace("{VNF_UNIQENESS}", unique)
+ .replace("{VF_MODULE_UNIQENESS}", unique)
+ .replace("{VF_MODULE_2_UNIQENESS}", unique)
+ .replace("{VG_UNIQUENESS}", unique);
+ MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
+ Optional<ServiceInfo> optionalServiceInfo = getJobById(currentUuid);
+ assertThat(optionalServiceInfo.get().getServiceInstanceName(), equalTo("vPE_Service_" + unique));
+ verifySearchNodeTypeByName(unique, "vPE_Service_", ResourceType.SERVICE_INSTANCE);
+ verifySearchNodeTypeByName(unique, "vmxnjr001_", ResourceType.GENERIC_VNF);
+ verifySearchNodeTypeByName(unique, "vmxnjr001_AVPN_base_vPE_BV_base_", ResourceType.VF_MODULE);
+ verifySearchNodeTypeByName(unique, "vmxnjr001_AVPN_base_vRE_BV_expansion_", ResourceType.VF_MODULE);
+ verifySearchNodeTypeByName(unique, "myVgName_", ResourceType.VOLUME_GROUP);
+ }
+ }
+
+ protected void verifySearchNodeTypeByName(String unique, String resourceName, ResourceType serviceInstance) {
+ verify(aaiClient, times(1)).searchNodeTypeByName(resourceName + unique, serviceInstance);
+ }
+
+ private HashMap<String, Object> getPropsMap() {
+ HashMap<String, Object> props = new HashMap<>();
+ props.put(FusionObject.Parameters.PARAM_USERID, 0);
+ return props;
+ }
+
+ @Test(enabled = false) //probably not needed with name uniqueness feature
+ public void pushBulkJob_bulkWithSize3_instancesNamesAreExactlyAsExpected() {
+ int bulkSize = 3;
+
+ final ServiceInstantiation request = generateMockServiceInstantiationPayload(
+ false,
+ createVnfList(instanceParamsMapWithoutParams, Collections.EMPTY_LIST, true),
+ bulkSize, true,PROJECT_NAME, true
+ );
+
+ // in "createJob()" we will probe the service, with the generated names
+ final Job job = mock(Job.class);
+ when(job.getStatus()).thenReturn(PENDING);
+ when(jobAdapter.createJob(any(), any(), any(), any(), any())).thenReturn(job);
+
+
+ final List<UUID> uuids = asyncInstantiationBL.pushBulkJob(request, "myUserId");
+
+
+ ArgumentCaptor<ServiceInstantiation> serviceInstantiationCaptor = new ArgumentCaptor<ServiceInstantiation>();
+ verify(jobAdapter, times(bulkSize)).createJob(any(), serviceInstantiationCaptor.capture(), any(), any(), any());
+
+ assertThat(serviceInstantiationCaptor.getAllValues().stream().map(v -> v.getInstanceName()).collect(Collectors.toList()),
+ containsInAnyOrder("vPE_Service_001", "vPE_Service_002", "vPE_Service_003"));
+
+ assertThat(uuids, hasSize(bulkSize));
+ }
+
+ @Test
+ public void generateMockServiceInstantiationPayload_serializeBackAndForth_sourceShouldBeTheSame() throws IOException {
+ ServiceInstantiation serviceInstantiationPayload = generateMockServiceInstantiationPayload(
+ false,
+ createVnfList(instanceParamsMapWithoutParams, ImmutableList.of(vnfInstanceParamsMapWithParamsToRemove, vnfInstanceParamsMapWithParamsToRemove), true),
+ 2, false,PROJECT_NAME, false);
+ ObjectMapper mapper = new ObjectMapper();
+ final String asString = mapper.writeValueAsString(serviceInstantiationPayload);
+
+ final ServiceInstantiation asObject = mapper.readValue(asString, ServiceInstantiation.class);
+ final String asString2 = mapper.writeValueAsString(asObject);
+
+ JsonAssert.assertJsonEquals(asString, asString2);
+ }
+
+ public static class ServiceInfoComparator implements Comparator<ServiceInfo> {
+
+ @Override
+ public int compare(ServiceInfo o1, ServiceInfo o2) {
+ int compare;
+
+ compare = o1.getCreatedBulkDate().compareTo(o2.getCreatedBulkDate());
+ if (compare != 0) {
+ return -compare;
+ }
+
+ // check jobStatus priority
+ int o1Priority = getPriority(o1);
+ int o2Priority = getPriority(o2);
+ compare = o1Priority - o2Priority;
+ if (compare != 0) {
+ return compare;
+ }
+
+ // check statusModifiedDate
+ return o1.getStatusModifiedDate().compareTo(o2.getStatusModifiedDate());
+ }
+
+ private int getPriority(ServiceInfo o) throws JSONException {
+ Job.JobStatus status = o.getJobStatus();
+ switch (status) {
+ case COMPLETED:
+ case FAILED:
+ return 1;
+ case IN_PROGRESS:
+ return 2;
+ case PAUSE:
+ return 3;
+ case STOPPED:
+ case PENDING:
+ return 4;
+ default:
+ return 5;
+ }
+ }
+ }
+
+ @DataProvider
+ public Object[][] pauseAndInstanceParams() {
+ return new Object[][]{
+ {Boolean.TRUE, instanceParamsMapWithoutParams, Collections.EMPTY_LIST},
+ {Boolean.FALSE, instanceParamsMapWithoutParams, Collections.EMPTY_LIST},
+ {Boolean.TRUE, vfModuleInstanceParamsMapWithParamsToRemove, Collections.singletonList(vnfInstanceParamsMapWithParamsToRemove)}
+ };
+ }
+
+ private ServiceInstantiation generateMockServiceInstantiationPayload(boolean isPause, Map<String, Vnf> vnfs) {
+ return generateMockServiceInstantiationPayload(isPause, vnfs, 1, true, PROJECT_NAME, false);
+ }
+
+ @Test
+ public void testUpdateServiceInfo_WithExistingServiceInfo_ServiceInfoIsUpdated() {
+ UUID uuid = createJobAndServiceInfo();
+ final String STEPH_CURRY = "Steph Curry";
+ asyncInstantiationBL.updateServiceInfo(uuid, x -> {
+ x.setServiceInstanceName(STEPH_CURRY);
+ x.setJobStatus(Job.JobStatus.IN_PROGRESS);
+ });
+ Optional<ServiceInfo> optionalServiceInfo = getJobById(uuid);
+ assertThat(optionalServiceInfo.get().getServiceInstanceName(), equalTo(STEPH_CURRY));
+ assertThat(optionalServiceInfo.get().getJobStatus(), equalTo(Job.JobStatus.IN_PROGRESS));
+ }
+
+ private Optional<ServiceInfo> getJobById(UUID jobId) {
+ List<ServiceInfo> serviceInfoList = dataAccessService.getList(ServiceInfo.class, null);
+ return serviceInfoList.stream().filter(x -> jobId.equals(x.getJobId())).findFirst();
+ }
+
+ private UUID createJobAndServiceInfo() {
+ UUID uuid = UUID.randomUUID();
+ addNewJob(uuid);
+ ServiceInfo serviceInfo = new ServiceInfo();
+ serviceInfo.setServiceInstanceName("Lebron James");
+ serviceInfo.setJobId(uuid);
+ serviceInfo.setJobStatus(Job.JobStatus.PENDING);
+ dataAccessService.saveDomainObject(serviceInfo, getPropsMap());
+ return uuid;
+ }
+
+ @Test(expectedExceptions = GenericUncheckedException.class, expectedExceptionsMessageRegExp = UPDATE_SERVICE_INFO_EXCEPTION_MESSAGE)
+ public void testUpdateServiceInfo_WithNonExisting_ThrowException() {
+ asyncInstantiationBL.updateServiceInfo(UUID.randomUUID(), x -> x.setServiceInstanceName("not matter"));
+ }
+
+ @Test(expectedExceptions = GenericUncheckedException.class, expectedExceptionsMessageRegExp = UPDATE_SERVICE_INFO_EXCEPTION_MESSAGE)
+ public void testUpdateServiceInfo_WithDoubleServiceWithSameJobUuid_ThrowException() {
+ UUID uuid = createJobAndServiceInfo();
+ ServiceInfo serviceInfo = new ServiceInfo();
+ serviceInfo.setJobId(uuid);
+ dataAccessService.saveDomainObject(serviceInfo, getPropsMap());
+ asyncInstantiationBL.updateServiceInfo(UUID.randomUUID(), x -> x.setServiceInstanceName("not matter"));
+ }
+
+
+
+ @Test
+ public void testRequestPath_WithPauseFlagTrue_RequestPathIsAsExpected() {
+ ServiceInstantiation serviceInstantiationPauseFlagTrue = generateMockServiceInstantiationPayload(true, createVnfList(instanceParamsMapWithoutParams, Collections.EMPTY_LIST, true));
+ String path = asyncInstantiationBL.getServiceInstantiationPath(serviceInstantiationPauseFlagTrue);
+ Assert.assertEquals(path, SystemProperties.getProperty("mso.restapi.serviceInstanceAssign"));
+ }
+
+ @Test
+ public void testRequestPath_WithPauseFlagFalse_RequestPathIsAsExpected() {
+ ServiceInstantiation serviceInstantiationPauseFlagFalse = generateMockServiceInstantiationPayload(false, createVnfList(instanceParamsMapWithoutParams, Collections.EMPTY_LIST, true));
+ String path = asyncInstantiationBL.getServiceInstantiationPath(serviceInstantiationPauseFlagFalse);
+ Assert.assertEquals(path, SystemProperties.getProperty("mso.restapi.serviceInstanceCreate"));
+ }
+
+ @Test
+ public void createServiceInfo_WithUserProvidedNamingFalse_ServiceInfoIsAsExpected() throws IOException {
+ createServiceInfo_WithUserProvidedNamingFalse_ServiceInfoIsAsExpected(true);
+ }
+
+ @Test
+ public void createServiceInfo_WithUserProvidedNamingFalseAndNoVfmodules_ServiceInfoIsAsExpected() throws IOException {
+ createServiceInfo_WithUserProvidedNamingFalse_ServiceInfoIsAsExpected(false);
+ }
+
+ private void createServiceInfo_WithUserProvidedNamingFalse_ServiceInfoIsAsExpected(boolean withVfmodules) throws IOException {
+ ServiceInstantiation serviceInstantiationPayload = generateMockServiceInstantiationPayload(true,
+ createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, Collections.EMPTY_LIST, false),
+ 1,
+ false,PROJECT_NAME, true);
+ URL resource;
+ if (withVfmodules) {
+ resource = this.getClass().getResource("/payload_jsons/bulk_service_request_ecomp_naming.json");
+ } else {
+ // remove the vf modules
+ serviceInstantiationPayload.getVnfs().values().forEach(vnf -> vnf.getVfModules().clear());
+ resource = this.getClass().getResource("/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json");
+ }
+
+ RequestDetailsWrapper<ServiceInstantiationRequestDetails> result =
+ asyncInstantiationBL.generateServiceInstantiationRequest(null, serviceInstantiationPayload, "az2016");
+
+ String expected = IOUtils.toString(resource, "UTF-8");
+ MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
+ }
+
+ @Test
+ public void checkIfNullProjectNameSentToMso(){
+ ServiceInstantiation serviceInstantiationPayload = generateMockServiceInstantiationPayload(true,
+ createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, Collections.EMPTY_LIST, false),
+ 1,
+ false,null,false);
+ RequestDetailsWrapper<ServiceInstantiationRequestDetails> result =
+ asyncInstantiationBL.generateServiceInstantiationRequest(null, serviceInstantiationPayload, "az2016");
+ JsonNode jsonNode = new ObjectMapper().valueToTree(result.requestDetails);
+ Assert.assertTrue(jsonNode.get("project").isNull());
+ serviceInstantiationPayload = generateMockServiceInstantiationPayload(true,
+ createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, Collections.EMPTY_LIST, false),
+ 1,
+ false,"not null",false);
+ result = asyncInstantiationBL.generateServiceInstantiationRequest(null, serviceInstantiationPayload, "az2016");
+ jsonNode = new ObjectMapper().valueToTree(result.requestDetails);
+ Assert.assertTrue(jsonNode.get("project").get("projectName").asText().equalsIgnoreCase("not null"));
+
+
+
+ }
+
+ @Test
+ public void pushBulkJob_verifyCreatedDateBehavior_createdDateIsTheSameForAllServicesInSameBulk() {
+ LocalDateTime startTestDate = LocalDateTime.now().withNano(0);
+ final ServiceInstantiation request = generateMockServiceInstantiationPayload(
+ false,
+ createVnfList(instanceParamsMapWithoutParams, Collections.EMPTY_LIST, true),
+ 100, true,PROJECT_NAME, true
+ );
+
+ // in "createJob()" we will probe the service, with the generated names
+ final Job job = mock(Job.class);
+ when(job.getStatus()).thenReturn(PENDING);
+ when(jobAdapter.createJob(any(), any(), any(), any(), any())).thenReturn(job);
+
+ asyncInstantiationBL.pushBulkJob(request, "myUserId");
+ List<ServiceInfo> serviceInfoList = dataAccessService.getList(ServiceInfo.class, getPropsMap());
+
+ List<Date> creationDates = new ArrayList<>();
+ for (ServiceInfo serviceInfo : serviceInfoList) {
+ creationDates.add(serviceInfo.getCreatedBulkDate());
+ }
+ LocalDateTime endTestDate = LocalDateTime.now();
+
+ //creation date of all services is the same
+ Assert.assertTrue(creationDates.stream().distinct().count() <= 1);
+ LocalDateTime creationDate = fromDate(creationDates.get(0));
+ assertFalse(creationDate.isBefore(startTestDate));
+ assertFalse(creationDate.isAfter(endTestDate));
+ }
+
+ @DataProvider
+ public static Object[][] msoToJobStatusDataProvider() {
+ return new Object[][]{
+ {"IN_PROGRESS", JobStatus.IN_PROGRESS},
+ {"INPROGRESS", JobStatus.IN_PROGRESS},
+ {"IN ProGREsS", JobStatus.IN_PROGRESS},
+ {"JAMES_HARDEN", JobStatus.IN_PROGRESS},
+ {"FAILED", JobStatus.FAILED},
+ {"COMpleTE", JobStatus.COMPLETED},
+ {"PENDING", JobStatus.IN_PROGRESS},
+ {"Paused", JobStatus.PAUSE},
+ {"Pause", JobStatus.PAUSE},
+ {"PENDING_MANUAL_TASK", JobStatus.PAUSE},
+ {"UNLOCKED", JobStatus.IN_PROGRESS}
+ };
+ }
+
+ @Test(dataProvider = "msoToJobStatusDataProvider")
+ void whenGetStatusFromMso_calcRightJobStatus(String msoStatus, Job.JobStatus expectedJobStatus) {
+ AsyncRequestStatus asyncRequestStatus = asyncRequestStatusResponse(msoStatus);
+ assertThat(asyncInstantiationBL.calcStatus(asyncRequestStatus), equalTo(expectedJobStatus));
+ }
+
+ private void createNewAuditStatus(JobAuditStatus auditStatus)
+ {
+ Date createdDate= auditStatus.getCreated();
+ dataAccessService.saveDomainObject(auditStatus, getPropsMap());
+ setDateToStatus(auditStatus.getSource(), auditStatus.getJobStatus(), createdDate);
+ }
+
+
+
+ private static final String MSO_ARBITRARY_STATUS = "completed mso status";
+
+ @DataProvider
+ public static Object[][] auditStatuses(Method test) {
+ return new Object[][]{
+ {
+ SourceStatus.VID,
+ new String[]{ JobStatus.PENDING.toString(), JobStatus.IN_PROGRESS.toString()}
+ },
+ { SourceStatus.MSO,
+ new String[]{ JobStatus.IN_PROGRESS.toString(), MSO_ARBITRARY_STATUS }
+ }
+ };
+
+ }
+
+ private void setDateToStatus(SourceStatus source, String status, Date date) {
+ List<JobAuditStatus> jobAuditStatusList = dataAccessService.getList(JobAuditStatus.class, getPropsMap());
+ DaoUtils.tryWithSessionAndTransaction(sessionFactory, session -> {
+ jobAuditStatusList.stream()
+ .filter(auditStatus -> source.equals(auditStatus.getSource()) && status.equals(auditStatus.getJobStatus()))
+ .forEach(auditStatus -> {
+ auditStatus.setCreated(date);
+ session.saveOrUpdate(auditStatus);
+ });
+ return 1;
+ });
+ }
+
+
+ @Test(dataProvider = "auditStatuses")
+ public void givenSomeAuditStatuses_getStatusesOfSpecificSourceAndJobId_getSortedResultsMatchingToParameters(SourceStatus expectedSource, String [] expectedSortedStatuses){
+ UUID jobUuid = UUID.randomUUID();
+ List<JobAuditStatus> auditStatusList = com.google.common.collect.ImmutableList.of(
+ new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.VID, toDate(LocalDateTime.now().minusHours(2))),
+ new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, UUID.randomUUID(),"",toDate(LocalDateTime.now().minusHours(30))),
+ new JobAuditStatus(jobUuid, MSO_ARBITRARY_STATUS, SourceStatus.MSO, UUID.randomUUID(),"",toDate(LocalDateTime.now().minusHours(3))),
+ new JobAuditStatus(jobUuid, PENDING.toString(), SourceStatus.VID, toDate(LocalDateTime.now().minusHours(3))),
+ new JobAuditStatus(UUID.randomUUID(), PENDING.toString(), SourceStatus.VID, toDate(LocalDateTime.now().minusHours(3))));
+ auditStatusList.forEach((auditStatus) -> createNewAuditStatus(auditStatus));
+ List<JobAuditStatus> statuses = asyncInstantiationBL.getAuditStatuses(jobUuid, expectedSource);
+ List<String> statusesList = statuses.stream().map(status -> status.getJobStatus()).collect(Collectors.toList());
+ Assert.assertTrue(statuses.stream().allMatch(status -> (status.getSource().equals(expectedSource)&& status.getJobId().equals(jobUuid))),"Only statuses of " + expectedSource + " for " + jobUuid + " should be returned. Returned statuses: " + String.join(",", statusesList ));
+ assertThat(statusesList, contains(expectedSortedStatuses));
+ }
+
+
+
+ @Test
+ public void addSomeVidStatuses_getThem_verifyGetInsertedWithoutDuplicates(){
+ ImmutableList<JobStatus> statusesToBeInserted = ImmutableList.of(PENDING, IN_PROGRESS, IN_PROGRESS, COMPLETED);
+ UUID jobUuid = UUID.randomUUID();
+ statusesToBeInserted.forEach(status->
+ {
+ asyncInstantiationBL.auditVidStatus(jobUuid, status);
+ });
+ List<String> statusesFromDB = asyncInstantiationBL.getAuditStatuses(jobUuid, SourceStatus.VID).stream().map(auditStatus -> auditStatus.getJobStatus()).collect(Collectors.toList());
+ List<String> statusesWithoutDuplicates = statusesToBeInserted.stream().distinct().map(x -> x.toString()).collect(Collectors.toList());
+ assertThat(statusesFromDB, is(statusesWithoutDuplicates));
+ }
+
+ @DataProvider
+ public static Object[][] msoAuditStatuses(Method test) {
+ UUID jobUuid = UUID.randomUUID();
+ UUID requestId = UUID.randomUUID();
+ return new Object[][]{
+ {
+ jobUuid,
+ ImmutableList.of(
+ new JobAuditStatus(jobUuid, PENDING.toString(), SourceStatus.MSO, null, null),
+ new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, requestId, null),
+ new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, requestId, null),
+ new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, requestId, null),
+ new JobAuditStatus(jobUuid, COMPLETED.toString(), SourceStatus.MSO, requestId, null)),
+ ImmutableList.of(PENDING.toString(), IN_PROGRESS.toString(), COMPLETED.toString()),
+ "All distinct statuses should be without duplicates"
+ },
+ {
+ jobUuid,
+ ImmutableList.of(
+ new JobAuditStatus(jobUuid, PENDING.toString(), SourceStatus.MSO, null, null),
+ new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, requestId, null),
+ new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, requestId, "aa"),
+ new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, requestId, "aa"),
+ new JobAuditStatus(jobUuid, IN_PROGRESS.toString(), SourceStatus.MSO, UUID.randomUUID(), "aa"),
+ new JobAuditStatus(jobUuid, COMPLETED.toString(), SourceStatus.MSO, requestId, null)),
+ ImmutableList.of(PENDING.toString(), IN_PROGRESS.toString(), IN_PROGRESS.toString(),IN_PROGRESS.toString(), COMPLETED.toString()),
+ "Statuses should be without duplicates only with same requestId and additionalInfo"
+
+ }
+ };
+ }
+
+ @Test(dataProvider = "msoAuditStatuses")
+ public void addSomeMsoStatuses_getThem_verifyGetInsertedWithoutDuplicates(UUID jobUuid, ImmutableList<JobAuditStatus> msoStatuses, ImmutableList<String> expectedStatuses, String assertionReason) {
+ msoStatuses.forEach(status -> {
+ asyncInstantiationBL.auditMsoStatus(status.getJobId(), status.getJobStatus(), status.getRequestId() != null ? status.getRequestId().toString() : null, status.getAdditionalInfo());
+ });
+ List<String> statusesFromDB = asyncInstantiationBL.getAuditStatuses(jobUuid, SourceStatus.MSO).stream().map(auditStatus -> auditStatus.getJobStatus()).collect(Collectors.toList());
+ assertThat( assertionReason, statusesFromDB, is(expectedStatuses));
+ }
+
+ @Test
+ public void addSameStatusOfVidAndMso_verifyThatBothWereAdded(){
+ UUID jobUuid = UUID.randomUUID();
+ JobStatus sameStatus = IN_PROGRESS;
+ asyncInstantiationBL.auditMsoStatus(jobUuid, sameStatus.toString(),null,null);
+ asyncInstantiationBL.auditVidStatus(jobUuid, sameStatus);
+ List<JobAuditStatus> list = dataAccessService.getList(
+ JobAuditStatus.class,
+ String.format(" where JOB_ID = '%s'", jobUuid),
+ null, null);
+ Assert.assertEquals(list.size(),2);
+ assertThat(list,everyItem(hasProperty("jobStatus", is(sameStatus.toString()))));
+ }
+
+ @Test
+ public void verifyAsyncRequestStatus_canBeReadFromSample() throws IOException {
+ String body = "{" +
+ " \"request\": {" +
+ " \"requestId\": \"c0011670-0e1a-4b74-945d-8bf5aede1d9c\"," +
+ " \"startTime\": \"Mon, 11 Dec 2017 07:27:49 GMT\"," +
+ " \"requestScope\": \"service\"," +
+ " \"requestType\": \"createInstance\"," +
+ " \"instanceReferences\": {" +
+ " \"serviceInstanceId\": \"f8791436-8d55-4fde-b4d5-72dd2cf13cfb\"," +
+ " \"serviceInstanceName\": \"asdfasdf234234asdf\"," +
+ " \"requestorId\": \"il883e\"" +
+ " }," +
+ " \"requestStatus\": {" +
+ " \"requestState\": \"COMPLETE\"," +
+ " \"statusMessage\": \"Service Instance was created successfully.\"," +
+ " \"percentProgress\": 100," +
+ " \"finishTime\": \"Mon, 11 Dec 2017 07:27:53 GMT\"" +
+ " }" +
+ " }" +
+ "}";
+ ObjectMapper objectMapper = new ObjectMapper();
+ AsyncRequestStatus asyncRequestStatus = objectMapper.readValue(body, AsyncRequestStatus.class);
+ assertThat(asyncRequestStatus.request.requestStatus.getRequestState(), equalTo("COMPLETE"));
+
+ }
+
+ @Test
+ public void deleteJobInfo_pending_deleted() {
+ doNothing().when(jobsBrokerService).delete(any());
+ UUID uuid = createServicesInfoWithDefaultValues(PENDING);
+ asyncInstantiationBL.deleteJob(uuid);
+ assertNotNull(asyncInstantiationBL.getServiceInfoByJobId(uuid).getDeletedAt(), "service info wasn't deleted");
+ }
+
+ @Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = DELETE_SERVICE_INFO_STATUS_EXCEPTION_MESSAGE)
+ public void deleteJobInfo_notAllowdStatus_shouldSendError() {
+ UUID uuid = createServicesInfoWithDefaultValues(COMPLETED);
+ doThrow(new IllegalStateException(DELETE_SERVICE_INFO_STATUS_EXCEPTION_MESSAGE)).when(jobsBrokerService).delete(any());
+ try {
+ asyncInstantiationBL.deleteJob(uuid);
+ } catch (Exception e) {
+ assertNull(asyncInstantiationBL.getServiceInfoByJobId(uuid).getDeletedAt(), "service info shouldn't deleted");
+ throw e;
+ }
+ }
+
+ @DataProvider
+ public Object[][] jobStatusesFinal() {
+ return Arrays.stream(Job.JobStatus.values())
+ .filter(t -> ImmutableList.of(COMPLETED, FAILED, STOPPED).contains(t))
+ .map(v -> new Object[]{v}).collect(Collectors.toList()).toArray(new Object[][]{});
+ }
+
+ @Test(dataProvider = "jobStatusesFinal")
+ public void whenHideService_theServiceNotReturnedInServiceList(JobStatus jobStatus) {
+ UUID uuidToHide = createServicesInfoWithDefaultValues(jobStatus);
+ UUID uuidToShown = createServicesInfoWithDefaultValues(jobStatus);
+ List<UUID> serviceInfoList = listServicesUUID();
+ assertThat(serviceInfoList, hasItems(uuidToHide, uuidToShown));
+
+ asyncInstantiationBL.hideServiceInfo(uuidToHide);
+ serviceInfoList = listServicesUUID();
+ assertThat(serviceInfoList, hasItem(uuidToShown));
+ assertThat(serviceInfoList, not(hasItem(uuidToHide)));
+
+ }
+
+ protected List<UUID> listServicesUUID() {
+ return asyncInstantiationBL.getAllServicesInfo().stream().map(ServiceInfo::getJobId).collect(Collectors.toList());
+ }
+
+ @DataProvider
+ public Object[][] jobStatusesNotFinal() {
+ return Arrays.stream(Job.JobStatus.values())
+ .filter(t -> ImmutableList.of(PENDING, IN_PROGRESS, PAUSE).contains(t))
+ .map(v -> new Object[]{v}).collect(Collectors.toList()).toArray(new Object[][]{});
+ }
+
+ @Test( dataProvider = "jobStatusesNotFinal",
+ expectedExceptions = OperationNotAllowedException.class,
+ expectedExceptionsMessageRegExp = "jobId.*Service status does not allow hide service, status = .*")
+ public void hideServiceInfo_notAllowedStatus_shouldSendError(JobStatus jobStatus) {
+ UUID uuid = createServicesInfoWithDefaultValues(jobStatus);
+ try {
+ asyncInstantiationBL.hideServiceInfo(uuid);
+ } catch (Exception e) {
+ assertFalse(asyncInstantiationBL.getServiceInfoByJobId(uuid).isHidden(), "service info shouldn't be hidden");
+ throw e;
+ }
+ }
+
+ @Test
+ public void whenUseGetCounterInMultiThreads_EachThreadGetDifferentCounter() throws InterruptedException {
+ int SIZE = 200;
+ ExecutorService executor = Executors.newFixedThreadPool(SIZE);
+ List<Callable<Integer>> tasks = IntStream.rangeClosed(1, SIZE)
+ .mapToObj(x-> ((Callable<Integer>)() -> asyncInstantiationBL.getCounterForName("a")))
+ .collect(Collectors.toList());
+ Set<Integer> expectedResults = IntStream.rangeClosed(1, SIZE).boxed().collect(Collectors.toSet());
+ executor.invokeAll(tasks)
+ .forEach(future -> {
+ try {
+ assertTrue( expectedResults.remove(future.get()), "got unexpected counter");
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ });
+
+ assertThat(expectedResults.size(), is(0));
+ }
+
+ @Test
+ public void whenUseGetCounterForSameName_numbersReturnedByOrder() {
+
+ String name = UUID.randomUUID().toString();
+ int SIZE=10;
+ for (int i=1; i<=SIZE; i++) {
+ assertThat(asyncInstantiationBL.getCounterForName(name), is(i));
+ }
+ }
+
+ @Test
+ public void whenNamedInUsedInAai_getNextNumber() {
+ String name = someCommonStepsAndGetName();
+ ResourceType type = ResourceType.GENERIC_VNF;
+ when(aaiClient.searchNodeTypeByName(name+"_001", type)).thenReturn(aaiNodeQueryResponseNameUsed(type));
+ when(aaiClient.searchNodeTypeByName(name+"_002", type)).thenReturn(aaiNodeQueryResponseNameFree());
+ assertThat(asyncInstantiationBL.getUniqueName(name, type), equalTo(name+"_002"));
+ }
+
+ private String someCommonStepsAndGetName() {
+ mockAaiClientAaiStatusOK();
+ return UUID.randomUUID().toString();
+ }
+
+ private void mockAaiClientAaiStatusOK() {
+ when(aaiClient.searchNodeTypeByName(eq(AsyncInstantiationBusinessLogicImpl.NAME_FOR_CHECK_AAI_STATUS), any())).thenReturn(aaiNodeQueryResponseNameFree());
+ }
+
+ @Test(expectedExceptions=InvalidAAIResponseException.class)
+ public void whenAaiBadResponseCode_throwInvalidAAIResponseException() {
+ String name = someCommonStepsAndGetName();
+ ResourceType type = ResourceType.SERVICE_INSTANCE;
+ when(aaiClient.searchNodeTypeByName(name+"_001", type)).thenReturn(aaiNodeQueryBadResponse());
+ asyncInstantiationBL.getUniqueName(name, type);
+ }
+
+ @Test(expectedExceptions=MaxRetriesException.class)
+ public void whenAaiAlwaysReturnNameUsed_throwInvalidAAIResponseException() {
+ String name = someCommonStepsAndGetName();
+ ResourceType type = ResourceType.VF_MODULE;
+ when(aaiClient.searchNodeTypeByName(any(), eq(type))).thenReturn(aaiNodeQueryResponseNameUsed(type));
+ asyncInstantiationBL.setMaxRetriesGettingFreeNameFromAai(10);
+ asyncInstantiationBL.getUniqueName(name, type);
+ }
+
+ @Test
+ public void testFormattingOfNameAndCounter() {
+ AsyncInstantiationBusinessLogicImpl bl = (AsyncInstantiationBusinessLogicImpl) asyncInstantiationBL;
+ assertThat(bl.formatNameAndCounter("x", 3), equalTo("x_003"));
+ assertThat(bl.formatNameAndCounter("x", 99), equalTo("x_099"));
+ assertThat(bl.formatNameAndCounter("x", 100), equalTo("x_100"));
+ assertThat(bl.formatNameAndCounter("x", 1234), equalTo("x_1234"));
+ }*/
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/services/CsvServiceTest.java b/onap-enabler-be/src/test/java/org/onap/osam/services/CsvServiceTest.java
new file mode 100644
index 0000000..1847e18
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/services/CsvServiceTest.java
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+//package org.onap.vid.services;
+//import org.apache.commons.io.IOUtils;
+//import org.onap.vid.services.CsvServiceImpl;
+//import org.skyscreamer.jsonassert.JSONAssert;
+//import org.skyscreamer.jsonassert.JSONCompareMode;
+//import org.testng.Assert;
+//import org.testng.annotations.DataProvider;
+//import org.testng.annotations.Test;
+//import org.json.JSONObject;
+//
+//import javax.ws.rs.BadRequestException;
+//import java.io.IOException;
+//import java.lang.reflect.Method;
+//import java.net.URL;
+//import java.util.List;
+//
+//@Test
+//public class CsvServiceTest {
+//
+// private CsvServiceImpl csvService = new CsvServiceImpl();
+// private final static String CSV_FOLDER = "csv_files/{CSV_FILE}";
+// private final static String VALID_CSV = "csv_to_json.csv";
+// private final static String ONE_LINE_CSV = "one_line.csv";
+// private final static String EMPTY_CSV = "empty_file.csv";
+// private final static String MISSING_CONTENT_CSV = "missing_content.csv";
+// private final static String MISSING_VALUES_CSV = "missing_values.csv";
+//
+//
+///*
+// @Test
+// public void parseValidCsv() throws IllegalAccessException, IOException, InstantiationException {
+// String expectedJson = getExpectation("vnfConfigUpdatePayload.json");
+// readAndParse(VALID_CSV,16,expectedJson);
+//
+// }*/
+//
+// private String getExpectation(String modelFileName) throws IOException {
+// // load expected result
+// final URL resource = this.getClass().getResource("/" + modelFileName);
+// String expected = IOUtils.toString(resource, "UTF-8");
+// return expected;
+// }
+///*
+// @Test
+// public void parseOneLineCsv() throws IllegalAccessException, IOException, InstantiationException {
+// String expectedJson ="{\"payload\":{\"request-parameters\":{\"vnf-name\":\"ibcx0099v\"}}}";
+// readAndParse(ONE_LINE_CSV,1,expectedJson);
+// }*/
+//
+// @DataProvider
+// public static Object[][] invalidFiles(Method test) {
+// return new Object[][]{
+// {MISSING_CONTENT_CSV}, {MISSING_VALUES_CSV}
+// };
+// }
+///*
+// @Test(dataProvider = "invalidFiles", expectedExceptions = {BadRequestException.class}, expectedExceptionsMessageRegExp = "Invalid csv file")
+// public void parseMissingContentCsv(String invalidFile) throws IllegalAccessException, IOException, InstantiationException {
+// readAndParse(invalidFile, 2, null);
+// }
+//
+//
+// @Test
+// public void parseEmptyCsv() throws IllegalAccessException, IOException, InstantiationException {
+// String expectedJson ="{}";
+// readAndParse(EMPTY_CSV,0,expectedJson);
+// }
+//
+// private void readAndParse(String fileName, int expectedNumRows, String expectedJson) throws IllegalAccessException, IOException, InstantiationException {
+// final URL resource = CsvServiceTest.class.getClassLoader().getResource(CSV_FOLDER.replaceFirst("\\{CSV_FILE\\}", fileName));
+// Assert.assertNotNull(resource, "The csv file was not found");
+// List<String[]> content = csvService.readCsv(resource.getPath());
+// Assert.assertEquals(content.size(), expectedNumRows, "The number of non-empty lines in file is wrong");
+// JSONObject json = csvService.convertCsvToJson (content);
+// JSONAssert.assertEquals(expectedJson, json, JSONCompareMode.STRICT);
+//
+// }*/
+//
+//
+//}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/services/JobsBrokerServiceTest.java b/onap-enabler-be/src/test/java/org/onap/osam/services/JobsBrokerServiceTest.java
new file mode 100644
index 0000000..e9f6f2a
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/services/JobsBrokerServiceTest.java
@@ -0,0 +1,625 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+//
+//import com.google.common.collect.ImmutableList;
+//import com.google.common.collect.ImmutableMap;
+//import org.apache.commons.lang.RandomStringUtils;
+//import org.apache.commons.lang3.RandomUtils;
+//import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+//import org.apache.commons.lang3.builder.ToStringStyle;
+//import org.hibernate.SessionFactory;
+//import org.onap.vid.exceptions.GenericUncheckedException;
+//import org.onap.vid.exceptions.OperationNotAllowedException;
+//import org.onap.vid.job.Job;
+//import org.onap.vid.job.JobAdapter;
+//import org.onap.vid.job.JobType;
+//import org.onap.vid.job.JobsBrokerService;
+//import org.onap.vid.job.impl.JobDaoImpl;
+//import org.onap.vid.job.impl.JobsBrokerServiceInDatabaseImpl;
+//import org.onap.vid.utils.DaoUtils;
+//import org.onap.vid.config.DataSourceConfig;
+//import org.onap.vid.config.JobAdapterConfig;
+//import org.onap.portalsdk.core.domain.support.DomainVo;
+//import org.onap.portalsdk.core.service.DataAccessService;
+//import org.onap.portalsdk.core.util.SystemProperties;
+//import org.springframework.test.context.ContextConfiguration;
+//import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+//import org.testng.Assert;
+//import org.testng.annotations.AfterMethod;
+//import org.testng.annotations.BeforeMethod;
+//import org.testng.annotations.DataProvider;
+//import org.testng.annotations.Test;
+//
+//import javax.inject.Inject;
+//import java.lang.reflect.Method;
+//import java.time.LocalDateTime;
+//import java.time.ZoneId;
+//import java.util.*;
+//import java.util.concurrent.*;
+//import java.util.stream.Collectors;
+//import java.util.stream.IntStream;
+//import java.util.stream.Stream;
+//
+//import static java.util.concurrent.TimeUnit.MILLISECONDS;
+//import static org.hamcrest.CoreMatchers.equalTo;
+//import static org.hamcrest.CoreMatchers.is;
+//import static org.hamcrest.MatcherAssert.assertThat;
+//import static org.hamcrest.Matchers.both;
+//import static org.hamcrest.Matchers.containsInAnyOrder;
+//import static org.onap.vid.job.Job.JobStatus.*;
+//import static org.onap.vid.utils.Streams.not;
+//import static org.testng.Assert.assertNotNull;
+//import static org.testng.AssertJUnit.assertEquals;
+//
+//@ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, JobAdapterConfig.class})
+//public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
+//
+// private static final int JOBS_COUNT = 127;
+// private static final boolean DELETED = true;
+// private final ExecutorService executor = Executors.newFixedThreadPool(90);
+//
+// private final Set<Long> threadsIds = new ConcurrentSkipListSet<>();
+//
+// private final long FEW = 500;
+//
+// private final String JOBS_SHOULD_MATCH = "the jobs that added and those that pulled must be the same";
+// private final String JOBS_PEEKED_SHOULD_MATCH = "the jobs that added and those that peeked must be the same";
+// private static final String DELETE_SERVICE_INFO_STATUS_EXCEPTION_MESSAGE = "Service status does not allow deletion from the queue";
+// private static final String DELETE_SERVICE_NOT_EXIST_EXCEPTION_MESSAGE = "Service does not exist";
+// private JobsBrokerService broker;
+//
+// @Inject
+// JobAdapter jobAdapter;
+// @Inject
+// private DataAccessService dataAccessService;
+// @Inject
+// private SessionFactory sessionFactory;
+//
+//
+// private class NoJobException extends RuntimeException {
+// }
+//
+// private Future<Job> newJobAsync(JobsBrokerService b) {
+// return newJobAsync(b, createMockJob("user id"));
+// }
+//
+// private Future<Job> newJobAsync(JobsBrokerService b, Job.JobStatus status) {
+// return newJobAsync(b, createMockJob("user id", status));
+// }
+//
+// private Job createMockJob(String userId) {
+// return jobAdapter.createJob(
+// JobType.NoOp,
+// new JobAdapter.AsyncJobRequest() {
+// public int nothing = 42;
+// },
+// UUID.randomUUID(),
+// userId,
+// RandomUtils.nextInt());
+// }
+//
+// private Job createMockJob(String userId, Job.JobStatus jobStatus) {
+// Job job = createMockJob(userId);
+// job.setStatus(jobStatus);
+// return job;
+// }
+//
+// private Future<Job> newJobAsync(JobsBrokerService b, Job job) {
+// final Future<Job> jobFuture = executor.submit(() -> {
+// accountThreadId();
+//
+// b.add(job);
+//
+// return job;
+// });
+// return jobFuture;
+// }
+//
+// private void pushBackJobAsync(JobsBrokerService b, Job job) {
+// executor.submit(() -> {
+// accountThreadId();
+// b.pushBack(job);
+// return job;
+// });
+// }
+//
+// private Future<Optional<Job>> pullJobAsync(JobsBrokerService broker) {
+// final Future<Optional<Job>> job = executor.submit(() -> {
+// accountThreadId();
+// // Pull only pending jobs, as H2 database does not support our SQL for in-progress jobs
+// return broker.pull(Job.JobStatus.PENDING, UUID.randomUUID().toString());
+// });
+// return job;
+// }
+//
+// private Job waitForFutureOptionalJob(Future<Optional<Job>> retrievedOptionalJobFuture) {
+// try {
+// return retrievedOptionalJobFuture.get(FEW, MILLISECONDS).orElseThrow(NoJobException::new);
+// } catch (TimeoutException | InterruptedException | ExecutionException e) {
+// throw new RuntimeException(e);
+// }
+// }
+//
+// private Job waitForFutureJob(Future<Job> retrievedJobFuture) {
+// try {
+// return retrievedJobFuture.get(FEW, MILLISECONDS);
+// } catch (TimeoutException | InterruptedException | ExecutionException e) {
+// throw new RuntimeException(e);
+// }
+// }
+//
+// private List<Job> putAndGetALotOfJobs(JobsBrokerService broker) {
+// final List<Job> originalJobs = putALotOfJobs(broker);
+// final List<Job> retrievedJobs = getAlotOfJobs(broker);
+//
+// assertThat(JOBS_SHOULD_MATCH, retrievedJobs, containsInAnyOrder(originalJobs.toArray()));
+//
+// return retrievedJobs;
+// }
+//
+// private List<Job> putALotOfJobs(JobsBrokerService broker) {
+// int n = JOBS_COUNT;
+// return IntStream.range(0, n)
+// .mapToObj(i -> newJobAsync(broker))
+// .map(this::waitForFutureJob)
+// .collect(Collectors.toList());
+// }
+//
+// private List<Job> getAlotOfJobs(JobsBrokerService broker) {
+// int n = JOBS_COUNT;
+// return IntStream.range(0, n)
+// .mapToObj(i -> pullJobAsync(broker))
+// .map(this::waitForFutureOptionalJob)
+// .collect(Collectors.toList());
+// }
+//
+// private void pushBackJobs(List<Job> jobs, JobsBrokerService broker) {
+// jobs.forEach(job -> pushBackJobAsync(broker, job));
+// }
+//
+// private void accountThreadId() {
+// threadsIds.add(Thread.currentThread().getId());
+// }
+//
+// @AfterMethod
+// public void threadsCounter() {
+// System.out.println("participating threads count: " + threadsIds.size());
+// threadsIds.clear();
+// }
+//
+// @BeforeMethod
+// public void initializeBroker() {
+// broker = new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0);
+// ((JobsBrokerServiceInDatabaseImpl) broker).deleteAll();
+// }
+//
+// @Test
+// public void givenSingleJob_getIt_verifySameJob() {
+// final Job originalJob = waitForFutureJob(newJobAsync(broker));
+//
+// final Job retrievedJob = waitForFutureOptionalJob(pullJobAsync(broker));
+// assertThat(JOBS_SHOULD_MATCH, retrievedJob, is(originalJob));
+// }
+//
+// @Test
+// public void givenManyJobs_getJobsAndPushThemBack_alwaysSeeAllOfThemWithPeek() throws InterruptedException {
+// final List<Job> originalJobs = putALotOfJobs(broker);
+//
+// MILLISECONDS.sleep(FEW);
+// assertThat(JOBS_PEEKED_SHOULD_MATCH, broker.peek(), containsInAnyOrder(originalJobs.toArray()));
+//
+// final Job retrievedJob = waitForFutureOptionalJob(pullJobAsync(broker));
+//
+// MILLISECONDS.sleep(FEW);
+// assertThat(JOBS_PEEKED_SHOULD_MATCH, broker.peek(), containsInAnyOrder(originalJobs.toArray()));
+//
+// pushBackJobAsync(broker, retrievedJob);
+//
+// MILLISECONDS.sleep(FEW);
+// assertThat(JOBS_PEEKED_SHOULD_MATCH, broker.peek(), containsInAnyOrder(originalJobs.toArray()));
+// }
+//
+// @Test
+// public void givenManyJobs_getThemAll_verifySameJobs() {
+// putAndGetALotOfJobs(broker);
+// }
+//
+// @Test
+// public void givenManyJobs_getThemAllThenPushBackandGet_verifySameJobs() {
+// final List<Job> retrievedJobs1 = putAndGetALotOfJobs(broker);
+//
+// pushBackJobs(retrievedJobs1, broker);
+// final List<Job> retrievedJobs2 = getAlotOfJobs(broker);
+//
+// assertThat(JOBS_SHOULD_MATCH, retrievedJobs2, containsInAnyOrder(retrievedJobs1.toArray()));
+// }
+//
+// private static Date toDate(LocalDateTime localDateTime) {
+// return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
+// }
+//
+// private void setModifiedDateToJob(UUID jobUuid, Date date) {
+// DomainVo job = dataAccessService.getDomainObject(JobDaoImpl.class, jobUuid, DaoUtils.getPropsMap());
+// job.setModified(date);
+// DaoUtils.tryWithSessionAndTransaction(sessionFactory, session -> {
+// session.saveOrUpdate(job);
+// return 1;
+// });
+// }
+//
+//
+// public static JobDaoImpl createNewJob(Integer indexInBulk, UUID templateId, String userId, Job.JobStatus status, String takenBy, LocalDateTime date) {
+// return createNewJob(indexInBulk, templateId, userId, status, takenBy, date, false);
+// }
+//
+// public static JobDaoImpl createNewJob(Integer indexInBulk, UUID templateId, String userId, Job.JobStatus status, String takenBy, LocalDateTime date, boolean deleted){
+// JobDaoImpl job = new JobDaoImpl();
+// job.setTypeAndData(JobType.NoOp, ImmutableMap.of("x", RandomStringUtils.randomAlphanumeric(15)));
+// job.setIndexInBulk(indexInBulk);
+// job.setTemplateId(templateId);
+// job.setType(JobType.NoOp);
+// job.setStatus(status);
+// job.setTakenBy(takenBy);
+// job.setCreated(toDate(date));
+// job.setModified(toDate(date));
+// job.setUserId(userId);
+// if (deleted) {
+// job.setDeletedAt(new Date());
+// }
+// return job;
+// }
+//
+// @DataProvider
+// public static Object[][] jobs(Method test) {
+// LocalDateTime oldestDate = LocalDateTime.now().minusHours(30);
+// UUID sameTemplate = UUID.randomUUID();
+// return new Object[][]{
+// {ImmutableList.of(
+// createNewJob(11, UUID.randomUUID(), "userId", PENDING, null, oldestDate),
+// createNewJob(22, UUID.randomUUID(), "userId", PENDING, null, oldestDate),
+// createNewJob(11, UUID.randomUUID(), "userId", PENDING, null, LocalDateTime.now().minusHours(2)),
+// createNewJob(44, UUID.randomUUID(), "userId", PENDING, null, LocalDateTime.now().minusHours(5))),
+// 4,
+// 0,
+// PENDING,
+// "Broker should pull the first pending job by oldest date then by job index"
+// },
+// { ImmutableList.of(
+// createNewJob(11, UUID.randomUUID(), "userId", COMPLETED,null, oldestDate),
+// createNewJob(11, UUID.randomUUID(), "userId", PENDING,null, oldestDate, DELETED),createNewJob(12, UUID.randomUUID(), "userId", FAILED,null, oldestDate),
+// createNewJob(13, UUID.randomUUID(), "userId", IN_PROGRESS,null, oldestDate),
+// createNewJob(14, UUID.randomUUID(), "userId", STOPPED,null, oldestDate),
+// createNewJob(22, UUID.randomUUID(), "userId", PENDING,null, oldestDate),
+// createNewJob(33, UUID.randomUUID(), "userId", PENDING,null, LocalDateTime.now().minusHours(2))),
+// 6,
+// 5,
+// PENDING,
+// "Broker should pull the only pending - first pending job by oldest job - ignore deleted,completed, failed, in-progress and stopped statuses"
+// },
+// {ImmutableList.of(
+// createNewJob(11, UUID.randomUUID(), "userId", IN_PROGRESS, UUID.randomUUID().toString(), oldestDate),
+// createNewJob(22, UUID.randomUUID(), "userId", IN_PROGRESS, UUID.randomUUID().toString(), oldestDate),
+// createNewJob(33, UUID.randomUUID(), "userId", PENDING, null, LocalDateTime.now().minusHours(2))),
+// 2,
+// -1,
+// PENDING,
+// "Broker should not pull any job when it exceeded mso limit with count (in-progress) statuses"
+// },
+// {ImmutableList.of(
+// createNewJob(11, UUID.randomUUID(), "userId", IN_PROGRESS, UUID.randomUUID().toString(), oldestDate),
+// createNewJob(22, UUID.randomUUID(), "userId", PENDING, UUID.randomUUID().toString(), oldestDate),
+// createNewJob(33, UUID.randomUUID(), "userId", PENDING, null, LocalDateTime.now().minusHours(2))),
+// 2,
+// -1,
+// PENDING,
+// "Broker should not pull any job when it exceeded mso limit with count(in-progress or pending && taken) statuses"
+// },
+// {ImmutableList.of(
+// createNewJob(11, UUID.randomUUID(), "userId", IN_PROGRESS, UUID.randomUUID().toString(), oldestDate),
+// createNewJob(22, UUID.randomUUID(), "userId", PENDING, UUID.randomUUID().toString(), oldestDate),
+// createNewJob(33, UUID.randomUUID(), "userId", PENDING, null, LocalDateTime.now().minusHours(2))),
+// 3,
+// 2,
+// PENDING,
+// "Broker should pull first job when it doesn't exceeded mso limit with count(in-progress or pending && taken) statuses"
+// },
+// {ImmutableList.of(
+// createNewJob(11, sameTemplate, "userId", PENDING, UUID.randomUUID().toString(), oldestDate),
+// createNewJob(22, sameTemplate, "userId", PENDING, null, oldestDate),
+// createNewJob(33, sameTemplate, "userId", PENDING, null, LocalDateTime.now().minusHours(2))),
+// 3,
+// -1,
+// PENDING,
+// "Broker should not pull any job when there is another job from this template that was taken"
+// },
+// {ImmutableList.of(
+// createNewJob(11, sameTemplate, "userId", IN_PROGRESS, null, oldestDate),
+// createNewJob(22, sameTemplate, "userId", PENDING, null, oldestDate),
+// createNewJob(33, sameTemplate, "userId", PENDING, null, LocalDateTime.now().minusHours(2))),
+// 3,
+// -1,
+// PENDING,
+// "Broker should not pull any job when there is another job from this template that in progress"
+// },
+// {ImmutableList.of(
+// createNewJob(11, sameTemplate, "userId", FAILED, null, oldestDate),
+// createNewJob(22, sameTemplate, "userId", STOPPED, null, oldestDate),
+// createNewJob(33, sameTemplate, "userId", PENDING, null, LocalDateTime.now().minusHours(2))),
+// 3,
+// -1,
+// PENDING,
+// "Broker should not pull any job when there is another job from this template that was failed"
+// },
+// {ImmutableList.of(
+// createNewJob(11, sameTemplate, "userId", FAILED, null, oldestDate, DELETED),
+// createNewJob(22, sameTemplate, "userId", STOPPED,null, oldestDate),
+// createNewJob(33, sameTemplate, "userId", PENDING,null, LocalDateTime.now().minusHours(2))),
+// 3,
+// 2,
+// PENDING,
+// "Broker should pull pending job when there is another job from this template that was deleted, although failed"
+// },
+// { ImmutableList.of(
+// createNewJob(11, UUID.randomUUID(), "userA", IN_PROGRESS, null, oldestDate),
+// createNewJob(22, UUID.randomUUID(), "userA", PENDING, null, oldestDate),
+// createNewJob(33, UUID.randomUUID(), "userB", PENDING, null, LocalDateTime.now().minusHours(2))),
+// 3,
+// 2,
+// PENDING,
+// "Broker should prioritize jobs of user that has no in-progress jobs"
+// },
+// {ImmutableList.of(
+// createNewJob(11, UUID.randomUUID(), "userA", PENDING, UUID.randomUUID().toString(), oldestDate),
+// createNewJob(22, UUID.randomUUID(), "userA", PENDING, null, oldestDate),
+// createNewJob(33, UUID.randomUUID(), "userB", PENDING, null, LocalDateTime.now().minusHours(2))),
+// 3,
+// 2,
+// PENDING,
+// "Broker should prioritize jobs of user that has no taken jobs"
+// },
+// {ImmutableList.of(
+// createNewJob(11, UUID.randomUUID(), "userA", IN_PROGRESS, UUID.randomUUID().toString(), oldestDate),
+// createNewJob(22, UUID.randomUUID(), "userA", PENDING, null, LocalDateTime.now().minusHours(2)),
+// createNewJob(31, UUID.randomUUID(), "userB", IN_PROGRESS, null, LocalDateTime.now().minusHours(2)),
+// createNewJob(32, UUID.randomUUID(), "userB", IN_PROGRESS, null, LocalDateTime.now().minusHours(2)),
+// createNewJob(33, UUID.randomUUID(), "userB", PENDING, null, oldestDate)),
+// 5,
+// 4,
+// PENDING,
+// "Broker should take oldest job when there is one in-progress job to each user"
+// },
+// {ImmutableList.of(
+// createNewJob(11, UUID.randomUUID(), UUID.randomUUID().toString(), IN_PROGRESS, null, oldestDate),
+// createNewJob(22, UUID.randomUUID(), UUID.randomUUID().toString(), IN_PROGRESS, null, oldestDate),
+// createNewJob(33, UUID.randomUUID(), UUID.randomUUID().toString(), PENDING, null, LocalDateTime.now().minusHours(2))),
+// 2,
+// -1,
+// PENDING,
+// "Broker should not pull any job when it exceeded mso limit with count(in-progress or pending && taken) statuses"
+// },
+// {ImmutableList.of(
+// createNewJob(11, UUID.randomUUID(), "userId", IN_PROGRESS, UUID.randomUUID().toString(), oldestDate),
+// createNewJob(22, UUID.randomUUID(), "userId", IN_PROGRESS, null, oldestDate),
+// createNewJob(11, UUID.randomUUID(), "userId", IN_PROGRESS, null, LocalDateTime.now().minusHours(2)),
+// createNewJob(44, UUID.randomUUID(), "userId", IN_PROGRESS, null, LocalDateTime.now().minusHours(5))),
+// 20,
+// 1,
+// IN_PROGRESS,
+// "Broker with in progress topic should pull the first in progress and not taken job by oldest date"
+// },
+// {ImmutableList.of(
+// createNewJob(11, UUID.randomUUID(), "userId", COMPLETED, null, oldestDate),
+// createNewJob(12, UUID.randomUUID(), "userId", FAILED, null, oldestDate),
+// createNewJob(13, UUID.randomUUID(), "userId", PENDING,null, oldestDate),
+// createNewJob(14, UUID.randomUUID(), "userId", STOPPED,null, oldestDate),
+// createNewJob(11, UUID.randomUUID(), "userId", IN_PROGRESS,null, oldestDate, DELETED),createNewJob(22, UUID.randomUUID(), "userId", IN_PROGRESS,null, oldestDate),
+// createNewJob(33, UUID.randomUUID(), "userId", IN_PROGRESS,null, LocalDateTime.now().minusHours(2))),
+// 20,
+// 5,
+// IN_PROGRESS,
+// "Broker with in progress topic should pull only in-progress jobs - first in-progress job by oldest date - ignore deleted,completed, failed, pending and stopped statuses"
+// },
+// {ImmutableList.of(
+// createNewJob(11, UUID.randomUUID(), "userId", IN_PROGRESS, null, LocalDateTime.now()),
+// createNewJob(22, UUID.randomUUID(), "userId", IN_PROGRESS, null, LocalDateTime.now().minusSeconds(1)),
+// createNewJob(33, UUID.randomUUID(), "userId", IN_PROGRESS, null, LocalDateTime.now().minusSeconds(2))),
+// 20,
+// -1,
+// IN_PROGRESS,
+// "Broker with in progress topic should not pull any job if its modified date is smaller than now-interval (20 seconds)"
+// }
+//
+// };
+// }
+//
+//
+// @Test(dataProvider = "jobs")
+// public void givenSomeJobs_pullNextJob_returnNextOrNothingAsExpected(List<JobDaoImpl> jobs, int msoLimit, int expectedIndexSelected, Job.JobStatus topic, String assertionReason) {
+// JobsBrokerServiceInDatabaseImpl broker = new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, msoLimit, 20);
+// for (JobDaoImpl job : jobs) {
+// Date modifiedDate = job.getModified();
+// broker.add(job);
+// setModifiedDateToJob(job.getUuid(), modifiedDate);
+// }
+// Optional<Job> nextJob = broker.pull(topic, UUID.randomUUID().toString());
+// boolean shouldAnyBeSelected = expectedIndexSelected >= 0;
+// Assert.assertEquals(nextJob.isPresent(), shouldAnyBeSelected, assertionReason);
+// if (shouldAnyBeSelected) {
+// Assert.assertEquals(jobs.get(expectedIndexSelected), nextJob.get(), assertionReason);
+// }
+// }
+//
+// @DataProvider
+// public Object[][] topics() {
+// return Arrays.stream(Job.JobStatus.values())
+// .filter(not(t -> ImmutableList.of(PENDING, IN_PROGRESS).contains(t)))
+// .map(v -> new Object[]{v}).collect(Collectors.toList()).toArray(new Object[][]{});
+// }
+//
+// @Test(dataProvider = "topics", expectedExceptions = GenericUncheckedException.class, expectedExceptionsMessageRegExp = "Unsupported topic.*")
+// public void pullUnexpectedTopic_exceptionIsThrown(Job.JobStatus topic) {
+// broker.pull(topic, UUID.randomUUID().toString());
+// }
+//
+// @Test(expectedExceptions = NoJobException.class)
+// public void givenNonPendingJobs_getJobAsPendingTopic_verifyNothingRetrieved() {
+// Stream.of(Job.JobStatus.values())
+// .filter(not(s -> s.equals(PENDING)))
+// .map(s -> createMockJob("some user id", s))
+// .map(job -> newJobAsync(broker, job))
+// .map(this::waitForFutureJob)
+// .collect(Collectors.toList());
+//
+// waitForFutureOptionalJob(pullJobAsync(broker));
+// }
+//
+// @Test
+// public void givenPendingAndNonPendingJobs_getJobAsPendingTopic_verifyAJobRetrieved() {
+// newJobAsync(broker); // this negated the expected result of the call below
+// givenNonPendingJobs_getJobAsPendingTopic_verifyNothingRetrieved();
+// }
+//
+// @Test(expectedExceptions = NoJobException.class)
+// public void givenManyJobs_pullThemAllAndAskOneMore_verifyFinallyNothingRetrieved() {
+// putAndGetALotOfJobs(broker);
+// waitForFutureOptionalJob(pullJobAsync(broker));
+// }
+//
+// @Test(expectedExceptions = NoJobException.class)
+// public void givenNoJob_requestJob_verifyNothingRetrieved() throws InterruptedException, ExecutionException, TimeoutException {
+// final Future<Optional<Job>> futureOptionalJob = pullJobAsync(broker);
+// assertThat("job should not be waiting yet", futureOptionalJob.get(FEW, MILLISECONDS).isPresent(), is(false));
+// waitForFutureOptionalJob(futureOptionalJob);
+// }
+//
+// @Test(expectedExceptions = IllegalStateException.class)
+// public void givenSinglePulledJob_pushBackDifferentJob_verifyPushingRejected() {
+// waitForFutureJob(newJobAsync(broker));
+// waitForFutureJob(newJobAsync(broker));
+// waitForFutureOptionalJob(pullJobAsync(broker));
+//
+// Job myJob = createMockJob("user id");
+// myJob.setUuid(UUID.randomUUID());
+//
+// broker.pushBack(myJob); //Should fail
+// }
+//
+// @Test
+// public void givenSingleJob_pushBackModifiedJob_verifyPulledIsVeryVeryTheSame() {
+// final ImmutableMap<String, Object> randomDataForMostRecentJobType =
+// ImmutableMap.of("42", 42, "complex", ImmutableList.of("a", "b", "c"));
+//
+// waitForFutureJob(newJobAsync(broker));
+// final Job job = waitForFutureOptionalJob(pullJobAsync(broker));
+//
+// job.setStatus(Job.JobStatus.PENDING);
+// job.setTypeAndData(JobType.NoOp, ImmutableMap.of("good", "morning"));
+// job.setTypeAndData(JobType.HttpCall, ImmutableMap.of());
+// job.setTypeAndData(JobType.ServiceInstantiation, randomDataForMostRecentJobType);
+//
+// broker.pushBack(job);
+// final Job retrievedJob = waitForFutureOptionalJob(pullJobAsync(broker));
+//
+// assertThat(JOBS_SHOULD_MATCH, retrievedJob, is(job));
+// assertThat(JOBS_SHOULD_MATCH, retrievedJob.getData(), both(equalTo(job.getData())).and(equalTo(randomDataForMostRecentJobType)));
+// assertThat(JOBS_SHOULD_MATCH, jobDataReflected(retrievedJob), is(jobDataReflected(job)));
+// }
+//
+// private static String jobDataReflected(Job job) {
+// return new ReflectionToStringBuilder(job, ToStringStyle.SHORT_PREFIX_STYLE)
+// .setExcludeFieldNames("created", "modified", "takenBy")
+// .toString();
+// }
+//
+// @Test(expectedExceptions = IllegalStateException.class)
+// public void givenSingleJob_pushBackTwice_verifyPushingRejected() {
+// waitForFutureJob(newJobAsync(broker));
+// final Job job = waitForFutureOptionalJob(pullJobAsync(broker));
+//
+// broker.pushBack(job);
+// broker.pushBack(job); //Should fail
+// }
+//
+// @Test
+// public void addJob_PeekItById_verifySameJobWasPeeked() {
+// String userId = UUID.randomUUID().toString();
+// Job myJob = createMockJob(userId);
+// UUID uuid = broker.add(myJob);
+// Job peekedJob = broker.peek(uuid);
+// assertEquals("added testId is not the same as peeked TestsId",
+// userId,
+// peekedJob.getData().get("userId"));
+// }
+//
+// @Test(dataProvider = "jobStatusesForSuccessDelete", expectedExceptions = NoJobException.class)
+// public void givenOneJob_deleteIt_canPeekOnItButCantPull(Job.JobStatus status) {
+// final Job job = waitForFutureJob(newJobAsync(broker, status));
+// broker.delete(job.getUuid());
+// assertNotNull(((JobDaoImpl) broker.peek(job.getUuid())).getDeletedAt(), "job should be deleted");
+// waitForFutureOptionalJob(pullJobAsync(broker));
+// }
+//
+// @DataProvider
+// public static Object[][] jobStatusesForSuccessDelete() {
+// return new Object[][]{
+// {PENDING},
+// {STOPPED}
+// };
+// }
+//
+// @Test(
+// dataProvider = "jobStatusesForFailedDelete",
+// expectedExceptions = OperationNotAllowedException.class,
+// expectedExceptionsMessageRegExp=DELETE_SERVICE_INFO_STATUS_EXCEPTION_MESSAGE
+// )
+// public void deleteJob_notAllowedStatus_exceptionIsThrown(Job.JobStatus status, boolean taken) {
+// final Job job = waitForFutureJob(newJobAsync(broker, createMockJob("some user id", status)));
+//
+// if (taken) {
+// waitForFutureOptionalJob(pullJobAsync(broker));
+// }
+//
+//
+// broker.delete(job.getUuid());
+// }
+//
+// @DataProvider
+// public static Object[][] jobStatusesForFailedDelete() {
+// return new Object[][]{
+// {PENDING, true},
+// {IN_PROGRESS, false},
+// {COMPLETED, false},
+// {PAUSE, false},
+// {FAILED, false},
+// };
+// }
+//
+// @Test(expectedExceptions = OperationNotAllowedException.class, expectedExceptionsMessageRegExp = DELETE_SERVICE_NOT_EXIST_EXCEPTION_MESSAGE)
+// public void deleteJob_notExist_exceptionIsThrown() {
+// waitForFutureJob(newJobAsync(broker, createMockJob("some user id", PENDING)));
+// broker.delete(new UUID(111, 111));
+// }
+//
+//}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/services/PortDetailsTranslatorTest.java b/onap-enabler-be/src/test/java/org/onap/osam/services/PortDetailsTranslatorTest.java
new file mode 100644
index 0000000..f9db3ce
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/services/PortDetailsTranslatorTest.java
@@ -0,0 +1,305 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableList;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.osam.aai.model.AaiGetPortMirroringSourcePorts;
+import org.onap.osam.aai.model.PortDetailsTranslator;
+import org.onap.osam.aai.model.RelatedTo;
+import org.onap.osam.aai.model.SimpleResult;
+import org.onap.osam.properties.Features;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import org.togglz.core.manager.FeatureManager;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.collection.IsEmptyCollection.empty;
+import static org.mockito.Mockito.when;
+
+public class PortDetailsTranslatorTest {
+
+ private static final ObjectMapper om = new ObjectMapper();
+
+ @InjectMocks
+ private PortDetailsTranslator portDetailsTranslator = new PortDetailsTranslator();
+
+ @Mock
+ private FeatureManager featureManager;
+
+ @BeforeMethod
+ public void initMocks() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ when(featureManager.isActive(Features.FLAG_ADVANCED_PORTS_FILTER)).thenReturn(true);
+ }
+
+ @Test
+ public void extractPortDetailsFromProperties_givenValidAaiResponse() throws IOException {
+
+ final String aaiResponse = "{\n" +
+ " \"results\": [\n" +
+ " {\n" +
+ " \"id\": \"4876980240\",\n" +
+ " \"node-type\": \"l-interface\",\n" +
+ " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\",\n" +
+ " \"properties\": {\n" +
+ " \"interface-name\": \"zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\",\n" +
+ " \"selflink\": \"https://network-aic.rdm5b.cci.att.com:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" +
+ " \"interface-id\": \"6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" +
+ " \"macaddr\": \"02:6d:e7:bf:87:6f\",\n" +
+ " \"network-name\": \"APP-C-24595-D-T001-vprobe_int_pktmirror_net_1\",\n" +
+ " \"is-port-mirrored\": false,\n" +
+ " \"resource-version\": \"1519383879190\",\n" +
+ " \"in-maint\": false,\n" +
+ " \"is-ip-unnumbered\": false\n" +
+ " }\n" +
+ " }\n" +
+ " ]\n" +
+ "}";
+
+ AaiGetPortMirroringSourcePorts aaiGetPortMirroringSourcePorts = om.readValue(aaiResponse, AaiGetPortMirroringSourcePorts.class);
+
+
+ PortDetailsTranslator.PortDetails portDetails = PortDetailsTranslator.extractPortDetailsFromProperties(aaiGetPortMirroringSourcePorts.getResults().get(0).getProperties(), aaiResponse);
+
+ assertThat(portDetails, is(instanceOf(PortDetailsTranslator.PortDetailsOk.class)));
+
+ PortDetailsTranslator.PortDetailsOk portDetailsOk = (PortDetailsTranslator.PortDetailsOk) portDetails;
+ assertThat(portDetailsOk.getInterfaceName(), is("zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib"));
+ assertThat(portDetailsOk.getInterfaceId(), is("6de7bf87-6faa-4984-9492-18d1188b3d4a"));
+ assertThat(portDetailsOk.getIsPortMirrored(), is(false));
+ }
+
+ @Test
+ public void extractPortDetailsFromProperties_givenAaiResponseWithInstanceNameNull_yieldException() throws IOException {
+ final String aaiResponse = "{\n" +
+ " \"results\": [\n" +
+ " {\n" +
+ " \"id\": \"4876980240\",\n" +
+ " \"node-type\": \"l-interface\",\n" +
+ " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\",\n" +
+ " \"properties\": {\n" +
+ " \"interface-name\": null,\n" +
+ " \"selflink\": \"https://network-aic.rdm5b.cci.att.com:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" +
+ " \"interface-id\": \"6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" +
+ " \"macaddr\": \"02:6d:e7:bf:87:6f\",\n" +
+ " \"network-name\": \"APP-C-24595-D-T001-vprobe_int_pktmirror_net_1\",\n" +
+ " \"is-port-mirrored\": false,\n" +
+ " \"resource-version\": \"1519383879190\",\n" +
+ " \"in-maint\": false,\n" +
+ " \"is-ip-unnumbered\": false\n" +
+ " }\n" +
+ " }\n" +
+ " ]\n" +
+ "}";
+
+ AaiGetPortMirroringSourcePorts aaiGetPortMirroringSourcePorts = om.readValue(aaiResponse, AaiGetPortMirroringSourcePorts.class);
+ PortDetailsTranslator.PortDetails portDetails = PortDetailsTranslator.extractPortDetailsFromProperties(aaiGetPortMirroringSourcePorts.getResults().get(0).getProperties(),aaiResponse);
+
+ assertThat(portDetails, is(instanceOf(PortDetailsTranslator.PortDetailsError.class)));
+
+ PortDetailsTranslator.PortDetailsError portDetailsError = (PortDetailsTranslator.PortDetailsError) portDetails;
+ assertThat(portDetailsError.getErrorDescription(), is("Value of 'interface-name' is missing."));
+ assertThat(portDetailsError.getRawAaiResponse(), is(aaiResponse));
+ }
+
+ @Test
+ public void extractPortDetailsFromProperties_givenAaiResponseWithInstanceIdNull_yieldException() throws IOException {
+ final String aaiResponse = "{\n" +
+ " \"results\": [\n" +
+ " {\n" +
+ " \"id\": \"4876980240\",\n" +
+ " \"node-type\": \"l-interface\",\n" +
+ " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\",\n" +
+ " \"properties\": {\n" +
+ " \"interface-name\": \"zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\",\n" +
+ " \"selflink\": \"https://network-aic.rdm5b.cci.att.com:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" +
+ " \"interface-id\": null,\n" +
+ " \"macaddr\": \"02:6d:e7:bf:87:6f\",\n" +
+ " \"network-name\": \"APP-C-24595-D-T001-vprobe_int_pktmirror_net_1\",\n" +
+ " \"is-port-mirrored\": false,\n" +
+ " \"resource-version\": \"1519383879190\",\n" +
+ " \"in-maint\": false,\n" +
+ " \"is-ip-unnumbered\": false\n" +
+ " }\n" +
+ " }\n" +
+ " ]\n" +
+ "}";
+
+ AaiGetPortMirroringSourcePorts aaiGetPortMirroringSourcePorts = om.readValue(aaiResponse, AaiGetPortMirroringSourcePorts.class);
+ PortDetailsTranslator.PortDetails portDetails = PortDetailsTranslator.extractPortDetailsFromProperties(aaiGetPortMirroringSourcePorts.getResults().get(0).getProperties(),aaiResponse);
+
+ assertThat(portDetails, is(instanceOf(PortDetailsTranslator.PortDetailsError.class)));
+
+ PortDetailsTranslator.PortDetailsError portDetailsError = (PortDetailsTranslator.PortDetailsError) portDetails;
+ assertThat(portDetailsError.getErrorDescription(), is("Value of 'interface-id' is missing."));
+ assertThat(portDetailsError.getRawAaiResponse(), is(aaiResponse));
+ }
+
+ @Test
+ public void extractPortDetailsFromProperties_givenAaiResponseWithEmptyInstanceId_yieldException() throws IOException {
+ final String aaiResponse = "{\n" +
+ " \"results\": [\n" +
+ " {\n" +
+ " \"id\": \"4876980240\",\n" +
+ " \"node-type\": \"l-interface\",\n" +
+ " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\",\n" +
+ " \"properties\": {\n" +
+ " \"interface-name\": \"\",\n" +
+ " \"selflink\": \"https://network-aic.rdm5b.cci.att.com:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" +
+ " \"interface-id\": \"6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" +
+ " \"macaddr\": \"02:6d:e7:bf:87:6f\",\n" +
+ " \"network-name\": \"APP-C-24595-D-T001-vprobe_int_pktmirror_net_1\",\n" +
+ " \"is-port-mirrored\": false,\n" +
+ " \"resource-version\": \"1519383879190\",\n" +
+ " \"in-maint\": false,\n" +
+ " \"is-ip-unnumbered\": false\n" +
+ " }\n" +
+ " }\n" +
+ " ]\n" +
+ "}";
+
+ AaiGetPortMirroringSourcePorts aaiGetPortMirroringSourcePorts = om.readValue(aaiResponse, AaiGetPortMirroringSourcePorts.class);
+ PortDetailsTranslator.PortDetails portDetails = PortDetailsTranslator.extractPortDetailsFromProperties(aaiGetPortMirroringSourcePorts.getResults().get(0).getProperties(),aaiResponse);
+
+ assertThat(portDetails, is(instanceOf(PortDetailsTranslator.PortDetailsError.class)));
+
+ PortDetailsTranslator.PortDetailsError portDetailsError = (PortDetailsTranslator.PortDetailsError) portDetails;
+ assertThat(portDetailsError.getErrorDescription(), is("Value of 'interface-name' is empty."));
+ assertThat(portDetailsError.getRawAaiResponse(), is(aaiResponse));
+ }
+
+ @Test
+ public void extractPortDetailsFromProperties_givenAaiResponseWithIsPortMirroredNull_yieldException() throws IOException {
+ final String aaiResponse = "{\n" +
+ " \"results\": [\n" +
+ " {\n" +
+ " \"id\": \"4876980240\",\n" +
+ " \"node-type\": \"l-interface\",\n" +
+ " \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/rdm5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\",\n" +
+ " \"properties\": {\n" +
+ " \"interface-name\": \"zrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\",\n" +
+ " \"selflink\": \"https://network-aic.rdm5b.cci.att.com:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" +
+ " \"interface-id\": \"6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" +
+ " \"macaddr\": \"02:6d:e7:bf:87:6f\",\n" +
+ " \"network-name\": \"APP-C-24595-D-T001-vprobe_int_pktmirror_net_1\",\n" +
+ " \"is-port-mirrored\": null,\n" +
+ " \"resource-version\": \"1519383879190\",\n" +
+ " \"in-maint\": false,\n" +
+ " \"is-ip-unnumbered\": false\n" +
+ " }\n" +
+ " }\n" +
+ " ]\n" +
+ "}";
+
+ AaiGetPortMirroringSourcePorts aaiGetPortMirroringSourcePorts = om.readValue(aaiResponse, AaiGetPortMirroringSourcePorts.class);
+ PortDetailsTranslator.PortDetails portDetails = PortDetailsTranslator.extractPortDetailsFromProperties(aaiGetPortMirroringSourcePorts.getResults().get(0).getProperties(),aaiResponse);
+
+ assertThat(portDetails, is(instanceOf(PortDetailsTranslator.PortDetailsError.class)));
+
+ PortDetailsTranslator.PortDetailsError portDetailsError = (PortDetailsTranslator.PortDetailsError) portDetails;
+ assertThat(portDetailsError.getErrorDescription(), is("Value of 'is-port-mirrored' is missing."));
+ assertThat(portDetailsError.getRawAaiResponse(), is(aaiResponse));
+ }
+
+ @Test
+ public void getFilteredPortList_givenEmptyList_ReturnEmptyList() {
+
+ final ImmutableList<SimpleResult> input = ImmutableList.of();
+
+ List<SimpleResult> result = portDetailsTranslator.getFilteredPortList(input);
+ assertThat("List size if different than expected", result, is(empty()));
+ }
+
+ @DataProvider
+ public static Object[][] trueAndFalse() {
+ return new Object[][]{
+ { Boolean.TRUE }, { Boolean.FALSE }
+ };
+ }
+
+ @Test(dataProvider = "trueAndFalse")
+ public void getFilteredPortList_givenFeatureFlagIsOff_returnAllLInterfaces(Boolean advancedPortsFilterFlag) throws IOException {
+ when(featureManager.isActive(Features.FLAG_ADVANCED_PORTS_FILTER)).thenReturn(advancedPortsFilterFlag);
+
+ final String relationshipLabelSource = "org.onap.relationships.inventory.Source";
+ final String nodeTypeLInterface = "l-interface";
+
+ SimpleResult lInterfaceWithSource =
+ buildSimpleResult(nodeTypeLInterface, relationshipLabelSource);
+ SimpleResult lInterfaceWithTwoSources =
+ buildSimpleResult(nodeTypeLInterface, relationshipLabelSource, relationshipLabelSource);
+ SimpleResult lInterfaceWithSourceAndMore =
+ buildSimpleResult(nodeTypeLInterface, relationshipLabelSource, "not a source");
+ SimpleResult lInterfaceWithoutSource =
+ buildSimpleResult(nodeTypeLInterface, "not a source");
+ SimpleResult lInterfaceWithoutRelations =
+ buildSimpleResult(nodeTypeLInterface);
+ SimpleResult fooTypeWithSource =
+ buildSimpleResult("not an l-interface", relationshipLabelSource);
+ SimpleResult fooTypeWithoutSource =
+ buildSimpleResult("not an l-interface", "not a source");
+
+ final ImmutableList<SimpleResult> input = ImmutableList.of(
+ fooTypeWithSource, fooTypeWithoutSource,
+ lInterfaceWithTwoSources, lInterfaceWithSourceAndMore,
+ lInterfaceWithoutSource, lInterfaceWithSource,
+ lInterfaceWithoutRelations);
+
+ List<SimpleResult> result = portDetailsTranslator.getFilteredPortList(input);
+
+ if (advancedPortsFilterFlag) {
+ assertThat("List should contain all l-interfaces with a related source", result, containsInAnyOrder(
+ lInterfaceWithSource, lInterfaceWithSourceAndMore,
+ lInterfaceWithTwoSources));
+ } else {
+ assertThat("List should contain all l-interfaces", result, containsInAnyOrder(
+ lInterfaceWithSource, lInterfaceWithoutSource,
+ lInterfaceWithoutRelations, lInterfaceWithSourceAndMore,
+ lInterfaceWithTwoSources));
+ }
+ }
+
+ private SimpleResult buildSimpleResult(String nodeType, String... relationshipLabels) {
+ SimpleResult simpleResult = new SimpleResult();
+ simpleResult.setNodeType(nodeType);
+ simpleResult.setRelatedTo(Stream.of(relationshipLabels).map(label ->
+ new RelatedTo("my foo id", label, "logical-link", "foo url"))
+ .collect(Collectors.toList())
+ );
+ return simpleResult;
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/services/RoleGenaratorServiceImplTest.java b/onap-enabler-be/src/test/java/org/onap/osam/services/RoleGenaratorServiceImplTest.java
new file mode 100644
index 0000000..8e3f5b0
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/services/RoleGenaratorServiceImplTest.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import org.junit.Test;
+
+public class RoleGenaratorServiceImplTest {
+
+ private RoleGenaratorServiceImpl createTestSubject() {
+ return new RoleGenaratorServiceImpl();
+ }
+
+ @Test
+ public void testGenerateRoleScript() throws Exception {
+ RoleGenaratorServiceImpl testSubject;
+ Boolean firstRun = null;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.generateRoleScript(firstRun);
+ }
+
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/services/WorkflowServiceImplTest.java b/onap-enabler-be/src/test/java/org/onap/osam/services/WorkflowServiceImplTest.java
new file mode 100644
index 0000000..83e3652
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/services/WorkflowServiceImplTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.services;
+
+import java.util.*;
+
+import org.junit.Test;
+
+public class WorkflowServiceImplTest {
+
+ private WorkflowServiceImpl createTestSubject() {
+ return new WorkflowServiceImpl();
+ }
+
+ @Test
+ public void testGetWorkflowsForVNFs() throws Exception {
+ WorkflowServiceImpl testSubject;
+ Collection<String> vnfNames = new ArrayList<String>();
+ Collection<String> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getWorkflowsForVNFs(vnfNames);
+ }
+
+ @Test
+ public void testGetAllWorkflows() throws Exception {
+ WorkflowServiceImpl testSubject;
+ Collection<String> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAllWorkflows();
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/testUtils/IntersectionTest.java b/onap-enabler-be/src/test/java/org/onap/osam/testUtils/IntersectionTest.java
new file mode 100644
index 0000000..a4d4f22
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/testUtils/IntersectionTest.java
@@ -0,0 +1,120 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.testUtils;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.osam.utils.Intersection;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class IntersectionTest {
+
+ @Test
+ public void testFourArrays(){
+ List<String> l1 = new ArrayList<String>();
+ l1.add("1");
+ l1.add("2");
+
+ List<String> l2 = new ArrayList<String>();
+ l2.add("2");
+ l2.add("3");
+
+ List<String> l3 = new ArrayList<String>();
+ l3.add("2");
+ l3.add("4");
+
+ List<String> l4 = new ArrayList<String>();
+ l4.add("2");
+ l4.add("5");
+
+ List<List<String>> all = new ArrayList<>();
+ all.add(l1);
+ all.add(l2);
+ all.add(l3);
+ all.add(l4);
+ Intersection<String> m = new Intersection<>();
+ List<String> ans = m.intersectMultipileArray(all);
+ Assert.assertEquals(1,ans.size());
+ Assert.assertEquals(ans.get(0),"2");
+
+ }
+
+
+
+ @Test
+ public void testTwoArrays(){
+ List<String> l1 = new ArrayList<String>();
+ l1.add("1");
+ l1.add("2");
+
+ List<String> l2 = new ArrayList<String>();
+ l2.add("2");
+ l2.add("3");
+
+ List<List<String>> all = new ArrayList<>();
+ all.add(l1);
+ all.add(l2);
+ Intersection<String> m = new Intersection<>();
+ List<String> l3 = m.intersectMultipileArray(all);
+ Assert.assertEquals(l3.size(),1);
+ Assert.assertEquals(l3.get(0),"2");
+
+ }
+
+
+ @Test
+ public void testNoIntersection(){
+ List<String> l1 = new ArrayList<String>();
+ l1.add("1");
+ l1.add("2");
+
+ List<String> l2 = new ArrayList<String>();
+ l2.add("3");
+ l2.add("4");
+
+ List<List<String>> all = new ArrayList<>();
+ all.add(l1);
+ all.add(l2);
+ Intersection<String> m = new Intersection<>();
+ List<String> l3 = m.intersectMultipileArray(all);
+ Assert.assertEquals(l3.size(),0);
+
+ }
+
+ @Test
+ public void testOneArrays(){
+ List<String> l1 = new ArrayList<String>();
+ l1.add("1");
+ l1.add("2");
+ List<List<String>> all = new ArrayList<>();
+ all.add(l1);
+ Intersection<String> m = new Intersection<>();
+ List<String> l3 = m.intersectMultipileArray(all);
+ Assert.assertEquals(l3.size(),2);
+ Assert.assertEquals(l3.get(0),"1");
+ Assert.assertEquals(l3.get(1),"2");
+
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/testUtils/RegExMatcher.java b/onap-enabler-be/src/test/java/org/onap/osam/testUtils/RegExMatcher.java
new file mode 100644
index 0000000..be5702e
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/testUtils/RegExMatcher.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.testUtils;
+
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+
+public class RegExMatcher extends TypeSafeMatcher<String> {
+
+ private final String regEx;
+
+ public RegExMatcher(String regEx) {
+ this.regEx = regEx;
+ }
+
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("matches regEx="+regEx);
+ }
+
+
+ @Override
+ protected boolean matchesSafely(String item) {
+ return item.matches(regEx);
+ }
+
+ public static RegExMatcher matchesRegEx(final String regEx) {
+ return new RegExMatcher(regEx);
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/testUtils/StubServerUtil.java b/onap-enabler-be/src/test/java/org/onap/osam/testUtils/StubServerUtil.java
new file mode 100644
index 0000000..ea2f896
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/testUtils/StubServerUtil.java
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.testUtils;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.xebialabs.restito.semantics.Action;
+import com.xebialabs.restito.semantics.Call;
+import com.xebialabs.restito.semantics.Condition;
+import com.xebialabs.restito.server.StubServer;
+
+import java.util.List;
+
+import static com.xebialabs.restito.builder.stub.StubHttp.whenHttp;
+import static com.xebialabs.restito.semantics.Action.contentType;
+import static com.xebialabs.restito.semantics.Action.stringContent;
+
+public class StubServerUtil {
+
+ private static final String APPLICATION_JSON = "application/json";
+ private ObjectMapper objectMapper;
+
+
+ private StubServer stubServer;
+
+ public StubServerUtil() {
+ this.objectMapper = new ObjectMapper();
+ this.stubServer = new StubServer();
+ }
+
+
+ public void runServer() {
+ stubServer.run();
+ }
+
+ public void runSecuredServer(){
+ stubServer.secured().run();
+ }
+
+ public void stopServer() {
+ stubServer.stop();
+ }
+
+
+ public String constructTargetUrl(String protocol, String relativePath) {
+ return String.format("%s://localhost:%s/%s", protocol, stubServer.getPort(), relativePath);
+ }
+
+ public void prepareGetCall(String path, Action actionToReturn,Object returnObj, Action expectedAction, String contentType) throws JsonProcessingException {
+ whenHttp(stubServer)
+ .match(Condition.get(path))
+ .then(expectedAction, actionToReturn, contentType(contentType));
+ }
+
+
+ public void prepareGetCall(String path, Object returnObj, Action expectedAction) throws JsonProcessingException {
+ prepareGetCall(path, jsonContent(returnObj),returnObj, expectedAction, APPLICATION_JSON);
+ }
+
+ public void prepareDeleteCall(String path, Object returnObj, Action expectedAction) throws JsonProcessingException {
+ whenHttp(stubServer)
+ .match(Condition.delete(path))
+ .then(expectedAction, jsonContent(returnObj), contentType(APPLICATION_JSON));
+ }
+
+ public void preparePostCall(String path, Object returnObj, Action expectedAction) throws JsonProcessingException {
+ whenHttp(stubServer)
+ .match(Condition.post(path),
+ Condition.withPostBodyContaining(objectMapper.writeValueAsString(returnObj)))
+ .then(expectedAction, jsonContent(returnObj), contentType(APPLICATION_JSON));
+ }
+
+ public void preparePutCall(String path, Object returnObj, Action expectedStatus) throws JsonProcessingException {
+ whenHttp(stubServer)
+ .match(Condition.put(path),
+ Condition.withPostBodyContaining(objectMapper.writeValueAsString(returnObj)))
+ .then(expectedStatus, jsonContent(returnObj), contentType(APPLICATION_JSON));
+ }
+
+ public List<Call> getServerCalls() {
+ return stubServer.getCalls();
+ }
+
+ private Action jsonContent(Object returnObj) throws JsonProcessingException {
+ return stringContent(objectMapper.writeValueAsString(returnObj));
+ }
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/testUtils/TestUtils.java b/onap-enabler-be/src/test/java/org/onap/osam/testUtils/TestUtils.java
new file mode 100644
index 0000000..64c985b
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/testUtils/TestUtils.java
@@ -0,0 +1,171 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.testUtils;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableList;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.mockito.MockSettings;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.Response;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+import static fj.parser.Parser.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
+
+public class TestUtils {
+
+ public static void assertJsonStringEqualsIgnoreNulls(String expected, String actual) {
+ if (expected == null || expected == JSONObject.NULL) {return;}
+
+ JSONObject expectedJSON = new JSONObject(expected);
+ JSONObject actualJSON = new JSONObject(actual);
+ Iterator<?> keys = expectedJSON.keys();
+
+ while( keys.hasNext() ) {
+ String key = (String)keys.next();
+ Object expectedValue = expectedJSON.get(key);
+ if (expectedValue == JSONObject.NULL){
+ continue;
+ }
+
+ Object actualValue = actualJSON.get(key);
+
+ if (expectedValue instanceof JSONObject) {
+ String expectedVal = expectedValue.toString();
+ String actualVal = actualValue.toString();
+ assertJsonStringEqualsIgnoreNulls(expectedVal, actualVal);
+ }
+ else if (expectedValue instanceof JSONArray) {
+ if (actualValue instanceof JSONArray) {
+ JSONArray expectedJSONArray = (JSONArray)expectedValue;
+ JSONArray actualJSONArray = (JSONArray)actualValue;
+ for (int i = 0; i < expectedJSONArray.length(); i++) {
+ String expectedItem = expectedJSONArray.get(i).toString();
+ String actualItem = actualJSONArray.get(i).toString();
+ if (expectedValue instanceof JSONObject)
+ assertJsonStringEqualsIgnoreNulls(expectedItem, actualItem);
+ }
+ }
+ else {
+ fail("expected: " + expectedValue + " got:" + actualValue);
+ }
+ }
+ else {
+ Assert.assertEquals(expectedValue, actualValue);
+ }
+ }
+ }
+
+ public static <T> T readJsonResourceFileAsObject(String pathInResource, Class<T> valueType) throws IOException {
+ return readJsonResourceFileAsObject(pathInResource, valueType, false);
+ }
+
+ public static <T> T readJsonResourceFileAsObject(String pathInResource, Class<T> valueType, boolean ignoreUnknownProperties)
+ throws IOException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, ignoreUnknownProperties);
+ return objectMapper.readValue(
+ TestUtils.class.getResource(pathInResource),
+ valueType);
+ }
+
+
+ public static class JavaxRsClientMocks {
+ private final javax.ws.rs.client.Client fakeClient;
+ private final javax.ws.rs.client.Invocation.Builder fakeBuilder;
+ private final Response fakeResponse;
+
+ public javax.ws.rs.client.Client getFakeClient() {
+ return fakeClient;
+ }
+
+ public javax.ws.rs.client.Invocation.Builder getFakeBuilder() {
+ return fakeBuilder;
+ }
+
+ public Response getFakeResponse() {
+ return fakeResponse;
+ }
+
+ public JavaxRsClientMocks() {
+ final MockSettings mockSettings = withSettings().defaultAnswer(new TriesToReturnMockByType());
+
+ fakeClient = mock(javax.ws.rs.client.Client.class, mockSettings);
+ fakeBuilder = mock(javax.ws.rs.client.Invocation.Builder.class, mockSettings);
+ fakeResponse = mock(Response.class, mockSettings);
+ final javax.ws.rs.client.WebTarget fakeWebTarget = mock(javax.ws.rs.client.WebTarget.class, mockSettings);
+
+ TriesToReturnMockByType.setAvailableMocks(
+ fakeClient,
+ fakeWebTarget,
+ fakeBuilder,
+ fakeResponse
+ );
+
+ Mockito.when(fakeBuilder.get(any(Class.class))).thenReturn(null);
+ Mockito.when(fakeBuilder.get(eq(InputStream.class))).thenReturn(new ByteArrayInputStream(new byte[]{}));
+ Mockito.when(fakeBuilder.get(any(GenericType.class))).thenReturn(null);
+
+ Mockito.when(fakeResponse.getStatus()).thenReturn(200);
+ Mockito.when(fakeResponse.getStatusInfo()).thenReturn(Response.Status.OK);
+ }
+ }
+
+ /*
+ inspired out from newer Mockito version
+ returns a mock from given list if it's a matching return-type
+ */
+ private static class TriesToReturnMockByType implements Answer<Object>, Serializable {
+ private final Answer<Object> defaultReturn = RETURNS_DEFAULTS;
+ private static List<Object> availableMocks = ImmutableList.of();
+
+ static void setAvailableMocks(Object... mocks) {
+ availableMocks = ImmutableList.copyOf(mocks);
+ }
+
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ Class<?> methodReturnType = invocation.getMethod().getReturnType();
+
+ return availableMocks.stream()
+ .filter(mock -> methodReturnType.isAssignableFrom(mock.getClass()))
+ //.peek(m -> System.out.println("found a mock: " + m.getClass().getName()))
+ .findFirst()
+ .orElse(defaultReturn.answer(invocation));
+ }
+ }
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/utils/LoggingTest.java b/onap-enabler-be/src/test/java/org/onap/osam/utils/LoggingTest.java
new file mode 100644
index 0000000..252a638
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/utils/LoggingTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.utils;
+
+import org.junit.Test;
+
+import com.att.eelf.configuration.EELFLogger;
+
+public class LoggingTest {
+
+ private Logging createTestSubject() {
+ return new Logging();
+ }
+
+ @Test
+ public void testGetMethodName() throws Exception {
+ String result;
+
+ // default test
+ result = Logging.getMethodName();
+ }
+
+ @Test
+ public void testGetMethodCallerName() throws Exception {
+ String result;
+
+ // default test
+ result = Logging.getMethodCallerName();
+ }
+
+ @Test
+ public void testGetRequestsLogger() throws Exception {
+ String serverName = "";
+ EELFLogger result;
+
+ // default test
+ result = Logging.getRequestsLogger(serverName);
+ }
+
+
+}
diff --git a/onap-enabler-be/src/test/java/org/onap/osam/utils/LoggingUtilsTest.java b/onap-enabler-be/src/test/java/org/onap/osam/utils/LoggingUtilsTest.java
new file mode 100644
index 0000000..6187cad
--- /dev/null
+++ b/onap-enabler-be/src/test/java/org/onap/osam/utils/LoggingUtilsTest.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OSAM
+ * ================================================================================
+ * Copyright (C) 2018 AT&T
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.onap.osam.utils;
+
+import com.fasterxml.jackson.core.JsonLocation;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import org.onap.osam.exceptions.GenericUncheckedException;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import sun.security.provider.certpath.SunCertPathBuilderException;
+import sun.security.validator.ValidatorException;
+
+import javax.crypto.BadPaddingException;
+import javax.net.ssl.SSLHandshakeException;
+import javax.ws.rs.ProcessingException;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.onap.osam.testUtils.RegExMatcher.matchesRegEx;
+
+public class LoggingUtilsTest {
+
+ @DataProvider
+ public static Object[][] exceptions() {
+ Exception e0 = new CertificateException("No X509TrustManager implementation available");
+ Exception noTrustMngrImplException = new SSLHandshakeException(e0.toString());
+ noTrustMngrImplException.initCause(e0);
+
+ Exception e1 = new BadPaddingException("Given final block not properly padded");
+ Exception incorrectPasswordException = new IOException("keystore password was incorrect",
+ new UnrecoverableKeyException("failed to decrypt safe contents entry: " + e1));
+ String incorrectPasswordExceptionDescription = "" +
+ "java.io.IOException: keystore password was incorrect: " +
+ "java.security.UnrecoverableKeyException: failed to decrypt safe contents entry: " +
+ "javax.crypto.BadPaddingException: Given final block not properly padded";
+
+ Exception e2 = new SunCertPathBuilderException("unable to find valid certification path to requested target");
+ Exception noValidCert = new ProcessingException(new ValidatorException("PKIX path building failed: " + e2.toString(), e2));
+ String noValidCertDescription = "" +
+ "javax.ws.rs.ProcessingException: " +
+ "sun.security.validator.ValidatorException: PKIX path building failed: " +
+ "sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target";
+
+ RuntimeException fasterxmlMappingException = new RuntimeException(new JsonMappingException("Can not deserialize instance of java.lang.String out of START_ARRAY token",
+ new com.fasterxml.jackson.core.JsonLocation("{ example json }", 15, 1, 20)));
+ String fasterxmlMappingDescription = "" +
+ "com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_ARRAY token\n" +
+ " at [Source: { example json }; line: 1, column: 20]";
+
+ return new Object[][]{
+ {"javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No X509TrustManager implementation available",
+ noTrustMngrImplException},
+ {"java.lang.StringIndexOutOfBoundsException: String index out of range: 4",
+ new StringIndexOutOfBoundsException(4)},
+ {"java.io.FileNotFoundException: osam/WEB-INF/cert/aai-client-cert.p12",
+ new FileNotFoundException("osam/WEB-INF/cert/aai-client-cert.p12")},
+ {"NullPointerException at LoggingUtilsTest.java:[0-9]+",
+ new NullPointerException("null")},
+ {incorrectPasswordExceptionDescription,
+ incorrectPasswordException},
+ {incorrectPasswordExceptionDescription,
+ new GenericUncheckedException(incorrectPasswordException)},
+ {"javax.ws.rs.ProcessingException: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_expired",
+ new ProcessingException(new SSLHandshakeException("Received fatal alert: certificate_expired"))},
+ {noValidCertDescription,
+ noValidCert},
+ {escapeBrackets(fasterxmlMappingDescription),
+ fasterxmlMappingException},
+ {"org.onap.osam.exceptions.GenericUncheckedException: top message: org.onap.osam.exceptions.GenericUncheckedException: root message",
+ new GenericUncheckedException("top message", new IOException("sandwich message", new GenericUncheckedException("root message")))},
+ {"org.onap.osam.exceptions.GenericUncheckedException: basa",
+ new GenericUncheckedException("basa")}
+ };
+
+ }
+
+ @Test(dataProvider = "exceptions")
+ public void testExceptionToDescription(String expectedDescription, Exception exceptionToDescribe) {
+ String expectedButDotsEscaped = expectedDescription.replace(".", "\\.");
+
+ assertThat(Logging.exceptionToDescription(exceptionToDescribe), matchesRegEx(expectedButDotsEscaped));
+ }
+
+ private static String escapeBrackets(String in) {
+ return in.replaceAll("[\\(\\[\\{\\)]", "\\\\$0");
+ }
+}
diff --git a/onap-enabler-be/src/test/resources/WEB-INF/conf/asdc.properties b/onap-enabler-be/src/test/resources/WEB-INF/conf/asdc.properties
new file mode 100644
index 0000000..970730b
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/WEB-INF/conf/asdc.properties
@@ -0,0 +1,17 @@
+asdc.client.type=REST
+#
+#asdc.client.rest.protocol=http
+#asdc.client.rest.host=135.21.125.36
+#asdc.client.rest.port=8080
+#asdc.client.rest.auth=Basic VklEOnZpbjNSaXBlbmVkSnVtYjBKZXRTcHJpbmtsZXM=
+#
+#dev
+#asdc.client.rest.protocol=http
+#asdc.client.rest.host=135.21.125.105
+#asdc.client.rest.port=8080
+#asdc.client.rest.auth=Basic VGVzdDoxMjM0NTY=
+#IST
+asdc.client.rest.protocol=https
+asdc.client.rest.host=asdcbe.mtsnjpw1.aic.cip.att.com
+asdc.client.rest.port=8443
+asdc.client.rest.auth=Basic dmlkOnZpZGlzdA==
diff --git a/onap-enabler-be/src/test/resources/WEB-INF/conf/quartz.properties b/onap-enabler-be/src/test/resources/WEB-INF/conf/quartz.properties
new file mode 100644
index 0000000..92ab425
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/WEB-INF/conf/quartz.properties
@@ -0,0 +1,36 @@
+#################################################################################
+# Quartz configurations for Quantum Work Flow #
+#################################################################################
+
+org.quartz.scheduler.instanceId = AUTO
+
+#################################################################################
+# Main configurations
+org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
+org.quartz.threadPool.threadCount = 30
+
+============================================================================
+# Configure JobStore
+#============================================================================
+
+org.quartz.jobStore.misfireThreshold = 60000
+
+org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
+org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
+org.quartz.jobStore.useProperties = false
+#org.quartz.jobStore.dataSource = myDS
+org.quartz.jobStore.tablePrefix = FN_QZ_
+
+org.quartz.jobStore.isClustered = true
+org.quartz.jobStore.clusterCheckinInterval = 20000
+
+#============================================================================
+# Configure Datasources
+#============================================================================
+
+org.quartz.dataSource.myDS.driver = org.mariadb.jdbc.Driver
+org.quartz.dataSource.myDS.URL = jdbc:mariadb://localhost:3306/vid_openecomp_epsdk
+org.quartz.dataSource.myDS.user = euser
+org.quartz.dataSource.myDS.password = euser
+org.quartz.dataSource.myDS.maxConnections = 5
+org.quartz.dataSource.myDS.validationQuery=select 0 from dual
diff --git a/onap-enabler-be/src/test/resources/WEB-INF/conf/raptor.properties b/onap-enabler-be/src/test/resources/WEB-INF/conf/raptor.properties
new file mode 100644
index 0000000..d0d01fd
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/WEB-INF/conf/raptor.properties
@@ -0,0 +1,168 @@
+##C## Mention the name of the framework. At present RAPTOR supports FUSION
+system=fusion
+##C## Determines the priority for the debug message.
+debug_level=5
+##C## Determines the number of records can be downloaded in excel when you select "download all" option.
+download_limit=65000
+csv_download_limit=10
+##C## Determines the number of records to be displayed in a single page.
+default_page_size=50
+##C## Determines the list size in the form field.
+form_fields_list_size=99000
+##C## Determines the scheduler interval
+#scheduler_interval=0 => disabled
+scheduler_interval=0
+##C## System Name
+system_name=RAPTOR
+##C## This is used for Bread crumbs.
+base_title=ANALYSIS
+##C## whether to allow SQL-based report definition (security risk); super users are always allowed to create SQL-based reports
+allow_sql_based_reports=yes
+##C## Determines whether to include disclaimer page at the bottom of each screen
+show_disclaimer=yes
+disclaimer_positioned_top_in_csvexcel=yes
+##C## Determines whether to display the form page as a separate page before running the report
+display_form_before_run=yes
+##C## Determines whether to include the form page on the report data page
+include_form_with_data=yes
+##C## Determines whether to cache chart data in the session => faster re-display if the data volume does not get too large
+cache_chart_data=yes
+##C## Determines whether to cache report data for the currently displayed page in the session => faster re-display
+ ##C## if the data volume does not get too large
+cache_cur_page_data=yes
+##C## Determines Chart width
+default_chart_width=700
+##C## Determines Chart height
+default_chart_height=420
+##C## Determines whether to permit report deletion only by report owner or by everyone with "write" access
+delete_only_by_owner=no
+##C## Determines whether to log each report execution and update time and user ID
+enable_report_log=yes
+##C## Determines whether to cache user roles info in memory (saves many DB reads, but does not account for roles
+ ##C## assigned after the cache was loaded)
+cache_user_roles=yes
+##C## Determines whether to convert month formats (e.g. MM/YYYY) to the last day of the month (true) or
+ ##C## first day (false) - like 12/2003 is converted to either 12/31/2003 or 12/01/2003
+month_format_use_last_day=no
+##C## Determines whether to print the report title in the download files
+print_title_in_download=yes
+##C## Determines whether to show report description when the report is run and in the quick links
+show_descr_at_runtime=no
+##C## Determines whether to skip labels on the Line chart axis when they overlap
+#DEPRECATED skip_chart_labels_to_fit=no
+##C## Determines whether to show chart types that are purpose and/or data specific
+show_nonstandard_charts=yes
+##C## Determines whether to allow the user to change the chart type at runtime
+allow_runtime_chart_sel=yes
+##C## Determines whether to display the report title as chart title as well
+display_chart_title=yes
+##C## Determines whether to merge/blank multi-level row headings in cross-tab report
+merge_crosstab_row_headings=yes
+##C## Determines whether to display chart when displaying the report at first or just a "Show Chart" button
+display_chart_by_default=yes
+##C## Determines whether to print the form field values in the download files
+print_params_in_download=yes
+##C## Determines the limitation to the characters in chart label.
+skip_chart_labels_limit=30
+##C## Determines whether to users with read-only rights for a report can copy it
+can_copy_on_read_only=yes
+##C## Determines the no of decimals to be displayed in Totals column
+#max_decimals_on_totals=-1 => don't truncate, display all decimal digits
+max_decimals_on_totals=2
+##C## Determines which JFreeChart to use.
+jfree_version=latest
+#jfree_version=0.9.11
+# Added this restriction so that heavily used system which contain
+# more than 1000 users can enable this feature not to display whole
+# users in the drop down menu
+display_all_users=yes
+##Sheet name
+sheet_name=raptor
+#shell_script_name=/home/sundar/test.sh
+#download_query_folder=/titan/PROJECT3/RAPTOR/raptor/dwnld/query/
+## this directory is mentioned if the flat file is downloaded using shell script
+shell_script_dir=/titan/PROJECT3/RAPTOR/raptor/dwnld/
+flat_file_lower_limit=1
+flat_file_upper_limit=200000
+## whatever request mentioned here would be parsed in sql and request parameter would be filled
+request_get_params=isEmbedded
+print_footer_in_download=yes
+## footer mentioned here appears in downloaded excel
+footer_first_line=AT&T Proprietary
+footer_second_line=Use Pursuant to Company Instructions
+## to run report in popup window
+report_in_popup_window=yes
+## to run each report in new popup window if the above is selected
+popup_in_new_window=yes
+## "Yes" allows the request param to be passed to the drill down report
+pass_request_param_in_drilldown=yes
+## Show PDF download icon
+show_pdf_download=yes
+# Show Folder Tree
+show_folder_tree=no
+#Show folder tree only for Admin Users
+show_folder_tree_only_to_admin_users=no
+#folder tree should be minimized
+folder_tree_minimized=yes
+## whatever session mentioned here would be parsed in sql and session parameter would be filled
+session_params=login_id
+display_formfield_info=yes
+customize_formfield_info=yes
+#schedule limit for end users
+schedule_limit=10
+# customized query if you need any restrictions for schedule and security tab for fusion
+#schedule_custom_query_for_users=getAllUsersByCustomer
+#schedule_custom_query_for_roles=getAllRolesByCustomer
+# customized query if you need any restrictions for schedule and security tab for prisms example
+#schedule_custom_query_for_users=SELECT au.user_id, au.first_name||' '||au.last_name user_name FROM app_user au order by 2
+schedule_custom_query_for_users=SELECT au.user_id id, au.first_name||' '||au.last_name name FROM app_user au where user_id = 1 order by 2
+#schedule_custom_query_for_roles=SELECT ar.role_id, ar.descr role_name FROM app_role ar order by 2
+schedule_date_pattern=MM/dd/yyyy hh:mm:ss a
+## This is used to display in right format in chart timestamp axis as we give in the sql
+#chart_yearly_format=yyyy
+#chart_monthly_format=MMM-yyyy
+chart_daily_format=MM/dd/yyyy
+chart_hourly_format=MM/dd HH
+#chart_minute_format=HH:mm
+chart_minute_format=MM-dd-yyyy-HH:mm
+#chart_second_format=HH:mm:ss
+chart_second_format=MM-dd-yyyy
+#chart_millisecond_format=HH:mm:ss.S
+schedule_help_text=This form is used to schedule a specific Reporting Platform report to be delivered to one or more email addresses associated with your Company's Business Direct user logins. Note that report output delivered via email does not include the capability to drill down/back up to additional data levels. So, select the appropriate data level report for the scheduled report. View the status of scheduled report requests in the My Schedules menu item.
+use_loginid_in_schedYN=Y
+session_params_for_scheduling=login_id
+session_date_formfield_auto_incr=yes
+display_session_param_pdfexcel=login_id;Login Id
+session_params_for_displaying_in_scheduling=login_id;Login Id
+application_server=tomcat
+#gmap properties
+gmap_key=ABQIAAAAToJSSetKBMjBJx8MiRw4ghQiU0SbbKnm8C5eu25cpyLwgkLzyRShrQTbgZtqnKAqZU9JwcSq1bKwiA
+PROJECT-FOLDER=/Users/sundar/git/st_quantum/quantum/target/quantum-1.0
+#
+MARKET-SHAPEFILE-FOLDER=resources/files
+# output folder for files generated on server side
+OUTPUT-FOLDER=resources/temp
+# tile size in pixel
+TILE-SIZE=256
+#check if map is disabled or not
+map_allowed=Y
+max_drilldown_level=2
+admin_role_equiv_to_super_role=N
+show_loading_during_formfield_chain=Y
+show_print_icon=N
+globally_nowrap=N
+calendar_output_date_format=MM/dd/yyyy
+memory_threshold_percentage=99
+print_params_in_csv_download=yes
+notitle_in_dashboard=yes
+generate_store_sched_reports=yes
+show_excel_2007_download=yes
+print_excel_in_landscape=yes
+show_animated_chart_option=yes
+show_animated_chart_only=no
+adjust_content_based_on_height=yes
+custom_submit_button_text=Run Button
+customize_formfield_layout=yes
+#db_type=postgresql
+#db_type=oracle
+db_type=mysql
diff --git a/onap-enabler-be/src/test/resources/WEB-INF/conf/raptor_app_fusion.properties b/onap-enabler-be/src/test/resources/WEB-INF/conf/raptor_app_fusion.properties
new file mode 100644
index 0000000..2c65ad8
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/WEB-INF/conf/raptor_app_fusion.properties
@@ -0,0 +1,20 @@
+temp_folder_path=/demeter/WebApps/dev/ECOMP_PORTAL/temp/
+upload_folder_path=/demeter/WebApps/dev/ECOMP_PORTAL/files/
+excel_template_path=/demeter/WebApps/dev/ECOMP_PORTAL/files/raptor_template/
+temp_folder_url=temp/
+upload_folder_url=upload/
+smtp_server=zeus.homer.att.com
+default_email_sender=dev-local@homer.att.com
+error_page=error_page.jsp
+jsp_context_path=raptor/
+img_folder_url=static/fusion/raptor/images/
+base_folder_url=static/fusion/raptor/
+direct_access_url=http://localhost:8080/quantum/raptor_email_attachment.htm?action=raptor&source_page=report_run&display_content=y
+#base_action_url=report.htm#/report_run/
+drill_action_url=report.htm#/report_run/c_master=
+base_action_url=report_wizard.htm?action=
+base_action_url_ng=report#/
+base_action_param=c_master=
+super_role_id=1
+admin_role_ids=1
+quick_links_menu_ids=HOME,CUSTOMER,REPORTS
diff --git a/onap-enabler-be/src/test/resources/WEB-INF/conf/raptor_db_fusion.properties b/onap-enabler-be/src/test/resources/WEB-INF/conf/raptor_db_fusion.properties
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/WEB-INF/conf/raptor_db_fusion.properties
diff --git a/onap-enabler-be/src/test/resources/WEB-INF/conf/raptor_pdf.properties b/onap-enabler-be/src/test/resources/WEB-INF/conf/raptor_pdf.properties
new file mode 100644
index 0000000..ffb42a7
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/WEB-INF/conf/raptor_pdf.properties
@@ -0,0 +1,30 @@
+## pdf file specific properties
+pdf_data_font_size=9
+pdf_data_font_family=Arial
+#reduce the font size from html config
+pdf_data_font_size_offset=2
+pdf_data_alternate_color=true
+#data row background(white), alternate(light light blue/gray)
+pdf_data_background_alternate_hex_code=#EDEDED
+pdf_data_default_background_hex_code=#FFFFFF
+#header font (white) background (gray)
+pdf_data_table_header_font_hex_code=#FFFFFF
+pdf_data_table_header_background_hex_code=#8A9BB3
+#footer header
+pdf_footer_font_size=9
+pdf_footer_font_family=Arial
+pdf_att_proprietary=AT&T Proprietary\nUse Pursuant to Company Instructions
+pdf_att_proprierary_font_size=7
+pdf_date_timezone=GMT
+pdf_date_pattern=MM/dd/yyyy hh:mm:ss a
+##page number position at 1 - footer middle, 0 -- header right, 2 - both
+pdf_page_number_position=1
+pdf_word_before_page_number=Page
+pdf_word_after_page_number=
+pdf_coverpage_firstcolumn_size=0.3
+pdf_image_auto_rotate=false
+display_create_owner_info=true
+#session_info=customer,customerId
+display_loginid_for_downloaded_by=false
+# please use false if you want landscape to be default.
+is_default_orientation_portrait=true
diff --git a/onap-enabler-be/src/test/resources/WEB-INF/conf/sql.properties b/onap-enabler-be/src/test/resources/WEB-INF/conf/sql.properties
new file mode 100644
index 0000000..e0f89f0
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/WEB-INF/conf/sql.properties
@@ -0,0 +1,303 @@
+#SQL Statements for PostgreSQL
+
+#ReportLoader.java
+
+load.custom.report.xml = SELECT cr.report_xml FROM cr_report cr WHERE rep_id=?
+
+# need to copy to oracle
+load.remoteDB.schema = SELECT 'local' SCHEMA_ID, 'local' SCHEMA_DESC, null DATASOURCE_TYPE FROM dual union SELECT a.SCHEMA_ID, a.SCHEMA_DESC, DATASOURCE_TYPE FROM SCHEMA_INFO a where schema_id <> 'local' order by schema_id
+load.remoteDB.schema.where = SELECT a.SCHEMA_ID, a.SCHEMA_DESC, DATASOURCE_TYPE FROM SCHEMA_INFO a where schema_id = '[schema_id]'
+#formfield rendering
+
+formfield.id.name.sql.prefix=SELECT id, name FROM (
+formfield.id.name.sql=SELECT id, name
+
+formfield.id.name.sql.suffix=
+
+report.security.create= SELECT coalesce(cr.owner_id, cr.create_id) AS owner_id, cr.create_id, DATE_FORMAT(cr.create_date, '%m/%d/%Y') create_date, maint_id, DATE_FORMAT(cr.maint_date, '%m/%d/%Y') update_date, cr.public_yn FROM cr_report cr WHERE cr.rep_id = [rw.getReportID()]
+
+db.update.report.xml = SELECT cr.rep_id, cr.report_xml FROM cr_report cr WHERE rep_id=? FOR UPDATE
+
+update.custom.report.rec = UPDATE cr_report SET title='[Utils.oracleSafe(rw.getReportName())]', descr='[Utils.oracleSafe(rw.getReportDescr())]', public_yn='[(rw.isPublic()]', menu_id='[rw.getMenuID()]', menu_approved_yn='[(rw.isMenuApproved()]', owner_id=[rw.getOwnerID()], maint_id=[rw.getUpdateID()], maint_date=STR_TO_DATE('[rw.getUpdateDate()]', '[Globals.getOracleTimeFormat()]'), dashboard_type_yn='[(rw.isDashboardType()]', dashboard_yn= '[(rw.getReportType().equals(AppConstants.RT_DASHBOARD)]' WHERE rep_id = [rw.getReportID()]
+
+is.report.already.scheduled = select rep_id from cr_report_schedule where rep_id = ?
+
+create.custom.report.rec = INSERT INTO cr_report(rep_id, title, descr, public_yn, menu_id, menu_approved_yn, report_xml, owner_id, create_id, create_date, maint_id, maint_date, dashboard_type_yn, dashboard_yn, folder_id) VALUES([rw.getReportID()], '[Utils.oracleSafe(rw.getReportName())]', '[Utils.oracleSafe(rw.getReportDescr())]', '[rw.isPublic()]', '[rw.getMenuID()]', '[rw.isMenuApproved()]', '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>', [rw.getOwnerID()], [rw.getCreateID()], STR_TO_DATE('[rw.getCreateDate()]', '[Globals.getOracleTimeFormat()]'), [rw.getUpdateID()], STR_TO_DATE('[rw.getUpdateDate()]', '[Globals.getOracleTimeFormat()]'), '[rw.isDashboardType()]', '[rw.getReportType().equals(AppConstants.RT_DASHBOARD)]',[rw.getFolderId()])
+
+get.user.report.names = SELECT cr.rep_id, cr.title FROM cr_report cr WHERE coalesce(cr.owner_id, cr.create_id) = [userID]
+
+get.report.owner.id = SELECT coalesce(cr.owner_id, cr.create_id) AS owner FROM cr_report cr WHERE rep_id = ?
+
+delete.report.record.log = DELETE FROM cr_report_log WHERE rep_id = [reportID]
+
+delete.report.record.users = DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID]
+
+delete.report.record.schedule = DELETE FROM cr_report_schedule WHERE rep_id = [reportID]
+
+delete.report.record.access = DELETE FROM cr_report_access WHERE rep_id = [reportID]
+
+delete.report.record.email = DELETE FROM cr_report_email_sent_log WHERE rep_id = [reportID]
+
+delete.report.record.favorite = DELETE FROM cr_favorite_reports WHERE rep_id = [reportID]
+
+delete.report.record.report = DELETE FROM cr_report WHERE rep_id = [reportID]
+
+load.quick.links = select finalcr.rep_id, finalcr.title, finalcr.descr from (SELECT cr.rep_id, cr.title, cr.descr FROM (SELECT rep_id, MIN(read_only_yn) read_only_yn FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = [userID]) UNION ALL (SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN ([roleList.toString()]))) report_access GROUP BY rep_id) ra LEFT JOIN cr_report cr ON cr.rep_id = ra.rep_id WHERE cr.menu_id LIKE '%[nvls(menuId)]%' AND cr.menu_approved_yn = 'Y' AND (coalesce(cr.owner_id, cr.create_id) = [userID] OR cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL) UNION SELECT cr.rep_id, cr.title, cr.descr FROM cr_report cr WHERE cr.menu_id LIKE '%[nvls(menuId)]%' AND (coalesce(cr.owner_id, cr.create_id) = [userID] OR cr.public_yn = 'Y' or EXISTS (select * from fn_user_role where user_id=[userID] and role_id in (1)))) finalcr ORDER BY finalcr.title
+
+load.folder.reports = SELECT cr.rep_id, cr.rep_id report_id, concat([rep_title_sql] , (CASE WHEN cr.public_yn = 'Y' THEN '' ELSE '[PRIVATE_ICON]' END),cr.title,'</a>') title, cr.descr, concat(au.first_name,' ',au.last_name) owner_name, DATE_FORMAT(cr.create_date, '%m/%d/%Y') create_date, CASE WHEN coalesce(cr.owner_id, cr.create_id) = [userID] THEN 'N' ELSE coalesce(ra.read_only_yn, 'Y') END read_only_yn, CASE WHEN coalesce(cr.owner_id, cr.create_id) = [userID] THEN 'Y' ELSE 'N' END user_is_owner_yn FROM cr_report cr JOIN app_user au ON coalesce(cr.owner_id, cr.create_id) = au.user_id AND cr.folder_id= '[folderId]' LEFT JOIN (SELECT rep_id, MIN(read_only_yn) read_only_yn FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = [userID]) UNION ALL(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN ([roleList.toString()]))) report_access GROUP BY rep_id) ra ON cr.rep_id = ra.rep_id
+#If roleList.toString() is '' PostgreSQL returns an error - needs to be null instead of empty
+
+load.folder.reports.user = AND coalesce(cr.owner_id, cr.create_id) = [userID]
+
+load.folder.reports.publicsql = AND (coalesce(cr.owner_id, cr.create_id) = [userID] OR cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL)
+
+load.quick.download.links = SELECT a.file_name, b.title,DATE_FORMAT(a.dwnld_start_time, '%W %d-%m-%Y %H:%i:%s') as time, a.dwnld_start_time FROM cr_report_dwnld_log a, cr_report b where a.user_id = [userID] and a.rep_id = b.rep_id and (a.dwnld_start_time) >= STR_TO_DATE(DATE_FORMAT(now() - INTERVAL 1 DAY, '%m/%d/%Y'), '%m/%d/%Y') and a.record_ready_time is not null order by a.dwnld_start_time
+
+load.reports.to.schedule = SELECT cr.rep_id, Initcap(cr.title), cr.descr FROM cr_report cr LEFT OUTER JOIN (SELECT rep_id, MIN(read_only_yn) read_only_yn FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = [userID]) UNION ALL (SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN ([roleList.toString()]))) report_access GROUP BY rep_id) ra ON cr.rep_id = ra.rep_id AND (cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL or cr.owner_id = [userID] )ORDER BY Initcap(cr.title)
+
+load.reports.to.add.in.dashboard = SELECT cr.rep_id, cr.title, cr.descr FROM cr_report cr LEFT OUTER JOIN (SELECT rep_id, MIN(read_only_yn) read_only_yn FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = [userID]) UNION ALL (SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN ([roleList.toString()]))) report_access GROUP BY rep_id) ra ON cr.rep_id = ra.rep_id AND (coalesce(cr.owner_id, cr.create_id) = [userID] OR cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL) AND (cr.dashboard_yn = 'N' or cr.dashboard_yn is null) ORDER BY cr.title
+
+load.my.recent.links = select rep_id, title, descr, form_fields from ( select rep_id, title, descr, form_fields from (select cr.rep_id, cr.title, a.form_fields, cr.descr, a.log_time, a.user_id, a.action, a.action_value from cr_report_log a, cr_report cr where user_id = [userID] AND action = 'Report Execution Time' and a.rep_id = cr.rep_id order by log_time desc) AS x) AS y where LIMIT 1, 6
+
+create.report.log.entry = INSERT INTO cr_report_log (rep_id, log_time, user_id, action, action_value, form_fields) VALUES([reportID], now(), [userID], '[action]' , '[executionTime]', '[form_fields]')
+
+create.report.log.entry.exec.time = INSERT INTO cr_report_log (rep_id, log_time, user_id, action, action_value, form_fields) VALUES([reportID], NOW() + INTERVAL 1 SECOND, [userID], '[action]' , '[executionTime]', '[formFields]')
+
+clear.report.log.entries = DELETE FROM cr_report_log WHERE rep_id = ? and user_id = ?
+
+load.report.log.entries = SELECT x.log_time, x.user_id, (CASE WHEN x.action = 'Report Execution Time' THEN concat('<a href=\"[AppUtils.getRaptorActionURL()]report.run.container&c_master=',x.rep_id,'&',x.form_fields,'&fromReportLog=Y&display_content=Y&noFormFields=Y&refresh=Y\">',x.action,'</a>') ELSE x.action END) action, (CASE WHEN x.action = 'Report Execution Time' THEN action_value ELSE 'N/A' END) time_taken, (CASE WHEN x.action = 'Report Execution Time' THEN concat('<a href=\"[AppUtils.getRaptorActionURL()]report.run.container&c_master=',x.rep_id,'&',x.form_fields,'&fromReportLog=Y&display_content=Y&noFormFields=Y&refresh=Y\"><img src=\"[AppUtils.getImgFolderURL()]test_run.gif" width=\"12\" height=\"12\" border=0 alt=\"Run report\"/></a>') ELSE 'N/A' END) run_image, x.name FROM (SELECT rl.rep_id, DATE_FORMAT(rl.log_time, '%m/%d/%Y %h:%i:%s %p') log_time, rl.action_value, concat(fuser.last_name ,', ',fuser.first_name) name, rl.user_id, rl.action, rl.form_fields FROM cr_report_log rl, fn_user fuser WHERE rl.rep_id = [nvls(reportId)] and rl.action != 'Report Run' and fuser.user_id = rl.user_id ORDER BY rl.log_time DESC) x LIMIT 100
+
+does.user.can.schedule.report = select crs.sched_user_id, count(*) from cr_report_schedule crs where sched_user_id = [userId] group by crs.sched_user_id having count(*) >= [Globals.getScheduleLimit()]
+
+does.user.can.schedule = select crs.schedule_id from cr_report_schedule crs where schedule_id = [scheduleId]
+
+get.system.date.time = select DATE_FORMAT(now(),'%m/%d/%Y %H:%i:%s')
+
+get.next.day.date.time = select DATE_FORMAT(NOW() + INTERVAL 1 DAY,'%m/%d/%Y %H:%i:%s')
+
+get.next.fifteen.minutes.date.time = select DATE_FORMAT(NOW() + INTERVAL 15 MINUTES,'%m/%d/%Y %H:%i:%s')
+
+get.next.thirty.minutes.date.time = select DATE_FORMAT(NOW() + INTERVAL 30 MINUTES,'%m/%d/%Y %H:%i:%s')
+
+get.template.file = select template_file from cr_report_template_map where report_id = [reportId]
+
+load.pdf.img.lookup = select image_id, image_loc from cr_raptor_pdf_img
+
+load.action.img.lookup = select image_id, image_loc from cr_raptor_action_img
+
+
+#ActionHandler.java
+
+report.values.map.def.a = SELECT x FROM (SELECT DISTINCT
+
+report.values.map.def.b = TO_CHAR([colName], '[nvl(displayFormat, AppConstants.DEFAULT_DATE_FORMAT)]')
+
+report.values.map.def.c = [colName]
+
+report.values.map.def.d = x FROM [rdef.getTableById(tableId).getTableName()] WHERE [colName] IS NOT NULL ORDER BY 1) xx LIMIT <= [Globals.getDefaultPageSize()]
+
+test.sched.cond.popup = SELECT 1 WHERE EXISTS ([sql])
+
+download.all.email.sent = Select user_id, rep_id from CR_REPORT_EMAIL_SENT_LOG where gen_key='[pdfAttachmentKey.trim()]' and log_id =[report_email_sent_log_id.trim()] and (now() - sent_date) < '1 day' limit 1
+
+download.all.gen.key = select schedule_id from cr_report_email_sent_log u where U.GEN_KEY = '[pdfAttachmentKey]'
+
+download.all.retrieve = SELECT au.user_id FROM (SELECT rs.schedule_id, rs.rep_id FROM cr_report_schedule rs WHERE rs.enabled_yn='Y' AND rs.run_date IS NOT NULL AND rs.schedule_id = [scheduleId]) x, cr_report r, app_user au WHERE x.rep_id = r.rep_id AND au.user_id IN (SELECT rsu.user_id FROM cr_report_schedule_users rsu WHERE rsu.schedule_id = x.schedule_id and rsu.schedule_id = [scheduleId] UNION SELECT ur.user_id FROM fn_user_role ur WHERE ur.role_id IN (SELECT rsu2.role_id FROM cr_report_schedule_users rsu2 WHERE rsu2.schedule_id = x.schedule_id and rsu2.schedule_id = [scheduleId]))
+
+download.all.insert = insert into cr_report_dwnld_log (user_id,rep_id,file_name,dwnld_start_time,filter_params) values (?,?,?,?,?)
+
+#ReportWrapper.java
+
+report.wrapper.format = SELECT coalesce(cr.owner_id, cr.create_id) owner_id, cr.create_id, DATE_FORMAT(cr.create_date, '[Globals.getOracleTimeFormat()]') create_date, maint_id, DATE_FORMAT(cr.maint_date, '[Globals.getOracleTimeFormat()]') update_date, cr.menu_id, cr.menu_approved_yn FROM cr_report cr WHERE cr.rep_id= [reportID]
+
+generate.subset.sql = SELECT [colNames.toString()] FROM (SELECT [colNames.toString()] FROM ([reportSQL]) AS x ) AS y
+
+report.sql.only.first.part = SELECT [colNames.toString()] FROM (SELECT [colNames.toString()] FROM (
+
+report.sql.only.second.part.a = [startRow]
+
+report.sql.only.second.part.b = [pageSize]
+#MYSQL: LIMIT [startRow], [pageSize]
+#ORacle: rownum >= [startRow] and rownum <= ([startRow]+[pageSize])
+#Postgre: limit [pageSize] offset [startRow]
+
+report.sql.only.second.part.b.noorderby = LIMIT [startRow]
+
+generate.sql.visual.select = SELECT
+
+generate.sql.visual.count = COUNT(*) cnt
+
+generate.sql.visual.dual =
+#No DUAL table in PostgreSQL so this is blank
+
+#ReportRuntime.java
+
+load.crosstab.report.data = SELECT [colNames.toString()] FROM ( [reportSQL]
+
+#RaptorRunHandler.java
+
+generate.sql.handler = SELECT x.* from ([sql]) AS x LIMIT 2
+
+generate.sql.select = SELECT [colNames.toString()] FROM (SELECT [colNames.toString()] FROM ([sql]) AS y) AS x
+
+#ReportSchedule.java
+
+load.schedule.data = SELECT rs.enabled_yn, DATE_FORMAT(rs.start_date, '%m/%d/%Y') start_date, DATE_FORMAT(rs.end_date, '%m/%d/%Y') end_date, DATE_FORMAT(rs.run_date, '%m/%d/%Y') run_date, coalesce(DATE_FORMAT(rs.run_date, '%h'), '12') run_hour, coalesce(DATE_FORMAT(rs.run_date, '%i'), '00') run_min, coalesce(DATE_FORMAT(rs.run_date, '%p'), 'AM') run_ampm, rs.recurrence, rs.conditional_yn, rs.notify_type, rs.max_row, rs.initial_formfields, rs.schedule_id, coalesce(DATE_FORMAT(rs.end_date, '%h'), '11') end_hour, coalesce(DATE_FORMAT(rs.end_date, '%i'), '45') end_min, coalesce(DATE_FORMAT(rs.end_date, '%p'), 'PM') end_ampm, encrypt_yn, attachment_yn FROM cr_report_schedule rs WHERE rs.rep_id = [reportID]
+
+load.schedule.getid = SELECT rsu.user_id, concat(fuser.last_name,', ',fuser.first_name), fuser.login_id FROM cr_report_schedule_users rsu, fn_user fuser WHERE rsu.rep_id = [reportID] AND rsu.schedule_id = [getScheduleID()] and rsu.user_id IS NOT NULL and rsu.user_id = fuser.user_id
+
+load.schedule.users = SELECT rsu.role_id FROM cr_report_schedule_users rsu WHERE rsu.rep_id = [reportID] AND rsu.schedule_id = [getScheduleID()] AND rsu.role_id IS NOT NULL
+
+new.schedule.data = select coalesce(max(schedule_id),0)+1 AS sequence from cr_report_schedule
+
+new.report.data = select coalesce(max(rep_id),0)+1 AS rep_id from cr_report
+
+execute.update = DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]
+
+execute.update.users = INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])
+
+execute.update.roles = INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])
+
+execute.update.activity = INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))
+
+delete.schedule.data = SELECT 1 FROM cr_report_schedule WHERE rep_id = [reportID] and sched_user_id = [getScheduleUserID()] and schedule_id = [getScheduleID()]
+
+delete.schedule.data.users = DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]
+
+delete.schedule.data.id = DELETE FROM cr_report_schedule where rep_id = [reportID] and sched_user_id = [getScheduleUserID()] and schedule_id = [getScheduleID()]
+
+load.cond.sql = SELECT condition_large_sql FROM cr_report_schedule WHERE schedule_id=?
+
+load.cond.sql.select = SELECT condition_sql FROM cr_report_schedule WHERE schedule_id = [scheduleId]
+
+persist.cond.sql.update = update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]
+#EMPTY CLOB() changed to ''
+
+persist.cond.sql.large = SELECT condition_large_sql FROM cr_report_schedule cr WHERE schedule_id=? FOR UPDATE
+
+persist.cond.sql.set = update cr_report_schedule set condition_sql = ? where schedule_id = [scheduleId]
+
+#DataCache.java
+
+get.data.view.actions = SELECT ts.web_view_action FROM cr_table_source ts WHERE ts.web_view_action IS NOT NULL
+
+get.public.report.id.names = SELECT rep_id, title FROM cr_report WHERE public_yn = 'Y' ORDER BY title
+
+get.private.accessible.names.a = SELECT cr.rep_id, cr.title FROM cr_report cr WHERE cr.rep_id not in (select rep_id from cr_report_access cra where user_id = '[user_id]'
+
+get.private.accessible.names.if = OR role_id in (
+
+get.private.accessible.names.b = ) AND public_yn = 'N' and cr.owner_id = '[user_id]' order by 2
+
+get.group.accessible.names.a = SELECT cr.rep_id, cr.title FROM cr_report cr WHERE cr.rep_id in (select rep_id from cr_report_access cra where user_id = '[user_id]'
+
+get.group.accessible.names.b = ) AND public_yn = 'N' order by 2
+
+get.report.table.sources.a = SELECT table_name, display_name, pk_fields, web_view_action, large_data_source_yn, filter_sql FROM cr_table_source
+
+get.report.table.sources.where = where SOURCE_DB= '[dBInfo]'
+
+get.report.table.sources.if = where SOURCE_DB is null or SOURCE_DB = '[AppConstants.DB_LOCAL]'
+
+get.report.table.sources.else = ORDER BY table_name
+
+grab.report.table.a = SELECT ts.table_name, ts.display_name, ts.pk_fields, ts.web_view_action, ts.large_data_source_yn, ts.filter_sql FROM cr_table_source ts WHERE
+
+grab.report.table.if = ts.SOURCE_DB= '[dBInfo]'
+
+grab.report.table.else = (ts.SOURCE_DB is null or ts.SOURCE_DB = '[AppConstants.DB_LOCAL]')
+
+grab.report.table.b = except SELECT ts.table_name, ts.display_name, ts.pk_fields, ts.web_view_action, ts.large_data_source_yn, ts.filter_sql from cr_table_source ts where table_name in (select table_name from cr_table_role where role_id not IN [sb.toString()]) and
+
+grab.report.table.c = ORDER BY 1
+
+get.report.table.crjoin = SELECT src_table_name, dest_table_name, join_expr FROM cr_table_join
+
+get.report.table.joins = SELECT tj.src_table_name, tj.dest_table_name, tj.join_expr FROM cr_table_join tj WHERE ((EXISTS (SELECT 1 FROM cr_table_role trs WHERE trs.table_name=tj.src_table_name AND trs.role_id IN [sb.toString()])) OR (NOT EXISTS (SELECT 1 FROM cr_table_role trs WHERE trs.table_name=tj.src_table_name))) AND ((EXISTS (SELECT 1 FROM cr_table_role trd WHERE trd.table_name=tj.dest_table_name AND trd.role_id IN [sb.toString()])) OR (NOT EXISTS (SELECT 1 FROM cr_table_role trd WHERE trd.table_name=tj.dest_table_name)))
+
+generate.report.table.col = SELECT a.table_name, a.column_name, a.data_type, a.label FROM user_column_def a WHERE a.table_name = '[tableName.toUpperCase()]' ORDER BY a.column_id
+
+generate.db.user.sql.a = SELECT utc.table_name, utc.column_name, utc.data_type,
+
+generate.db.user.sql.if = utc.column_name FROM user_tab_columns utc
+
+generate.db.user.sql.else = coalesce(x.label, utc.column_name) FROM user_tab_columns utc
+
+generate.db.user.sql.b = WHERE utc.table_name = '[tableName.toUpperCase()]'
+
+generate.db.user.sql.c = AND utc.table_name = x.table_name AND utc.column_name = x.column_name
+
+generate.db.user.sql.d = ORDER BY utc.column_id
+
+#SearchHandler.java
+
+load.report.search.result = SELECT cr.rep_id, cr.rep_id report_id, [rep_title_sql] title, cr.descr, concat(au.first_name,' ',au.last_name) owner_name, DATE_FORMAT(cr.create_date, '%m/%d/%Y') create_date, CASE WHEN coalesce(cr.owner_id, cr.create_id) = [userID] THEN 'N' ELSE coalesce(ra.read_only_yn, 'Y') END read_only_yn, CASE WHEN coalesce(cr.owner_id, cr.create_id) = [userID] THEN 'Y' ELSE 'N' END user_is_owner_yn, case when report_xml like '%<allowSchedule>N</allowSchedule>%' then 'N' when report_xml like '%<allowSchedule>Y</allowSchedule>%' or 1 = (select distinct 1 from cr_report_schedule where rep_id = cr.rep_id) then 'Y' else 'N' end FROM cr_report cr JOIN fn_user au ON coalesce (cr.owner_id, cr.create_id) = au.user_id [fReportID] [fReportName] LEFT JOIN(SELECT rep_id, MIN(read_only_yn) read_only_yn FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = [userID]) UNION ALL (SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN ([roleList.toString()]))) report_access GROUP BY rep_id) ra ON ra.rep_id = cr.rep_id
+
+load.report.search.instr = WHERE cr.menu_id LIKE '%[menuId]%'
+
+load.report.search.result.user = WHERE coalesce(cr.owner_id, cr.create_id) = [userID]
+
+load.report.search.result.public = WHERE (coalesce(cr.owner_id, cr.create_id) = [userID] OR cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL)
+
+load.report.search.result.fav = WHERE cr.rep_id in (select rep_id from cr_favorite_reports where user_id = [userID]
+
+load.report.search.result.sort = ORDER BY CASE coalesce(cr.owner_id, cr.create_id) WHEN [userID] THEN ' ' WHEN 'upper(concat(au.first_name,' ',au.last_name))' ELSE 'upper(cr.title)' END
+
+load.folder.report.result = SELECT cr.rep_id, cr.rep_id report_id, concat([rep_title_sql] , (CASE WHEN cr.public_yn = 'Y' THEN '' ELSE '[PRIVATE_ICON]' END),cr.title,'</a>') title, cr.descr, concat(au.first_name,' ',au.last_name) owner_name, TO_CHAR(cr.create_date, 'MM/DD/YYYY') create_date, CASE WHEN coalesce(cr.owner_id, cr.create_id) = [userID] THEN 'N' ELSE coalesce(ra.read_only_yn, 'Y') END read_only_yn, CASE WHEN coalesce(cr.owner_id, cr.create_id) = [userID] THEN 'Y' ELSE 'N' END user_is_owner_yn FROM cr_report cr JOIN fn_user au ON coalesce (cr.owner_id, cr.create_id) = au.user_id AND TO_CHAR(cr.rep_id, 'FM99999999') like coalesce('%[fReportID]%', TO_CHAR(cr.rep_id, 'FM99999999')) AND UPPER(cr.title) LIKE UPPER('%[fReportName]%') LEFT JOIN(SELECT rep_id, MIN(read_only_yn) read_only_yn FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = [userID]) UNION ALL (SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN ([roleList.toString()]))) report_access GROUP BY rep_id) ra ON ra.rep_id = cr.rep_id
+
+load.folder.report.result.sort = ORDER BY CASE coalesce(cr.owner_id, cr.create_id) WHEN [userID] THEN ' ' WHEN '(concat(au.first_name,' ',au.last_name))' ELSE 'cr.title' END
+
+#WizardProcessor.java
+
+process.filter.add.edit = '[argValue]'
+
+#ReportDefinition.java
+
+persist.report.adhoc = SELECT nextval('[Globals.getAdhocReportSequence()]') AS sequence
+
+#Globals.java
+
+initialize.roles = SELECT 1 WHERE EXISTS (SELECT 1 FROM cr_table_role)
+
+initialize.version = SELECT cr_raptor.get_version
+
+# scheduler
+
+
+scheduler.available.schedules = SELECT x.rep_id, x.schedule_id, x.conditional_yn, x.condition_large_sql, x.notify_type, x.max_row, x.initial_formfields, x.processed_formfields, r.title, x.user_id FROM ( SELECT rs.rep_id, rs.schedule_id, rs.sched_user_id user_id, rs.conditional_yn, rs.condition_large_sql, rs.notify_type, rs.max_row, rs.initial_formfields, rs.processed_formfields FROM cr_report_schedule rs WHERE rs.enabled_yn='Y' AND rs.start_date <= [currentDate] AND (rs.end_date >= [currentDate] or rs.end_date is null ) AND rs.run_date IS NOT NULL ) x, cr_report r WHERE x.rep_id = r.rep_id
+
+random.string = select ( concat('Z' , round(random() * 1000000000000) ) )
+
+
+scheduler.user.emails = SELECT au.user_id FROM (SELECT rs.schedule_id, rs.rep_id FROM cr_report_schedule rs WHERE rs.enabled_yn='Y' AND rs.start_date <= now() AND rs.end_date >= now() AND rs.run_date IS NOT NULL AND rs.schedule_id = [p_schedule_id] ) x, cr_report r, fn_user au WHERE x.rep_id = r.rep_id AND au.user_id IN (SELECT rsu.user_id FROM cr_report_schedule_users rsu WHERE rsu.schedule_id = x.schedule_id and rsu.schedule_id = [p_schedule_id] UNION SELECT ur.user_id FROM fn_user_role ur WHERE ur.role_id IN (SELECT rsu2.role_id FROM cr_report_schedule_users rsu2 WHERE rsu2.schedule_id = x.schedule_id and rsu2.schedule_id = [p_schedule_id]))
+
+
+# my logins
+
+app.query = SELECT APP_ID, ML_APP_NAME, MOTS_ID from fn_app
+
+user.log.query = SELECT DISTINCT IFNULL(SBCID, '') CUID, '' AWID, CONCAT('"',IFNULL(SBCID, ''),'"') APPLICATIONUSERID, CONCAT('"',IFNULL(FIRST_NAME, ''),'"') FIRST_NAME, CONCAT('"',substr(IFNULL(MIDDLE_NAME, ''), 0, 1),'"') MIDDLE_INITIAL, CONCAT('"',IFNULL(LAST_NAME, ''),'"') LAST_NAME, IFNULL(DATE_FORMAT(LAST_LOGIN_DATE, '%Y/%m/%d'), '') LAST_LOGON_DATE, DATE_FORMAT(CREATED_DATE, '%Y/%m/%d') ACCOUNT_ACTIVATION_DATE, IFNULL(DATE_FORMAT(MODIFIED_DATE, '%Y/%m/%d'), '') LAST_DATE_ACCOUNT_MODIFIED, '' LAST_PASSWORD_CHANGE_DATE, CONCAT('"',IFNULL(FIRST_NAME, ''),' ',IFNULL(MIDDLE_NAME, ''),' ',IFNULL(LAST_NAME, ''),'"') FULL_USER_NAME, '' NT_ID, IFNULL(EMAIL, '') EMAIL FROM FN_USER FU, FN_USER_ROLE FUR WHERE FU.USER_ID \= FUR.USER_ID and FUR.app_id \= ? and ACTIVE_YN \= 'Y' and sbcid is not null order by 1
+
+profile.log.query = SELECT DISTINCT CONCAT('"' , ROLE_NAME , '"') PROFILE_NAME, '""' SECURITY_SETTINGS FROM FN_ROLE FR, FN_USER_ROLE FUR WHERE FUR.ROLE_ID \= FR.ROLE_ID and FR.ACTIVE_YN \= 'Y' and ((FUR.APP_ID \= 1 and FR.ROLE_NAME <> 'Standard User') or (FUR.APP_ID \= ? and FUR.APP_ID <> 1)) ORDER BY 1
+
+user.profile.log.query = SELECT DISTINCT IFNULL(SBCID, '') CUID, '' AWID, CONCAT('"' , IFNULL(SBCID, '') , '"') APPLICATIONUSERID , CONCAT('"' , ROLE_NAME , '"') PROFILE_NAME FROM FN_USER A, FN_USER_ROLE B, FN_ROLE C WHERE A.USER_ID \= B.USER_ID AND B.ROLE_ID \= C.ROLE_ID AND A.ACTIVE_YN \= 'Y' AND C.ACTIVE_YN \= 'Y' AND a.sbcid is not null AND ((B.APP_ID \= 1 and C.ROLE_NAME <> 'Standard User') or (B.APP_ID \= ? and B.APP_ID <> 1)) ORDER BY 1
+
+all.accounts.log.query = SELECT DISTINCT IFNULL(SBCID, '') CUID, (case when A.ACTIVE_YN\='Y' then 'ACTIVE' else 'INACTIVE' end) ACTIVE_YN, CONCAT('"' , IFNULL(SBCID, '') , '"') APPLICATIONUSERID , IFNULL(DATE_FORMAT(LAST_LOGIN_DATE, '%Y/%m/%d'), '') LAST_LOGON_DATE, '' LAST_PASSWORD_CHANGE_DATE, CONCAT('"' , ROLE_NAME , '"') PROFILE_NAME FROM FN_USER A, FN_USER_ROLE B, FN_ROLE C WHERE A.USER_ID \= B.USER_ID AND B.ROLE_ID \= C.ROLE_ID AND a.sbcid is not null AND ((B.APP_ID \= 1 and C.ROLE_NAME <> 'Standard User') or (B.APP_ID \= ? and B.APP_ID <> 1)) ORDER BY 1
+
+# basic sql
+
+seq.next.val = SELECT nextval('[sequenceName]') AS id
+
+current.date = now()
+
+nvl = IFNULL
+
+# report security
+report.user.access = SELECT ra.role_id, ra.user_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.rep_id = [reportID]
+add.user.access = INSERT INTO cr_report_access (rep_id, order_no, role_id, user_id, read_only_yn) VALUES([reportID], IFNULL((select order_no from (SELECT MAX(order_no) AS order_no FROM cr_report_access WHERE rep_id=[reportID]) AS temp), 0)+1, NULL, [userID], '[readOnlyAccess]')
+update.user.access = UPDATE cr_report_access SET read_only_yn='[readOnlyAccess]' WHERE rep_id=[reportID] AND user_id=[userID]
+remove.user.access = DELETE FROM cr_report_access WHERE rep_id=[reportID] AND user_id=[userID]
+add.role.access = INSERT INTO cr_report_access (rep_id, order_no, role_id, user_id, read_only_yn) VALUES([reportID], IFNULL((select order_no from (SELECT MAX(order_no) AS order_no FROM cr_report_access WHERE rep_id=[reportID]) AS temp), 0)+1, [roleID], NULL, '[readOnlyAccess]')
+update.role.access = UPDATE cr_report_access SET read_only_yn='[readOnlyAccess]' WHERE rep_id=[reportID] AND role_id=[roleID]
+remove.role.access = DELETE FROM cr_report_access WHERE rep_id=[reportID] AND role_id=[roleID]
+
diff --git a/onap-enabler-be/src/test/resources/WEB-INF/conf/system.properties b/onap-enabler-be/src/test/resources/WEB-INF/conf/system.properties
new file mode 100644
index 0000000..20ddc0f
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/WEB-INF/conf/system.properties
@@ -0,0 +1,190 @@
+# Properties read by ECOMP Core library, epsdk-core.jar
+
+##########################################################################
+# The following properties should NOT be changed by partner applications.
+##########################################################################
+
+application_user_id = 30000
+post_default_role_id = 16
+clustered = true
+
+#Enable Fusion Mobile capabilities for the application
+mobile_enable = false
+
+# Cache config file is needed on the classpath
+cache_config_file_path = /WEB-INF/classes/cache.ccf
+cache_switch = 199
+cache_load_on_startup = false
+
+user_name = fullName
+decryption_key = AGLDdG4D04BKm2IxIWEr8o==
+#db.userName=XXXX
+#db.password=XXXX
+#db.connectionURL=jdbc:oracle:thin:@XXXX/XX
+#db.hib.dialect=org.hibernate.dialect.Oracle10gDialect
+#db.driver=oracle.jdbc.driver.OracleDriver
+#Hibernate
+#hb.dialect=org.hibernate.dialect.Oracle10gDialect
+#hb.show_sql=true
+
+#Postgre
+#db.userName=XXXX
+#db.password=XXXX
+#db.connectionURL=jdbc:postgresql://XXXX/XX
+#db.hib.dialect=org.hibernate.dialect.PostgreSQLDialect
+#db.driver=org.postgresql.Driver
+#hb.dialect=org.hibernate.dialect.PostgreSQLDialect
+#hb.show_sql=true
+
+#Mysql
+db.driver = com.mysql.jdbc.Driver
+#db.connectionURL = jdbc:mysql://demeter.homer.att.com:3306/ecomp_sdk_1707_att
+db.connectionURL = jdbc:mysql://localhost:3306/vid_portal
+db.userName = euser
+db.password = euser
+db.hib.dialect = org.hibernate.dialect.MySQLDialect
+db.min_pool_size = 5
+db.max_pool_size = 10
+hb.dialect = org.hibernate.dialect.MySQLDialect
+# SQL statements are logged to stdout
+hb.show_sql = true
+hb.idle_connection_test_period = 3600
+app_display_name = VID
+files_path = /opt/app/vid/license
+
+# menu settings
+#menu_query_name = menuData
+#menu_properties_file_location = /WEB-INF/fusion/menu/
+#application_menu_set_name = APP
+#application_menu_attribute_name = applicationMenuData
+#application_menu_properties_name = menu.properties
+#business_direct_menu_set_name = BD
+#business_direct_menu_properties_name = bd.menu.properties
+#business_direct_menu_attribute_name = businessDirectMenuData
+
+application_name = Virtual Infrastructure Deployment
+
+
+#element map files
+#element_map_file_path = /tmp
+#element_map_icon_path = app/vid/icons/
+element_map_file_path = app/fusionapp/files/
+element_map_icon_path = app/fusionapp/icons/
+
+#aai related properties
+#dev server
+#aai.server.url.base=https://mtanjv9aaas40.aic.cip.att.com:8443/aai/
+#aai.server.url=https://mtanjv9aaas40.aic.cip.att.com:8443/aai/v10/
+#aai.oldserver.url.base=https://mtanjv9aaas40.aic.cip.att.com:8443/aai/servers/
+#aai.oldserver.url=https://mtanjv9aaas40.aic.cip.att.com:8443/aai/servers/v3/
+#ist servers
+aai.server.url.base=https://aai-ext1.test.att.com:8443/aai/
+#aai.server.url=https://aai-ext1.test.att.com:8443/aai/v12/
+aai.server.url=http://localhost:8080/vidSimulator/aai/v12/
+#aai.server.url=http://localhost:1080/aai
+#aai.server.url=https://aai-int2.test.att.com:8443/aai/v12/
+aai.vid.username=VID
+aai.vid.passwd.x=OBF:1jm91i0v1jl9
+
+
+
+
+
+
+
+
+aai.oldserver.url.base=https://aai-ext1.test.att.com:8443/aai/servers/
+aai.oldserver.url=https://aai-ext1.test.att.com:8443/aai/servers/v3/
+aai.truststore.filename=tomcat_keystore
+aai.truststore.passwd.x=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o
+aai.keystore.filename=aai-client-cert.p12
+aai.keystore.passwd.x=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o
+aai.use.client.cert=false
+aai.vnf.provstatus=PREPROV,NVTPROV,PROV,CAPPED
+
+#Cron Schedules have 6 required fields and 1 optional field:
+# Seconds Minutes Hours Day-of-Month Month Day-of-Week Year
+log_cron = 0 0/1 * * * ?;
+mylogins_feed_cron = 0 0/60 * * * ?;
+#sessiontimeout_feed_cron = 0 * * * * ? *
+my_login_feed_output_dir = /tmp/MyLogins
+
+# ECOMP Portal Shared Context REST API URL
+ecomp_shared_context_rest_url= https://www.ecomp.att.com:8080/ecompportal/context
+
+# Link shown in Help menu
+contact_us_link = https://wiki.web.att.com/display/EcompPortal/ECOMP+Portal+Home
+
+# Camunda cockpit link
+camunda_cockpit_link = https://cloopwf.client.research.att.com:8443/camunda/app/cockpit/default/#/dashboard
+# An Unique 128-bit value defined to identify a specific version
+# of an application deployed on a specific virtual machine.
+# This value must be generated and updated by the application
+# which is using the ECOMP SDK at the time of its deployment.
+# Online Unique UUID generator - https://www.uuidgenerator.net/
+instance_uuid=8da691c9-987d-43ed-a358-00ac2f35685d
+
+# R Cloud feature
+guard_notebook_url=https://rcloud.research.att.com/mini.html?notebook=a06a9cf14211012e221bf842c168849d&
+
+#ECOMP redirect url
+#ecomp_redirect_url = https://webtest.csp.att.com/ecomp_portal_dev_n1/ecompui/process_csp
+#ecomp_rest_url = https://webtest.csp.att.com/ecomp_portal_dev_n1/ecompui/auxapi
+# Replace these default values with the ones for your specific App. Ecomp Portal admin obtains from EP website.
+#ueb_app_mailbox_name = ECOMP-PORTAL-OUTBOX-90
+#ueb_app_key = sYH0NJnsKmJC1B2A
+#ueb_app_secret = YOtknsT2wVFz9WISlSPDaAtd
+
+#MSO related properties
+#simulator
+#mso.server.url=http://localhost:8089
+#mso.server.url=https://msoapih-app.mtsnj.aic.cip.att.com:8443/ecomp/mso/infra
+#dev2dev
+#good
+#dev
+#mso.server.url=http://mtanjv9moah10-eth0.aic.cip.att.com:8080/ecomp/mso/infra
+#istScrum-Master
+mso.client.type=LOCAL
+mso.server.url=http://vm1.mso.simpledemo.openecomp.org:8080
+mso.polling.interval.msecs=10000
+mso.max.polls=10
+mso.user.name=infraportal
+mso.password.x=OBF:1ghz1kfx1j1w1m7w1i271e8q1eas1hzj1m4i1iyy1kch1gdz
+mso.restapi.svc.instance=/serviceInstances/v5
+mso.restapi.vnf.instance=/serviceInstances/v5/<service_instance_id>/vnfs
+mso.restapi.vnf.changemanagement.instance=/serviceInstances/v5/<service_instance_id>/vnfs/<vnf_instance_id>/<request_type>
+mso.restapi.network.instance=/serviceInstances/v5/<service_instance_id>/networks
+mso.restapi.vf.module.instance=/serviceInstances/v6/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules
+mso.restapi.vf.module.scaleout=/serviceInstantiation/v7/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules/scaleOut
+mso.restapi.volume.group.instance=/serviceInstances/v5/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups
+mso.restapi.get.orc.req=/orchestrationRequests/v5
+mso.restapi.get.orc.reqs=/orchestrationRequests/v5?
+mso.restapi.get.man.tasks=/tasks/v1
+mso.restapi.configurations=/serviceInstances/v6/<service_instance_id>/configurations
+mso.restapi.configuration.instance=${mso.restapi.configurations}<configuration_id>
+
+vid.truststore.filename=/opt/app/vid/etc/vid_keystore.jks
+mso.dme2.client.timeout=30000
+mso.dme2.client.read.timeout=120000
+
+scheduler.server.url=http://mtanjv9sdlg10.aic.cip.att.com:8989/scheduler
+scheduler.create.new.vnf.change.instance=/v1/ChangeManagement/schedules/
+scheduler.get.time.slots=/v1/ChangeManagement/schedules/
+scheduler.get.schedules=/v1/ChangeManagement/schedules/scheduleDetails/
+
+
+#vid.truststore.filename=/Users/Oren/Downloads/vid_keystore2.jks
+
+vid.truststore.passwd.x=OBF:1wgg1wfq1uus1uui1x131x0r1x1v1x1j1uvo1uve1wg81wfi
+#mso.dme2.server.url=http://mso-api-handler-anap-v1.mso.ecomp.att.com/services/ecomp/mso?
+mso.dme2.server.url=http://mso-api-handler-anap-v1.mso.ecomp.att.com/services/ecomp/mso?version=1607&envContext=TEST&routeOffer=st_mtsnj
+#mso.dme2.server.url=https://ActiveAndAvailableInventory-CloudNetwork-v1.aai.att.com/aai?version=1&envContext=DEV&routeOffer=devINT1
+mso.dme2.enabled=false
+asdc.model.namespace=org.openecomp.
+sdc.svc.api.path=sdc/v1/catalog/services
+sdc.resource.api.path=sdc/v1/catalog/resource
+
+# Application base URL has the host and app context only; a proper prefix of the on-boarded URL.
+# Only required for applications using WebJunction or FE/BE separation. For example:
+# app_base_url = https://www.e-access.att.com/app_junction/app_context/
+
diff --git a/onap-enabler-be/src/test/resources/WEB-INF/conf/system.properties.cml b/onap-enabler-be/src/test/resources/WEB-INF/conf/system.properties.cml
new file mode 100644
index 0000000..51e788e
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/WEB-INF/conf/system.properties.cml
@@ -0,0 +1,93 @@
+# Properties read by ECOMP Core library, epsdk-core.jar
+
+##########################################################################
+# The following properties should NOT be changed by partner applications.
+##########################################################################
+
+application_user_id = 30000
+post_default_role_id = 16
+clustered = true
+
+#Enable Fusion Mobile capabilities for the application
+mobile_enable = false
+
+# Cache config file is needed on the classpath
+cache_config_file_path = /WEB-INF/classes/cache.ccf
+cache_switch = 199
+cache_load_on_startup = false
+
+user_name = fullName
+decryption_key = AGLDdG4D04BKm2IxIWEr8o==
+
+##########################################################################
+# The following properties REQUIRE changes by partner applications.
+##########################################################################
+
+#Oracle
+#db.userName=quantumbd
+#db.password=c1syn2yhmr
+#db.connectionURL=jdbc:oracle:thin:@dbhost.yourcompany.com:1527:mod112a
+#db.hib.dialect=org.hibernate.dialect.Oracle10gDialect
+#db.driver=oracle.jdbc.driver.OracleDriver
+#Hibernate
+#hb.dialect=org.hibernate.dialect.Oracle10gDialect
+#hb.show_sql=true
+
+#Postgres
+#db.userName=quantumbd
+#db.password=c1syn2yhmr
+#db.connectionURL=jdbc:postgresql://dbhost.yourcompany.com:61382/quantum
+#db.hib.dialect=org.hibernate.dialect.PostgreSQLDialect
+#db.driver=org.postgresql.Driver
+#hb.dialect=org.hibernate.dialect.PostgreSQLDialect
+#hb.show_sql=true
+
+
+
+#Mysql
+db.driver = org.mariadb.jdbc.Driver
+#db.connectionURL = jdbc:mariadb://localhost:3306/vid_openecomp_epsdk
+#db.userName = ecomp_sdk_user
+#db.password = ecomp_sdk_pass
+db.hib.dialect = org.hibernate.dialect.MySQLDialect
+db.min_pool_size = 5
+db.max_pool_size = 10
+hb.dialect = org.hibernate.dialect.MySQLDialect
+# SQL statements are logged to stdout
+hb.show_sql = true
+hb.idle_connection_test_period = 3600
+
+app_display_name = EPSDK App ATT
+# license file area
+files_path = /tmp
+
+#element map files
+element_map_file_path = app/fusionapp/files/
+element_map_icon_path = app/fusionapp/icons/
+
+#Cron Schedules have 6 required fields and 1 optional field:
+# Seconds Minutes Hours Day-of-Month Month Day-of-Week Year
+log_cron = 0 0/1 * * * ?;
+
+# ECOMP Portal Shared Context REST API URL
+ecomp_shared_context_rest_url= https://www.ecomp.att.com:8080/ecompportal/context
+
+# Link shown in Help menu
+contact_us_link = https://wiki.web.att.com/display/EcompPortal/ECOMP+Portal+Home
+
+# Camunda cockpit link
+camunda_cockpit_link = https://cloopwf.client.research.att.com:8443/camunda/app/cockpit/default/#/dashboard
+
+# An Unique 128-bit value defined to identify a specific version
+# of an application deployed on a specific virtual machine.
+# This value must be generated and updated by the application
+# which is using the ECOMP SDK at the time of its deployment.
+# Online Unique UUID generator - https://www.uuidgenerator.net/
+instance_uuid=8da691c9-987d-43ed-a358-00ac2f35685d
+
+# R Cloud feature
+guard_notebook_url=https://rcloud.research.att.com/mini.html?notebook=a06a9cf14211012e221bf842c168849d&
+
+# Application base URL has the host and app context only; a proper prefix of the on-boarded URL.
+# Only required for applications using WebJunction or FE/BE separation. For example:
+# app_base_url = https://www.e-access.att.com/app_junction/app_context/
diff --git a/onap-enabler-be/src/test/resources/WEB-INF/fusion/conf/fusion.properties b/onap-enabler-be/src/test/resources/WEB-INF/fusion/conf/fusion.properties
new file mode 100644
index 0000000..b482c21
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/WEB-INF/fusion/conf/fusion.properties
@@ -0,0 +1,69 @@
+# domain settings
+#domain_class_location = com.att.fusion.domain.
+
+# validator settings
+#default_error_message = Default error message
+
+# login settings
+login_method_csp = csp
+login_method_web_junction = web_junction
+login_method_backdoor = backdoor
+login_method_attribute_name = login_method
+
+#login message
+login.error.hrid.empty = Login failed, please contact system administrator.
+login.error.hrid.not-found = User not found, please contact system administrator.
+login.error.user.inactive = Account is disabled, please contact system administrator.
+
+# CSP settings
+csp_cookie_name = attESSec
+csp_gate_keeper_data_key = MgmtSysCtr
+csp_gate_keeper_prod_key = PROD
+csp_login_url = https://www.e-access.att.com/empsvcs/hrpinmgt/pagLogin/?sysName=MgmtSysCtr&retURL=
+csp_logout_url = https://www.e-access.att.com/empsvcs/hrpinmgt/pagLogout/?retURL=
+
+authentication_mechanism = BOTH
+
+#csp_gate_keeper_prod_key = DEVL
+user_attribute_name = user
+#csp_login_url = https://www.e-access.att.com/empsvcs/hrpinmgt/pagLogin/?sysName=MgmtSysCtr&retURL=
+#csp_logout_url = https://webtest.csp.att.com/empsvcs/hrpinmgt/pagLogout/?retURL=
+
+# Web Junction settings
+#web_junction_user_id_header_name = iv-user
+
+# User Session settings
+#user_attribute_name = user
+roles_attribute_name = roles
+role_functions_attribute_name = role_functions
+role_function_list = role_function_list
+#client_device_attribute_name = client_device
+#client_device_emulation = false
+#client_device_type_to_emulate = com.att.fusion.web.clientdevice.mobile.IPhoneDevice
+
+# POST settings
+post_initial_context_factory = com.sun.jndi.ldap.LdapCtxFactory
+post_provider_url = ldap://ldap.webphone.att.com:389
+post_security_principal = ou=people,o=att,c=us
+post_max_result_size = 499
+
+# menu settings
+menu_query_name = menuData
+#menu_properties_file_location = /WEB-INF/fusion/menu/
+application_menu_set_name = APP
+application_menu_attribute_name = applicationMenuData
+#application_menu_properties_name = menu.properties
+business_direct_menu_set_name = BD
+#business_direct_menu_properties_name = bd.menu.properties
+business_direct_menu_attribute_name = businessDirectMenuData
+
+# RAPTOR config settings
+#raptor_config_file_path = /WEB-INF/conf/
+
+# Role settings
+sys_admin_role_id = 1
+#sys_admin_role_function_delete_from_ui = true
+
+# Profile Search settings
+#profile_search_report_id=181
+#callable_profile_search_report_id=386
diff --git a/onap-enabler-be/src/test/resources/asdc.properties b/onap-enabler-be/src/test/resources/asdc.properties
new file mode 100644
index 0000000..bbe736d
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/asdc.properties
@@ -0,0 +1,6 @@
+asdc.client.type=LOCAL
+
+asdc.client.rest.protocol=http
+asdc.client.rest.host=c2.vm1.sdc.simpledemo.openecomp.org
+asdc.client.rest.port=8080
+asdc.client.rest.auth=Basic dmlkOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU=
diff --git a/onap-enabler-be/src/test/resources/cr-csar.JSON b/onap-enabler-be/src/test/resources/cr-csar.JSON
new file mode 100644
index 0000000..326ec16
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/cr-csar.JSON
@@ -0,0 +1,77 @@
+{
+ "service": {
+ "uuid": "76f27dfe-33e5-472f-8e0b-acf524adc4f0",
+ "invariantUuid": "c3618e16-bb5b-433a-a6e0-565ca79d8b65",
+ "name": "MSO_Example_Service",
+ "version": "1.0",
+ "toscaModelURL": null,
+ "category": "Network L4+",
+ "serviceType": "",
+ "serviceRole": "",
+ "description": "MSO_Example_Service",
+ "serviceEcompNaming": "true",
+ "instantiationType": "ClientConfig",
+ "inputs": {
+
+ }
+ },
+ "vnfs": {
+
+ },
+ "networks": {
+
+ },
+ "collectionResource": {
+ "MSO_Example 0": {
+ "uuid": "4f8068d9-fb13-49fc-9e39-634d2094b659",
+ "invariantUuid": "2fc1b3b8-b8ed-413e-add8-3d903cf2b458",
+ "description": "MSO_Example",
+ "name": "MSO_Example",
+ "version": "0.2",
+ "customizationUuid": "fffc356d-9e95-4d9c-aa64-7273f33aae84",
+ "inputs": null,
+ "commands": {
+
+ },
+ "properties": {
+ "MSO_Example..NetworkCollection..0_network_collection_function": "fffff",
+ "MSO_Example..NetworkCollection..0_network_collection_description": "ddd",
+ "MSO_Example..Fixed..0_quantity": "89"
+ },
+ "type": "CR",
+ "category": "Network L2-3",
+ "subcategory": "Infrastructure",
+ "resourceVendor": "cisco",
+ "customizationUUID": "fffc356d-9e95-4d9c-aa64-7273f33aae84",
+ "resourceVendorRelease": "1.0",
+ "resourceVendorModelNumber": "",
+ "networksCollection": {
+ "MSO_Example..NetworkCollection..0": {
+ "uuid": "f4cb3cb6-a45d-474d-9af8-f4ae2e733ef7",
+ "invariantUuid": "f3cf3727-f779-4721-b989-851722c64ca4",
+ "name": "MSO_Example..NetworkCollection..0",
+ "version": "1",
+ "networkCollectionProperties": {
+ "networkCollectionFunction": "fffff",
+ "networkCollectionDescription": "ddd"
+ }
+ }
+ }
+ }
+ },
+ "configurations": {
+
+ },
+ "serviceProxies": {
+
+ },
+ "vfModules": {
+
+ },
+ "volumeGroups": {
+
+ },
+ "pnfs": {
+
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/csv_files/csv_to_json.csv b/onap-enabler-be/src/test/resources/csv_files/csv_to_json.csv
new file mode 100644
index 0000000..2e0f41d
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/csv_files/csv_to_json.csv
@@ -0,0 +1,99 @@
+payload,request-parameters,,,vnf-name,ibcx0099v
+payload,request-parameters,[vm],,vm-name,ibcx0001vm001
+payload,request-parameters,[vm],[vnfc],vnfc-name,ibcx0001vm001dbg001
+payload,request-parameters,[vm],[vnfc],vnfc-function-code,dbg
+payload,request-parameters,[vm],[vnfc],vnfc-type,DBE-VM #1
+payload,request-parameters,[vm],[vnfc],group-notation,ibcx0001vm001dbg001pair
+payload,request-parameters,[vm],[vnfc],ipaddress-v4-oam-vip,135.21.166.39
+payload,request-parameters,[vm],,vm-name,ibcx0001vm002
+payload,request-parameters,[vm],[vnfc],vnfc-name,ibcx0001vm002dbg001
+payload,request-parameters,[vm],[vnfc],vnfc-function-code,dbg
+payload,request-parameters,[vm],[vnfc],vnfc-type,DBE-VM #1
+payload,request-parameters,[vm],[vnfc],group-notation,ibcx0001vm001dbg001pair
+,,,,,
+payload,request-parameters,,,template-name,vdbe_template1
+payload,configuration,,,configuration-string," <configuration xmlns=""http://xml.juniper.net/xnm/1.1/xnm""
+ xmlns:a=""http://xml.juniper.net/junos/15.1X49/junos"" >
+ <version>15.1X49-D50.3</version>
+ <groups>
+ <name>node0</name>
+ <system>
+ <host-name>$node0_hostname</host-name>
+ <backup-router>
+ <address>$node0_backup_router_address</address>
+ <destination>0.0.0.0/0</destination>
+ </backup-router>
+ </system>
+ </groups>
+ </configuration>"
+payload,configuration,,,configuration-json,"{
+ ""version"": ""15.1X49-D50.3"",
+ ""groups"": {
+ ""name"": ""node0"",
+ ""system"": {
+ ""host-name"": ""$node0_hostname"",
+ ""backup-router"": {
+ ""address"": ""$node0_backup_router_address"",
+ ""destination"": ""0.0.0.0/0""
+ }
+ }
+ }
+}"
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+payload,configuration-parameters,nat_source_sp_v6rogerssnat_address1,2001:1890:fc45:f025:135:25:246:c806/128
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
diff --git a/onap-enabler-be/src/test/resources/csv_files/empty_file.csv b/onap-enabler-be/src/test/resources/csv_files/empty_file.csv
new file mode 100644
index 0000000..e7bc056
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/csv_files/empty_file.csv
@@ -0,0 +1,18 @@
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
+,,,,,
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/csv_files/missing_content.csv b/onap-enabler-be/src/test/resources/csv_files/missing_content.csv
new file mode 100644
index 0000000..0c02fc8
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/csv_files/missing_content.csv
@@ -0,0 +1,2 @@
+payload,request-parameters,,,ibcx0099v
+payload,request-parameters,,aa,vv
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/csv_files/missing_values.csv b/onap-enabler-be/src/test/resources/csv_files/missing_values.csv
new file mode 100644
index 0000000..9a2a8d6
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/csv_files/missing_values.csv
@@ -0,0 +1,2 @@
+payload,,,,,
+payload,request-parameters,,aa,vv
diff --git a/onap-enabler-be/src/test/resources/csv_files/one_line.csv b/onap-enabler-be/src/test/resources/csv_files/one_line.csv
new file mode 100644
index 0000000..315e939
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/csv_files/one_line.csv
@@ -0,0 +1 @@
+payload,request-parameters,,,vnf-name,ibcx0099v
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/git.properties b/onap-enabler-be/src/test/resources/git.properties
new file mode 100644
index 0000000..ada0a47
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/git.properties
@@ -0,0 +1,3 @@
+git.commit.id=123987
+git.commit.message.short=Test short commit message
+git.commit.time=1999-09-12T13\:48\:55+0200
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/mso.properties b/onap-enabler-be/src/test/resources/mso.properties
new file mode 100644
index 0000000..b58ba56
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/mso.properties
@@ -0,0 +1,17 @@
+mso.server.url=http://mtanjv9moah01-eth0.aic.cip.att.com:8080/ecomp/mso/infra
+mso.polling.interval.msecs=2000
+mso.max.polls=3
+mso.user.name=infraportal
+mso.password.x=OBF:1ghz1kfx1j1w1m7w1i271e8q1eas1hzj1m4i1iyy1kch1gdz
+mso.restapi.svc.instance=/serviceInstances/v3
+mso.restapi.vnf.instance=/serviceInstances/v3/<service_instance_id>/vnfs
+mso.restapi.network.instance=/serviceInstances/v3/<service_instance_id>/networks
+mso.restapi.vf.module.instance=/serviceInstantiation/v7/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules/scaleOut
+mso.restapi.volume.group.instance=/serviceInstances/v3/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups
+mso.restapi.configurations=/serviceInstances/v6/<service_instance_id>/configurations
+mso.restapi.get.orc.req=/orchestrationRequests/v3
+mso.restapi.get.orc.reqs=/orchestrationRequests/v3?
+mso.restapi.get.man.tasks=/tasks/v1
+mso.dme2.client.timeout=30000
+mso.dme2.client.read.timeout=120000
+mso.dme2.server.url=http://mso-api-handler-anap-v1.mso.ecomp.att.com/services/ecomp/mso?version=1607&envContext=TEST&routeOffer=st_mtsnj
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/msoRequest.json b/onap-enabler-be/src/test/resources/msoRequest.json
new file mode 100644
index 0000000..f7f0a82
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/msoRequest.json
@@ -0,0 +1,25 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "instanceName": "KLKLKL",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "1"
+ },
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "709d1be4-9a3f-4a29-8c4d-a20465e808a3",
+ "modelVersionId": "1de57bcf-365a-4ba7-8a51-7377b7144586",
+ "modelName": "1707vidnf",
+ "modelVersion": "2.0"
+ },
+ "requestParameters": {
+ "userParams": [],
+ "subscriptionServiceType": "HNGATEWAY",
+ "aLaCarte": true
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "21014aa2-9e71128cae7-jl319x"
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/objectconfig.properties b/onap-enabler-be/src/test/resources/objectconfig.properties
new file mode 100644
index 0000000..0093129
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/objectconfig.properties
@@ -0,0 +1,18 @@
+baseURL=http://vid.onap.org:9080/vid/login_external.htm
+
+
+
+login=//input[@class='fn-ebz-text ng-pristine ng-valid']
+pwd=//input[@class='span3 ng-pristine ng-valid']
+loginButton=loginBtn
+
+
+profilelink=html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[5]/a/span
+refreshButtonSubscriberName=//img[@src='static/fusion/images/refresh.jpg']
+
+subscriberNameDropDown=.//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select
+serviceTypeDropDown=.//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select
+submitButton=.//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button
+
+test.loginId=2222
+test.loginPassword=2222
diff --git a/onap-enabler-be/src/test/resources/payload_jsons/activateOperationalEnvironmentsPayloadToMso.json b/onap-enabler-be/src/test/resources/payload_jsons/activateOperationalEnvironmentsPayloadToMso.json
new file mode 100644
index 0000000..c6a8cf7
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/payload_jsons/activateOperationalEnvironmentsPayloadToMso.json
@@ -0,0 +1,23 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "resourceType": "operationalEnvironment",
+ "source": "VID",
+ "requestorId": "<userId>"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "resourceType": "operationalEnvironment",
+ "instanceId": "<relatedInstanceId>",
+ "instanceName": "<relatedInstanceName>"
+ }
+ }
+ ],
+ "requestParameters": {
+ "operationalEnvironmentType": "VNF",
+ "workloadContext": "<workloadContext>",
+ "manifest": <manifest>
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/payload_jsons/bulk_service_request.json b/onap-enabler-be/src/test/resources/payload_jsons/bulk_service_request.json
new file mode 100644
index 0000000..e57c5a9
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/payload_jsons/bulk_service_request.json
@@ -0,0 +1,95 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelName": "MOW AVPN vMX BV vPE 1 Service",
+ "modelVersion": "10.0"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "{some project name}"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "{some subscriber id}"
+ },
+ "requestInfo": {
+ "instanceName": "vPE_Service",
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": true,
+ "requestorId": "az2016"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "VMX",
+ "aLaCarte": false,
+ "userParams": [{
+ "service": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MOW AVPN vMX BV vPE 1 Service",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a"
+ },
+ "instanceName": "vPE_Service",
+ "instanceParams": [{
+ "instanceParams_test1": "some text",
+ "instanceParams_test2": "another text"
+ }],
+ "resources": {
+ "vnfs": [{
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "2016-73_MOW-AVPN-vPE-BV-L",
+ "modelVersionId": "7f40c192-f63c-463e-ba94-286933b895f8",
+ "modelCustomizationName": "2016-73_MOW-AVPN-vPE-BV-L 0",
+ "modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "platform": {
+ "platformName": "platformName"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "lineOfBusinessName"
+ },
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "instanceName": "vmxnjr001",
+ "instanceParams": [],
+ "vfModules": [{
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0",
+ "modelVersionId": "4c75f813-fa91-45a4-89d0-790ff5f1ae79",
+ "modelCustomizationId": "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"
+ },
+ "instanceName": "vmxnjr001_AVPN_base_vPE_BV_base_001",
+ "instanceParams": [{
+ "vmx_int_net_len": "24"
+ }]
+ },
+ {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1",
+ "modelVersionId": "56e2b103-637c-4d1a-adc8-3a7f4a6c3240",
+ "modelCustomizationId": "72d9d1cd-f46d-447a-abdb-451d6fb05fa8"
+ },
+ "instanceName": "vmxnjr001_AVPN_base_vRE_BV_expansion_001",
+ "instanceParams": [{
+ "availability_zone_0": "mtpocdv-kvm-az01",
+ "vre_a_volume_size_0": "100"
+ }]
+ }]
+ }]
+ }
+ }
+ }]
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json b/onap-enabler-be/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json
new file mode 100644
index 0000000..52e9b54
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json
@@ -0,0 +1,90 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelName": "MOW AVPN vMX BV vPE 1 Service",
+ "modelVersion": "10.0"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "{some project name}"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "{some subscriber id}"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "az2016"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "VMX",
+ "aLaCarte": false,
+ "userParams": [{
+ "service": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MOW AVPN vMX BV vPE 1 Service",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a"
+ },
+ "instanceParams": [{
+ "instanceParams_test1": "some text",
+ "instanceParams_test2": "another text"
+ }],
+ "resources": {
+ "vnfs": [{
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "2016-73_MOW-AVPN-vPE-BV-L",
+ "modelVersionId": "7f40c192-f63c-463e-ba94-286933b895f8",
+ "modelCustomizationName": "2016-73_MOW-AVPN-vPE-BV-L 0",
+ "modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "platform": {
+ "platformName": "platformName"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "lineOfBusinessName"
+ },
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "instanceParams": [],
+ "vfModules": [{
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0",
+ "modelVersionId": "4c75f813-fa91-45a4-89d0-790ff5f1ae79",
+ "modelCustomizationId": "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"
+ },
+ "instanceParams": [{
+ "vmx_int_net_len": "24"
+ }]
+ },
+ {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1",
+ "modelVersionId": "56e2b103-637c-4d1a-adc8-3a7f4a6c3240",
+ "modelCustomizationId": "72d9d1cd-f46d-447a-abdb-451d6fb05fa8"
+ },
+ "instanceParams": [{
+ "availability_zone_0": "mtpocdv-kvm-az01",
+ "vre_a_volume_size_0": "100"
+ }]
+ }]
+ }]
+ }
+ }
+ }]
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json b/onap-enabler-be/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json
new file mode 100644
index 0000000..3640593
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json
@@ -0,0 +1,67 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelName": "MOW AVPN vMX BV vPE 1 Service",
+ "modelVersion": "10.0"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "{some project name}"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "{some subscriber id}"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "az2016"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "VMX",
+ "aLaCarte": false,
+ "userParams": [{
+ "service": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MOW AVPN vMX BV vPE 1 Service",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a"
+ },
+ "instanceParams": [{
+ "instanceParams_test1": "some text",
+ "instanceParams_test2": "another text"
+ }],
+ "resources": {
+ "vnfs": [{
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "2016-73_MOW-AVPN-vPE-BV-L",
+ "modelVersionId": "7f40c192-f63c-463e-ba94-286933b895f8",
+ "modelCustomizationName": "2016-73_MOW-AVPN-vPE-BV-L 0",
+ "modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "platform": {
+ "platformName": "platformName"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "lineOfBusinessName"
+ },
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "instanceParams": []
+ }]
+ }
+ }
+ }]
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/payload_jsons/bulk_service_request_unique_names.json b/onap-enabler-be/src/test/resources/payload_jsons/bulk_service_request_unique_names.json
new file mode 100644
index 0000000..e6c58b9
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/payload_jsons/bulk_service_request_unique_names.json
@@ -0,0 +1,96 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelName": "MOW AVPN vMX BV vPE 1 Service",
+ "modelVersion": "10.0"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "{some project name}"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "{some subscriber id}"
+ },
+ "requestInfo": {
+ "instanceName": "vPE_Service_{SERVICE_UNIQENESS}",
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": true,
+ "requestorId": "az2016"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "VMX",
+ "aLaCarte": false,
+ "userParams": [{
+ "service": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MOW AVPN vMX BV vPE 1 Service",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a"
+ },
+ "instanceName": "vPE_Service_{SERVICE_UNIQENESS}",
+ "instanceParams": [{
+ "instanceParams_test1": "some text",
+ "instanceParams_test2": "another text"
+ }],
+ "resources": {
+ "vnfs": [{
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "2016-73_MOW-AVPN-vPE-BV-L",
+ "modelVersionId": "7f40c192-f63c-463e-ba94-286933b895f8",
+ "modelCustomizationName": "2016-73_MOW-AVPN-vPE-BV-L 0",
+ "modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "platform": {
+ "platformName": "platformName"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "lineOfBusinessName"
+ },
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "instanceName": "vmxnjr001_{VNF_UNIQENESS}",
+ "instanceParams": [],
+ "vfModules": [{
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0",
+ "modelVersionId": "4c75f813-fa91-45a4-89d0-790ff5f1ae79",
+ "modelCustomizationId": "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"
+ },
+ "instanceName": "vmxnjr001_AVPN_base_vPE_BV_base_{VF_MODULE_UNIQENESS}",
+ "instanceParams": [{
+ "vmx_int_net_len": "24"
+ }]
+ },
+ {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1",
+ "modelVersionId": "56e2b103-637c-4d1a-adc8-3a7f4a6c3240",
+ "modelCustomizationId": "72d9d1cd-f46d-447a-abdb-451d6fb05fa8"
+ },
+ "instanceName": "vmxnjr001_AVPN_base_vRE_BV_expansion_{VF_MODULE_2_UNIQENESS}",
+ "volumeGroupInstanceName" : "myVgName_{VG_UNIQUENESS}",
+ "instanceParams": [{
+ "availability_zone_0": "mtpocdv-kvm-az01",
+ "vre_a_volume_size_0": "100"
+ }]
+ }]
+ }]
+ }
+ }
+ }]
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/payload_jsons/createOperationalEnvironmentsPayloadToMso.json b/onap-enabler-be/src/test/resources/payload_jsons/createOperationalEnvironmentsPayloadToMso.json
new file mode 100644
index 0000000..3a96bb9
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/payload_jsons/createOperationalEnvironmentsPayloadToMso.json
@@ -0,0 +1,24 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "resourceType": "operationalEnvironment",
+ "instanceName": "<instanceName>",
+ "source": "VID",
+ "requestorId": "<userId>"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "resourceType": "operationalEnvironment",
+ "instanceId": "<ecompInstanceId>",
+ "instanceName": "<ecompInstanceName>"
+ }
+ }
+ ],
+ "requestParameters": {
+ "operationalEnvironmentType": "<operationalEnvType>",
+ "tenantContext": "<tenantContext>",
+ "workloadContext": "<workloadContext>"
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/payload_jsons/deactivateOperationalEnvironmentsPayloadToMso.json b/onap-enabler-be/src/test/resources/payload_jsons/deactivateOperationalEnvironmentsPayloadToMso.json
new file mode 100644
index 0000000..38c2224
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/payload_jsons/deactivateOperationalEnvironmentsPayloadToMso.json
@@ -0,0 +1,12 @@
+{
+ "requestDetails": {
+ "requestInfo": {
+ "resourceType": "operationalEnvironment",
+ "source": "VID",
+ "requestorId": "<userId>"
+ },
+ "requestParameters": {
+ "operationalEnvironmentType": "VNF"
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/payload_jsons/mso_request_create_configuration.json b/onap-enabler-be/src/test/resources/payload_jsons/mso_request_create_configuration.json
new file mode 100644
index 0000000..5502e8f
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/payload_jsons/mso_request_create_configuration.json
@@ -0,0 +1,62 @@
+
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "configuration",
+ "modelInvariantId": "c30a024e-a6c6-4670-b73c-3df64eb57ff6",
+ "modelVersionId": "f58d039d-4cfc-40ec-bd75-1f05f0458a6c",
+ "modelName": "Port Mirroring Configuration By Policy",
+ "modelVersion": "1.0",
+ "modelCustomizationId": "4b7ebace-bad6-4526-9be6-bf248e20fc5f",
+ "modelCustomizationName": "Port Mirroring Configuration By Policy 1"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "AAIAIC25"
+ },
+ "requestInfo": {
+ "instanceName":"test_sssdad",
+ "source": "VID",
+ "requestorId": "1"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "c187e9fe-40c3-4862-b73e-84ff056205f6 ",
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "b7d923c9-6175-41f1-91ba-4565c4953408",
+ "modelVersionId": "ee6d61be-4841-4f98-8f23-5de9da846ca7",
+ "modelName": "ServiceContainerMultiplepProbes",
+ "modelVersion": "1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "9be14a4f-7367-4cf9-96a1-f08f10f485a7",
+ "instanceDirection": "source",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelInvariantId": "a7eac2b3-8444-40ee-92e3-b3359b32445c",
+ "modelVersionId": "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6",
+ "modelName": "vmmeService2",
+ "modelVersion": "1.0",
+ "modelCustomizationId": "060be63d-5f9c-4fd0-8ef7-830d5e8eca17"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "AS-pnf2-10219--as988q",
+ "instanceDirection": "destination",
+ "modelInfo": {
+ "modelType": "pnf"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": []
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/payload_jsons/mso_service_instantiation.json b/onap-enabler-be/src/test/resources/payload_jsons/mso_service_instantiation.json
new file mode 100644
index 0000000..115a715
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/payload_jsons/mso_service_instantiation.json
@@ -0,0 +1,95 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "Test",
+ "modelVersion": "1.0"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "TODO"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "TODO",
+ "subscriberName": "TODO"
+ },
+ "requestInfo": {
+ "productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": true,
+ "requestorId": "az2016"
+ },
+ "requestParameters": {
+ "subscriptionServiceType":"MOG",
+ "aLaCarte": false,
+ "userParams": [{
+ "name": "TODO",
+ "value": "TODO"
+ }
+ ]
+ }
+ }
+}
+/*
+{
+ "modelInfo":{
+ "modelType":"service",
+ "modelInvariantId":"5d48acb5-097d-4982-aeb2-f4a3bd87d31b",
+ "modelVersionId":"3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelName":"MOW AVPN vMX BV vPE 1 Service",
+ "modelVersion":"10.0"
+ },
+ "owningEntityId":"038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName":"PACKET CORE",
+ "projectName":"{some project name}",
+ "globalSubscriberId":"{some subscriber id}",
+ "productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "instanceName":"vPE_Service",
+ "subscriptionServiceType":"VMX",
+ "lcpCloudRegionId":"mdt1",
+ "tenantId":"88a6ca3ee0394ade9403f075db23167e",
+ "vnfs":[
+ {
+ "modelInfo":{
+ "modelName":"2016-73_MOW-AVPN-vPE-BV-L",
+ "modelVersionId":"7f40c192-f63c-463e-ba94-286933b895f8",
+ "modelCustomizationName":"2016-73_MOW-AVPN-vPE-BV-L 0",
+ "modelCustomizationId":"ab153b6e-c364-44c0-bef6-1f2982117f04"
+ },
+ "lcpCloudRegionId":"mdt1",
+ "tenantId":"88a6ca3ee0394ade9403f075db23167e",
+ "platformName":"test",
+ "productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "instanceName":"vmxnjr001",
+ "instanceParams":[
+
+ ],
+ "vfModules":[
+ {
+ "modelInfo":{
+ "modelType":"vfModule",
+ "modelName":"201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0",
+ "modelVersionId":"4c75f813-fa91-45a4-89d0-790ff5f1ae79",
+ "modelCustomizationId":"a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"
+ },
+ "instanceName":"vmxnjr001_AVPN_base_vPE_BV_base_001",
+ "instanceParams":[
+ {
+ "vmx_int_net_len":"24"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
+*/
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/payload_jsons/scaleOutVfModulePayload.json b/onap-enabler-be/src/test/resources/payload_jsons/scaleOutVfModulePayload.json
new file mode 100644
index 0000000..5fde429
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/payload_jsons/scaleOutVfModulePayload.json
@@ -0,0 +1,67 @@
+{
+ "vnfName":"test",
+ "vnfInstanceId":"123",
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b",
+ "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelName": "ws-service",
+ "modelVersion": "1.0",
+ "additionalProperties": {}
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687",
+ "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelName": "ws-sp",
+ "modelVersion": "1.0",
+ "modelCustomizationName": "ws-sp 0",
+ "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+ "additionalProperties": {}
+ }
+ }
+ }
+ ],
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "RegionOne",
+ "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e",
+ "additionalProperties": {}
+ },
+ "modelInfo": {
+ "modelCustomizationName": "WsSp..base_ws..module-0",
+ "modelCustomizationId": "bfcc8f57-7b56-4be8-a8f1-e44262c83318",
+ "modelInvariantId": "763b1172-b5f5-4062-9d79-2459710fa0bc",
+ "modelVersionId": "53f52586-236b-4d52-a94c-990883e054f0",
+ "modelName": "WsSp..base_ws..module-0",
+ "modelNameVersionId": null,
+ "modelType": "vfModule",
+ "modelVersion": "1",
+ "additionalProperties": {}
+ },
+ "requestInfo": {
+ "instanceName": "ws-test-0310-8_NaN",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "demo",
+ "additionalProperties": {}
+ },
+ "requestParameters": {
+ "additionalProperties": {}
+ },
+ "configurationParameters": [
+ {
+ "availability-zone": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]",
+ "xtz-123": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/payload_jsons/scaleOutVfModulePayloadToMso.json b/onap-enabler-be/src/test/resources/payload_jsons/scaleOutVfModulePayloadToMso.json
new file mode 100644
index 0000000..5409f89
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/payload_jsons/scaleOutVfModulePayloadToMso.json
@@ -0,0 +1,66 @@
+{
+ "requestDetails": {
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "fd84f066-ea75-4b23-acd0-3cf3fce7a99b",
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "c9817f08-07b2-458b-a02f-cd5407ee7a7b",
+ "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelName": "ws-service",
+ "modelVersion": "1.0",
+ "additionalProperties": {}
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "980fe98e-47f8-4164-862d-4ebb026cec75",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelInvariantId": "734f0952-6678-44e7-8918-f9aa4694b687",
+ "modelVersionId": "0e0bb964-e687-4439-9a9e-de9cd1ff5367",
+ "modelName": "ws-sp",
+ "modelVersion": "1.0",
+ "modelCustomizationName": "ws-sp 0",
+ "modelCustomizationId": "5815868c-35f8-4c5a-b899-e6eb49f52986",
+ "additionalProperties": {}
+ }
+ }
+ }
+ ],
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "RegionOne",
+ "tenantId": "1e097c6713e74fd7ac8e4295e605ee1e",
+ "additionalProperties": {}
+ },
+ "modelInfo": {
+ "modelCustomizationName": "WsSp..base_ws..module-0",
+ "modelCustomizationId": "bfcc8f57-7b56-4be8-a8f1-e44262c83318",
+ "modelInvariantId": "763b1172-b5f5-4062-9d79-2459710fa0bc",
+ "modelVersionId": "53f52586-236b-4d52-a94c-990883e054f0",
+ "modelName": "WsSp..base_ws..module-0",
+ "modelNameVersionId": null,
+ "modelType": "vfModule",
+ "modelVersion": "1",
+ "additionalProperties": {}
+ },
+ "requestInfo": {
+ "instanceName": "ws-test-0310-8_NaN",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "demo",
+ "additionalProperties": {}
+ },
+ "requestParameters": {
+ "additionalProperties": {}
+ },
+ "configurationParameters": [
+ {
+ "availability-zone": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]",
+ "xtz-123": "$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/pnf.csar b/onap-enabler-be/src/test/resources/pnf.csar
new file mode 100644
index 0000000..eb42484
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/pnf.csar
Binary files differ
diff --git a/onap-enabler-be/src/test/resources/policy-configuration-by-policy-false.JSON b/onap-enabler-be/src/test/resources/policy-configuration-by-policy-false.JSON
new file mode 100644
index 0000000..648ff70
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/policy-configuration-by-policy-false.JSON
@@ -0,0 +1,166 @@
+{
+ "service": {
+ "uuid": "ee6d61be-4841-4f98-8f23-5de9da845544",
+ "invariantUuid": "b7d923c9-6175-41f1-91ba-4565c4955555",
+ "name": "ServiceContainerMultiplepProbes2",
+ "version": "2.0",
+ "toscaModelURL": null,
+ "category": "Network L1-3",
+ "serviceType": "portMirroring",
+ "serviceRole": "pProbe",
+ "description": "sdfsdfsdf",
+ "serviceEcompNaming": "true",
+ "inputs": {}
+ },
+ "vnfs": {},
+ "networks": {},
+ "configurations": {
+ "Port Mirroring Configuration By Policy 1": {
+ "uuid": "f58d039d-4cfc-40ec-bd75-1f05f0434567",
+ "invariantUuid": "c30a024e-a6c6-4670-b73c-3df64eb57ff6",
+ "description": "A port mirroring configuration by policy object",
+ "name": "Port Mirroring Configuration By Policy",
+ "version": "1.0",
+ "customizationUuid": "4b7ebace-bad6-4526-9be6-bf248e20fc5f",
+ "inputs": {},
+ "commands": {},
+ "properties": {
+ "collector_node": "pprobeservice_proxy 5",
+ "policy_name": "policy2",
+ "equip_vendor": "Cisco",
+ "equip_model": "Nexus 3048-TP"
+ },
+ "type": "Configuration",
+ "modelCustomizationName": "Port Mirroring Configuration By Policy 1",
+ "sourceNodes": [
+ "vmmeservice2_proxy 2",
+ "vmmeservice2_proxy 3"
+ ],
+ "collectorNodes": [
+ "pprobeservice_proxy 5"
+ ],
+ "configurationByPolicy": false
+ },
+ "Port Mirroring Configuration By Policy 0": {
+ "uuid": "f58d039d-4cfc-40ec-bd75-1f05f0458a6c",
+ "invariantUuid": "c30a024e-a6c6-4670-b73c-3df64eb57ff6",
+ "description": "A port mirroring configuration by policy object",
+ "name": "Port Mirroring Configuration By Policy",
+ "version": "1.0",
+ "customizationUuid": "08a181aa-72eb-435f-9593-e88a3ad0a86b",
+ "inputs": {},
+ "commands": {},
+ "properties": {
+ "collector_node": "pprobeservice_proxy 4",
+ "policy_name": "policy1",
+ "equip_vendor": "Cisco",
+ "equip_model": "Nexus 3048-TP"
+ },
+ "type": "Configuration",
+ "modelCustomizationName": "Port Mirroring Configuration By Policy 0",
+ "sourceNodes": [
+ "vmmeservice2_proxy 2",
+ "vmmeservice_proxy 1",
+ "vmmeservice_proxy 0"
+ ],
+ "collectorNodes": [
+ ],
+ "configurationByPolicy": true
+ }
+ },
+ "serviceProxies": {
+ "vmmeservice_proxy 0": {
+ "uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
+ "invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
+ "description": "A Proxy for Service vmmeService",
+ "name": "vmmeService Service Proxy",
+ "version": "1.0",
+ "customizationUuid": "d7cfe338-eeda-4217-ba13-f24b0811fb17",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "Service Proxy",
+ "sourceModelUuid": "c3e6c9bd-b24d-458e-aa99-e0cadf70c5e5",
+ "sourceModelInvariant": "dd8a805d-3946-4f11-9831-e26cd6aec9a3",
+ "sourceModelName": "vmmeService"
+ },
+ "vmmeservice_proxy 1": {
+ "uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
+ "invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
+ "description": "A Proxy for Service vmmeService",
+ "name": "vmmeService Service Proxy",
+ "version": "1.0",
+ "customizationUuid": "7a69f133-564c-4eb6-b93e-0a8281967efb",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "Service Proxy",
+ "sourceModelUuid": "c3e6c9bd-b24d-458e-aa99-e0cadf70c5e5",
+ "sourceModelInvariant": "dd8a805d-3946-4f11-9831-e26cd6aec9a3",
+ "sourceModelName": "vmmeService"
+ },
+ "vmmeservice2_proxy 3": {
+ "uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
+ "invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
+ "description": "A Proxy for Service vmmeService2",
+ "name": "vmmeService2 Service Proxy",
+ "version": "1.0",
+ "customizationUuid": "9d81c21f-e29c-44f6-b5f6-caa974ee078a",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "Service Proxy",
+ "sourceModelUuid": "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6",
+ "sourceModelInvariant": "a7eac2b3-8444-40ee-92e3-b3359b32445c",
+ "sourceModelName": "vmmeService2"
+ },
+ "pprobeservice_proxy 4": {
+ "uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
+ "invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
+ "description": "A Proxy for Service pProbeService",
+ "name": "pProbeService Service Proxy",
+ "version": "1.0",
+ "customizationUuid": "271efa3b-276e-4536-976a-cc9c9c014f1e",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "Service Proxy",
+ "sourceModelUuid": "8a84e59b-45fe-4851-8ff1-34225a0b32c3",
+ "sourceModelInvariant": "83b458fd-5dd3-419b-a9e3-7335814a0911",
+ "sourceModelName": "pProbeService"
+ },
+ "pprobeservice_proxy 5": {
+ "uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
+ "invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
+ "description": "A Proxy for Service pProbeService",
+ "name": "pProbeService Service Proxy",
+ "version": "1.0",
+ "customizationUuid": "d64623ae-5935-4afd-803e-c86e94d8e740",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "Service Proxy",
+ "sourceModelUuid": "8a84e59b-45fe-4851-8ff1-34225a0b32c3",
+ "sourceModelInvariant": "83b458fd-5dd3-419b-a9e3-7335814a0911",
+ "sourceModelName": "pProbeService"
+ },
+ "vmmeservice2_proxy 2": {
+ "uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
+ "invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
+ "description": "A Proxy for Service vmmeService2",
+ "name": "vmmeService2 Service Proxy",
+ "version": "1.0",
+ "customizationUuid": "060be63d-5f9c-4fd0-8ef7-830d5e8eca17",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "Service Proxy",
+ "sourceModelUuid": "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6",
+ "sourceModelInvariant": "a7eac2b3-8444-40ee-92e3-b3359b32445c",
+ "sourceModelName": "vmmeService2"
+ }
+ },
+ "vfModules": {},
+ "volumeGroups": {},
+ "pnfs": {}
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/policy-configuration-csar.JSON b/onap-enabler-be/src/test/resources/policy-configuration-csar.JSON
new file mode 100644
index 0000000..77f2685
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/policy-configuration-csar.JSON
@@ -0,0 +1,168 @@
+{
+ "service": {
+ "uuid": "ee6d61be-4841-4f98-8f23-5de9da846ca7",
+ "invariantUuid": "b7d923c9-6175-41f1-91ba-4565c4953408",
+ "name": "ServiceContainerMultiplepProbes",
+ "version": "1.0",
+ "toscaModelURL": null,
+ "category": "Network L1-3",
+ "serviceType": "portMirroring",
+ "serviceRole": "pProbe",
+ "description": "sdfsdfsdf",
+ "serviceEcompNaming": "true",
+ "inputs": {}
+ },
+ "vnfs": {},
+ "networks": {},
+ "configurations": {
+ "Port Mirroring Configuration By Policy 1": {
+ "uuid": "f58d039d-4cfc-40ec-bd75-1f05f0458a6c",
+ "invariantUuid": "c30a024e-a6c6-4670-b73c-3df64eb57ff6",
+ "description": "A port mirroring configuration by policy object",
+ "name": "Port Mirroring Configuration By Policy",
+ "version": "1.0",
+ "customizationUuid": "4b7ebace-bad6-4526-9be6-bf248e20fc5f",
+ "inputs": {},
+ "commands": {},
+ "properties": {
+ "collector_node": "pprobeservice_proxy 5",
+ "policy_name": "policy2",
+ "equip_vendor": "Cisco",
+ "equip_model": "Nexus 3048-TP"
+ },
+ "type": "Configuration",
+ "modelCustomizationName": "Port Mirroring Configuration By Policy 1",
+ "sourceNodes": [
+ "vmmeservice2_proxy 2",
+ "vmmeservice2_proxy 3",
+ "vmmeservice_proxy 1"
+ ],
+ "collectorNodes": [
+ "pprobeservice_proxy 5"
+ ],
+ "configurationByPolicy": true
+ },
+ "Port Mirroring Configuration By Policy 0": {
+ "uuid": "f58d039d-4cfc-40ec-bd75-1f05f0458a6c",
+ "invariantUuid": "c30a024e-a6c6-4670-b73c-3df64eb57ff6",
+ "description": "A port mirroring configuration by policy object",
+ "name": "Port Mirroring Configuration By Policy",
+ "version": "1.0",
+ "customizationUuid": "08a181aa-72eb-435f-9593-e88a3ad0a86b",
+ "inputs": {},
+ "commands": {},
+ "properties": {
+ "collector_node": "pprobeservice_proxy 4",
+ "policy_name": "policy1",
+ "equip_vendor": "Cisco",
+ "equip_model": "Nexus 3048-TP"
+ },
+ "type": "Configuration",
+ "modelCustomizationName": "Port Mirroring Configuration By Policy 0",
+ "sourceNodes": [
+ "vmmeservice2_proxy 2",
+ "vmmeservice_proxy 1",
+ "vmmeservice_proxy 0"
+ ],
+ "collectorNodes": [
+ "pprobeservice_proxy 4"
+ ],
+ "configurationByPolicy": true
+ }
+ },
+ "serviceProxies": {
+ "vmmeservice_proxy 0": {
+ "uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
+ "invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
+ "description": "A Proxy for Service vmmeService",
+ "name": "vmmeService Service Proxy",
+ "version": "1.0",
+ "customizationUuid": "d7cfe338-eeda-4217-ba13-f24b0811fb17",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "Service Proxy",
+ "sourceModelUuid": "c3e6c9bd-b24d-458e-aa99-e0cadf70c5e5",
+ "sourceModelInvariant": "dd8a805d-3946-4f11-9831-e26cd6aec9a3",
+ "sourceModelName": "vmmeService"
+ },
+ "vmmeservice_proxy 1": {
+ "uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
+ "invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
+ "description": "A Proxy for Service vmmeService",
+ "name": "vmmeService Service Proxy",
+ "version": "1.0",
+ "customizationUuid": "7a69f133-564c-4eb6-b93e-0a8281967efb",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "Service Proxy",
+ "sourceModelUuid": "c3e6c9bd-b24d-458e-aa99-e0cadf70c5e5",
+ "sourceModelInvariant": "dd8a805d-3946-4f11-9831-e26cd6aec9a3",
+ "sourceModelName": "vmmeService"
+ },
+ "vmmeservice2_proxy 3": {
+ "uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
+ "invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
+ "description": "A Proxy for Service vmmeService2",
+ "name": "vmmeService2 Service Proxy",
+ "version": "1.0",
+ "customizationUuid": "9d81c21f-e29c-44f6-b5f6-caa974ee078a",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "Service Proxy",
+ "sourceModelUuid": "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6",
+ "sourceModelInvariant": "a7eac2b3-8444-40ee-92e3-b3359b32445c",
+ "sourceModelName": "vmmeService2"
+ },
+ "pprobeservice_proxy 4": {
+ "uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
+ "invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
+ "description": "A Proxy for Service pProbeService",
+ "name": "pProbeService Service Proxy",
+ "version": "1.0",
+ "customizationUuid": "271efa3b-276e-4536-976a-cc9c9c014f1e",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "Service Proxy",
+ "sourceModelUuid": "8a84e59b-45fe-4851-8ff1-34225a0b32c3",
+ "sourceModelInvariant": "83b458fd-5dd3-419b-a9e3-7335814a0911",
+ "sourceModelName": "pProbeService"
+ },
+ "pprobeservice_proxy 5": {
+ "uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
+ "invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
+ "description": "A Proxy for Service pProbeService",
+ "name": "pProbeService Service Proxy",
+ "version": "1.0",
+ "customizationUuid": "d64623ae-5935-4afd-803e-c86e94d8e740",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "Service Proxy",
+ "sourceModelUuid": "8a84e59b-45fe-4851-8ff1-34225a0b32c3",
+ "sourceModelInvariant": "83b458fd-5dd3-419b-a9e3-7335814a0911",
+ "sourceModelName": "pProbeService"
+ },
+ "vmmeservice2_proxy 2": {
+ "uuid": "a32fee17-5b59-4c34-ba6f-6dd2f1c61fee",
+ "invariantUuid": "2933b574-d28d-45ea-bf22-4df2907e4a10",
+ "description": "A Proxy for Service vmmeService2",
+ "name": "vmmeService2 Service Proxy",
+ "version": "1.0",
+ "customizationUuid": "060be63d-5f9c-4fd0-8ef7-830d5e8eca17",
+ "inputs": {},
+ "commands": {},
+ "properties": {},
+ "type": "Service Proxy",
+ "sourceModelUuid": "2a2ea15f-07c6-4b89-bfca-e8aba39a34d6",
+ "sourceModelInvariant": "a7eac2b3-8444-40ee-92e3-b3359b32445c",
+ "sourceModelName": "vmmeService2"
+ }
+ },
+ "vfModules": {},
+ "volumeGroups": {},
+ "pnfs": {}
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/roles.json b/onap-enabler-be/src/test/resources/roles.json
new file mode 100644
index 0000000..db32392
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/roles.json
@@ -0,0 +1,8 @@
+{
+ "roles": [
+ "VID_Subscriber_serviceType1_Tenant1",
+ "VID_Subscriber_serviceType1_Tenant2",
+ "read_motorola_epost_tow",
+ "read_motorola_epost"
+ ]
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/sampleTosca.csar b/onap-enabler-be/src/test/resources/sampleTosca.csar
new file mode 100644
index 0000000..d9c469a
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/sampleTosca.csar
Binary files differ
diff --git a/onap-enabler-be/src/test/resources/services/change_management_software_update_expected_mso_request.json b/onap-enabler-be/src/test/resources/services/change_management_software_update_expected_mso_request.json
new file mode 100644
index 0000000..5bdc9ea
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/services/change_management_software_update_expected_mso_request.json
@@ -0,0 +1,15 @@
+{
+ "requestDetails": {
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "az2016"
+ },
+ "requestParameters": {
+ "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}"
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/services/change_management_software_update_request.json b/onap-enabler-be/src/test/resources/services/change_management_software_update_request.json
new file mode 100644
index 0000000..2ce2a77
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/services/change_management_software_update_request.json
@@ -0,0 +1,26 @@
+{ "requestDetails": [
+ {
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "requestorId": "az2016"
+ },
+ "requestParameters": {
+ "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}"
+ },
+ "vnfName": "vidVnf",
+ "vnfInstanceId": "abe59ceb-6909-4a2c-ad6a-c46d90b18f0b",
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "166b2c5b-6746-4613-bd38-faf46f7afb73"
+ }
+ }
+ ]
+ }
+ ],
+ "requestType": "VNF In Place Software Update"
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/vf-csar.JSON b/onap-enabler-be/src/test/resources/vf-csar.JSON
new file mode 100644
index 0000000..b07ff37
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/vf-csar.JSON
@@ -0,0 +1,178 @@
+{
+ "networks": {
+
+ },
+ "service": {
+ "category": "Mobility",
+ "description": "Bla bla",
+ "serviceRole": null,
+ "serviceType": null,
+ "inputs": {
+ "greatdefect0_availability_zone_max_count": {
+ "constraints": [
+
+ ],
+ "default": 1,
+ "description": "",
+ "entry_schema": null,
+ "required": true,
+ "type": "integer"
+ },
+ "greatdefect0_itc_name_0": {
+ "constraints": [
+
+ ],
+ "default": "ab",
+ "description": "ixla itc instance name",
+ "entry_schema": null,
+ "required": true,
+ "type": "string"
+ },
+ "greatdefect0_vf_module_id": {
+ "constraints": [
+
+ ],
+ "default": "abc",
+ "description": "Unique ID for this VF Module instance",
+ "entry_schema": null,
+ "required": true,
+ "type": "string"
+ }
+ },
+ "invariantUuid": "bd9bf71a-df22-4c95-8638-89f15d875395",
+ "name": "Moriya_new_test",
+ "serviceEcompNaming": "true",
+ "toscaModelURL": null,
+ "uuid": "48a52540-8772-4368-9cdb-1f124ea5c931",
+ "version": "1.0",
+ "instantiationType": null
+ },
+ "vfModules": {
+ "greatdefect0..Greatdefect..base_ixla..module-0": {
+ "customizationUuid": "316e323d-611d-4007-a647-b1d2ecdaee9e",
+ "description": null,
+ "invariantUuid": "80ff85fb-cb11-42cb-9737-e47095d42756",
+ "modelCustomizationName": "Greatdefect..base_ixla..module-0",
+ "name": "Greatdefect..base_ixla..module-0",
+ "uuid": "01166434-ef34-4969-aaf2-626203d72e48",
+ "version": "3",
+ "volumeGroupAllowed": false
+ },
+ "greatdefect0..Greatdefect..module_1_ixla..module-2": {
+ "customizationUuid": "1106fca3-235a-4f92-8d5a-960a7336b32f",
+ "description": null,
+ "invariantUuid": "e0297a51-c670-452e-b31c-c5b37c6ad40f",
+ "modelCustomizationName": "Greatdefect..module_1_ixla..module-2",
+ "name": "Greatdefect..module_1_ixla..module-2",
+ "uuid": "6f09e053-56a6-4fbb-8299-e1de616825cc",
+ "version": "3",
+ "volumeGroupAllowed": false
+ },
+ "greatdefect0..Greatdefect..module_2_ixla..module-1": {
+ "customizationUuid": "b52c1fda-fbbf-4de3-ad9b-190d4a14990c",
+ "description": null,
+ "invariantUuid": "23befc6e-aa97-4004-b215-4979c3f84913",
+ "modelCustomizationName": "Greatdefect..module_2_ixla..module-1",
+ "name": "Greatdefect..module_2_ixla..module-1",
+ "uuid": "dea8e41f-c996-4557-b521-263210d96baa",
+ "version": "3",
+ "volumeGroupAllowed": false
+ }
+ },
+ "vnfs": {
+ "greatdefect 0": {
+ "uuid": "3b25707a-d345-4a80-8744-73adf8f2e67b",
+ "invariantUuid": "d149c45a-b42f-419a-9fac-f9c359fc2034",
+ "description": "checl-IdanWithSecondFix",
+ "name": "greatdefect",
+ "version": "3.0",
+ "customizationUuid": "9123ced3-fbcd-42f7-b103-5965c54bbd66",
+ "inputs": {
+
+ },
+ "commands": {
+
+ },
+ "properties": {
+ "availability_zone_max_count": "get_input:greatdefect0_availability_zone_max_count",
+ "itc_flavor_name": "nv.c8r24d160",
+ "itc_image_name": "NIMBUS_IXLA-ITC_8.20_EA_KVM_210117.qcow2",
+ "itc_name_0": "get_input:greatdefect0_itc_name_0",
+ "itm_flavor_name": "nv.c2r4d50",
+ "itm_image_name": "NIMBUS_IXLA-ITM_8.20.EA_KVM.qcow2",
+ "vf_module_id": "get_input:greatdefect0_vf_module_id"
+ },
+ "type": "VF",
+ "modelCustomizationName": "greatdefect 0",
+ "vfModules": {
+ "greatdefect0..Greatdefect..module_1_ixla..module-2": {
+ "uuid": "6f09e053-56a6-4fbb-8299-e1de616825cc",
+ "invariantUuid": "e0297a51-c670-452e-b31c-c5b37c6ad40f",
+ "customizationUuid": "1106fca3-235a-4f92-8d5a-960a7336b32f",
+ "description": null,
+ "name": "Greatdefect..module_1_ixla..module-2",
+ "version": "3",
+ "modelCustomizationName": "Greatdefect..module_1_ixla..module-2",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": null
+ },
+ "inputs": {
+
+ },
+ "volumeGroupAllowed": false
+ },
+ "greatdefect0..Greatdefect..base_ixla..module-0": {
+ "uuid": "01166434-ef34-4969-aaf2-626203d72e48",
+ "invariantUuid": "80ff85fb-cb11-42cb-9737-e47095d42756",
+ "customizationUuid": "316e323d-611d-4007-a647-b1d2ecdaee9e",
+ "description": null,
+ "name": "Greatdefect..base_ixla..module-0",
+ "version": "3",
+ "modelCustomizationName": "Greatdefect..base_ixla..module-0",
+ "properties": {
+ "minCountInstances": 1,
+ "maxCountInstances": 1,
+ "initialCount": 1,
+ "vfModuleLabel": null
+ },
+ "inputs": {
+
+ },
+ "volumeGroupAllowed": false
+ },
+ "greatdefect0..Greatdefect..module_2_ixla..module-1": {
+ "uuid": "dea8e41f-c996-4557-b521-263210d96baa",
+ "invariantUuid": "23befc6e-aa97-4004-b215-4979c3f84913",
+ "customizationUuid": "b52c1fda-fbbf-4de3-ad9b-190d4a14990c",
+ "description": null,
+ "name": "Greatdefect..module_2_ixla..module-1",
+ "version": "3",
+ "modelCustomizationName": "Greatdefect..module_2_ixla..module-1",
+ "properties": null,
+ "inputs": {
+
+ },
+ "volumeGroupAllowed": false
+ }
+ },
+ "volumeGroups": {
+
+ }
+ }
+ },
+ "volumeGroups": {
+
+ },
+ "configurations": {
+
+ },
+ "serviceProxies": {
+
+ },
+ "pnfs": {
+
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/vf-with-annotation-csar.json b/onap-enabler-be/src/test/resources/vf-with-annotation-csar.json
new file mode 100644
index 0000000..2729d6c
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/vf-with-annotation-csar.json
@@ -0,0 +1,644 @@
+{
+ "service": {
+ "uuid": "f4d84bb4-a416-4b4e-997e-0059973630b9",
+ "invariantUuid": "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9",
+ "name": "ADIOD vMX vPE_BV Service 488",
+ "version": "1.0",
+ "toscaModelURL": null,
+ "category": "Network L1-3",
+ "serviceType": "",
+ "serviceRole": "",
+ "description": "ADIOD vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM",
+ "serviceEcompNaming": "true",
+ "instantiationType": "Macro",
+ "inputs": {
+ "2017488_adiodvpe0_ASN": {
+ "type": "string",
+ "description": "AV/PE",
+ "entry_schema": null,
+ "inputProperties": null,
+ "constraints": [
+
+ ],
+ "required": true,
+ "default": "AV_vPE"
+ }
+ }
+ },
+ "vnfs": {
+ "2017-488_ADIOD-vPE 0": {
+ "uuid": "ea81d6f7-0861-44a7-b7d5-d173b562c350",
+ "invariantUuid": "5be7e99e-8eb2-4d97-be63-8081ff3cd10e",
+ "description": "Name ADIOD vPE Description The provider edge function for the ADIOD service supported by the Junipers VMX product Category Router Vendor Juniper Vendor Release Code 17.2 Owners Mary Fragale. Updated 9-25 to use v8.0 of the Juniper Valid 2 VLM",
+ "name": "2017-488_ADIOD-vPE",
+ "version": "9.0",
+ "customizationUuid": "41516cc6-5098-4b40-a619-f8d5f55fc4d8",
+ "inputs": {
+
+ },
+ "commands": {
+
+ },
+ "properties": {
+ "vmxvre_retype": "RE-VMX",
+ "vnf_config_template_version": "get_input:2017488_adiodvpe0_vnf_config_template_version",
+ "sriov44_net_id": "48d399b3-11ee-48a8-94d2-f0ea94d6be8d",
+ "int_ctl_net_id": "2f323477-6936-4d01-ac53-d849430281d9",
+ "vmxvpfe_sriov41_0_port_mac": "00:11:22:EF:AC:DF",
+ "int_ctl_net_name": "VMX-INTXI",
+ "vmx_int_ctl_prefix": "128.0.0.0",
+ "sriov43_net_id": "da349ca1-6de9-4548-be88-2d88e99bfef5",
+ "sriov42_net_id": "760669ba-013d-4d9b-b0e7-4151fe2e6279",
+ "sriov41_net_id": "25ad52d5-c165-40f8-b3b0-ddfc2373280a",
+ "nf_type": "ROUTER",
+ "vmxvpfe_int_ctl_ip_1": "128.0.0.16",
+ "is_AVPN_service": "false",
+ "vmx_RSG_name": "vREXI-affinity",
+ "vmx_int_ctl_forwarding": "l2",
+ "vmxvre_oam_ip_0": "10.40.123.5",
+ "vmxvpfe_sriov44_0_port_mac": "00:11:22:EF:AC:DF",
+ "vmxvpfe_sriov41_0_port_vlanstrip": "false",
+ "vmxvpfe_sriov42_0_port_vlanfilter": "4001",
+ "vmxvpfe_sriov44_0_port_unknownunicastallow": "true",
+ "vmxvre_image_name_0": "vre172_nova_img",
+ "vmxvre_instance": "0",
+ "vmxvpfe_sriov43_0_port_mac": "00:11:22:EF:AC:DF",
+ "vmxvre_flavor_name": "ns.c1r16d32.v5",
+ "vmxvpfe_volume_size_0": "40.0",
+ "vmxvpfe_sriov43_0_port_vlanfilter": "4001",
+ "nf_naming": "{ecomp_generated_naming=true}",
+ "multi_stage_design": "false",
+ "nf_naming_code": "me6",
+ "vmxvre_name_0": "vREXI",
+ "vmxvpfe_sriov42_0_port_vlanstrip": "false",
+ "vmxvpfe_volume_name_0": "vPFEXI_FBVolume",
+ "vmx_RSG_id": "bd89a33c-13c3-4a04-8fde-1a57eb123141",
+ "vmxvpfe_image_name_0": "vpfe172_nova_img",
+ "vmxvpfe_sriov43_0_port_unknownunicastallow": "true",
+ "vmxvpfe_sriov44_0_port_unknownmulticastallow": "true",
+ "vmxvre_console": "vidconsole",
+ "vmxvpfe_sriov44_0_port_vlanfilter": "4001",
+ "vmxvpfe_sriov42_0_port_mac": "00:11:22:EF:AC:DF",
+ "vmxvpfe_volume_id_0": "47cede15-da2f-4397-a101-aa683220aff3",
+ "vmxvpfe_sriov42_0_port_unknownmulticastallow": "true",
+ "vmxvpfe_sriov44_0_port_vlanstrip": "false",
+ "vf_module_id": "123",
+ "nf_function": "ADIOD vPE",
+ "vmxvpfe_sriov43_0_port_unknownmulticastallow": "true",
+ "vmxvre_int_ctl_ip_0": "128.0.0.1",
+ "AIC_CLLI": "get_input:2017488_adiodvpe0_AIC_CLLI",
+ "vnf_name": "mtnj309me6vre",
+ "vmxvpfe_sriov41_0_port_unknownunicastallow": "true",
+ "vmxvre_volume_type_1": "HITACHI",
+ "vmxvpfe_sriov44_0_port_broadcastallow": "true",
+ "vmxvre_volume_type_0": "HITACHI",
+ "vmxvpfe_volume_type_0": "HITACHI",
+ "vmxvpfe_sriov43_0_port_broadcastallow": "true",
+ "bandwidth_units": "get_input:2017488_adiodvpe0_bandwidth_units",
+ "vnf_id": "123",
+ "vmxvre_oam_prefix": "24",
+ "availability_zone_0": "get_input:2017488_adiodvpe0_availability_zone_0",
+ "ASN": "get_input:2017488_adiodvpe0_ASN",
+ "vmxvre_chassis_i2cid": "161",
+ "vmxvpfe_name_0": "vPFEXI",
+ "bandwidth": "get_input:2017488_adiodvpe0_bandwidth",
+ "availability_zone_max_count": "1",
+ "vmxvre_volume_size_0": "45.0",
+ "vmxvre_volume_size_1": "50.0",
+ "vmxvpfe_sriov42_0_port_broadcastallow": "true",
+ "vmxvre_oam_gateway": "10.40.123.1",
+ "vmxvre_volume_name_1": "vREXI_FAVolume",
+ "vmxvre_ore_present": "0",
+ "vmxvre_volume_name_0": "vREXI_FBVolume",
+ "vmxvre_type": "0",
+ "vnf_instance_name": "get_input:2017488_adiodvpe0_vnf_instance_name",
+ "vmxvpfe_sriov41_0_port_unknownmulticastallow": "true",
+ "oam_net_id": "b95eeb1d-d55d-4827-abb4-8ebb94941429",
+ "vmx_int_ctl_len": "24",
+ "vmxvpfe_sriov43_0_port_vlanstrip": "false",
+ "vmxvpfe_sriov41_0_port_broadcastallow": "true",
+ "vmxvre_volume_id_1": "6e86797e-03cd-4fdc-ba72-2957119c746d",
+ "vmxvpfe_sriov41_0_port_vlanfilter": "4001",
+ "nf_role": "vPE",
+ "vmxvre_volume_id_0": "f4eacb79-f687-4e9d-b760-21847c8bb15a",
+ "vmxvpfe_sriov42_0_port_unknownunicastallow": "true",
+ "vmxvpfe_flavor_name": "ns.c20r16d25.v5"
+ },
+ "type": "VF",
+ "modelCustomizationName": "2017-488_ADIOD-vPE 0",
+ "vfModules": {
+ "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": {
+ "uuid": "a5d8df05-11cb-4351-96e0-b6d4168ea4df",
+ "invariantUuid": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
+ "customizationUuid": "f3d97417-0c8d-424e-8ff7-b2eb4fbcecc3",
+ "description": null,
+ "name": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "version": "8",
+ "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "ADIOD_vRE_BV"
+ },
+ "inputs": {
+ "2017488_adiodvpe0_bandwidth_units": {
+ "type": "string",
+ "description": "Units of bandwidth",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "bandwidth_units"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "Gbps"
+ },
+ "2017488_adiodvpe0_bandwidth": {
+ "type": "string",
+ "description": "Requested VPE bandwidth",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "bandwidth"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "10"
+ },
+ "2017488_adiodvpe0_vnf_instance_name": {
+ "type": "string",
+ "description": "The hostname assigned to the vpe.",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "vnf_instance_name"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "mtnj309me6"
+ },
+ "2017488_adiodvpe0_vnf_config_template_version": {
+ "type": "string",
+ "description": "VPE Software Version",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "vnf_config_template_version"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "17.2"
+ },
+ "2017488_adiodvpe0_AIC_CLLI": {
+ "type": "string",
+ "description": "AIC Site CLLI",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "AIC_CLLI"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "ATLMY8GA"
+ }
+ },
+ "volumeGroupAllowed": true
+ },
+ "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": {
+ "uuid": "040e591e-5d30-4e0d-850f-7266e5a8e013",
+ "invariantUuid": "b34833bb-6aa9-4ad6-a831-70b06367a091",
+ "customizationUuid": "5c5f91f9-5e31-4120-b892-5536587ec258",
+ "description": null,
+ "name": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
+ "version": "6",
+ "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
+ "properties": {
+ "minCountInstances": 1,
+ "maxCountInstances": 1,
+ "initialCount": 1,
+ "vfModuleLabel": "ADIOD_base_vPE_BV"
+ },
+ "inputs": {
+
+ },
+ "volumeGroupAllowed": false
+ },
+ "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vPFE_BV..module-2": {
+ "uuid": "b3e8b26e-cff0-49fc-a4e6-f3e16c8440fe",
+ "invariantUuid": "eff8cc59-53a1-4101-aed7-8cf24ecf8339",
+ "customizationUuid": "6e410843-257c-46d9-ba8a-8d94e1362452",
+ "description": null,
+ "name": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "version": "8",
+ "modelCustomizationName": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "ADIOD_vPFE_BV"
+ },
+ "inputs": {
+ "2017488_adiodvpe0_availability_zone_0": {
+ "type": "string",
+ "description": "The Availability Zone to launch the instance.",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vPFE_BV",
+ "paramName": "availability_zone_0"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "mtpocfo-kvm-az01"
+ }
+ },
+ "volumeGroupAllowed": true
+ }
+ },
+ "volumeGroups": {
+ "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": {
+ "uuid": "a5d8df05-11cb-4351-96e0-b6d4168ea4df",
+ "invariantUuid": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
+ "customizationUuid": "f3d97417-0c8d-424e-8ff7-b2eb4fbcecc3",
+ "description": null,
+ "name": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "version": "8",
+ "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "ADIOD_vRE_BV"
+ },
+ "inputs": {
+ "2017488_adiodvpe0_bandwidth_units": {
+ "type": "string",
+ "description": "Units of bandwidth",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "bandwidth_units"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "Gbps"
+ },
+ "2017488_adiodvpe0_bandwidth": {
+ "type": "string",
+ "description": "Requested VPE bandwidth",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "bandwidth"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "10"
+ },
+ "2017488_adiodvpe0_vnf_instance_name": {
+ "type": "string",
+ "description": "The hostname assigned to the vpe.",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "vnf_instance_name"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "mtnj309me6"
+ },
+ "2017488_adiodvpe0_vnf_config_template_version": {
+ "type": "string",
+ "description": "VPE Software Version",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "vnf_config_template_version"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "17.2"
+ },
+ "2017488_adiodvpe0_AIC_CLLI": {
+ "type": "string",
+ "description": "AIC Site CLLI",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "AIC_CLLI"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "ATLMY8GA"
+ }
+ }
+ },
+ "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vPFE_BV..module-2": {
+ "uuid": "b3e8b26e-cff0-49fc-a4e6-f3e16c8440fe",
+ "invariantUuid": "eff8cc59-53a1-4101-aed7-8cf24ecf8339",
+ "customizationUuid": "6e410843-257c-46d9-ba8a-8d94e1362452",
+ "description": null,
+ "name": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "version": "8",
+ "modelCustomizationName": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "ADIOD_vPFE_BV"
+ },
+ "inputs": {
+ "2017488_adiodvpe0_availability_zone_0": {
+ "type": "string",
+ "description": "The Availability Zone to launch the instance.",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vPFE_BV",
+ "paramName": "availability_zone_0"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "mtpocfo-kvm-az01"
+ }
+ }
+ }
+ }
+ }
+ },
+ "networks": {
+
+ },
+ "collectionResource": {
+
+ },
+ "configurations": {
+
+ },
+ "serviceProxies": {
+
+ },
+ "vfModules": {
+ "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": {
+ "uuid": "a5d8df05-11cb-4351-96e0-b6d4168ea4df",
+ "invariantUuid": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
+ "customizationUuid": "f3d97417-0c8d-424e-8ff7-b2eb4fbcecc3",
+ "description": null,
+ "name": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "version": "8",
+ "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "ADIOD_vRE_BV"
+ },
+ "inputs": {
+ "2017488_adiodvpe0_bandwidth_units": {
+ "type": "string",
+ "description": "Units of bandwidth",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "bandwidth_units"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "Gbps"
+ },
+ "2017488_adiodvpe0_bandwidth": {
+ "type": "string",
+ "description": "Requested VPE bandwidth",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "bandwidth"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "10"
+ },
+ "2017488_adiodvpe0_vnf_instance_name": {
+ "type": "string",
+ "description": "The hostname assigned to the vpe.",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "vnf_instance_name"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "mtnj309me6"
+ },
+ "2017488_adiodvpe0_vnf_config_template_version": {
+ "type": "string",
+ "description": "VPE Software Version",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "vnf_config_template_version"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "17.2"
+ },
+ "2017488_adiodvpe0_AIC_CLLI": {
+ "type": "string",
+ "description": "AIC Site CLLI",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "AIC_CLLI"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "ATLMY8GA"
+ }
+ },
+ "volumeGroupAllowed": true
+ },
+ "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": {
+ "uuid": "040e591e-5d30-4e0d-850f-7266e5a8e013",
+ "invariantUuid": "b34833bb-6aa9-4ad6-a831-70b06367a091",
+ "customizationUuid": "5c5f91f9-5e31-4120-b892-5536587ec258",
+ "description": null,
+ "name": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
+ "version": "6",
+ "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
+ "properties": {
+ "minCountInstances": 1,
+ "maxCountInstances": 1,
+ "initialCount": 1,
+ "vfModuleLabel": "ADIOD_base_vPE_BV"
+ },
+ "inputs": {
+
+ },
+ "volumeGroupAllowed": false
+ },
+ "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vPFE_BV..module-2": {
+ "uuid": "b3e8b26e-cff0-49fc-a4e6-f3e16c8440fe",
+ "invariantUuid": "eff8cc59-53a1-4101-aed7-8cf24ecf8339",
+ "customizationUuid": "6e410843-257c-46d9-ba8a-8d94e1362452",
+ "description": null,
+ "name": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "version": "8",
+ "modelCustomizationName": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "ADIOD_vPFE_BV"
+ },
+ "inputs": {
+ "2017488_adiodvpe0_availability_zone_0": {
+ "type": "string",
+ "description": "The Availability Zone to launch the instance.",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vPFE_BV",
+ "paramName": "availability_zone_0"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "mtpocfo-kvm-az01"
+ }
+ },
+ "volumeGroupAllowed": true
+ }
+ },
+ "volumeGroups": {
+ "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": {
+ "uuid": "a5d8df05-11cb-4351-96e0-b6d4168ea4df",
+ "invariantUuid": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
+ "customizationUuid": "f3d97417-0c8d-424e-8ff7-b2eb4fbcecc3",
+ "description": null,
+ "name": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "version": "8",
+ "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "ADIOD_vRE_BV"
+ },
+ "inputs": {
+ "2017488_adiodvpe0_bandwidth_units": {
+ "type": "string",
+ "description": "Units of bandwidth",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "bandwidth_units"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "Gbps"
+ },
+ "2017488_adiodvpe0_bandwidth": {
+ "type": "string",
+ "description": "Requested VPE bandwidth",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "bandwidth"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "10"
+ },
+ "2017488_adiodvpe0_vnf_instance_name": {
+ "type": "string",
+ "description": "The hostname assigned to the vpe.",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "vnf_instance_name"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "mtnj309me6"
+ },
+ "2017488_adiodvpe0_vnf_config_template_version": {
+ "type": "string",
+ "description": "VPE Software Version",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "vnf_config_template_version"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "17.2"
+ },
+ "2017488_adiodvpe0_AIC_CLLI": {
+ "type": "string",
+ "description": "AIC Site CLLI",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vRE_BV",
+ "paramName": "AIC_CLLI"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "ATLMY8GA"
+ }
+ }
+ },
+ "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vPFE_BV..module-2": {
+ "uuid": "b3e8b26e-cff0-49fc-a4e6-f3e16c8440fe",
+ "invariantUuid": "eff8cc59-53a1-4101-aed7-8cf24ecf8339",
+ "customizationUuid": "6e410843-257c-46d9-ba8a-8d94e1362452",
+ "description": null,
+ "name": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "version": "8",
+ "modelCustomizationName": "2017488AdiodVpe..ADIOD_vPFE_BV..module-2",
+ "properties": {
+ "minCountInstances": 0,
+ "maxCountInstances": null,
+ "initialCount": 0,
+ "vfModuleLabel": "ADIOD_vPFE_BV"
+ },
+ "inputs": {
+ "2017488_adiodvpe0_availability_zone_0": {
+ "type": "string",
+ "description": "The Availability Zone to launch the instance.",
+ "entry_schema": null,
+ "inputProperties": {
+ "sourceType": "HEAT",
+ "vfModuleLabel": "ADIOD_vPFE_BV",
+ "paramName": "availability_zone_0"
+ },
+ "constraints": null,
+ "required": true,
+ "default": "mtpocfo-kvm-az01"
+ }
+ }
+ }
+ },
+ "pnfs": {
+
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/vf-with-vfcInstanceGroups.json b/onap-enabler-be/src/test/resources/vf-with-vfcInstanceGroups.json
new file mode 100644
index 0000000..334e2a7
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/vf-with-vfcInstanceGroups.json
@@ -0,0 +1,135 @@
+{
+ "service": {
+ "uuid": "6bce7302-70bd-4057-b48e-8d5b99e686ca",
+ "invariantUuid": "9aa04749-c02c-432d-a90c-18caa361c833",
+ "name": "vDBE_srv",
+ "version": "1.0",
+ "toscaModelURL": null,
+ "category": "Network L4+",
+ "serviceType": "",
+ "serviceRole": "",
+ "description": "vDBE_srv",
+ "serviceEcompNaming": "true",
+ "instantiationType": "A-La-Carte",
+ "inputs": {
+
+ }
+ },
+ "vnfs": {
+ "vDBE 0": {
+ "uuid": "61535073-2e50-4141-9000-f66fea69b433",
+ "invariantUuid": "fcdf49ce-6f0b-4ca2-b676-a484e650e734",
+ "description": "vDBE",
+ "name": "vDBE",
+ "version": "0.2",
+ "customizationUuid": "882e5dcb-ba9f-4766-8cde-e326638107db",
+ "inputs": {
+
+ },
+ "commands": {
+
+ },
+ "properties": {
+ "nf_naming": "{ecomp_generated_naming=true}",
+ "multi_stage_design": "false",
+ "oam_vfc_instance_group_function": "oambbb",
+ "availability_zone_max_count": "1",
+ "oam_network_collection_function": "oamaaa",
+ "ecomp_generated_naming": "true",
+ "untr_vfc_instance_group_function": "untrbbb",
+ "untr_network_collection_function": "untraaa"
+ },
+ "type": "VF",
+ "modelCustomizationName": "vDBE 0",
+ "vfModules": {
+ "vdbe0..Vdbe..main..module-0": {
+ "uuid": "25a4d009-2f5a-44b4-b02a-62c584c15912",
+ "invariantUuid": "614afb1a-3e7e-44e9-90ab-424d0070c781",
+ "customizationUuid": "3443b341-7b0b-498c-a84a-a7ee736cba7e",
+ "description": null,
+ "name": "Vdbe..main..module-0",
+ "version": "1",
+ "modelCustomizationName": "Vdbe..main..module-0",
+ "properties": {
+ "minCountInstances": 1,
+ "maxCountInstances": 1,
+ "initialCount": 1,
+ "vfModuleLabel": "main"
+ },
+ "inputs": {
+
+ },
+ "volumeGroupAllowed": false
+ }
+ },
+ "volumeGroups": {
+
+ },
+ "vfcInstanceGroups": {
+ "untr_group": {
+ "uuid": "5fca04e2-a889-4579-8338-f60f1bf285fa",
+ "invariantUuid": "fb1e384b-117a-46ae-9ad1-bf2f1ee1e49f",
+ "name": "untr_group",
+ "version": "1",
+ "vfcInstanceGroupProperties": {
+ "vfcParentPortRole": "untr",
+ "networkCollectionFunction": "untraaa",
+ "vfcInstanceGroupFunction": null,
+ "subinterfaceRole": "untr"
+ }
+ },
+ "oam_group": {
+ "uuid": "a0efd5fc-f7be-4502-936a-a6c6392b958f",
+ "invariantUuid": "9384abf9-1231-4da4-bd8d-89e4d2f8a749",
+ "name": "oam_group",
+ "version": "1",
+ "vfcInstanceGroupProperties": {
+ "vfcParentPortRole": "untr",
+ "networkCollectionFunction": "untraaa",
+ "vfcInstanceGroupFunction": null,
+ "subinterfaceRole": "untr"
+ }
+ }
+ }
+ }
+ },
+ "networks": {
+
+ },
+ "collectionResource": {
+
+ },
+ "configurations": {
+
+ },
+ "serviceProxies": {
+
+ },
+ "vfModules": {
+ "vdbe0..Vdbe..main..module-0": {
+ "uuid": "25a4d009-2f5a-44b4-b02a-62c584c15912",
+ "invariantUuid": "614afb1a-3e7e-44e9-90ab-424d0070c781",
+ "customizationUuid": "3443b341-7b0b-498c-a84a-a7ee736cba7e",
+ "description": null,
+ "name": "Vdbe..main..module-0",
+ "version": "1",
+ "modelCustomizationName": "Vdbe..main..module-0",
+ "properties": {
+ "minCountInstances": 1,
+ "maxCountInstances": 1,
+ "initialCount": 1,
+ "vfModuleLabel": "main"
+ },
+ "inputs": {
+
+ },
+ "volumeGroupAllowed": false
+ }
+ },
+ "volumeGroups": {
+
+ },
+ "pnfs": {
+
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/vl-csar.JSON b/onap-enabler-be/src/test/resources/vl-csar.JSON
new file mode 100644
index 0000000..8be2d09
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/vl-csar.JSON
@@ -0,0 +1,94 @@
+{
+ "service": {
+ "uuid": "68101369-6f08-4e99-9a28-fa6327d344f3",
+ "invariantUuid": "d752a44c-ac7b-4bda-8111-fb52312d101e",
+ "name": "Macro_flow_test",
+ "version": "1.0",
+ "toscaModelURL": null,
+ "category": "Network L1-3",
+ "serviceType": null,
+ "serviceRole": null,
+ "description": "dsfg",
+ "serviceEcompNaming": "true",
+ "instantiationType": "ClientConfig",
+ "inputs": {
+ "extvl0_network_scope": {
+ "type": "string",
+ "description": "Uniquely identifies the network scope. Valid values for the network scope includes: VF - VF-level network. Intra-VF network which connects the VFCs (VMs) inside the VF. SERVICE - Service-level network. Intra-Service network which connects the VFs within the service GLOBAL - Global network which can be shared by multiple services\n",
+ "entry_schema": null,
+ "inputProperties": null,
+ "constraints": [
+
+ ],
+ "required": true,
+ "default": null
+ },
+ "extvl0_network_role": {
+ "type": "string",
+ "description": "Unique label that defines the role that this network performs. example: vce oam network, vnat sr-iov1 network\n",
+ "entry_schema": null,
+ "inputProperties": null,
+ "constraints": [
+
+ ],
+ "required": true,
+ "default": null
+ },
+ "extvl0_exVL_naming_naming_policy": {
+ "type": "string",
+ "description": "Reference to naming policy that ECOMP will use when the name is auto-generated",
+ "entry_schema": null,
+ "inputProperties": null,
+ "constraints": [
+
+ ],
+ "required": true,
+ "default": null
+ }
+ }
+ },
+ "vnfs": {
+
+ },
+ "networks": {
+ "ExtVL 0": {
+ "uuid": "af584529-d7f0-420e-a6f3-c38b689c030f",
+ "invariantUuid": "379f816b-a7aa-422f-be30-17114ff50b7c",
+ "description": "ECOMP generic virtual link (network) base type for all other service-level and global networks",
+ "name": "ExtVL",
+ "version": "4.0",
+ "customizationUuid": "664f8aa7-3989-46ac-81c0-dd72a8a63f26",
+ "inputs": {
+
+ },
+ "commands": {
+
+ },
+ "properties": {
+ "network_role": "get_input:extvl0_network_role",
+ "exVL_naming": "{naming_policy=get_input:extvl0_exVL_naming_naming_policy}",
+ "network_scope": "get_input:extvl0_network_scope"
+ },
+ "type": "VL",
+ "modelCustomizationName": "ExtVL 0"
+ }
+ },
+ "collectionResource": {
+
+ },
+ "configurations": {
+
+ },
+ "serviceProxies": {
+
+ },
+ "vfModules": {
+
+ },
+ "volumeGroups": {
+
+ },
+ "pnfs": {
+
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/src/test/resources/vnfConfigUpdatePayload.json b/onap-enabler-be/src/test/resources/vnfConfigUpdatePayload.json
new file mode 100644
index 0000000..94161d9
--- /dev/null
+++ b/onap-enabler-be/src/test/resources/vnfConfigUpdatePayload.json
@@ -0,0 +1,40 @@
+{
+ "payload":{
+ "request-parameters":{
+ "vm":[
+ {
+ "vnfc":[
+ {
+ "ipaddress-v4-oam-vip":"135.21.166.39",
+ "vnfc-name":"ibcx0001vm001dbg001",
+ "vnfc-function-code":"dbg",
+ "vnfc-type":"DBE-VM #1",
+ "group-notation":"ibcx0001vm001dbg001pair"
+ }
+ ],
+ "vm-name":"ibcx0001vm001"
+ },
+ {
+ "vnfc":[
+ {
+ "vnfc-name":"ibcx0001vm002dbg001",
+ "vnfc-function-code":"dbg",
+ "vnfc-type":"DBE-VM #1",
+ "group-notation":"ibcx0001vm001dbg001pair"
+ }
+ ],
+ "vm-name":"ibcx0001vm002"
+ }
+ ],
+ "vnf-name":"ibcx0099v",
+ "template-name":"vdbe_template1"
+ },
+ "configuration":{
+ "configuration-json":"{\n \"version\": \"15.1X49-D50.3\",\n \"groups\": {\n \"name\": \"node0\",\n \"system\": {\n \"host-name\": \"$node0_hostname\",\n \"backup-router\": {\n \"address\": \"$node0_backup_router_address\",\n \"destination\": \"0.0.0.0/0\"\n }\n }\n }\n}",
+ "configuration-string": " <configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" \n xmlns:a=\"http://xml.juniper.net/junos/15.1X49/junos\" >\n <version>15.1X49-D50.3<\/version>\n <groups>\n <name>node0<\/name>\n <system>\n <host-name>$node0_hostname<\/host-name>\n <backup-router>\n <address>$node0_backup_router_address<\/address>\n <destination>0.0.0.0/0<\/destination>\n <\/backup-router>\n <\/system>\n <\/groups>\n <\/configuration>"
+ },
+ "configuration-parameters":{
+ "nat_source_sp_v6rogerssnat_address1":"2001:1890:fc45:f025:135:25:246:c806/128"
+ }
+ }
+}
\ No newline at end of file
diff --git a/onap-enabler-be/version.properties b/onap-enabler-be/version.properties
new file mode 100644
index 0000000..113097b
--- /dev/null
+++ b/onap-enabler-be/version.properties
@@ -0,0 +1,13 @@
+# Versioning variables
+# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )
+# because they are used in Jenkins, whose plug-in doesn't support
+
+major=0
+minor=0
+patch=1
+
+base_version=${major}.${minor}.${patch}
+
+# Release must be completed with git revision # in Jenkins
+release_version=${base_version}
+snapshot_version=${base_version}-SNAPSHOT