summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml1
-rw-r--r--sparkybe-onap-application/pom.xml208
-rw-r--r--sparkybe-onap-application/src/main/config/ajsc-override-web.xml13
-rw-r--r--sparkybe-onap-application/src/main/config/runner-web.xml14
-rw-r--r--sparkybe-onap-application/src/main/docker/Dockerfile21
-rw-r--r--sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java142
-rw-r--r--sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyConfigLoader.java (renamed from sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/PropertyConfigLoader.java)7
-rw-r--r--sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyHttpConfigLoader.java (renamed from sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNodeLink.java)57
-rw-r--r--sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySpringXmlConfiguration.java19
-rw-r--r--sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySslConfigLoader.java32
-rw-r--r--sparkybe-onap-application/src/main/scripts/start.sh58
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java84
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java155
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java2
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java36
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java34
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java98
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java203
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProviderTest.java60
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilderTest.java30
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java83
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/GizmoAdapterTest.java60
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java97
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java64
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/AggregationEntityTest.java33
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilderTest.java31
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntityTest.java30
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/SearchFilterTest.java35
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntityTest.java55
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntityTest.java39
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/TestUserManager.java32
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/subscription/services/SubscriptionServiceTest.java51
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java34
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java59
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java96
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoEntityTest.java62
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipEntityTest.java62
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipHintTest.java37
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContextTest.java110
-rw-r--r--version.properties13
40 files changed, 1372 insertions, 985 deletions
diff --git a/pom.xml b/pom.xml
index ced2b31..c869787 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,6 +7,7 @@
<artifactId>sparky-be</artifactId>
<version>1.2.0-SNAPSHOT</version>
<packaging>pom</packaging>
+ <name>aai-sparky-be</name>
<modules>
<module>sparkybe-onap-service/pom.xml</module>
diff --git a/sparkybe-onap-application/pom.xml b/sparkybe-onap-application/pom.xml
index 92c3126..646b8e3 100644
--- a/sparkybe-onap-application/pom.xml
+++ b/sparkybe-onap-application/pom.xml
@@ -1,5 +1,6 @@
-<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>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
@@ -8,9 +9,9 @@
</parent>
<groupId>org.onap.aai.sparky-be</groupId>
- <artifactId>sparkybe-onap-application</artifactId>
+ <artifactId>sparkybe-onap-application</artifactId>
<version>1.2.0-SNAPSHOT</version>
- <packaging>jar</packaging>
+ <packaging>jar</packaging>
<properties>
<java.version>1.8</java.version>
@@ -23,32 +24,34 @@
<nexusproxy>https://nexus.onap.org</nexusproxy>
<camel-spring-boot.version>2.20.0</camel-spring-boot.version>
<config-home>${basedir}/</config-home>
+ <docker.location>${basedir}/target</docker.location>
+ <docker.image.name>sparky-be</docker.image.name>
</properties>
<dependencyManagement>
- <dependencies>
+ <dependencies>
+
+ <!-- Camel BOM -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-boot-dependencies</artifactId>
+ <version>${camel-spring-boot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
- <!-- Camel BOM -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-spring-boot-dependencies</artifactId>
- <version>${camel-spring-boot.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
-
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>1.2.1</version>
- </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.1</version>
+ </dependency>
- </dependencies>
+ </dependencies>
-</dependencyManagement>
+ </dependencyManagement>
<dependencies>
@@ -73,14 +76,14 @@
</exclusion>
</exclusions>
</dependency>
-
+
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<exclusions>
<exclusion>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
@@ -125,7 +128,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- </dependency>
+ </dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-util -->
<dependency>
@@ -144,11 +147,11 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
- <dependency>
- <groupId>org.onap.aai.sparky-be</groupId>
- <artifactId>sparkybe-onap-service</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </dependency>
+ <dependency>
+ <groupId>org.onap.aai.sparky-be</groupId>
+ <artifactId>sparkybe-onap-service</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </dependency>
@@ -378,13 +381,22 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+ <folders>
+ <folder>
+ ${CONFIG_HOME}/portal/
+ </folder>
+ </folders>
+ </configuration>
</plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
+ <version>2.7</version>
<executions>
<execution>
- <id>copy-docker-file</id>
+ <id>copy-docker-file-to-target</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
@@ -400,8 +412,33 @@
<include>**/*</include>
</includes>
</resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.7</version>
+ <executions>
+ <execution>
+ <id>copy-scripts-to-target</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>target/scripts</outputDirectory>
+ <overwrite>true</overwrite>
+ <resources>
<resource>
- <directory>${basedir}/src/main/bin/</directory>
+ <directory>${basedir}/src/main/scripts</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
</resource>
</resources>
</configuration>
@@ -409,15 +446,16 @@
</executions>
</plugin>
- <plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
+ <version>3.0.0</version>
<executions>
<execution>
- <id>copy-installed</id>
+ <id>copy-war-to-target</id>
<phase>install</phase>
<goals>
- <goal>copy</goal>
+ <goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
@@ -426,15 +464,14 @@
<artifactId>${frontEndArtifactId}</artifactId>
<version>${frontEndVersion}</version>
<type>war</type>
- <outputDirectory>${basedir}/target/</outputDirectory>
- <destFileName>aai.war</destFileName>
+ <outputDirectory>${basedir}/target/static/</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
- </plugin>
-
+ </plugin>
+
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
@@ -486,38 +523,14 @@
</reportPlugins>
</configuration>
</plugin>
-
- <!-- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.7</version>
- <executions>
- <execution>
- <id>copy-docker-file</id>
- <phase>package</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>target</outputDirectory>
- <overwrite>true</overwrite>
- <resources>
- <resource>
- <directory>${basedir}/src/main/docker</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- <resource>
- <directory>${basedir}/src/main/scripts/</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- -->
+
+ <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId>
+ <version>2.7</version> <executions> <execution> <id>copy-docker-file</id>
+ <phase>package</phase> <goals> <goal>copy-resources</goal> </goals> <configuration>
+ <outputDirectory>target</outputDirectory> <overwrite>true</overwrite> <resources>
+ <resource> <directory>${basedir}/src/main/docker</directory> <filtering>true</filtering>
+ <includes> <include>**/*</include> </includes> </resource> <resource> <directory>${basedir}/src/main/scripts/</directory>
+ </resource> </resources> </configuration> </execution> </executions> </plugin> -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
@@ -525,7 +538,7 @@
<configuration>
<verbose>true</verbose>
<serverId>docker-hub</serverId>
- <imageName>${docker.push.registry}/onap/${project.artifactId}</imageName>
+ <imageName>${docker.push.registry}/onap/${docker.image.name}</imageName>
<dockerDirectory>${docker.location}</dockerDirectory>
<imageTags>
<imageTag>latest</imageTag>
@@ -534,41 +547,26 @@
</configuration>
</plugin>
<!-- license plugin -->
-<!-- <plugin>
- <groupId>com.mycila</groupId>
- <artifactId>license-maven-plugin</artifactId>
- <version>3.0</version>
- <configuration>
- <header>LICENSE</header>
- <includes>
- <include>src/main/java/**</include>
- </includes>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>format</goal>
- </goals>
- <phase>process-sources</phase>
- </execution>
- </executions>
- </plugin>
- -->
+ <!-- <plugin> <groupId>com.mycila</groupId> <artifactId>license-maven-plugin</artifactId>
+ <version>3.0</version> <configuration> <header>LICENSE</header> <includes>
+ <include>src/main/java/**</include> </includes> </configuration> <executions>
+ <execution> <goals> <goal>format</goal> </goals> <phase>process-sources</phase>
+ </execution> </executions> </plugin> -->
</plugins>
</build>
- <distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>ECOMP Release Repository</name>
- <url>${nexusproxy}/content/repositories/releases/</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>ECOMP Snapshot Repository</name>
- <url>${nexusproxy}/content/repositories/snapshots/</url>
- </snapshotRepository>
- </distributionManagement>
-
+ <distributionManagement>
+ <repository>
+ <id>ecomp-releases</id>
+ <name>ECOMP Release Repository</name>
+ <url>${nexusproxy}/content/repositories/releases/</url>
+ </repository>
+ <snapshotRepository>
+ <id>ecomp-snapshots</id>
+ <name>ECOMP Snapshot Repository</name>
+ <url>${nexusproxy}/content/repositories/snapshots/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
</project>
diff --git a/sparkybe-onap-application/src/main/config/ajsc-override-web.xml b/sparkybe-onap-application/src/main/config/ajsc-override-web.xml
deleted file mode 100644
index b8ff7da..0000000
--- a/sparkybe-onap-application/src/main/config/ajsc-override-web.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. -->
-<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- metadata-complete="false" version="3.0">
-
- <servlet-mapping>
- <servlet-name>PortalRestAPIProxy</servlet-name>
- <url-pattern>/api/v2/*</url-pattern>
- </servlet-mapping>
-
-
-</web-app> \ No newline at end of file
diff --git a/sparkybe-onap-application/src/main/config/runner-web.xml b/sparkybe-onap-application/src/main/config/runner-web.xml
deleted file mode 100644
index ca0c5e2..0000000
--- a/sparkybe-onap-application/src/main/config/runner-web.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. -->
-<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- metadata-complete="false" version="3.0">
-
- <servlet>
- <servlet-name>PortalRestAPIProxy</servlet-name>
- <servlet-class>org.openecomp.portalsdk.core.onboarding.crossapi.PortalRestAPIProxy</servlet-class>
- </servlet>
-
-
-
-</web-app>
diff --git a/sparkybe-onap-application/src/main/docker/Dockerfile b/sparkybe-onap-application/src/main/docker/Dockerfile
index d98110c..f5e620c 100644
--- a/sparkybe-onap-application/src/main/docker/Dockerfile
+++ b/sparkybe-onap-application/src/main/docker/Dockerfile
@@ -16,15 +16,22 @@ RUN export JAVA_HOME
# Build up the deployment folder structure
RUN mkdir -p $MICRO_HOME
RUN mkdir -p $BIN_HOME
+RUN mkdir -p $MICRO_HOME/lib/
+RUN mkdir -p $MICRO_HOME/static/services/aai/webapp/
-# copy swm/package/nix/dist_files/appl/sparky-be/${project.version}/ $MICRO_HOME/
-RUN ls -la $BIN_HOME/
+ADD *.jar $MICRO_HOME/lib/
+ADD scripts/* $MICRO_HOME/bin/
+COPY static/ $MICRO_HOME/static/services/aai/webapp/
+
+RUN chmod 755 $MICRO_HOME/bin/*
+RUN chmod 755 $MICRO_HOME/lib/*
+RUN chmod 755 $MICRO_HOME/static/*
+
+#RUN ls -la $BIN_HOME/
-#RUN chmod 755 $BIN_HOME/*
RUN ln -s /logs $MICRO_HOME/logs
EXPOSE 8000 8000
-
-CMD tail -F -n0 /etc/hosts
-#CMD /opt/app/sparky/bin/start.sh
-#CMD top
+EXPOSE 9517 9517
+
+CMD ["/opt/app/sparky/bin/start.sh"] \ No newline at end of file
diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java
index 548a48b..1077642 100644
--- a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java
+++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java
@@ -18,97 +18,32 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-/**
- * This copy of Woodstox XML processor is licensed under the
- * Apache (Software) License, version 2.0 ("the License").
- * See the License for details about distribution rights, and the
- * specific rights regarding derivate works.
- *
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/
- *
- * A copy is also included in the downloadable source code package
- * containing Woodstox, in file "ASL2.0", under the same directory
- * as this file.
- */
package org.onap.aai.sparky;
-import org.apache.camel.builder.RouteBuilder;
+import javax.servlet.Filter;
+
+import org.onap.aai.sparky.security.filter.LoginFilter;
+
import org.apache.camel.component.servlet.CamelHttpTransportServlet;
-import org.apache.camel.model.rest.RestBindingMode;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
-import org.springframework.boot.web.support.SpringBootServletInitializer;
-import org.springframework.context.ApplicationContext;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
-import org.springframework.stereotype.Component;
@SpringBootApplication
-public class Application /*extends SpringBootServletInitializer */ {
-
- private @Autowired AutowireCapableBeanFactory beanFactory;
-
- public static void main(String[] args) {
+public class Application {
- ApplicationContext applicationContext = SpringApplication.run(Application.class, args);
-
- /*for (String name : applicationContext.getBeanDefinitionNames()) {
- System.out.println(name);
- }*/
+ private Filter loginFilter = new LoginFilter();
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
}
-
- /* @Component
- class RestApi extends RouteBuilder {
-
- @Override
- public void configure() {
-
- //restConfiguration().component("restlet").contextPath("/rs").bindingMode(RestBindingMode.json);
-
- /*rest("/books").description("Books REST service")
- .get("/").description("The list of all the books")
- .route().routeId("books-api")
- .bean(Database.class, "findBooks")
- .endRest()
- .get("order/{id}").description("Details of an order by id")
- .route().routeId("order-api")
- .bean(Database.class, "findOrder(${header.id})");*/
- /* }
- }*/
-
-
- /*
- * TODO: we need to figure out the initialization required for our restlets
- */
-
- /*@Bean
- public ServletRegistrationBean restletBootstrapInitialization() {
-
- SpringServerServlet serverServlet = new SpringServerServlet();
- ServletRegistrationBean regBean = new ServletRegistrationBean( serverServlet, "/rest/*");
-
-
- Map<String,String> params = new HashMap<String,String>();
-
- params.put("org.restlet.component", "restletComponent");
-
- regBean.setInitParameters(params);
-
- return regBean;
- }*/
-
-
-
/*
* This initialization code enabled access to aai-ui-proxy-processor
*/
-
@Bean
ServletRegistrationBean servletRegistrationBean() {
final ServletRegistrationBean servlet =
@@ -117,51 +52,20 @@ public class Application /*extends SpringBootServletInitializer */ {
return servlet;
}
- /* @Bean
- public EmbeddedServletContainerFactory servletContainerFactory() {
- return new TomcatEmbeddedServletContainerFactory() {
-
- /*
- * Stackoverflow solution for adding a WAR into our embedded tomcat runtime
- * https://stackoverflow.com/questions/31374726/spring-boot-how-to-add-another-war-files-to-the-embedded-tomcat
- */
-
-
- /* @Override
- protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(Tomcat tomcat) {
- // Ensure that the webapps directory exists
- System.out.println("catalina base = " + tomcat.getServer().getCatalinaBase());
- new File(tomcat.getServer().getCatalinaBase(), "webapps").mkdirs();
-
- try {
- Context context = tomcat.addWebapp("/services/aai/webapp", "X:\\2018_dev\\OSEAAI\\NUC-7257-spring-boot-conversion\\onap_sparky-be\\src\\main\\resources\\extApps\\aai.war");
+ /**
+ * bind LoginFilter
+ */
+ @Bean
+ @ConditionalOnProperty(value = "sparky.portal.enabled", havingValue = "true")
+ public FilterRegistrationBean loginFilterRegistrationBean() {
+ FilterRegistrationBean registration = new FilterRegistrationBean();
+
+ registration.setFilter(loginFilter);
+ registration.addUrlPatterns("/*");
+
+ return registration;
+ }
- // Allow the webapp to load classes from your fat jar
- context.setParentClassLoader(getClass().getClassLoader());
- } catch (ServletException ex) {
- throw new IllegalStateException("Failed to add webapp", ex);
- }
- return super.getTomcatEmbeddedServletContainer(tomcat);
- }
- };
- }*/
- /**
- * bind LoginFilter
- */
-
- /*@Bean
- public FilterRegistrationBean myFilter() {
- FilterRegistrationBean registration = new FilterRegistrationBean();
- Filter myFilter = new LoginFilter();
- beanFactory.autowireBean(myFilter);
- registration.setFilter(myFilter);
- registration.addUrlPatterns("/*");
- return registration;
- }*/
-
-
-
-
}
diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/PropertyConfigLoader.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyConfigLoader.java
index dfc4b2b..5124ce7 100644
--- a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/PropertyConfigLoader.java
+++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyConfigLoader.java
@@ -24,7 +24,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
-@PropertySource("file:${CONFIG_HOME}/config/sparky-application.properties")
-public class PropertyConfigLoader {
-
+@PropertySource("file:${CONFIG_HOME}/sparky-application.properties")
+public class SparkyConfigLoader {
+
+
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNodeLink.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyHttpConfigLoader.java
index 05672f3..4c1d541 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNodeLink.java
+++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyHttpConfigLoader.java
@@ -18,56 +18,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.sparky.viewandinspect.entity;
+package org.onap.aai.sparky.config;
-/*
- * Expected JSON Output:
- *
- * { JsonNodeLink : { id : <value>, source : <value>, target : <value> } }
- *
- */
-
-/**
- * The Class JsonNodeLink.
- */
-public class JsonNodeLink {
-
- protected String id;
- protected String source;
- protected String target;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getSource() {
- return source;
- }
-
- public void setSource(String source) {
- this.source = source;
- }
-
- public String getTarget() {
- return target;
- }
-
- public void setTarget(String target) {
- this.target = target;
- }
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "JsonNodeLink [id=" + id + ", source=" + source + ", target=" + target + "]";
- }
+@Configuration
+@ConditionalOnProperty(value="sparky.ssl.enabled", havingValue = "true")
+@PropertySource("file:${CONFIG_HOME}/sparky-ssl-config.properties")
+public class SparkyHttpConfigLoader {
}
diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySpringXmlConfiguration.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySpringXmlConfiguration.java
index 79656d5..dbbe61d 100644
--- a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySpringXmlConfiguration.java
+++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySpringXmlConfiguration.java
@@ -18,25 +18,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-/**
- * This copy of Woodstox XML processor is licensed under the
- * Apache (Software) License, version 2.0 ("the License").
- * See the License for details about distribution rights, and the
- * specific rights regarding derivate works.
- *
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/
- *
- * A copy is also included in the downloadable source code package
- * containing Woodstox, in file "ASL2.0", under the same directory
- * as this file.
- */
+
package org.onap.aai.sparky.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@Configuration
-@ImportResource({"file:${CONFIG_HOME}/dynamic/spring-beans/*.xml"})
-public class SparkySpringXmlConfiguration {}
+@ImportResource({"file:${CONFIG_HOME}/spring-beans/*.xml"})
+public class SparkySpringXmlConfiguration {} \ No newline at end of file
diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySslConfigLoader.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySslConfigLoader.java
new file mode 100644
index 0000000..c493f64
--- /dev/null
+++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySslConfigLoader.java
@@ -0,0 +1,32 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-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.aai.sparky.config;
+
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+@Configuration
+@ConditionalOnProperty(value="sparky.ssl.enabled", havingValue = "false")
+@PropertySource("file:${CONFIG_HOME}/sparky-http-config.properties")
+public class SparkySslConfigLoader {
+
+}
diff --git a/sparkybe-onap-application/src/main/scripts/start.sh b/sparkybe-onap-application/src/main/scripts/start.sh
index 514d7c5..f2f6f31 100644
--- a/sparkybe-onap-application/src/main/scripts/start.sh
+++ b/sparkybe-onap-application/src/main/scripts/start.sh
@@ -1,59 +1,11 @@
#!/bin/sh
-BASEDIR="/opt/app/sparky"
-MICRO_HOME="$BASEDIR"
-CONFIG_HOME=${MICRO_HOME}/config
+APP_HOME="/opt/app/sparky"
+CONFIG_HOME=${APP_HOME}/appconfig
-if [ -z "$CONFIG_HOME" ]; then
- echo "CONFIG_HOME must be set in order to start up process"
- exit 1
-fi
-
-PROPS="-DCONFIG_HOME=${CONFIG_HOME}"
-
-#echo $CLASSPATH
+PROPS="-DAPP_HOME=${APP_HOME} -DCONFIG_HOME=${CONFIG_HOME}"
set -x
-exec java -Xms1024m -Xmx4096m $PROPS -jar ${MICRO_HOME}/sparky-be.jar --spring.config.name=sparky-be-application
-
-
-
-
-#if [ -z "$KEY_STORE_PASSWORD" ]; then
-# echo "KEY_STORE_PASSWORD must be set in order to start up process"
-# exit 1
-#else
-# sed -i /"KEY_STORE_PASSWORD"/d $AJSC_CONF_HOME/etc/sysprops/sys-props.properties
-# echo "KEY_STORE_PASSWORD=$KEY_STORE_PASSWORD" >> $AJSC_CONF_HOME/etc/sysprops/sys-props.properties
-#fi
-
-#if [ -z "$KEY_MANAGER_PASSWORD" ]; then
-# echo "KEY_MANAGER_PASSWORD must be set in order to start up process"
-# exit 1
-#else
-# sed -i /"KEY_MANAGER_PASSWORD"/d $AJSC_CONF_HOME/etc/sysprops/sys-props.properties
-# echo "KEY_MANAGER_PASSWORD=$KEY_MANAGER_PASSWORD" >> $AJSC_CONF_HOME/etc/sysprops/sys-props.properties
-#fi
-
-#CLASSPATH="$AJSC_HOME/lib/ajsc-runner-2.0.0.jar"
-#CLASSPATH="$CLASSPATH:$AJSC_HOME/extJars/"
-#CLASSPATH="$CLASSPATH:$CONFIG_HOME/portal/"
-#PROPS="-DAJSC_HOME=$AJSC_HOME"
-#PROPS="$PROPS -DAJSC_CONF_HOME=$BASEDIR/bundleconfig/"
-#PROPS="$PROPS -Dlogback.configurationFile=$BASEDIR/bundleconfig/etc/logback.xml"
-#PROPS="$PROPS -DAJSC_SHARED_CONFIG=$AJSC_CONF_HOME"
-#PROPS="$PROPS -DAJSC_EXTERNAL_LIB_FOLDERS=$AJSC_HOME/commonLibs"
-#PROPS="$PROPS -DAJSC_EXTERNAL_PROPERTIES_FOLDERS=$AJSC_HOME/ajsc-shared-config/etc"
-#PROPS="$PROPS -DAJSC_SERVICE_NAMESPACE=ajsc-tier-support-ui"
-#PROPS="$PROPS -DAJSC_SERVICE_VERSION=v1"
-#PROPS="$PROPS -DSOACLOUD_SERVICE_VERSION=0.0.0"
-#PROPS="$PROPS -Dserver.port=8000"
-#PROPS="$PROPS -DCONFIG_HOME=$CONFIG_HOME"
-
-#echo $CLASSPATH
+jar ufv ${APP_HOME}/lib/sparkybe-onap-application*.jar -C ${CONFIG_HOME}/portal/ BOOT-INF/classes/portal.properties
+java -Xms1024m -Xmx4096m $PROPS -jar ${APP_HOME}/lib/sparkybe-onap-application*.jar --sparky.ssl.enabled=${UI_SSL_ENABLED} --sparky.portal.enabled=${UI_PORTAL_ENABLED}
-#if [ "$UI_HTTPS_PORT" ]; then
-# /usr/lib/jvm/java-8-openjdk-amd64/bin/java -Xms1024m -Xmx4096m $PROPS -classpath $CLASSPATH com.att.ajsc.runner.Runner context=/ sslport=$UI_HTTPS_PORT
-#elif [ "$UI_HTTP_PORT" ]; then
-# /usr/lib/jvm/java-8-openjdk-amd64/bin/java -Xms1024m -Xmx4096m $PROPS -classpath $CLASSPATH com.att.ajsc.runner.Runner context=/ port=$UI_HTTP_PORT
-#fi
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java
index b58d91b..a2df3b5 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java
@@ -43,29 +43,31 @@ import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
public class AggregateSummaryProcessor {
- private static final Logger LOG = LoggerFactory.getInstance().getLogger(AggregateSummaryProcessor.class);
+ private static final Logger LOG =
+ LoggerFactory.getInstance().getLogger(AggregateSummaryProcessor.class);
private static final String KEY_FILTERS = "filters";
private ElasticSearchAdapter elasticSearchAdapter = null;
-
+
private String vnfAggregationIndexName;
private FiltersConfig filtersConfig;
-
- public AggregateSummaryProcessor(ElasticSearchAdapter elasticSearchAdapter, FiltersConfig filtersConfig) {
+
+ public AggregateSummaryProcessor(ElasticSearchAdapter elasticSearchAdapter,
+ FiltersConfig filtersConfig) {
this.elasticSearchAdapter = elasticSearchAdapter;
this.filtersConfig = filtersConfig;
}
-
+
public void setVnfAggregationIndexName(String vnfAggregationIndexName) {
this.vnfAggregationIndexName = vnfAggregationIndexName;
}
-
+
public void getFilteredAggregation(Exchange exchange) {
HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
ServletUtils.setUpMdcContext(exchange, request);
-
+
try {
String payload = exchange.getIn().getBody(String.class);
@@ -86,29 +88,29 @@ public class AggregateSummaryProcessor {
if (parameters.has(KEY_FILTERS)) {
requestFilters = parameters.getJSONArray(KEY_FILTERS);
} else {
-
+
JSONObject zeroResponsePayload = new JSONObject();
zeroResponsePayload.put("count", 0);
- //response.setStatus(Status.SUCCESS_OK);
- //response.setEntity(zeroResponsePayload.toString(), MediaType.APPLICATION_JSON);
+ // response.setStatus(Status.SUCCESS_OK);
+ // response.setEntity(zeroResponsePayload.toString(), MediaType.APPLICATION_JSON);
exchange.getOut().setBody(zeroResponsePayload.toString());
-
+
LOG.error(AaiUiMsgs.ERROR_FILTERS_NOT_FOUND);
return;
}
-
+
if (requestFilters != null && requestFilters.length() > 0) {
List<JSONObject> filtersToQuery = new ArrayList<JSONObject>();
- for(int i = 0; i < requestFilters.length(); i++) {
+ for (int i = 0; i < requestFilters.length(); i++) {
JSONObject filterEntry = requestFilters.getJSONObject(i);
filtersToQuery.add(filterEntry);
}
-
+
String jsonResponsePayload = getVnfFilterAggregations(filtersToQuery);
exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 200);
exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "application/json");
exchange.getOut().setBody(jsonResponsePayload);
-
+
} else {
String emptyResponse = getEmptyAggResponse();
exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 200);
@@ -118,10 +120,11 @@ public class AggregateSummaryProcessor {
}
}
} catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, "FilterProcessor failed to get filter list due to error = " + exc.getMessage());
+ LOG.error(AaiUiMsgs.ERROR_GENERIC,
+ "FilterProcessor failed to get filter list due to error = " + exc.getMessage());
}
}
-
+
private String getEmptyAggResponse() {
JSONObject aggPayload = new JSONObject();
aggPayload.put("totalChartHits", 0);
@@ -130,44 +133,45 @@ public class AggregateSummaryProcessor {
payload.append("groupby_aggregation", aggPayload);
return payload.toString();
- }
-
+ }
+
private static final String FILTER_ID_KEY = "filterId";
private static final String FILTER_VALUE_KEY = "filterValue";
private static final int DEFAULT_SHOULD_MATCH_SCORE = 1;
private static final String VNF_FILTER_AGGREGATION = "vnfFilterAggregation";
-
+
private String getVnfFilterAggregations(List<JSONObject> filtersToQuery) throws IOException {
-
+
List<SearchFilter> searchFilters = new ArrayList<SearchFilter>();
- for(JSONObject filterEntry : filtersToQuery) {
-
+ for (JSONObject filterEntry : filtersToQuery) {
+
String filterId = filterEntry.getString(FILTER_ID_KEY);
- if(filterId != null) {
+ if (filterId != null) {
SearchFilter filter = new SearchFilter();
filter.setFilterId(filterId);
-
- if(filterEntry.has(FILTER_VALUE_KEY)) {
+
+ if (filterEntry.has(FILTER_VALUE_KEY)) {
String filterValue = filterEntry.getString(FILTER_VALUE_KEY);
filter.addValue(filterValue);
}
-
+
searchFilters.add(filter);
}
}
-
+
// Create query for summary by entity type
- JsonObject vnfSearch = FilterQueryBuilder.createCombinedBoolAndAggQuery(filtersConfig, searchFilters, DEFAULT_SHOULD_MATCH_SCORE);
+ JsonObject vnfSearch = FilterQueryBuilder.createCombinedBoolAndAggQuery(filtersConfig,
+ searchFilters, DEFAULT_SHOULD_MATCH_SCORE);
// Parse response for summary by entity type query
OperationResult opResult = elasticSearchAdapter.doPost(
elasticSearchAdapter.buildElasticSearchUrlForApi(vnfAggregationIndexName,
SparkyConstants.ES_SEARCH_API),
vnfSearch.toString(), javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE);
-
- if ( opResult.wasSuccessful()) {
- return buildAggregateVnfResponseJson(opResult.getResult());
+
+ if (opResult.wasSuccessful()) {
+ return buildAggregateVnfResponseJson(opResult.getResult());
} else {
return buildEmptyAggregateVnfResponseJson();
}
@@ -178,27 +182,27 @@ public class AggregateSummaryProcessor {
finalOutputToFe.put("total", 0);
return finalOutputToFe.toString();
}
-
+
private String buildAggregateVnfResponseJson(String responseJsonStr) {
-
+
JSONObject finalOutputToFe = new JSONObject();
JSONObject responseJson = new JSONObject(responseJsonStr);
-
-
+
+
JSONObject hits = responseJson.getJSONObject("hits");
int totalHits = hits.getInt("total");
finalOutputToFe.put("total", totalHits);
-
+
JSONObject aggregations = responseJson.getJSONObject("aggregations");
String[] aggKeys = JSONObject.getNames(aggregations);
JSONObject aggregationsList = new JSONObject();
-
- for(String aggName : aggKeys) {
+
+ for (String aggName : aggKeys) {
JSONObject aggregation = aggregations.getJSONObject(aggName);
JSONArray buckets = aggregation.getJSONArray("buckets");
aggregationsList.put(aggName, buckets);
}
-
+
finalOutputToFe.put("aggregations", aggregationsList);
return finalOutputToFe.toString();
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java
index 252ff75..5fd0dc9 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java
@@ -20,46 +20,55 @@
*/
package org.onap.aai.sparky.aggregatevnf.search;
+import java.io.IOException;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
-import javax.json.JsonObject;
-import javax.ws.rs.core.MediaType;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
import org.onap.aai.cl.api.Logger;
import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.sparky.common.search.CommonSearchSuggestion;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
import org.onap.aai.sparky.logging.AaiUiMsgs;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
import org.onap.aai.sparky.search.api.SearchProvider;
import org.onap.aai.sparky.search.entity.QuerySearchEntity;
import org.onap.aai.sparky.search.entity.SearchSuggestion;
import org.onap.aai.sparky.search.filters.entity.UiFilterValueEntity;
import org.onap.aai.sparky.util.NodeUtils;
-import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
public class AggregateVnfSearchProvider implements SearchProvider {
-
- private static final Logger LOG = LoggerFactory.getInstance().getLogger(AggregateVnfSearchProvider.class);
+
+ private static final Logger LOG =
+ LoggerFactory.getInstance().getLogger(AggregateVnfSearchProvider.class);
private ObjectMapper mapper;
- private ElasticSearchAdapter elasticSearchAdapter = null;
+ private SearchServiceAdapter searchServiceAdapter = null;
private String autoSuggestIndexName;
private String vnfSearchSuggestionRoute;
- public AggregateVnfSearchProvider(ElasticSearchAdapter elasticSearchAdapter,
+ private static final String AUTO_SUGGEST_TEMPLATE = "{ " + "\"results-size\": %d,"
+ + "\"suggest-text\": \"%s\"," + "\"suggest-field\": \"%s\"" + "}";
+
+ private static final String KEY_SEARCH_RESULT = "searchResult";
+ private static final String KEY_HITS = "hits";
+ private static final String KEY_DOCUMENT = "document";
+ private static final String KEY_CONTENT = "content";
+ private static final String KEY_TEXT = "text";
+ private static final String KEY_FILTER_LIST = "filterList";
+
+ public AggregateVnfSearchProvider(SearchServiceAdapter searchServiceAdapter,
String autoSuggestIndexName, String vnfSearchSuggestionRoute) {
mapper = new ObjectMapper();
- this.elasticSearchAdapter = elasticSearchAdapter;
+ this.searchServiceAdapter = searchServiceAdapter;
this.autoSuggestIndexName = autoSuggestIndexName;
this.vnfSearchSuggestionRoute = vnfSearchSuggestionRoute;
}
-
+
public void setAutoSuggestIndexName(String autoSuggestIndexName) {
this.autoSuggestIndexName = autoSuggestIndexName;
}
@@ -68,58 +77,96 @@ public class AggregateVnfSearchProvider implements SearchProvider {
public List<SearchSuggestion> search(QuerySearchEntity queryRequest) {
List<SearchSuggestion> returnList = new ArrayList<SearchSuggestion>();
-
try {
- /* Create suggestions query */
- JsonObject vnfSearch = VnfSearchQueryBuilder.createSuggestionsQuery(String.valueOf(queryRequest.getMaxResults()), queryRequest.getQueryStr());
+ final String fullUrlStr =
+ searchServiceAdapter.buildSuggestServiceQueryUrl(autoSuggestIndexName);
+ String postBody =
+ String.format(AUTO_SUGGEST_TEMPLATE, Integer.parseInt(queryRequest.getMaxResults()),
+ queryRequest.getQueryStr(), "entity_suggest");
+ OperationResult opResult =
+ searchServiceAdapter.doPost(fullUrlStr, postBody, "application/json");
+ if (opResult.getResultCode() == 200) {
+ returnList = generateSuggestionsForSearchResponse(opResult.getResult());
+ } else {
+ LOG.error(AaiUiMsgs.ERROR_PARSING_JSON_PAYLOAD_VERBOSE, opResult.getResult());
+ return returnList;
+ }
+ } catch (Exception exc) {
+ LOG.error(AaiUiMsgs.ERROR_GENERIC, "Search failed due to error = " + exc.getMessage());
+ }
- /* Parse suggestions response */
- OperationResult opResult = elasticSearchAdapter.doPost(
- elasticSearchAdapter.buildElasticSearchUrlForApi(autoSuggestIndexName,
- SparkyConstants.ES_SUGGEST_API),
- vnfSearch.toString(), MediaType.APPLICATION_JSON_TYPE);
+ return returnList;
+ }
- String result = opResult.getResult();
+ private List<SearchSuggestion> generateSuggestionsForSearchResponse(String operationResult) {
- if (!opResult.wasSuccessful()) {
- LOG.error(AaiUiMsgs.ERROR_PARSING_JSON_PAYLOAD_VERBOSE, result);
- return returnList;
- }
+ if (operationResult == null || operationResult.length() == 0) {
+ return null;
+ }
- JSONObject responseJson = new JSONObject(result);
- String suggestionsKey = "vnfs";
- JSONArray suggestionsArray = new JSONArray();
- JSONArray suggestions = responseJson.getJSONArray(suggestionsKey);
- if (suggestions.length() > 0) {
- suggestionsArray = suggestions.getJSONObject(0).getJSONArray("options");
- for (int i = 0; i < suggestionsArray.length(); i++) {
- JSONObject querySuggestion = suggestionsArray.getJSONObject(i);
- if (querySuggestion != null) {
- CommonSearchSuggestion responseSuggestion = new CommonSearchSuggestion();
- responseSuggestion.setText(querySuggestion.getString("text"));
- responseSuggestion.setRoute(vnfSearchSuggestionRoute);
- responseSuggestion.setHashId(NodeUtils.generateUniqueShaDigest(querySuggestion.getString("text")));
-
- // Extract filter list from JSON and add to response suggestion
- JSONObject payload = querySuggestion.getJSONObject("payload");
- if (payload.length() > 0) {
- JSONArray filterList = payload.getJSONArray("filterList");
- for (int filter = 0; filter < filterList.length(); filter++) {
- String filterValueString = filterList.getJSONObject(filter).toString();
- UiFilterValueEntity filterValue = mapper.readValue(filterValueString, UiFilterValueEntity.class);
- responseSuggestion.getFilterValues().add(filterValue);
- }
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode rootNode = null;
+ List<SearchSuggestion> suggestionEntityList = new ArrayList<SearchSuggestion>();
+
+ try {
+ rootNode = mapper.readTree(operationResult);
+ JsonNode hitsNode = rootNode.get(KEY_SEARCH_RESULT);
+ // Check if there are hits that are coming back
+ if (hitsNode.has(KEY_HITS)) {
+ ArrayNode hitsArray = (ArrayNode) hitsNode.get(KEY_HITS);
+
+ /*
+ * next we iterate over the values in the hit array elements
+ */
+ Iterator<JsonNode> nodeIterator = hitsArray.elements();
+ JsonNode entityNode = null;
+ CommonSearchSuggestion responseSuggestion = null;
+ JsonNode sourceNode = null;
+
+ while (nodeIterator.hasNext()) {
+ entityNode = nodeIterator.next();
+ String responseText = getValueFromNode(entityNode, KEY_TEXT);
+ // do the point transformation as we build the response?
+ responseSuggestion = new CommonSearchSuggestion();
+ responseSuggestion.setRoute(vnfSearchSuggestionRoute);
+ responseSuggestion.setText(responseText);
+ responseSuggestion.setHashId(NodeUtils.generateUniqueShaDigest(responseText));
+
+ sourceNode = entityNode.get(KEY_DOCUMENT).get(KEY_CONTENT);
+ if (sourceNode.has(KEY_FILTER_LIST)) {
+ ArrayNode filtersArray = (ArrayNode) sourceNode.get(KEY_FILTER_LIST);
+ for (int i = 0; i < filtersArray.size(); i++) {
+ String filterValueString = filtersArray.get(i).toString();
+ UiFilterValueEntity filterValue =
+ mapper.readValue(filterValueString, UiFilterValueEntity.class);
+ responseSuggestion.getFilterValues().add(filterValue);
}
- returnList.add(responseSuggestion);
}
+ suggestionEntityList.add(responseSuggestion);
}
}
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, "Search failed due to error = " + exc.getMessage());
+ } catch (IOException exc) {
+ LOG.warn(AaiUiMsgs.SEARCH_RESPONSE_BUILDING_EXCEPTION, exc.getLocalizedMessage());
}
+ return suggestionEntityList;
- return returnList;
}
-
+
+ private String getValueFromNode(JsonNode node, String fieldName) {
+
+ if (node == null || fieldName == null) {
+ return null;
+ }
+
+ JsonNode valueNode = node.get(fieldName);
+
+ if (valueNode != null) {
+ return valueNode.asText();
+ }
+
+ return null;
+
+ }
+
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java
index 62d287e..c833bd3 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java
@@ -34,7 +34,7 @@ import javax.json.JsonObjectBuilder;
*/
public class VnfSearchQueryBuilder {
-
+
/**
* Creates the suggestions query.
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java
index 8d99221..6bb0c45 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java
@@ -30,8 +30,8 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
public class SparkyResourceLoader implements ResourceLoaderAware {
-
-
+
+
private static final String FILE_URI = "file:";
private ResourceLoader resourceLoader;
private String configHomeEnvVar;
@@ -42,7 +42,7 @@ public class SparkyResourceLoader implements ResourceLoaderAware {
public void setResourceLoader(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
-
+
public String getFullFileUri(String uriFilePath) {
return FILE_URI + System.getProperty(configHomeEnvVar) + uriFilePath;
}
@@ -50,38 +50,40 @@ public class SparkyResourceLoader implements ResourceLoaderAware {
public String getAbsolutePath(String uriFilePath) {
return System.getProperty(configHomeEnvVar) + uriFilePath;
}
-
+
protected Resource getResource(String uriFilePath, boolean isRelative) {
String fileUri = uriFilePath;
- if (!uriFilePath.startsWith("file:")) {
- fileUri = "file:" + uriFilePath;
- }
+ if (!uriFilePath.startsWith(FILE_URI)) {
+
+ if (isRelative) {
+ fileUri = getFullFileUri(fileUri);
+ } else {
+ fileUri = FILE_URI + uriFilePath;
+ }
- if (isRelative) {
- return resourceLoader.getResource(getFullFileUri(fileUri));
- } else {
- return resourceLoader.getResource(fileUri);
}
+ return resourceLoader.getResource(fileUri);
+
}
public File getResourceAsFile(String uriFilePath, boolean isRelativePath) throws IOException {
-
- Resource resource = getResource(uriFilePath, isRelativePath);
+
+ Resource resource = getResource(uriFilePath, isRelativePath);
if (resource.exists()) {
return resource.getFile();
}
return null;
-
+
}
public byte[] getResourceAsBytes(String uriFilePath, boolean isRelativePath) throws IOException {
- Resource resource = getResource(uriFilePath, isRelativePath);
+ Resource resource = getResource(uriFilePath, isRelativePath);
if (resource.exists()) {
return getResourceAsBytes(resource);
@@ -89,10 +91,10 @@ public class SparkyResourceLoader implements ResourceLoaderAware {
return null;
}
-
+
public byte[] getResourceAsBytes(Resource resource) throws IOException {
- if ( resource != null && resource.exists()) {
+ if (resource != null && resource.exists()) {
return Files.readAllBytes(Paths.get(resource.getFile().getAbsolutePath()));
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java
index 59de87c..614968e 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java
@@ -42,7 +42,8 @@ import org.slf4j.MDC;
public class SearchServiceAdapter {
private static final String VALUE_QUERY = "query";
-
+ private static final String SUGGEST_QUERY = "suggest";
+
private RestClient client;
private RestEndpointConfig endpointConfig;
private String serviceApiVersion;
@@ -51,20 +52,22 @@ public class SearchServiceAdapter {
/**
* Instantiates a new search adapter.
- * @throws Exception
+ *
+ * @throws Exception
*/
- public SearchServiceAdapter(RestEndpointConfig endpointConfig, String serviceApiVersion) throws Exception {
+ public SearchServiceAdapter(RestEndpointConfig endpointConfig, String serviceApiVersion)
+ throws Exception {
client = RestClientFactory.buildClient(endpointConfig);
commonHeaders = new HashMap<String, List<String>>();
commonHeaders.put("Accept", Arrays.asList("application/json"));
commonHeaders.put(Headers.FROM_APP_ID, Arrays.asList("AAI-UI"));
-
+
this.serviceApiVersion = serviceApiVersion;
this.endpointConfig = endpointConfig;
}
-
+
public String getServiceApiVersion() {
return serviceApiVersion;
}
@@ -88,21 +91,19 @@ public class SearchServiceAdapter {
}
public OperationResult doGet(String url, String acceptContentType) {
- OperationResult or =
- client.get(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE);
+ OperationResult or = client.get(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE);
return new OperationResult(or.getResultCode(), or.getResult());
}
public OperationResult doPut(String url, String payload, String acceptContentType) {
- OperationResult or = client.put(url, payload, getTxnHeader(),
- MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE);
+ OperationResult or = client.put(url, payload, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE,
+ MediaType.APPLICATION_JSON_TYPE);
return new OperationResult(or.getResultCode(), or.getResult());
}
public OperationResult doDelete(String url, String acceptContentType) {
- OperationResult or =
- client.delete(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE);
+ OperationResult or = client.delete(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE);
return new OperationResult(or.getResultCode(), or.getResult());
}
@@ -125,6 +126,17 @@ public class SearchServiceAdapter {
return buildSearchServiceUrlForApi(indexName, VALUE_QUERY);
}
+ /**
+ * Get Full URL for search
+ *
+ * @param api the api
+ * @param indexName
+ * @return the full url
+ */
+ public String buildSuggestServiceQueryUrl(String indexName) {
+ return buildSearchServiceUrlForApi(indexName, SUGGEST_QUERY);
+ }
+
public String buildSearchServiceUrlForApi(String indexName, String api) {
return String.format("https://%s:%s/services/search-data-service/%s/search/indexes/%s/%s",
endpointConfig.getEndpointIpAddress(), endpointConfig.getEndpointServerPort(),
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java
deleted file mode 100644
index ba64db0..0000000
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-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.aai.sparky.viewandinspect.config;
-
-/**
- * The Class TierSupportUiConstants.
- */
-public class TierSupportUiConstants {
-
- public static String APP_NAME = "AAIUI";
-
- /** Default to unix file separator if system property file.separator is null */
- public static final String FILESEP =
- (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
-
- public static String CONFIG_HOME = System.getProperty("CONFIG_HOME") + FILESEP;
- public static String AJSC_HOME = System.getProperty("AJSC_HOME") + FILESEP;
- public static String CONFIG_ROOT_LOCATION =
- AJSC_HOME + "bundleconfig" + FILESEP + "etc" + FILESEP;
- public static String STATIC_CONFIG_APP_LOCATION = CONFIG_ROOT_LOCATION + "appprops" + FILESEP;
- public static String DYNAMIC_CONFIG_APP_LOCATION = CONFIG_HOME;
-
- public static String CONFIG_OXM_LOCATION = CONFIG_HOME + "model" + FILESEP;
- public static String CONFIG_FILTERS_BASE_LOCATION = CONFIG_HOME + FILESEP;
- public static String CONFIG_AUTH_LOCATION = CONFIG_HOME + "auth" + FILESEP;
-
- public static String HOST = "host";
- public static String IP_ADDRESS = "ipAddress";
- public static String PORT = "port";
- public static String HTTP_PORT = "httpPort";
- public static String RETRIES = "numRequestRetries";
- public static String RESOURCE_VERSION = "resource-version";
- public static String URI = "URI";
-
- public static String AUTHORIZED_USERS_FILE_LOCATION =
- DYNAMIC_CONFIG_APP_LOCATION + "authorized-users.config";
- public static String USERS_FILE_LOCATION = DYNAMIC_CONFIG_APP_LOCATION + "users.config";
- public static String ROLES_FILE_LOCATION = DYNAMIC_CONFIG_APP_LOCATION + "roles.config";
- public static String PORTAL_AUTHENTICATION_FILE_LOCATION =
- DYNAMIC_CONFIG_APP_LOCATION + "portal" + FILESEP + "portal-authentication.properties";
-
- // Related to data-router properties
- public static String DR_URI_SUFFIX = "uriSuffix";
- public static String DR_CERT_NAME = "cert-name";
- public static String DR_KEYSTORE_PASSWORD = "keystore-password";
- public static String DR_KEYSTORE = "keystore";
- public static String DR_CONNECT_TIMEOUT = "connectTimeoutMs";
- public static String DR_READ_TIMEOUT = "readTimeoutMs";
-
- public static final String ES_SUGGEST_API = "_suggest";
- public static final String ES_COUNT_API = "_count";
- public static final String ES_SEARCH_API = "_search";
-
- public static final String UI_FILTER_VIEW_NAME_PARAMETER = "viewName";
- public static final String UI_FILTER_ID_LIST_PARAMETER = "filterIdList";
-
- public static final String ENTITY_AUTO_SUGGEST_INDEX_NAME_DEFAULT =
- "entityautosuggestindex-localhost";
- public static final String ENTITY_AUTO_SUGGEST_SETTINGS_FILE_DEFAULT =
- "/etc/autoSuggestSettings.json";
- public static final String ENTITY_AUTO_SUGGEST_MAPPINGS_FILE_DEFAULT =
- "/etc/autoSuggestMappings.json";
- public static final String ENTITY_DYNAMIC_MAPPINGS_FILE_DEFAULT = "/etc/dynamicMappings.json";
- public static final String FILTER_LIST_FILE_DEFAULT =
- CONFIG_FILTERS_BASE_LOCATION + "filters" + FILESEP + "aaiui_filters.json";
- public static final String FILTER_MAPPING_FILE_DEFAULT =
- CONFIG_FILTERS_BASE_LOCATION + "filters" + FILESEP + "aaiui_views.json";
-
- public static final String SUGGESTION_TEXT_SEPARATOR = " -- ";
-
- // Injected Attributes
- public static String URI_ATTR_NAME = "uri";
-
- public static final String URI_VERSION_REGEX_PATTERN = "aai/v[\\d]+/";
-
- public static final String getConfigPath(String configFile) {
- return AJSC_HOME + FILESEP + configFile;
- }
-
-}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java
deleted file mode 100644
index 67dd669..0000000
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-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.aai.sparky.viewandinspect.entity;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
-/*
- * We can use annotations to differentiate between intermediate data we use to build the node, and
- * the data that we actually want to appear in the exported JSON.
- */
-
-/*
- * This is our current ( 14-June-2016 ) working schema that will remain organic until we get it just
- * right.
- *
- * { "item-type": "customer", "item-name-key": "subscriber-name", “item-name-value” :
- * “subscriber-name-123456789-aai847-data-01”, "item-properties": [{ "property-name":
- * "subscriber-name", "property-value": "subscriber-name-123456789-aai847-data-01" }, {
- * "property-name": "global-customer-id", "property-value":
- * "global-customer-id-123456789-aai847-data-01" } ], "node-meta": { “color” : “#f2d2d2”,
- * "isSearchTarget" : false, "nodeGroups" : "1,2,3,4" }, }
- *
- */
-
-
-/**
- * The Class JsonNode.
- */
-public class JsonNode {
-
- private String id;
- private String itemType;
- private String itemNameKey;
- private String itemNameValue;
- private Map<String, String> itemProperties;
- private NodeMeta nodeMeta;
-
- @JsonIgnore
- private boolean isRootNode;
-
-
- @JsonIgnore
- private String resourceKey;
- @JsonIgnore
- private Collection<String> inboundNeighbors;
-
- @JsonIgnore
- private Collection<String> outboundNeighbors;
-
-
- @JsonIgnore
- private static final Logger LOG = Logger.getLogger(JsonNode.class);
-
- private VisualizationConfigs visualizationConfigs;
-
-
- /**
- * Instantiates a new json node.
- *
- * @param ain the ain
- */
- public JsonNode(ActiveInventoryNode ain, VisualizationConfigs visualizationConfigs) {
- this.resourceKey = ain.getNodeId();
- this.itemProperties = ain.getProperties();
- this.setItemType(ain.getEntityType());
- this.setItemNameKey(ain.getPrimaryKeyName());
- this.setItemNameValue(ain.getPrimaryKeyValue());
- this.setId(ain.getNodeId());
- this.isRootNode = ain.isRootNode();
- this.visualizationConfigs = visualizationConfigs;
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("---");
- LOG.debug("JsonNode constructor using AIN = " + ain.dumpNodeTree(true));
- LOG.debug("---");
- }
-
- inboundNeighbors = ain.getInboundNeighbors();
- outboundNeighbors = ain.getOutboundNeighbors();
-
- nodeMeta = new NodeMeta(this.visualizationConfigs);
-
- nodeMeta.setNodeIssue(ain.isNodeIssue());
- nodeMeta.setNodeValidated(ain.isNodeValidated());
- nodeMeta.setNodeDepth(ain.getNodeDepth());
-
- nodeMeta.setNumInboundNeighbors(ain.getInboundNeighbors().size());
- nodeMeta.setNumOutboundNeighbors(ain.getOutboundNeighbors().size());
-
- nodeMeta.setAtMaxDepth(ain.isAtMaxDepth());
- nodeMeta.setSelfLinkResolved(!ain.isSelflinkRetrievalFailure());
- nodeMeta.setProcessingErrorOccurred(ain.isProcessingErrorOccurred());
- nodeMeta.setHasNeighbors(
- ain.getOutboundNeighbors().size() > 0 || ain.getInboundNeighbors().size() > 0);
- nodeMeta.setProcessingState(ain.getState());
-
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getItemNameKey() {
- return itemNameKey;
- }
-
- public String getItemNameValue() {
- return itemNameValue;
- }
-
- public Map<String, String> getItemProperties() {
- return itemProperties;
- }
-
- public String getItemType() {
- return itemType;
- }
-
- public String getResourceKey() {
- return resourceKey;
- }
-
- public void setItemNameKey(String itemNameKey) {
- this.itemNameKey = itemNameKey;
- }
-
- public void setItemNameValue(String itemNameValue) {
- this.itemNameValue = itemNameValue;
- }
-
- public void setItemProperties(HashMap<String, String> itemProperties) {
- this.itemProperties = itemProperties;
- }
-
- public void setItemType(String itemType) {
- this.itemType = itemType;
- }
-
- public void setResourceKey(String resourceKey) {
- this.resourceKey = resourceKey;
- }
-
- public NodeMeta getNodeMeta() {
- return nodeMeta;
- }
-
- public void setNodeMeta(NodeMeta nodeMeta) {
- this.nodeMeta = nodeMeta;
- }
-
- public boolean isRootNode() {
- return isRootNode;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "JsonNode [" + (id != null ? "id=" + id + ", " : "")
- + (itemType != null ? "itemType=" + itemType + ", " : "")
- + (itemNameKey != null ? "itemNameKey=" + itemNameKey + ", " : "")
- + (itemNameValue != null ? "itemNameValue=" + itemNameValue + ", " : "")
- + (itemProperties != null ? "itemProperties=" + itemProperties + ", " : "")
- + (nodeMeta != null ? "nodeMeta=" + nodeMeta + ", " : "")
- + (resourceKey != null ? "resourceKey=" + resourceKey + ", " : "")
- + (inboundNeighbors != null ? "inboundNeighbors=" + inboundNeighbors + ", " : "")
- + (outboundNeighbors != null ? "outboundNeighbors=" + outboundNeighbors : "") + "]";
- }
-
-
-}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProviderTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProviderTest.java
new file mode 100644
index 0000000..06ebafa
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProviderTest.java
@@ -0,0 +1,60 @@
+package org.onap.aai.sparky.aggregatevnf.search;
+
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.ws.rs.core.MediaType;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.aai.restclient.client.OperationResult;
+import org.onap.aai.restclient.enums.RestAuthenticationMode;
+import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
+import org.onap.aai.sparky.search.entity.QuerySearchEntity;
+
+public class AggregateVnfSearchProviderTest {
+
+ private AggregateVnfSearchProvider aggregateVnfSearchProvider;
+ private RestEndpointConfig restEndpointConfig;
+ private SearchServiceAdapter searchserviceAdapter;
+ private QuerySearchEntity querySearchEntity;
+ private String successResponsePayload;
+ private OperationResult successResult = null;
+ private OperationResult resultValue = null;
+ private String goodDrTargetUrl = "https://0.0.0.0:9502/ui-request/servicegraph";
+
+ @Before
+ public void init() throws Exception {
+
+ restEndpointConfig = new RestEndpointConfig();
+ successResponsePayload = "good-payload";
+ successResult = new OperationResult(200, successResponsePayload);
+ restEndpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
+ searchserviceAdapter = Mockito.mock(SearchServiceAdapter.class);
+ resultValue = Mockito.mock(OperationResult.class);
+ aggregateVnfSearchProvider =
+ new AggregateVnfSearchProvider(searchserviceAdapter, "auto-suggest", "schema");
+ querySearchEntity = new QuerySearchEntity();
+
+ }
+
+ @Test
+ public void updateValues() {
+
+ assertNotNull(aggregateVnfSearchProvider.search(querySearchEntity));
+ aggregateVnfSearchProvider.setAutoSuggestIndexName("auto-suggest-index-1");
+
+ }
+
+ @Test
+ public void testProxyMessage_Success() {
+ Mockito.when(searchserviceAdapter.doPost(Mockito.eq(goodDrTargetUrl), Mockito.anyString(),
+ Mockito.eq(MediaType.APPLICATION_JSON_TYPE.toString()))).thenReturn(successResult);
+ Mockito.when(resultValue.getResultCode()).thenReturn(200);
+ aggregateVnfSearchProvider.search(querySearchEntity);
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilderTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilderTest.java
new file mode 100644
index 0000000..9949702
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilderTest.java
@@ -0,0 +1,30 @@
+package org.onap.aai.sparky.aggregatevnf.search;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class VnfSearchQueryBuilderTest {
+
+ private VnfSearchQueryBuilder vnfSearchQueryBuilder;
+
+ @Before
+ public void init() throws Exception {
+
+ vnfSearchQueryBuilder = new VnfSearchQueryBuilder();
+
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateValues() {
+
+
+
+ assertNotNull(vnfSearchQueryBuilder.createSuggestionsQuery("10","queryString"));
+ assertNotNull(vnfSearchQueryBuilder.getTermBlob("suggest-vnf","firewall"));
+ assertNotNull(vnfSearchQueryBuilder.getSortCriteria("term","ascending"));
+
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java
index 1273e80..af441c7 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java
@@ -5,7 +5,6 @@ import static org.junit.Assert.assertNull;
import java.util.ArrayList;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.restclient.enums.RestAuthenticationMode;
@@ -14,50 +13,44 @@ import org.onap.aai.sparky.config.oxm.OxmModelLoader;
import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
public class ActiveInventoryAdapterTest {
-
- private OxmModelLoader oxmModelLoader;
- private OxmEntityLookup oxmEntityLookup;
- private RestEndpointConfig endpointConfig;
- private ActiveInventoryAdapter aaiAdapter;
- private ArrayList<String> queryParams;
-
- @Before
- public void init() throws Exception {
-
- oxmModelLoader = new OxmModelLoader();
- oxmEntityLookup = new OxmEntityLookup();
- endpointConfig = new RestEndpointConfig();
- queryParams = new ArrayList<String>();
- endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
- aaiAdapter = new ActiveInventoryAdapter(oxmModelLoader,oxmEntityLookup,endpointConfig);
- }
-
-
- @SuppressWarnings("static-access")
- @Test
- public void updateValues()throws Exception {
-
- assertNotNull(aaiAdapter.getMessageHeaders());
- assertNotNull(aaiAdapter.getBasicAuthenticationCredentials());
- assertNotNull(aaiAdapter.getResourceBasePath());
- assertNotNull(aaiAdapter.extractResourcePath(""));
- assertNotNull(aaiAdapter.getGenericQueryForSelfLink("",queryParams));
- assertNull(aaiAdapter.getSelfLinkForEntity("","",""));
- assertNotNull(aaiAdapter.queryActiveInventory("",""));
- assertNotNull(aaiAdapter.queryActiveInventoryWithRetries("","",4));
- aaiAdapter.setOxmEntityLookup(oxmEntityLookup);
- assertNotNull(aaiAdapter.getOxmEntityLookup());
- aaiAdapter.setEndpointConfig(endpointConfig);
- assertNotNull(aaiAdapter.getEndpointConfig());
-
- //assertNull(aaiAdapter.repairSelfLink("",""));
- //assertNotNull(aaiAdapter.repairSelfLink(null,""));
- //assertNotNull(aaiAdapter.getSelfLinkForEntity(null,"",""));
- //assertNull(aaiAdapter.getSelfLinkForEntity("",null,""));
- //assertNotNull(aaiAdapter.getSelfLinkForEntity("","",null));
- //assertNotNull(aaiAdapter.getSelfLinksByEntityType(""));
- //assertNotNull(aaiAdapter.getSelfLinksByEntityType(null));
- }
+
+ private OxmModelLoader oxmModelLoader;
+ private OxmEntityLookup oxmEntityLookup;
+ private RestEndpointConfig endpointConfig;
+ private ActiveInventoryAdapter aaiAdapter;
+ private ArrayList<String> queryParams;
+
+ @Before
+ public void init() throws Exception {
+
+ oxmModelLoader = new OxmModelLoader();
+ oxmEntityLookup = new OxmEntityLookup();
+ endpointConfig = new RestEndpointConfig();
+ queryParams = new ArrayList<String>();
+ endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
+ aaiAdapter = new ActiveInventoryAdapter(oxmModelLoader, oxmEntityLookup, endpointConfig);
+ }
+
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateValues() throws Exception {
+
+ assertNotNull(aaiAdapter.getMessageHeaders());
+ assertNotNull(aaiAdapter.getBasicAuthenticationCredentials());
+ assertNotNull(aaiAdapter.getResourceBasePath());
+ assertNotNull(aaiAdapter.extractResourcePath("/services/inventory/v12/"));
+ assertNotNull(aaiAdapter.getGenericQueryForSelfLink("", queryParams));
+ assertNull(aaiAdapter.getSelfLinkForEntity("pserver", "PrimaryKeyName", "PrimaryKeyValue"));
+ assertNotNull(
+ aaiAdapter.queryActiveInventory("https://server.proxy:8443/aai/v11/", "application/json"));
+ assertNotNull(aaiAdapter.queryActiveInventoryWithRetries(
+ "https://server.proxy:8443/aai/v11/business/customers/", "application/json", 4));
+ aaiAdapter.setOxmEntityLookup(oxmEntityLookup);
+ assertNotNull(aaiAdapter.getOxmEntityLookup());
+ aaiAdapter.setEndpointConfig(endpointConfig);
+ assertNotNull(aaiAdapter.getEndpointConfig());
+ }
}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/GizmoAdapterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/GizmoAdapterTest.java
new file mode 100644
index 0000000..b17b6fb
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/GizmoAdapterTest.java
@@ -0,0 +1,60 @@
+package org.onap.aai.sparky.dal;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.restclient.enums.RestAuthenticationMode;
+import org.onap.aai.sparky.config.oxm.OxmModelLoader;
+import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
+
+public class GizmoAdapterTest {
+
+ private OxmModelLoader oxmModelLoader;
+ private RestEndpointConfig endpointConfig;
+ private GizmoAdapter gizmoAdapter;
+
+ @Before
+ public void init() throws Exception {
+
+ oxmModelLoader = new OxmModelLoader();
+ endpointConfig = new RestEndpointConfig();
+ endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
+ endpointConfig.setEndpointIpAddress("10.147.110.199");
+ endpointConfig.setEndpointServerPort("9885");
+ endpointConfig.setBasicAuthUserName("sparky");
+ endpointConfig.setBasicAuthPassword("sparky");
+ gizmoAdapter = new GizmoAdapter(oxmModelLoader, endpointConfig);
+ }
+
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateValues() throws Exception {
+
+ assertNotNull(gizmoAdapter.getMessageHeaders());
+ assertNotNull(gizmoAdapter.getBasicAuthenticationCredentials());
+ gizmoAdapter.setRelationshipsBasePath("/services/inventory/relationships/v10/");
+ assertNotNull(gizmoAdapter.getRelationshipsBasePath());
+ gizmoAdapter.setInventoryBasePath("/services/inventory/v10/");
+ assertNotNull(gizmoAdapter.getInventoryBasePath());
+ assertNotNull(gizmoAdapter.extractResourcePath("/services/inventory/v10/"));
+ assertNotNull(gizmoAdapter.getFullInventoryUrl("/services/inventory/v10/"));
+ assertNotNull(gizmoAdapter.addServerDetailsToUrl("/services/inventory/v10/"));
+ assertNotNull(gizmoAdapter.getFullRelationshipUrl(
+ "https://server.proxy:8443/aai/v11/business/customers/customer/customer-4"));
+ assertNotNull(gizmoAdapter.getBasicAuthenticationCredentials());
+ assertNotNull(gizmoAdapter.repairRelationshipSelfLink(
+ "https://server.proxy:8443/aai/v11/business/customers/", "PrimaryKeyValue"));
+ assertNotNull(gizmoAdapter.repairInventorySelfLink(
+ "https://server.proxy:8443/aai/v11/business/customers/", "PrimaryKeyValue"));
+ assertNotNull(gizmoAdapter.queryGizmo("https://server.proxy:8443/aai/v11/business/customers/",
+ "application/json"));
+ assertNotNull(gizmoAdapter.queryGizmoWithRetries(
+ "https://server.proxy:8443/aai/v11/business/customers/", "application/json", 4));
+ assertNull(gizmoAdapter.getSelfLinksByEntityType("vserver"));
+ gizmoAdapter.setEndpointConfig(endpointConfig);
+ assertNotNull(gizmoAdapter.getEndpointConfig());
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java
index 63b3ff4..3dbc36b 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java
@@ -1,4 +1,3 @@
-package org.onap.aai.sparky.editattributes;
/**
* ============LICENSE_START===================================================
* SPARKY (AAI UI service)
@@ -23,8 +22,8 @@ package org.onap.aai.sparky.editattributes;
* ECOMP and OpenECOMP are trademarks
* and service marks of AT&T Intellectual Property.
*/
-/*
-package org.openecomp.sparky.editattributes;
+
+package org.onap.aai.sparky.editattributes;
import static org.junit.Assert.assertEquals;
@@ -33,46 +32,53 @@ import java.util.Map;
import javax.ws.rs.core.Response.Status;
+import org.eclipse.persistence.dynamic.DynamicType;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
import org.onap.aai.sparky.config.oxm.OxmModelLoader;
-import org.onap.aai.sparky.dal.aai.config.ActiveInventoryConfig;
+import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
import org.onap.aai.sparky.editattributes.AttributeUpdater;
-import org.openecomp.sparky.dal.aai.config.ActiveInventoryConfigUtil;
+import org.onap.aai.sparky.editattributes.AttributeUpdater.AaiEditObject;
+
/**
* The Class AttributeUpdaterTest.
- *
+ */
public class AttributeUpdaterTest {
+ private ActiveInventoryAdapter aaiAdapter;
+
/**
* Sets the up.
*
* @throws Exception the exception
- *
+ */
@Before
- public void setUp() throws Exception {}
+ public void setUp() throws Exception {
+
+ aaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
+ }
/**
- * @throws Exception
+ * @throws Exception
*/
- /*
+
@Test
public void testUpdateObjectAttribute() throws Exception {
-
+
OxmEntityDescriptor desc = new OxmEntityDescriptor();
desc.addPrimaryKeyName("hostname");
desc.setEntityName("pserver");
-
- OxmEntityLookup entityLookup = OxmEntityLookup.getInstance();
+
+ OxmEntityLookup entityLookup = new OxmEntityLookup();
entityLookup.addEntityDescriptor("pserver", desc);
-
- AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup,
- new ActiveInventoryConfig(ActiveInventoryConfigUtil.getValidTestProperties()));
+
+ AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup, aaiAdapter);
Map<String, Object> attributes = new HashMap<>();
attributes.put("prov-status", "PREPROV");
attributes.put("in-maint", "true");
@@ -80,7 +86,7 @@ public class AttributeUpdaterTest {
"cloud-infrastructure/pservers/pserver/something", attributes, "someid");
assertEquals(Status.FORBIDDEN.getStatusCode(), result.getResultCode());
}
- */
+
// This needs the OXM file in place to work.
/**
@@ -88,62 +94,58 @@ public class AttributeUpdaterTest {
*
* @throws Exception the exception
*/
- //@Test
- /*public void testGetEditObjectFromUri() throws Exception {
-
+ @Test(expected = NullPointerException.class)
+ public void testGetEditObjectFromUri() throws Exception {
+
OxmModelLoader loader = new OxmModelLoader();
loader.setLatestVersionNum(11);
-
+
OxmEntityDescriptor desc = new OxmEntityDescriptor();
desc.addPrimaryKeyName("hostname");
desc.setEntityName("pserver");
-
- OxmEntityLookup entityLookup = OxmEntityLookup.getInstance();
+
+ OxmEntityLookup entityLookup = new OxmEntityLookup();
entityLookup.addEntityDescriptor("pserver", desc);
-
- DynamicType mockType = Mockito.mock(DynamicType.class);
- Class<? extends DynamicEntity> mockDynamicEntity = Mockito.mock(DynamicEntity.class);
- Mockito.when(mockType.getJavaClass()).thenReturn(mockDynamicEntity);
+ // DynamicType mockType = Mockito.mock(DynamicType.class);
+ // Class<? extends DynamicEntity> mockDynamicEntity = Mockito.mock(DynamicEntity.class);
-
-
-
- HashMap<String, DynamicType> typeLookup = new HashMap<String,DynamicType>();
- typeLookup.put("pserver", mockType);
+ // Mockito.when(mockType.getJavaClass()).thenReturn(mockDynamicEntity);
+
+
+
+ HashMap<String, DynamicType> typeLookup = new HashMap<String, DynamicType>();
+ // typeLookup.put("pserver", mockType);
entityLookup.setEntityTypeLookup(typeLookup);
-
-
- AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup,
- new ActiveInventoryConfig(ActiveInventoryConfigUtil.getValidTestProperties()));
- AaiEditObject result =
- updater.getEditObjectFromUri("cloud-infrastructure/pservers/pserver/mtznjtax101");
+
+
+ AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup, aaiAdapter);
+ AaiEditObject result = updater.getEditObjectFromUri(null);
assertEquals("Pserver", result.getObjectType());
assertEquals("pserver", result.getRootElement());
assertEquals("hostname", result.getKeyName());
assertEquals("mtznjtax101", result.getKeyValue());
- }*/
+ }
/**
* Test get relative uri.
*
* @throws Exception the exception
*/
- /*
+
@Test
public void testGetRelativeUri() throws Exception {
-
+
OxmEntityDescriptor desc = new OxmEntityDescriptor();
desc.addPrimaryKeyName("hostname");
desc.setEntityName("pserver");
-
- OxmEntityLookup entityLookup = OxmEntityLookup.getInstance();
+
+ OxmEntityLookup entityLookup = new OxmEntityLookup();
entityLookup.addEntityDescriptor("pserver", desc);
-
- AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup,
- new ActiveInventoryConfig(ActiveInventoryConfigUtil.getValidTestProperties()));
+
+ AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup, aaiAdapter);
// Test entity uri without "/aai/version/"
String result = updater.getRelativeUri("cloud-infrastructure/pservers/pserver/mtznjtax101");
assertEquals("/cloud-infrastructure/pservers/pserver/mtznjtax101", result);
@@ -159,6 +161,5 @@ public class AttributeUpdaterTest {
result = updater.getRelativeUri("/cloud-infrastructure/pservers/pserver/mtznjtax101");
assertEquals("/cloud-infrastructure/pservers/pserver/mtznjtax101", result);
}
-
+
}
-*/ \ No newline at end of file
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java
index 7963528..e463dde 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java
@@ -13,35 +13,39 @@ import org.onap.aai.restclient.enums.RestAuthenticationMode;
import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
public class SearchServiceAdapterTest {
-
- private SearchServiceAdapter searchServiceAdapter;
- private RestEndpointConfig endpointConfig;
-
- @Before
- public void init() throws Exception {
-
- endpointConfig = new RestEndpointConfig();
- endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
- searchServiceAdapter = new SearchServiceAdapter(endpointConfig,"1.0");
- }
-
-
- @Test
- public void updateValues() {
-
- searchServiceAdapter.setServiceApiVersion("2.0");
- assertNotNull(searchServiceAdapter.getServiceApiVersion());
- searchServiceAdapter.setEndpointConfig(endpointConfig);
- assertNotNull(searchServiceAdapter.getEndpointConfig());
- assertNotNull(searchServiceAdapter.doPost("https://10.247.40.25:8000","{maxResults:10, queryStr: f}","application/json"));
- assertNotNull(searchServiceAdapter.doGet("https://10.247.40.25:8000","application/json"));
- assertNotNull(searchServiceAdapter.doPut("https://10.247.40.25:8000","{maxResults:10, queryStr: f}","application/json"));
- assertNotNull(searchServiceAdapter.doDelete("https://10.247.40.25:8000","application/json"));
- assertNotNull(searchServiceAdapter.getTxnHeader());
- assertNotNull(searchServiceAdapter.buildSearchServiceQueryUrl("searchentity-localhost"));
- assertNotNull(searchServiceAdapter.buildSearchServiceUrlForApi("searchentity-localhost","2.0"));
-
-
- }
+
+ private SearchServiceAdapter searchServiceAdapter;
+ private RestEndpointConfig endpointConfig;
+
+ @Before
+ public void init() throws Exception {
+
+ endpointConfig = new RestEndpointConfig();
+ endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
+ searchServiceAdapter = new SearchServiceAdapter(endpointConfig, "1.0");
+ }
+
+
+ @Test
+ public void updateValues() {
+
+ searchServiceAdapter.setServiceApiVersion("2.0");
+ assertNotNull(searchServiceAdapter.getServiceApiVersion());
+ searchServiceAdapter.setEndpointConfig(endpointConfig);
+ assertNotNull(searchServiceAdapter.getEndpointConfig());
+ assertNotNull(searchServiceAdapter.doPost("https://10.247.40.25:8000",
+ "{maxResults:10, queryStr: f}", "application/json"));
+ assertNotNull(searchServiceAdapter.doGet("https://10.247.40.25:8000", "application/json"));
+ assertNotNull(searchServiceAdapter.doPut("https://10.247.40.25:8000",
+ "{maxResults:10, queryStr: f}", "application/json"));
+ assertNotNull(searchServiceAdapter.doDelete("https://10.247.40.25:8000", "application/json"));
+ assertNotNull(searchServiceAdapter.getTxnHeader());
+ assertNotNull(searchServiceAdapter.buildSearchServiceQueryUrl("searchentity-localhost"));
+ assertNotNull(
+ searchServiceAdapter.buildSearchServiceUrlForApi("searchentity-localhost", "2.0"));
+ assertNotNull(searchServiceAdapter.buildSuggestServiceQueryUrl("searchentity-localhost"));
+
+
+ }
}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/AggregationEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/AggregationEntityTest.java
new file mode 100644
index 0000000..fd9f112
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/AggregationEntityTest.java
@@ -0,0 +1,33 @@
+package org.onap.aai.sparky.search.filters.entity;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class AggregationEntityTest {
+
+ private AggregationEntity aggregateEntity;
+
+ @Before
+ public void init() throws Exception {
+ aggregateEntity = new AggregationEntity("aggregate-1", "autosuggest", 10);
+
+ }
+
+ @Test
+ public void updateValues() {
+
+ aggregateEntity.setAggregationName("aggregate-2");
+ assertNotNull(aggregateEntity.getAggregationName());
+ aggregateEntity.setAggregationFieldName("autosearch");
+ assertNotNull(aggregateEntity.getAggregationFieldName());
+ assertNotNull(aggregateEntity.getJsonObject());
+ aggregateEntity.setSize(25);
+ assertEquals(25, aggregateEntity.getSize());
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilderTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilderTest.java
new file mode 100644
index 0000000..df2d0e9
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilderTest.java
@@ -0,0 +1,31 @@
+package org.onap.aai.sparky.search.filters.entity;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class BoolQueryBuilderTest {
+
+ private BoolQueryBuilder boolQueryBuilder;
+ private MatchFilterCriteriaEntity matchQueryEntity;
+
+ @Before
+ public void init() throws Exception {
+
+ boolQueryBuilder = new BoolQueryBuilder();
+ matchQueryEntity = new MatchFilterCriteriaEntity("Criteria-1", "Value-1");
+
+ }
+
+ @Test
+ public void updateValues() {
+
+ boolQueryBuilder.addShouldFilter(matchQueryEntity);
+ boolQueryBuilder.addMustFilter(matchQueryEntity);
+ boolQueryBuilder.isMatchAll();
+ assertNotNull(boolQueryBuilder.getJsonObject());
+ boolQueryBuilder.setMinShouldMatch(25);
+
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntityTest.java
new file mode 100644
index 0000000..bf14cd7
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntityTest.java
@@ -0,0 +1,30 @@
+package org.onap.aai.sparky.search.filters.entity;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class MatchFilterCriteriaEntityTest {
+
+ private MatchFilterCriteriaEntity matchFilterCriteriaEntity;
+
+ @Before
+ public void init() throws Exception {
+ matchFilterCriteriaEntity = new MatchFilterCriteriaEntity("criteria-1", "value-1");
+
+ }
+
+ @Test
+ public void updateValues() {
+
+ matchFilterCriteriaEntity.setCriteriaName("criteria-2");
+ assertNotNull(matchFilterCriteriaEntity.getCriteriaName());
+ matchFilterCriteriaEntity.setCriteriaValue("value-2");
+ assertNotNull(matchFilterCriteriaEntity.getCriteriaValue());
+ assertNotNull(matchFilterCriteriaEntity.getJsonObject());
+ assertNotNull(matchFilterCriteriaEntity.toString());
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/SearchFilterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/SearchFilterTest.java
new file mode 100644
index 0000000..04744ac
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/SearchFilterTest.java
@@ -0,0 +1,35 @@
+package org.onap.aai.sparky.search.filters.entity;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class SearchFilterTest {
+
+ private SearchFilter searchFilter, searchFilter2, searchFilter3;
+ private ArrayList<String> lst = new ArrayList<String>();
+
+ @Before
+ public void init() throws Exception {
+ searchFilter = new SearchFilter();
+ searchFilter2 = new SearchFilter("Filter-1");
+ searchFilter3 = new SearchFilter("Filter-2", "running");
+
+ }
+
+ @Test
+ public void updateValues() {
+
+ searchFilter.setFilterId("filterID");
+ assertNotNull(searchFilter.getFilterId());
+ searchFilter.setValues(lst);
+ assertNotNull(searchFilter.getValues());
+ searchFilter.addValue(null);
+ assertNotNull(searchFilter.toString());
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntityTest.java
new file mode 100644
index 0000000..3af51f8
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntityTest.java
@@ -0,0 +1,55 @@
+package org.onap.aai.sparky.search.filters.entity;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.sparky.search.filters.config.UiFilterConfig;
+
+
+public class UiFilterEntityTest {
+
+ private UiFilterEntity uiFilterEntity, uiFilterEntity2;
+ private UiFilterConfig filterConfig;
+
+
+
+ @Before
+ public void init() throws Exception {
+
+ filterConfig = new UiFilterConfig("1", "Prov-Status", "Prov-Status", "DropDown", "false",
+ "Any Prov Status", null, "options", null, null);
+ uiFilterEntity = new UiFilterEntity();
+ uiFilterEntity2 = new UiFilterEntity(filterConfig);
+ }
+
+
+ @Test
+ public void updateValues() {
+
+ uiFilterEntity.setOptionsValues(null);
+ assertNull(uiFilterEntity.getOptionsValues());
+ uiFilterEntity.setDefaultValue(null);
+ assertNull(uiFilterEntity.getDefaultValue());
+ uiFilterEntity.setFilterValueList(null);
+ assertNull(uiFilterEntity.getFilterValueList());
+ uiFilterEntity.setFilterId("1");
+ assertNotNull(uiFilterEntity.getFilterId());
+ uiFilterEntity.setFilterName("Prov-Status");
+ assertNotNull(uiFilterEntity.getFilterName());
+ uiFilterEntity.setDisplayName("Prov-Status");
+ assertNotNull(uiFilterEntity.getDisplayName());
+ uiFilterEntity.setDataType("DropDown");
+ assertNotNull(uiFilterEntity.getDataType());
+ uiFilterEntity.setMultiSelect("false");
+ assertNotNull(uiFilterEntity.getMultiSelect());
+ uiFilterEntity.setWatermark("Any Prov Status");
+ assertNotNull(uiFilterEntity.getWatermark());
+ uiFilterEntity.setOptionsType("options");
+ assertNotNull(uiFilterEntity.getOptionsType());
+
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntityTest.java
new file mode 100644
index 0000000..07e8430
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntityTest.java
@@ -0,0 +1,39 @@
+package org.onap.aai.sparky.search.filters.entity;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class UiFilterValueEntityTest {
+
+ private UiFilterValueEntity uiFilterValueEntity;
+ private UiFilterValueEntity uiFilterValueEntity2;
+
+
+
+ @Before
+ public void init() throws Exception {
+ uiFilterValueEntity = new UiFilterValueEntity();
+ uiFilterValueEntity = new UiFilterValueEntity("1", "Prov", "Prov-Status");
+ }
+
+
+ @Test
+ public void updateValues() {
+
+ uiFilterValueEntity.setFilterId("1");
+ assertNotNull(uiFilterValueEntity.getFilterId());
+ uiFilterValueEntity.setFilterValue("Prov");
+ assertNotNull(uiFilterValueEntity.getFilterValue());
+ uiFilterValueEntity.setDisplayName("Prov-Status");
+ assertNotNull(uiFilterValueEntity.getDisplayName());
+ assertNotNull(uiFilterValueEntity.toString());
+ uiFilterValueEntity.setFilterId(null);
+ uiFilterValueEntity.setFilterValue(null);
+ uiFilterValueEntity.setDisplayName(null);
+ assertNotNull(uiFilterValueEntity.toString());
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/TestUserManager.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/TestUserManager.java
index c34854a..784d807 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/TestUserManager.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/TestUserManager.java
@@ -55,7 +55,7 @@ import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
-@RunWith(PowerMockRunner.class)
+
// @PrepareForTest(RolesConfig.class)
public class TestUserManager {
@@ -72,14 +72,20 @@ public class TestUserManager {
enum TestData {
// @formatter:off
- NO_FILE ("src/test/resources/portal/no-users.config"),
- CONCURRENT_USERS ("src/test/resources/portal/concurrent-users.config"),
- CONCURRENT_EDIT_USERS ("src/test/resources/portal/concurrent-edit-users.config");
-// ROLES_CONFIG_FILE ("src/test/resources/portal/roles.config");
+ NO_FILE("src/test/resources/portal/no-users.config"), CONCURRENT_USERS(
+ "src/test/resources/portal/concurrent-users.config"), CONCURRENT_EDIT_USERS(
+ "src/test/resources/portal/concurrent-edit-users.config");
+ // ROLES_CONFIG_FILE ("src/test/resources/portal/roles.config");
private String filename;
- TestData(String filename) {this.filename = filename;}
- public String getFilename() {return this.filename;}
+
+ TestData(String filename) {
+ this.filename = filename;
+ }
+
+ public String getFilename() {
+ return this.filename;
+ }
// @formatter:on
}
@@ -131,8 +137,8 @@ public class TestUserManager {
return pushTask(concurrentUsers, String.valueOf(NodeUtils.getRandomTxnId()));
};
- List<Callable<EcompUser>> callables = Arrays.asList(pushTask, pushTask, pushTask, pushTask,
- pushTask);
+ List<Callable<EcompUser>> callables =
+ Arrays.asList(pushTask, pushTask, pushTask, pushTask, pushTask);
ExecutorService executor = Executors.newWorkStealingPool();
executor.invokeAll(callables).stream().map(future -> {
@@ -174,9 +180,9 @@ public class TestUserManager {
return editTask(LOGINID_3, "Amy");
};
- List<Callable<EcompUser>> callables = Arrays.asList(pushTaskRandomId, pushTaskRandomId,
- pushTaskId3, editTaskId1, pushTaskRandomId, pushTaskRandomId, editTaskId3, editTaskId2,
- pushTaskRandomId);
+ List<Callable<EcompUser>> callables =
+ Arrays.asList(pushTaskRandomId, pushTaskRandomId, pushTaskId3, editTaskId1,
+ pushTaskRandomId, pushTaskRandomId, editTaskId3, editTaskId2, pushTaskRandomId);
ExecutorService executor = Executors.newWorkStealingPool();
List<EcompUser> userTasks = executor.invokeAll(callables).stream().map(future -> {
@@ -262,4 +268,4 @@ public class TestUserManager {
return user;
}
-} \ No newline at end of file
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/subscription/services/SubscriptionServiceTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/subscription/services/SubscriptionServiceTest.java
new file mode 100644
index 0000000..c32c13f
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/subscription/services/SubscriptionServiceTest.java
@@ -0,0 +1,51 @@
+package org.onap.aai.sparky.subscription.services;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.sparky.subscription.config.SubscriptionConfig;
+
+public class SubscriptionServiceTest {
+
+ private SubscriptionService subscriptionService, subscriptionService2;
+ private SubscriptionConfig subscriptionConfig, subscriptionConfig2;
+
+ @Before
+ public void init() throws Exception {
+ subscriptionConfig = new SubscriptionConfig();
+ subscriptionConfig.setSubscriptionTarget("portal");
+ subscriptionConfig.setSubscriptionOrigin("sparky");
+ subscriptionConfig.setSubscriptionMessageType("subscribe");
+ subscriptionConfig.setSubscriptionTopic("portal-dispalyNotification");
+ subscriptionConfig.setLaunchOITarget("portal");
+ subscriptionConfig.setLaunchOIOrigin("sparky");
+ subscriptionConfig.setLaunchOIMessageType("publish");
+ subscriptionConfig.setLaunchOITopic("portal-displayNotification");
+ subscriptionConfig.setIsLaunchOIEnabled(true);
+
+ subscriptionConfig2 = new SubscriptionConfig();
+ subscriptionConfig2.setSubscriptionTarget("");
+ subscriptionConfig2.setSubscriptionOrigin("");
+ subscriptionConfig2.setSubscriptionMessageType("");
+ subscriptionConfig2.setSubscriptionTopic("");
+ subscriptionConfig2.setLaunchOITarget("");
+ subscriptionConfig2.setLaunchOIOrigin("");
+ subscriptionConfig2.setLaunchOIMessageType("");
+ subscriptionConfig2.setLaunchOITopic("");
+ subscriptionConfig2.setIsLaunchOIEnabled(true);
+
+ subscriptionService = new SubscriptionService(subscriptionConfig);
+ subscriptionService2 = new SubscriptionService(subscriptionConfig2);
+
+ }
+
+ @Test
+ public void updateValues() throws Exception {
+
+ assertNotNull(subscriptionService.buildSubscriptionPayload());
+ assertNotNull(subscriptionService2.buildSubscriptionPayload());
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java
new file mode 100644
index 0000000..a55e3ee
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java
@@ -0,0 +1,34 @@
+package org.onap.aai.sparky.util;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ConfigHelperTest {
+
+ private ConfigHelper configHelper;
+ private Properties props;
+
+ @Before
+ public void init() throws Exception {
+ configHelper = new ConfigHelper();
+ props = new Properties();
+
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateValues() throws Exception {
+
+
+ assertNotNull(configHelper.getConfigWithPrefix("aai-ui", props));
+ assertFalse(configHelper.isEssDevModeEnabled());
+ assertNotNull(configHelper.getFilepath("sparky-aaui", false));
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java
new file mode 100644
index 0000000..75b1ed1
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java
@@ -0,0 +1,59 @@
+package org.onap.aai.sparky.util;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+
+public class NodeUtilsTest {
+
+
+ private NodeUtils nodeUtils;
+ private JsonNode jsonNode, jsonNode2;
+ private ArrayList<String> lst;
+ private Object obj;
+
+ @Before
+ public void init() throws Exception {
+ nodeUtils = new NodeUtils();
+ jsonNode = JsonNodeFactory.instance.objectNode();
+ jsonNode2 = jsonNode;
+ lst = new ArrayList<String>();
+ obj = new Object();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateValues() throws IOException {
+
+
+ assertNotNull(nodeUtils.buildDepthPadding(2));
+ assertNotNull(nodeUtils.isNumeric("234"));
+ assertNull(nodeUtils.calculateEditAttributeUri(null));
+ assertNotNull(nodeUtils.generateUniqueShaDigest("unique-101"));
+ assertNull(nodeUtils.getNodeFieldAsText(jsonNode,""));
+ assertNotNull(nodeUtils.getDurationBreakdown(2));
+ assertTrue(nodeUtils.isEqual(jsonNode,jsonNode2));
+ assertNotNull(nodeUtils.concatArray(lst));
+ assertNotNull(nodeUtils.concatArray(lst," "));
+ assertNotNull(nodeUtils.getDurationBreakdown(2));
+ assertNotNull(nodeUtils.buildEntityResourceKey("vserver","1232342"));
+ assertNull(nodeUtils.extractResourceIdFromLink(null));
+ assertNotNull(nodeUtils.getXmlStreamConstantAsStr(2));
+ assertNotNull(nodeUtils.convertObjectToJson(obj,false));
+ assertNull(nodeUtils.convertJsonStrToJsonNode(null));
+ assertNull(nodeUtils.extractObjectValueByKey(null,null));
+ assertNull(nodeUtils.extractFieldValueFromObject(null,null));
+
+
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java
index 5dbf7bb..dfa4b27 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java
@@ -13,50 +13,54 @@ import org.junit.Test;
public class VisualizationConfigTest {
- private VisualizationConfigs visualConfig;
- private ArrayList<String> shallowEntities;
-
- @Before
- public void init() throws Exception {
- visualConfig = new VisualizationConfigs();
- shallowEntities = new ArrayList<String>();
-
- }
-
-
- @Test
- public void updateValues() {
-
- visualConfig.setShallowEntities(shallowEntities);
- assertNotNull(visualConfig.getShallowEntities());
- visualConfig.setMakeAllNeighborsBidirectional(true);
- assertTrue(visualConfig.makeAllNeighborsBidirectional());
- visualConfig.setSelectedSearchedNodeClassName("selectedsearchedNodeClass");
- assertNotNull(visualConfig.getSelectedSearchedNodeClassName());
- visualConfig.setGeneralNodeClassName("generalNodeClass");
- assertNotNull(visualConfig.getGeneralNodeClassName());
- visualConfig.setSearchNodeClassName("searchedNodeClass");
- assertNotNull(visualConfig.getSearchNodeClassName());
- visualConfig.setAaiEntityNodeDescriptors("/etc/aaiEntityNodeDescriptors.json");
- assertNotNull(visualConfig.getAaiEntityNodeDescriptors());
- visualConfig.setVisualizationDebugEnabled(true);
- assertTrue(visualConfig.isVisualizationDebugEnabled());
- visualConfig.setMaxSelfLinkTraversalDepth(3);
- assertEquals(3,visualConfig.getMaxSelfLinkTraversalDepth());
- visualConfig.setNumOfThreadsToFetchNodeIntegrity(25);
- assertEquals(25,visualConfig.getNumOfThreadsToFetchNodeIntegrity());
- assertNotNull(visualConfig.toString());
- visualConfig.setAaiEntityNodeDescriptors(null);
- assertNull(visualConfig.getAaiEntityNodeDescriptors());
- visualConfig.setGeneralNodeClassName(null);
- assertNull(visualConfig.getGeneralNodeClassName());
- visualConfig.setSearchNodeClassName(null);
- assertNull(visualConfig.getSearchNodeClassName());
- visualConfig.setSelectedSearchedNodeClassName(null);
- assertNull(visualConfig.getSelectedSearchedNodeClassName());
- assertNotNull(visualConfig.toString());
-
-
- }
-
+ private VisualizationConfigs visualConfig;
+ private ArrayList<String> shallowEntities;
+
+ @Before
+ public void init() throws Exception {
+ visualConfig = new VisualizationConfigs();
+ shallowEntities = new ArrayList<String>();
+
+ }
+
+
+ @Test
+ public void updateValues() {
+
+ visualConfig.setShallowEntities(shallowEntities);
+ assertNotNull(visualConfig.getShallowEntities());
+ visualConfig.setGizmoEnabled(true);
+ assertTrue(visualConfig.isGizmoEnabled());
+ visualConfig.setMakeAllNeighborsBidirectional(true);
+ assertTrue(visualConfig.makeAllNeighborsBidirectional());
+ visualConfig.setSelectedSearchedNodeClassName("selectedsearchedNodeClass");
+ assertNotNull(visualConfig.getSelectedSearchedNodeClassName());
+ visualConfig.setGeneralNodeClassName("generalNodeClass");
+ assertNotNull(visualConfig.getGeneralNodeClassName());
+ visualConfig.setSearchNodeClassName("searchedNodeClass");
+ assertNotNull(visualConfig.getSearchNodeClassName());
+ visualConfig.setAaiEntityNodeDescriptors("/etc/aaiEntityNodeDescriptors.json");
+ assertNotNull(visualConfig.getAaiEntityNodeDescriptors());
+ visualConfig.setVisualizationDebugEnabled(true);
+ assertTrue(visualConfig.isVisualizationDebugEnabled());
+ visualConfig.setMaxSelfLinkTraversalDepth(3);
+ assertEquals(3, visualConfig.getMaxSelfLinkTraversalDepth());
+ visualConfig.setNumOfThreadsToFetchNodeIntegrity(25);
+ assertEquals(25, visualConfig.getNumOfThreadsToFetchNodeIntegrity());
+ assertNotNull(visualConfig.toString());
+ visualConfig.setShallowEntities(null);
+ assertNull(visualConfig.getShallowEntities());
+ visualConfig.setAaiEntityNodeDescriptors(null);
+ assertNull(visualConfig.getAaiEntityNodeDescriptors());
+ visualConfig.setGeneralNodeClassName(null);
+ assertNull(visualConfig.getGeneralNodeClassName());
+ visualConfig.setSearchNodeClassName(null);
+ assertNull(visualConfig.getSearchNodeClassName());
+ visualConfig.setSelectedSearchedNodeClassName(null);
+ assertNull(visualConfig.getSelectedSearchedNodeClassName());
+ assertNotNull(visualConfig.toString());
+
+
+ }
+
}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoEntityTest.java
new file mode 100644
index 0000000..4080a02
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoEntityTest.java
@@ -0,0 +1,62 @@
+package org.onap.aai.sparky.viewandinspect.entity;
+
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class GizmoEntityTest {
+
+ private GizmoEntity gizmoEntity;
+ private Map<String, String> props;
+ private GizmoRelationshipHint[] gizmoRelationshipHintArr;
+
+
+
+ @Before
+ public void init() throws Exception {
+
+ gizmoEntity = new GizmoEntity();
+ props = new HashMap<String, String>();
+ }
+
+ @Test
+ public void updateValues() {
+
+
+ gizmoEntity.setId("1664646");
+ assertNotNull(gizmoEntity.getId());
+ gizmoEntity.setType("pserver");
+ assertNotNull(gizmoEntity.getType());
+ gizmoEntity.setUrl("https://magicaltest.com:6666/v2/tenant-id/servers/vserver-id");
+ assertNotNull(gizmoEntity.getUrl());
+ gizmoEntity.setProperties(props);
+ assertNotNull(gizmoEntity.getProperties());
+ gizmoEntity.setIn(gizmoRelationshipHintArr);
+ assertNull(gizmoEntity.getIn());
+ gizmoEntity.setOut(gizmoRelationshipHintArr);
+ assertNull(gizmoEntity.getOut());
+ assertNotNull(gizmoEntity.toString());
+
+
+ gizmoEntity.setId(null);
+ assertNull(gizmoEntity.getId());
+ gizmoEntity.setType(null);
+ assertNull(gizmoEntity.getType());
+ gizmoEntity.setUrl(null);
+ assertNull(gizmoEntity.getUrl());
+ gizmoEntity.setProperties(null);
+ assertNull(gizmoEntity.getProperties());
+ gizmoEntity.setIn(null);
+ assertNull(gizmoEntity.getIn());
+ gizmoEntity.setOut(null);
+ assertNull(gizmoEntity.getOut());
+ assertNotNull(gizmoEntity.toString());
+
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipEntityTest.java
new file mode 100644
index 0000000..2f00a5d
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipEntityTest.java
@@ -0,0 +1,62 @@
+package org.onap.aai.sparky.viewandinspect.entity;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class GizmoRelationshipEntityTest {
+
+
+ private GizmoRelationshipEntity gizmoRelationshipEntity;
+ private Map<String, String> props;
+
+
+
+ @Before
+ public void init() throws Exception {
+
+ gizmoRelationshipEntity = new GizmoRelationshipEntity();
+ props = new HashMap<String, String>();
+
+ }
+
+ @Test
+ public void updateValues() {
+
+
+ gizmoRelationshipEntity.setId("1664646");
+ assertNotNull(gizmoRelationshipEntity.getId());
+ gizmoRelationshipEntity.setType("pserver");
+ assertNotNull(gizmoRelationshipEntity.getType());
+ gizmoRelationshipEntity.setUrl("https://magicaltest.com:6666/v2/tenant-id/servers/vserver-id");
+ assertNotNull(gizmoRelationshipEntity.getUrl());
+ gizmoRelationshipEntity.setSource("pserver");
+ assertNotNull(gizmoRelationshipEntity.getSource());
+ gizmoRelationshipEntity.setTarget("generic-vnf");
+ assertNotNull(gizmoRelationshipEntity.getTarget());
+ gizmoRelationshipEntity.setProperties(props);
+ assertNotNull(gizmoRelationshipEntity.getProperties());
+ assertNotNull(gizmoRelationshipEntity.toString());
+
+ gizmoRelationshipEntity.setId(null);
+ assertNull(gizmoRelationshipEntity.getId());
+ gizmoRelationshipEntity.setType(null);
+ assertNull(gizmoRelationshipEntity.getType());
+ gizmoRelationshipEntity.setUrl(null);
+ assertNull(gizmoRelationshipEntity.getUrl());
+ gizmoRelationshipEntity.setSource(null);
+ assertNull(gizmoRelationshipEntity.getSource());
+ gizmoRelationshipEntity.setTarget(null);
+ assertNull(gizmoRelationshipEntity.getTarget());
+ gizmoRelationshipEntity.setProperties(null);
+ assertNull(gizmoRelationshipEntity.getProperties());
+ assertNotNull(gizmoRelationshipEntity.toString());
+
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipHintTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipHintTest.java
new file mode 100644
index 0000000..b2c6ad9
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipHintTest.java
@@ -0,0 +1,37 @@
+package org.onap.aai.sparky.viewandinspect.entity;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class GizmoRelationshipHintTest {
+
+ private GizmoRelationshipHint gizmoRelationshipHint;
+
+ @Before
+ public void init() throws Exception {
+
+ gizmoRelationshipHint = new GizmoRelationshipHint();
+
+ }
+
+ @Test
+ public void updateValues() {
+
+
+ gizmoRelationshipHint.setId("1664646");
+ assertNotNull(gizmoRelationshipHint.getId());
+ gizmoRelationshipHint.setType("pserver");
+ assertNotNull(gizmoRelationshipHint.getType());
+ gizmoRelationshipHint.setUrl("https://magicaltest.com:6666/v2/tenant-id/servers/vserver-id");
+ assertNotNull(gizmoRelationshipHint.getUrl());
+ gizmoRelationshipHint.setSource("pserver");
+ assertNotNull(gizmoRelationshipHint.getSource());
+ gizmoRelationshipHint.setTarget("generic-vnf");
+ assertNotNull(gizmoRelationshipHint.getTarget());
+
+
+
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContextTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContextTest.java
new file mode 100644
index 0000000..ed7caeb
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContextTest.java
@@ -0,0 +1,110 @@
+package org.onap.aai.sparky.viewandinspect.services;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+
+import org.hamcrest.Matcher;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
+import org.onap.aai.cl.mdc.MdcContext;
+import org.onap.aai.restclient.client.OperationResult;
+import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
+import org.onap.aai.sparky.config.oxm.OxmModelLoader;
+import org.onap.aai.sparky.config.oxm.OxmModelProcessor;
+import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
+import org.onap.aai.sparky.dal.GizmoAdapter;
+import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
+import org.onap.aai.sparky.sync.entity.SearchableEntity;
+import org.onap.aai.sparky.util.NodeUtils;
+import org.onap.aai.sparky.util.StringCollectionContainsMatcher;
+import org.onap.aai.sparky.util.TestResourceLoader;
+import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
+import org.onap.aai.sparky.viewandinspect.entity.ActiveInventoryNode;
+import org.onap.aai.sparky.viewandinspect.entity.QueryParams;
+import org.onap.aai.sparky.viewandinspect.enumeration.NodeProcessingState;
+
+public class BaseGizmoVisualizationContextTest {
+
+
+
+ private static SecureRandom secureRandom = new SecureRandom();
+ private static Logger LOG =
+ LoggerFactory.getInstance().getLogger(BaseGizmoVisualizationContextTest.class);
+
+ private BaseGizmoVisualizationContext baseGizmoVisualizationContext;
+ private ExecutorService graphExecutorService;
+ private VisualizationConfigs visualizationConfig;
+
+ private OxmEntityLookup oxmEntityLookup;
+
+ private GizmoAdapter gizmoAdapter;
+ private RestEndpointConfig gizmoRestEndPointConfig;
+
+ @Before
+ public void init() throws Exception {
+ long contextId = secureRandom.nextLong();
+ baseGizmoVisualizationContext = new BaseGizmoVisualizationContext(contextId, gizmoAdapter,
+ graphExecutorService, visualizationConfig, oxmEntityLookup);
+
+ graphExecutorService = NodeUtils.createNamedExecutor("SLNC-WORKER", 5, LOG);
+ visualizationConfig = new VisualizationConfigs();
+
+ ArrayList<String> shallowEntities = new ArrayList<String>();
+ shallowEntities.add("cloud-region");
+
+ visualizationConfig.setShallowEntities(shallowEntities);
+ visualizationConfig.setMaxSelfLinkTraversalDepth(2);
+
+ oxmEntityLookup = new OxmEntityLookup();
+
+ gizmoAdapter = Mockito.mock(GizmoAdapter.class);
+
+
+ Set<OxmModelProcessor> processors = new HashSet<OxmModelProcessor>();
+
+ processors.add(oxmEntityLookup);
+
+
+ OxmModelLoader oxmModelLoader = new OxmModelLoader(-1, processors);
+ oxmModelLoader.loadLatestOxmModel();
+
+ gizmoRestEndPointConfig = new RestEndpointConfig();
+ gizmoRestEndPointConfig.setNumRequestRetries(5);
+
+ Mockito.when(gizmoAdapter.getEndpointConfig()).thenReturn(gizmoRestEndPointConfig);
+
+ MdcContext.initialize("" + secureRandom.nextLong(), "AAI-UI", "", "partner-name",
+ "localhost:4242");
+
+
+ }
+
+ @Test
+ public void validateBasicConstruction() throws Exception {
+
+ long contextId = secureRandom.nextLong();
+
+ baseGizmoVisualizationContext = new BaseGizmoVisualizationContext(contextId, gizmoAdapter,
+ graphExecutorService, visualizationConfig, oxmEntityLookup);
+
+ assertEquals(contextId, baseGizmoVisualizationContext.getContextId());
+
+ }
+
+
+
+}
diff --git a/version.properties b/version.properties
new file mode 100644
index 0000000..faf06bb
--- /dev/null
+++ b/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=1
+minor=2
+patch=0
+
+base_version=${major}.${minor}.${patch}
+
+# Release must be completed with git revision # in Jenkins
+release_version=${base_version}
+snapshot_version=${base_version}-SNAPSHOT