aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/application.properties2
-rw-r--r--pom.xml748
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PnfInstance.java317
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java204
-rw-r--r--src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java32
-rw-r--r--src/test/resources/junit/aai-service-instance.json43
-rw-r--r--src/test/resources/junit/genericVnfInput.json96
-rw-r--r--src/test/resources/junit/pnfSampleInput.json22
8 files changed, 1084 insertions, 380 deletions
diff --git a/config/application.properties b/config/application.properties
index bb02e75..dea9aa7 100644
--- a/config/application.properties
+++ b/config/application.properties
@@ -37,7 +37,7 @@ aai.username=AAI
aai.password=OBF:1gfr1ev31gg7
aai.httpProtocol=https
aai.connectionTimeout=5000
-aai.readTimeout=1000
+aai.readTimeout=5000
# HTTP Basic Authorization credentials for Rest Service API
http.userId=admin
diff --git a/pom.xml b/pom.xml
index c514851..5a68ea4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,368 +1,380 @@
-<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.onap.logging-analytics.pomba</groupId>
- <artifactId>pomba-aai-context-builder</artifactId>
- <version>1.4.0-SNAPSHOT</version>
-
- <parent>
- <groupId>org.onap.oparent</groupId>
- <artifactId>oparent</artifactId>
- <version>1.2.1</version>
- <relativePath/>
- </parent>
-
- <properties>
- <aai.rest.client.version>1.3.0</aai.rest.client.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <logback.version>1.2.3</logback.version>
- <swagger.directory>${project.build.directory}/generated-resources/swagger</swagger.directory>
- <!--docker -->
- <docker.tag>${project.version}-${timestamp}</docker.tag>
- <docker.latest.tag>${project.version}-latest</docker.latest.tag>
- </properties>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-dependencies</artifactId>
- <version>1.5.17.RELEASE</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-security</artifactId>
- </dependency>
-
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-jersey</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.logging-analytics.pomba</groupId>
- <artifactId>pomba-audit-common</artifactId>
- <version>1.3.1</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-client</artifactId>
- <version>1.19.4</version>
- <exclusions>
- <exclusion>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>1.2.3</version>
- </dependency>
- <!-- logging dependencies -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.7</version>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- </dependency>
- <dependency>
- <groupId>com.jayway.jsonpath</groupId>
- <artifactId>json-path</artifactId>
- </dependency>
-
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-core</artifactId>
- <version>1.5.9</version>
- </dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-annotations</artifactId>
- <version>1.5.9</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.github.tomakehurst</groupId>
- <artifactId>wiremock</artifactId>
- <version>2.18.0</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.onap.aai</groupId>
- <artifactId>rest-client</artifactId>
- <version>${aai.rest.client.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- </dependencies>
-
- <build>
- <finalName>${project.artifactId}</finalName>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
-
- <resources>
- <resource>
- <targetPath>config</targetPath>
- <directory>config</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
- </build>
-
- <profiles>
- <profile>
- <id>docker</id>
- <build>
- <plugins>
- <plugin>
- <groupId>io.fabric8</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>0.28.0</version>
- <configuration>
- <verbose>true</verbose>
- <apiVersion>1.23</apiVersion>
- <images>
- <image>
- <name>onap/${project.artifactId}</name>
- <alias>${project.artifactId}</alias>
- <build>
- <cleanup>try</cleanup>
- <dockerFileDir>${project.basedir}/target/docker-stage</dockerFileDir>
- <tags>
- <tag>${docker.snapshot.tag}</tag>
- <tag>${docker.latest.tag}</tag>
- </tags>
- </build>
- </image>
- </images>
- </configuration>
- <executions>
- <execution>
- <id>generate-images</id>
- <goals>
- <goal>build</goal>
- </goals>
- </execution>
- <execution>
- <id>push-images</id>
- <phase>deploy</phase>
- <goals>
- <goal>build</goal>
- <goal>push</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <version>3.1.0</version>
- <executions>
- <execution>
- <id>copy-resources</id>
- <!-- here the phase you need -->
- <phase>prepare-package</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.outputDirectory}</outputDirectory>
- <resources>
- <resource>
- <directory>
- ${project.build.directory}/generated-resources/swagger
- </directory>
- <targetPath>META-INF/resources/swagger</targetPath>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>com.github.kongchen</groupId>
- <artifactId>swagger-maven-plugin</artifactId>
- <version>3.1.3</version>
- <configuration>
- <apiSources>
- <apiSource>
- <locations>org.onap.pomba.contextbuilder.aai.service.rs</locations>
- <basePath>/aaicontextbuilder</basePath>
- <info>
- <title>${project.artifactId} Service</title>
- <version>${project.version}</version>
- </info>
- <swaggerDirectory>${swagger.directory}</swaggerDirectory>
- </apiSource>
- </apiSources>
- </configuration>
- <executions>
- <execution>
- <!-- <phase>compile</phase> -->
- <phase>package</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <id>copy-dockerfile</id>
- <goals>
- <goal>copy-resources</goal>
- </goals><!-- here the phase you need -->
- <phase>package</phase>
- <configuration>
- <outputDirectory>${project.basedir}/target/docker-stage</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/docker</directory>
- <includes>
- <include>Dockerfile</include>
- </includes>
- <filtering>true</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>copy-properties</id>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <phase>validate</phase>
- <configuration>
- <outputDirectory>${project.basedir}/target/docker-stage/config</outputDirectory>
- <resources>
- <resource>
- <directory>config</directory>
- <includes>
- <include>*.properties</include>
- <include>*.xml</include>
- </includes>
- <filtering>false</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>copy-script</id>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/docker</directory>
- <includes>
- <include>*.sh</include>
- </includes>
- <filtering>false</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>copy-jar</id>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
- <resources>
- <resource>
- <directory>target</directory>
- <includes>
- <include>*.jar</include>
- </includes>
- <filtering>false</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.onap.logging-analytics.pomba</groupId>
+ <artifactId>pomba-aai-context-builder</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>1.2.1</version>
+ <relativePath/>
+ </parent>
+
+ <properties>
+ <aai.rest.client.version>1.3.0</aai.rest.client.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <logback.version>1.2.3</logback.version>
+ <swagger.directory>${project.build.directory}/generated-resources/swagger</swagger.directory>
+ <!--docker -->
+ <docker.tag>${project.version}-${timestamp}</docker.tag>
+ <docker.latest.tag>${project.version}-latest</docker.latest.tag>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>1.5.17.RELEASE</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <!-- Jolt transformation dependencies -->
+ <dependency>
+ <groupId>com.bazaarvoice.jolt</groupId>
+ <artifactId>jolt-core</artifactId>
+ <version>0.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.bazaarvoice.jolt</groupId>
+ <artifactId>json-utils</artifactId>
+ <version>0.1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-security</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-jersey</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.logging-analytics.pomba</groupId>
+ <artifactId>pomba-audit-common</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>1.19.4</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.3</version>
+ </dependency>
+ <!-- logging dependencies -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.jsonpath</groupId>
+ <artifactId>json-path</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-core</artifactId>
+ <version>1.5.9</version>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>1.5.9</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.github.tomakehurst</groupId>
+ <artifactId>wiremock</artifactId>
+ <version>2.18.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onap.aai</groupId>
+ <artifactId>rest-client</artifactId>
+ <version>${aai.rest.client.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ <resources>
+ <resource>
+ <targetPath>config</targetPath>
+ <directory>config</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>docker</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>0.28.0</version>
+ <configuration>
+ <verbose>true</verbose>
+ <apiVersion>1.23</apiVersion>
+ <images>
+ <image>
+ <name>onap/${project.artifactId}</name>
+ <alias>${project.artifactId}</alias>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFileDir>${project.basedir}/target/docker-stage</dockerFileDir>
+ <tags>
+ <tag>${docker.snapshot.tag}</tag>
+ <tag>${docker.latest.tag}</tag>
+ </tags>
+ </build>
+ </image>
+ </images>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-images</id>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>push-images</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>build</goal>
+ <goal>push</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <!-- here the phase you need -->
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.outputDirectory}</outputDirectory>
+ <resources>
+ <resource>
+ <directory>
+ ${project.build.directory}/generated-resources/swagger
+ </directory>
+ <targetPath>META-INF/resources/swagger</targetPath>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>com.github.kongchen</groupId>
+ <artifactId>swagger-maven-plugin</artifactId>
+ <version>3.1.3</version>
+ <configuration>
+ <apiSources>
+ <apiSource>
+ <locations>org.onap.pomba.contextbuilder.aai.service.rs</locations>
+ <basePath>/aaicontextbuilder</basePath>
+ <info>
+ <title>${project.artifactId} Service</title>
+ <version>${project.version}</version>
+ </info>
+ <swaggerDirectory>${swagger.directory}</swaggerDirectory>
+ </apiSource>
+ </apiSources>
+ </configuration>
+ <executions>
+ <execution>
+ <!-- <phase>compile</phase> -->
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>copy-dockerfile</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals><!-- here the phase you need -->
+ <phase>package</phase>
+ <configuration>
+ <outputDirectory>${project.basedir}/target/docker-stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/docker</directory>
+ <includes>
+ <include>Dockerfile</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-properties</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${project.basedir}/target/docker-stage/config</outputDirectory>
+ <resources>
+ <resource>
+ <directory>config</directory>
+ <includes>
+ <include>*.properties</include>
+ <include>*.xml</include>
+ </includes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-script</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/docker</directory>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-jar</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
+ <resources>
+ <resource>
+ <directory>target</directory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PnfInstance.java b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PnfInstance.java
new file mode 100644
index 0000000..f470b78
--- /dev/null
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PnfInstance.java
@@ -0,0 +1,317 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=====================================================
+ */
+
+package org.onap.pomba.contextbuilder.aai.datatype;
+
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.onap.pomba.contextbuilder.aai.exception.AuditError;
+import org.onap.pomba.contextbuilder.aai.exception.AuditException;
+
+public class PnfInstance {
+
+ @SerializedName("pnf-id")
+ @Expose
+ private String pnfId;
+ @SerializedName("pnf-name")
+ @Expose
+ private String pnfName;
+ @SerializedName("nf-function")
+ @Expose
+ private String nfFunction;
+ @SerializedName("nf-role")
+ @Expose
+ private String nfRole;
+ @SerializedName("resource-version")
+ @Expose
+ private String resourceVersion;
+ @SerializedName("pnf-name2")
+ @Expose
+ private String pnfName2;
+ @SerializedName("pnf-name2-source")
+ @Expose
+ private String pnfName2Source;
+ @SerializedName("equip-type")
+ @Expose
+ private String equipmentType;
+ @SerializedName("equip-vendor")
+ @Expose
+ private String equipmentVendor;
+ @SerializedName("equip-model")
+ @Expose
+ private String equipmentModel;
+ @SerializedName("management-option")
+ @Expose
+ private String managementOptions;
+ @SerializedName("sw-version")
+ @Expose
+ private String swVersion;
+ @SerializedName("frame-id")
+ @Expose
+ private String frameId;
+ @SerializedName("serial-number")
+ @Expose
+ private String serialNumber;
+ @SerializedName("model-invariant-id")
+ @Expose
+ private String modelInvariantId;
+ @SerializedName("model-version-id")
+ @Expose
+ private String modelVersionId;
+
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+ public String getPnfId() {
+ return pnfId;
+ }
+
+ public void setPnfId(String pnfId) {
+ this.pnfId = pnfId;
+ }
+
+ public String getPnfName() {
+ return pnfName;
+ }
+
+ public void setPnfName(String name) {
+ this.pnfName = name;
+ }
+ public String getNfFunction() {
+ return nfFunction;
+ }
+
+ public void setNfFunction(String nfFunction) {
+ this.nfFunction = nfFunction;
+ }
+
+ public String getNfRole() {
+ return nfRole;
+ }
+
+ public void setNfRole(String networkRole) {
+ this.nfRole = networkRole;
+ }
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public String getPnfName2() {
+ return pnfName2;
+ }
+
+ public void setPnfName2(String name2) {
+ this.pnfName2 = name2;
+ }
+
+ public String getPnfName2Source() {
+ return pnfName2Source;
+ }
+
+ public void setPnfName2Source(String name2Source) {
+ this.pnfName2Source = name2Source;
+ }
+
+ public String getEquipmentType() {
+ return equipmentType;
+ }
+
+ public void setEquipmentType(String equipmentType) {
+ this.equipmentType = equipmentType;
+ }
+
+ public String getEquipmentVendor() {
+ return equipmentVendor;
+ }
+
+ public void setEquipmentVendor(String equipmentVendor) {
+ this.equipmentVendor = equipmentVendor;
+ }
+
+ public String getEquipmentModel() {
+ return equipmentModel;
+ }
+
+ public void setEquipmentModel(String equipmentModel) {
+ this.equipmentModel = equipmentModel;
+ }
+
+ public String getManagementOptions() {
+ return managementOptions;
+ }
+
+ public void setManagementOptions(String managementOptions) {
+ this.managementOptions = managementOptions;
+ }
+
+ public String getSwVersion() {
+ return swVersion;
+ }
+
+ public void setSwVersion(String swVersion) {
+ this.swVersion = swVersion;
+ }
+
+ public String getFrameId() {
+ return frameId;
+ }
+
+ public void setFrameId(String frameId) {
+ this.frameId = frameId;
+ }
+
+ public String getSerialNumber() {
+ return serialNumber;
+ }
+
+ public void setSerialNumber(String serialNumber) {
+ this.serialNumber = serialNumber;
+ }
+
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+
+ private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
+
+ public String toJson() {
+ return gson.toJson(this);
+ }
+
+
+ public static PnfInstance fromJson(String payload) throws AuditException {
+ try {
+ if (payload == null || payload.isEmpty()) {
+ throw new AuditException("Empty Json response");
+ }
+ return gson.fromJson(payload, PnfInstance.class);
+ } catch (Exception ex) {
+ throw new AuditException(AuditError.JSON_READER_PARSE_ERROR, ex);
+ }
+ }
+
+ /**
+ * No args constructor for use in serialization
+ *
+ */
+ public PnfInstance() {
+ }
+
+ /**
+ *
+ * @param uuid
+ * @param name
+ * @param networkRole
+ * @param name2
+ * @param name2Source
+ * @param equipmentType
+ * @param equipmentVendor
+ * @param equipmentModel
+ * @param managementOptions
+ * @param swVersion
+ * @param frameId
+ * @param serialNumber
+ * @param modelInvariantId
+ * @param modelVersionId
+ *
+ */
+ public PnfInstance(String uuid, String name, String networkRole, String name2, String name2Source,String equipmentType,String equipmentVendor,String equipmentModel,String managementOptions,String swVersion, String frameId, String serialNumber, String modelInvariantId, String modelVersionId) {
+ super();
+ this.pnfId = uuid;
+ this.pnfName = name;
+ this.nfRole = networkRole;
+ this.pnfName2 = name2;
+ this.pnfName2Source = name2Source;
+ this.equipmentType = equipmentType;
+ this.equipmentVendor = equipmentVendor;
+ this.equipmentModel = equipmentModel;
+ this.managementOptions = managementOptions;
+ this.swVersion = swVersion;
+ this.frameId = frameId;
+ this.serialNumber = serialNumber;
+ this.modelInvariantId = modelInvariantId;
+ this.modelVersionId = modelVersionId;
+ }
+
+
+
+ /////////// common functions //////////////////////
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("uuid", pnfId)
+ .append("name", pnfName)
+ .append("networkRole", nfRole)
+ .append("name2", pnfName2)
+ .append("name2Source", pnfName2Source)
+ .append("equipmentType", equipmentType)
+ .append("equipmentVendor", equipmentVendor)
+ .append("equipmentModel", equipmentModel)
+ .append("managementOptions", managementOptions)
+ .append("swVersion", swVersion)
+ .append("frameId", frameId)
+ .append("serialNumber", serialNumber)
+ .append("modelInvariantId", modelInvariantId)
+ .append("modelVersionId", modelVersionId)
+ .toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(pnfId).append(frameId).append(serialNumber).append(modelInvariantId).append(modelVersionId).toHashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if (!(other instanceof PnfInstance)) {
+ return false;
+ }
+ PnfInstance rhs = ((PnfInstance) other);
+ return new EqualsBuilder()
+ .append(pnfId, rhs.pnfId)
+ .append(pnfName, rhs.pnfName)
+ .append(pnfName2, rhs.pnfName2)
+ .append(equipmentType, rhs.equipmentType)
+ .append(equipmentModel, rhs.equipmentModel)
+ .append(frameId, rhs.frameId)
+ .append(serialNumber, rhs.serialNumber)
+ .isEquals();
+ }
+}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java b/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java
index 1f34cc6..88f3db4 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java
@@ -37,7 +37,8 @@ import org.onap.pomba.common.datatypes.Attribute;
import org.onap.pomba.common.datatypes.DataQuality;
import org.onap.pomba.common.datatypes.ModelContext;
import org.onap.pomba.common.datatypes.Service;
-import org.onap.pomba.common.datatypes.VF;
+//import org.onap.pomba.common.datatypes.VF;
+import org.onap.pomba.common.datatypes.VNF;
import org.onap.pomba.common.datatypes.VFModule;
import org.onap.pomba.common.datatypes.VM;
import org.onap.pomba.common.datatypes.VNFC;
@@ -53,7 +54,9 @@ import org.onap.pomba.contextbuilder.aai.exception.AuditError;
import org.onap.pomba.contextbuilder.aai.exception.AuditException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+import org.onap.pomba.contextbuilder.aai.datatype.PnfInstance;
+import org.onap.pomba.common.datatypes.PNF;
+import com.bazaarvoice.jolt.JsonUtils;
public class RestUtil {
@@ -80,6 +83,7 @@ public class RestUtil {
private static final String VF_MODULES = "vf-modules";
private static final String VF_MODULE = "vf-module";
+ private static final String CATALOG_PNF = "pnf";
// Relationship Json Path
private static final String RELATIONSHIP_LIST = "relationship-list";
@@ -100,6 +104,20 @@ public class RestUtil {
private static final String HOSTNAME = "hostName";
private static final String IMAGEID = "imageId";
+ //Attribute Names for PNF
+ private static final String PNF_NETWORK_FUNCTION = "networkFunction";
+ private static final String PNF_NETWORK_ROLE = "networkRole";
+ private static final String PNF_RESOURCE_VERSION = "resourceVersion";
+ private static final String PNF_NAME2 = "name2";
+ private static final String PNF_NAME2_SOURCE = "name2Source";
+ private static final String PNF_EQUIPMENT_TYPE = "equipType";
+ private static final String PNF_EQUIPMENT_VENDOR = "equipVendor";
+ private static final String PNF_EQUIPMENT_MODEL = "equipModel";
+ private static final String PNF_MANAGEMENT_OPTIONS = "managementOptions";
+ private static final String PNF_SW_VERSION = "swVersion";
+ private static final String PNF_FRAME_ID = "frameId";
+ private static final String PNF_SERIAL_NUMBER = "serialNumber";
+
/**
* Validates the URL parameter.
*
@@ -183,6 +201,8 @@ public class RestUtil {
return null;
}
+ log.info("ResourceLink from AAI:" + resourceLink);
+
// Build URl to get ServiceInstance Payload
String url = baseURL + resourceLink;
@@ -196,6 +216,7 @@ public class RestUtil {
// Only return the empty Json on the root level. i.e service instance
return null;
}
+ log.info("Message from AAI:" + JsonUtils.toPrettyJsonString(JsonUtils.jsonToObject(serviceInstancePayload)) );
List<String> genericVNFLinkLst = extractRelatedLink(serviceInstancePayload, CATALOG_GENERIC_VNF);
log.info(LogMessages.NUMBER_OF_API_CALLS, "genericVNF", genericVNFLinkLst.size());
@@ -212,6 +233,8 @@ public class RestUtil {
if (isEmptyJson(genericVNFPayload)) {
log.info(LogMessages.NOT_FOUND, "GenericVNF with url ", genericVNFLink);
} else {
+ log.info("Message from AAI for VNF " + genericVNFURL + ",message body:" + JsonUtils.toPrettyJsonString(JsonUtils.jsonToObject(genericVNFPayload)) );
+
// Logic to Create the Generic VNF Instance POJO object
VnfInstance vnfInstance = VnfInstance.fromJson(genericVNFPayload);
vnfLst.add(vnfInstance);
@@ -224,8 +247,35 @@ public class RestUtil {
}
}
+
+ //Obtain PNF (Physical Network Function)
+ List<String> genericPNFLinkLst = extractRelatedLink(serviceInstancePayload, CATALOG_PNF);
+ log.info(LogMessages.NUMBER_OF_API_CALLS, "PNF", genericPNFLinkLst.size());
+ log.info(LogMessages.API_CALL_LIST, "PNF", printOutAPIList(genericPNFLinkLst));
+
+ String genericPNFPayload = null;
+ List<PnfInstance> pnfLst = new ArrayList<PnfInstance>(); // List of the PNF POJO object
+
+ for (String genericPNFLink : genericPNFLinkLst) {
+ // With latest AAI development, in order to retrieve the both generic PNF
+ String genericPNFURL = baseURL + genericPNFLink;
+ // Response from generic PNF API call
+ genericPNFPayload =
+ getResource(aaiClient, genericPNFURL, aaiBasicAuthorization, transactionId, MediaType.valueOf(MediaType.APPLICATION_JSON));
+
+ if (isEmptyJson(genericPNFPayload)) {
+ log.info(LogMessages.NOT_FOUND, "GenericPNF with url ", genericPNFLink);
+ } else {
+ log.info("Message from AAI for PNF " + genericPNFLink + ",message body:" + JsonUtils.toPrettyJsonString(JsonUtils.jsonToObject(genericPNFPayload)) );
+
+ // Logic to Create the Generic VNF Instance POJO object
+ PnfInstance pnfInstance = PnfInstance.fromJson(genericPNFPayload);
+ pnfLst.add(pnfInstance);
+ }
+ }
+
// Transform to common model and return
- return transform(ServiceInstance.fromJson(serviceInstancePayload), vnfLst, vnfcMap, vnf_vfmodule_vserver_Map);
+ return transform(ServiceInstance.fromJson(serviceInstancePayload), vnfLst, vnfcMap, vnf_vfmodule_vserver_Map, pnfLst);
}
/*
@@ -250,6 +300,7 @@ public class RestUtil {
if (isEmptyJson(vnfcPayload)) {
log.info(LogMessages.NOT_FOUND, "VNFC with url", vnfcLink);
} else {
+ log.info("Message from AAI for VNFC with url " + vnfcLink + ",message body:" + JsonUtils.toPrettyJsonString(JsonUtils.jsonToObject(vnfcPayload)) );
// Logic to Create the VNFC POJO object
VnfcInstance vnfcInstance = VnfcInstance.fromJson(vnfcPayload);
vnfcLst.add(vnfcInstance);
@@ -322,18 +373,18 @@ public class RestUtil {
* Transform AAI Representation to Common Model
*/
private static ModelContext transform(ServiceInstance svcInstance, List<VnfInstance> vnfLst,
- Map<String, List<VnfcInstance>> vnfcMap, Map<String, Map<String, List<Vserver>>> vnf_vfmodule_vserver_Map) {
+ Map<String, List<VnfcInstance>> vnfcMap, Map<String, Map<String, List<Vserver>>> vnf_vfmodule_vserver_Map, List<PnfInstance> pnfLst_fromAAi) {
ModelContext context = new ModelContext();
Service service = new Service();
- service.setInvariantUuid(svcInstance.getModelInvariantId());
+ service.setModelInvariantUUID(svcInstance.getModelInvariantId());
service.setName(svcInstance.getServiceInstanceName());
service.setUuid(svcInstance.getServiceInstanceId());
service.setDataQuality(DataQuality.ok());
- List<VF> vfLst = new ArrayList<VF>();
+ List<VNF> vfLst = new ArrayList<VNF>();
for (VnfInstance vnf : vnfLst) {
- VF vf = new VF();
- vf.setInvariantUuid(vnf.getModelInvariantId());
+ VNF vf = new VNF();
+ vf.setModelInvariantUUID(vnf.getModelInvariantId());
vf.setName(vnf.getVnfName());
vf.setUuid(vnf.getModelVersionId());
vf.setType(vnf.getVnfType());
@@ -350,7 +401,7 @@ public class RestUtil {
for (VnfcInstance vnfc : vnfcInstanceLst) {
VNFC vnfcModel = new VNFC();
- vnfcModel.setInvariantUuid(vnfc.getModelInvariantId());
+ vnfcModel.setModelInvariantUUID(vnfc.getModelInvariantId());
vnfcModel.setName(vnfc.getVnfcName());
vnfcModel.setUuid(vnfc.getModelVersionId());
vnfcLst.add(vnfcModel);
@@ -381,7 +432,7 @@ public class RestUtil {
VFModule vfModule = new VFModule();
vfModule.setUuid(modelVersionId);
- vfModule.setInvariantUuid(modelInvariantId);
+ vfModule.setModelInvariantUUID(modelInvariantId);
vfModule.setMaxInstances(getMaxInstance(vfmoduleEntry.getKey(), maxInstanceMap));
vfModule.setDataQuality(DataQuality.ok());
@@ -440,11 +491,142 @@ public class RestUtil {
} // done the vnfInstance
context.setService(service);
- context.setVfs(vfLst);
+ context.setVnfs(vfLst);
+ //Add PNF info
+ context.setPnfs(transformPNF(pnfLst_fromAAi));
return context;
}
+ /*
+ * Transform AAI Representation to Common Model
+ */
+ public static List<PNF> transformPNF(List<PnfInstance> pnfLst_from_AAI) {
+ if (pnfLst_from_AAI.isEmpty()) {
+ log.info(LogMessages.API_CALL_LIST, "Nill PNF list");
+ return null;
+ }
+ List<PNF> pnfLst = new ArrayList<PNF>();
+
+ for (PnfInstance pnf_from_aai : pnfLst_from_AAI) {
+ PNF pnf = new PNF();
+ pnf.setModelInvariantUUID(pnf_from_aai.getPnfId());
+ pnf.setName(pnf_from_aai.getPnfName());
+ pnf.setModelVersionID(pnf_from_aai.getModelVersionId());
+ pnf.setModelInvariantUUID(pnf_from_aai.getModelInvariantId());
+ pnf.setDataQuality(DataQuality.ok());
+ List<Attribute> attributeList = new ArrayList<Attribute>();
+ pnf.setAttributes(attributeList);
+
+ // Iterate through the ENUM Attribute list
+ for (Attribute.Name name: Attribute.Name.values()) {
+ if (name.toString().equals(PNF_NETWORK_FUNCTION )) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.networkFunction);
+ att.setValue(String.valueOf( pnf_from_aai.getNfFunction()));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals(PNF_NETWORK_ROLE )) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.networkRole);
+ att.setValue(String.valueOf( pnf_from_aai.getNfRole()));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals(PNF_RESOURCE_VERSION)) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.resourceVersion);
+ att.setValue(String.valueOf( pnf_from_aai.getResourceVersion()));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals(PNF_NAME2)) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.name2);
+ att.setValue(String.valueOf( pnf_from_aai.getPnfName2()));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals(PNF_NAME2_SOURCE )) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.name2Source);
+ att.setValue(String.valueOf( pnf_from_aai.getPnfName2Source()));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals(PNF_EQUIPMENT_TYPE )) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.equipType);
+ att.setValue(String.valueOf( pnf_from_aai.getEquipmentType()));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals(PNF_EQUIPMENT_VENDOR )) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.equipVendor);
+ att.setValue(String.valueOf( pnf_from_aai.getEquipmentVendor()));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals(PNF_EQUIPMENT_MODEL)) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.equipModel);
+ att.setValue(String.valueOf( pnf_from_aai.getEquipmentModel()));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals(PNF_MANAGEMENT_OPTIONS)) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.managementOptions);
+ att.setValue(String.valueOf( pnf_from_aai.getManagementOptions()));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals(PNF_SW_VERSION)) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.swVersion);
+ att.setValue(String.valueOf( pnf_from_aai.getManagementOptions()));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals(PNF_FRAME_ID)) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.frameId);
+ att.setValue(String.valueOf( pnf_from_aai.getFrameId()));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals(PNF_SERIAL_NUMBER)) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.serialNumber);
+ att.setValue(String.valueOf( pnf_from_aai.getSerialNumber()));
+ attributeList.add(att);
+ }
+
+ }
+
+ pnf.setAttributes(attributeList);
+ pnfLst.add(pnf);
+
+ } // done the vnfInstance
+
+
+ return pnfLst;
+ }
+
/*
* Return the Vserver Attribute value by looking through the relationship. i.e. if "related-to" is "pserver", we will get
diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java
index ad8193a..3753ea6 100644
--- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java
+++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java
@@ -42,6 +42,7 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
+import org.onap.pomba.common.datatypes.ModelContext;
@RunWith(SpringJUnit4ClassRunner.class)
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class })
@@ -127,4 +128,35 @@ public class RestUtilTest {
}
return content.toString();
}
+
+
+ ////
+ @Test
+ public void testretrieveAAIModelDataFromAAI() throws Exception {
+
+ String transactionId = UUID.randomUUID().toString();
+ String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json
+ String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId;
+ // 1. simulate the response to obtainResourceLink based on ServiceInstanceId
+ addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule);
+ // 2. simulate the response of AAI (1 vnf and 1 pnf)
+ addResponse( "/aai/v11/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb",
+ "junit/aai-service-instance.json", aaiEnricherRule);
+
+ // 3. simulate the rsp of VNF
+ addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39?depth=2",
+ "junit/genericVnfInput.json", aaiEnricherRule);
+
+ // 4. simulate the response of PNF based on the resourceLink in (2)
+ //note: match pnf_id in junit/aai-service-instance.json
+ addResponse( "/aai/v13/network/pnfs/pnf/amdocsPnfName",
+ "junit/pnfSampleInput.json", aaiEnricherRule);
+
+ ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization);
+
+ assertEquals(modelCtx.getVnfs().size(), 1);
+ assertEquals(modelCtx.getPnfs().size(), 1);
+
+ }
+
}
diff --git a/src/test/resources/junit/aai-service-instance.json b/src/test/resources/junit/aai-service-instance.json
new file mode 100644
index 0000000..b98c5f6
--- /dev/null
+++ b/src/test/resources/junit/aai-service-instance.json
@@ -0,0 +1,43 @@
+{
+ "service-instance-id": "adc3cc2a-c73e-414f-8ddb-367de81300cb",
+ "service-instance-name": "Firewall1",
+ "model-invariant-id": "0c5a20de-87ad-442c-9190-f38ab0a6bb7f",
+ "model-version-id": "d3d6cf83-d03a-43cc-99ff-206d40bb9a72",
+ "resource-version": "1527637758480",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "related-link": "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "8a9ddb25-2e79-449c-a40d-5011bac0da39"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "Firewall-1"
+ }
+ ]
+ },
+ {
+ "related-to": "pnf",
+ "related-link": "/aai/v13/network/pnfs/pnf/amdocsPnfName",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "amdocsPnfName"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pnf.pnf-name",
+ "property-value": "Phillip"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/src/test/resources/junit/genericVnfInput.json b/src/test/resources/junit/genericVnfInput.json
new file mode 100644
index 0000000..aac8bd6
--- /dev/null
+++ b/src/test/resources/junit/genericVnfInput.json
@@ -0,0 +1,96 @@
+{
+ "vnf-id": "8a9ddb25-2e79-449c-a40d-5011bac0da39",
+ "vnf-name": "Firewall-1",
+ "vnf-type": "vFW-vSINK-service/vFWvSINK 0",
+ "service-id": "8ea56b0d-459d-4668-b363-c9567432d8b7",
+ "prov-status": "PREPROV",
+ "orchestration-status": "Created",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1527637940029",
+ "model-invariant-id": "59dd4d63-8f21-406c-98c0-3b057bb86820",
+ "model-version-id": "e2d52f32-a952-46f5-800c-c250903625d6",
+ "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc",
+ "nf-type": "",
+ "nf-function": "",
+ "nf-role": "",
+ "nf-naming-code": "",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFWCL/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "Demonstration"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "vFWCL"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "adc3cc2a-c73e-414f-8ddb-367de81300cb"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "Firewall1"
+ }
+ ]
+ },
+ {
+ "related-to": "l3-network",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951870",
+ "relationship-data": [
+ {
+ "relationship-key": "l3-network.network-id",
+ "relationship-value": "HNP1d77c-1094-41ec-b7f3-94bb30951870"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "l3-network.network-name",
+ "property-value": "HNPORTALOAM.OAM"
+ }
+ ]
+ },
+ {
+ "related-to": "l3-network",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951872",
+ "relationship-data": [
+ {
+ "relationship-key": "l3-network.network-id",
+ "relationship-value": "HNP1d77c-1094-41ec-b7f3-94bb30951872"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "l3-network.network-name",
+ "property-value": "HNPORTAL_SRIOV_2"
+ }
+ ]
+ }
+ ]
+ },
+ "vf-modules": {
+ "vf-module": [
+ {
+ "vf-module-id": "1563b649-9e05-4288-b7d9-e3639a54ace6",
+ "vf-module-name": "vFW_SINC_Module-2",
+ "heat-stack-id": "vFW_SINC_Module-2/41c4533a-748d-4cf4-a8d3-eccdd0aeb0d4",
+ "orchestration-status": "active",
+ "is-base-vf-module": true,
+ "resource-version": "1527638439198",
+ "model-invariant-id": "74bc1518-282d-4148-860f-8892b6369456",
+ "model-version-id": "4e3d28cf-d654-41af-a47b-04b4bd0ac58e",
+ "model-customization-id": "cc51ab7d-9b03-4bd6-9104-09df0c7c7907",
+ "module-index": 0
+ }
+ ]
+ }
+}
diff --git a/src/test/resources/junit/pnfSampleInput.json b/src/test/resources/junit/pnfSampleInput.json
new file mode 100644
index 0000000..44f4a2d
--- /dev/null
+++ b/src/test/resources/junit/pnfSampleInput.json
@@ -0,0 +1,22 @@
+{
+ "pnf-name": "amdocsPnfName",
+ "pnf-name2": "amdocsPnfName2",
+ "pnf-name2-source": "pombaName2Source",
+ "pnf-id": "11112222pnf88889999",
+ "equip-type": "software",
+ "equip-vendor": "8df84f0a-737a-4628-be9c-c3c78454f9d9",
+ "equip-model": "123134236",
+ "management-option": "TBD",
+ "sw-version": "2",
+ "in-maint": "true",
+ "frame-id": "99888",
+ "serial-number": "c44b872f6830498b88c4989d67b2a6b7",
+ "status": "ACTIVE",
+ "nf-role": "22222",
+ "model-invariant-id": "12345",
+ "model-version-id": "2123",
+ "admin_state_up": true,
+ "tenant_id": "c44b872f6830498b88c4989d67b2a6b7",
+ "created_at": "2018-03-20T16:49:01Z",
+ "provider:network_type": "vlan"
+} \ No newline at end of file