diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-03-21 14:16:56 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-03-21 14:18:16 -0400 |
commit | db675a54e8e7bb3553e059d237774b4b737488f1 (patch) | |
tree | c2eaec34581f45ee16cb15ea3a208a61348b6fc0 | |
parent | 558a73181640d0d19f7f05cab6e0b8568574b504 (diff) |
added custom validators for use with openpojo
Change-Id: I7c9fdeb6bccddb1b7ec6bf845351731c3043aafa
Issue-ID: SO-510
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
15 files changed, 1114 insertions, 649 deletions
diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml index 67b1f3124e..67d81dbb49 100644 --- a/adapters/mso-catalog-db-adapter/pom.xml +++ b/adapters/mso-catalog-db-adapter/pom.xml @@ -45,7 +45,7 @@ jaxws-maven-plugin </artifactId> <versionRange> - [2.3,) + [2.3.1,) </versionRange> <goals> <goal>wsgen</goal> @@ -87,12 +87,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> - <version>1.3</version> - <scope>test</scope> -</dependency> -<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> diff --git a/adapters/mso-tenant-adapter/pom.xml b/adapters/mso-tenant-adapter/pom.xml index 6604e7e664..0b15b0dd6f 100644 --- a/adapters/mso-tenant-adapter/pom.xml +++ b/adapters/mso-tenant-adapter/pom.xml @@ -151,11 +151,5 @@ <artifactId>status-control</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> - <version>1.10.19</version> - <scope>test</scope> - </dependency> </dependencies> </project> diff --git a/adapters/mso-vnf-adapter/pom.xml b/adapters/mso-vnf-adapter/pom.xml index 643f42f2ba..c4eb83c879 100644 --- a/adapters/mso-vnf-adapter/pom.xml +++ b/adapters/mso-vnf-adapter/pom.xml @@ -1,175 +1,169 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.so</groupId>
- <artifactId>adapters</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </parent>
- <groupId>org.onap.so.adapters</groupId>
- <artifactId>mso-vnf-adapter</artifactId>
- <packaging>war</packaging>
- <name>mso-vnf-adapter</name>
- <description>Web Service and REST endpoint for VNF operations</description>
-
- <build>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <warSourceDirectory>WebContent</warSourceDirectory>
- <failOnMissingWebXml>false</failOnMissingWebXml>
- <attachClasses>true</attachClasses>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.jvnet.jax-ws-commons</groupId>
- <artifactId>jaxws-maven-plugin</artifactId>
- <version>2.3</version>
- <executions>
- <execution>
- <id>Synch</id>
- <goals>
- <goal>wsgen</goal>
- </goals>
- <configuration>
- <verbose>true</verbose>
- <sei>org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl</sei>
- <genWsdl>true</genWsdl>
- <inlineSchemas>true</inlineSchemas>
- </configuration>
- </execution>
- <execution>
- <id>Asynch</id>
- <goals>
- <goal>wsgen</goal>
- </goals>
- <configuration>
- <verbose>true</verbose>
- <sei>org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsyncImpl</sei>
- <genWsdl>true</genWsdl>
- <inlineSchemas>true</inlineSchemas>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.onap.so.adapters</groupId>
- <artifactId>mso-adapter-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.ws</groupId>
- <artifactId>jaxws-tools</artifactId>
- <version>2.2.7</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <!--This plugin's configuration is used to store Eclipse m2e settings
- only. It has no influence on the Maven build itself. -->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>
- org.jvnet.jax-ws-commons
- </groupId>
- <artifactId>
- jaxws-maven-plugin
- </artifactId>
- <versionRange>
- [2.3,)
- </versionRange>
- <goals>
- <goal>wsgen</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore></ignore>
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.onap.so.adapters</groupId>
- <artifactId>mso-adapter-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so.adapters</groupId>
- <artifactId>mso-adapters-rest-interface</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so.adapters</groupId>
- <artifactId>mso-vnf-adapter-async-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>javax</groupId>
- <artifactId>javaee-web-api</artifactId>
- <version>6.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.spec.javax.ejb</groupId>
- <artifactId>jboss-ejb-api_3.2_spec</artifactId>
- <version>1.0.0.Final</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-ext-api</artifactId>
- <version>2.2.0.Final</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>status-control</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>aria-client</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.jmockit</groupId>
- <artifactId>jmockit</artifactId>
- <version>1.8</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- <scope>test</scope>
- </dependency>
- <!-- <dependency> -->
- <!-- <groupId>org.onap.so</groupId> -->
- <!-- <artifactId>mso-catalog-db</artifactId> -->
- <!-- <version>${project.version}</version> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>log4j</groupId> -->
- <!-- <artifactId>log4j</artifactId> -->
- <!-- <version>1.2.17</version> -->
- <!-- </dependency> -->
- </dependencies>
-</project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so</groupId> + <artifactId>adapters</artifactId> + <version>1.2.0-SNAPSHOT</version> + </parent> + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-vnf-adapter</artifactId> + <packaging>war</packaging> + <name>mso-vnf-adapter</name> + <description>Web Service and REST endpoint for VNF operations</description> + + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.4</version> + <configuration> + <warSourceDirectory>WebContent</warSourceDirectory> + <failOnMissingWebXml>false</failOnMissingWebXml> + <attachClasses>true</attachClasses> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxws-maven-plugin</artifactId> + <version>2.4.1</version> + <executions> + <execution> + <id>Synch</id> + <goals> + <goal>wsgen</goal> + </goals> + <configuration> + <verbose>true</verbose> + <sei>org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl</sei> + <genWsdl>true</genWsdl> + <inlineSchemas>true</inlineSchemas> + </configuration> + </execution> + <execution> + <id>Asynch</id> + <goals> + <goal>wsgen</goal> + </goals> + <configuration> + <verbose>true</verbose> + <sei>org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsyncImpl</sei> + <genWsdl>true</genWsdl> + <inlineSchemas>true</inlineSchemas> + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-tools</artifactId> + <version>2.2.7</version> + </dependency> + </dependencies> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings + only. It has no influence on the Maven build itself. --> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId> + org.codehaus.mojo + </groupId> + <artifactId> + jaxws-maven-plugin + </artifactId> + <versionRange> + [2.4.1,) + </versionRange> + <goals> + <goal>wsgen</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + <dependencies> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-adapters-rest-interface</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-vnf-adapter-async-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>javax</groupId> + <artifactId>javaee-web-api</artifactId> + <version>6.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.spec.javax.ejb</groupId> + <artifactId>jboss-ejb-api_3.2_spec</artifactId> + <version>1.0.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.ejb3</groupId> + <artifactId>jboss-ejb3-ext-api</artifactId> + <version>2.2.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>status-control</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>aria-client</artifactId> + <version>1.2.0</version> + </dependency> + <dependency> + <groupId>org.jmockit</groupId> + <artifactId>jmockit</artifactId> + <version>1.8</version> + <scope>test</scope> + </dependency> + <!-- <dependency> --> + <!-- <groupId>org.onap.so</groupId> --> + <!-- <artifactId>mso-catalog-db</artifactId> --> + <!-- <version>${project.version}</version> --> + <!-- </dependency> --> + <!-- <dependency> --> + <!-- <groupId>log4j</groupId> --> + <!-- <artifactId>log4j</artifactId> --> + <!-- <version>1.2.17</version> --> + <!-- </dependency> --> + </dependencies> +</project> diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml index a06a16ddd8..ff21372240 100644 --- a/asdc-controller/pom.xml +++ b/asdc-controller/pom.xml @@ -28,12 +28,6 @@ </build> <dependencies> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> - <version>1.10.19</version> - <scope>test</scope> - </dependency> <dependency> <groupId>org.jmockit</groupId> <artifactId>jmockit</artifactId> diff --git a/bpmn/MSOInfrastructureBPMN/pom.xml b/bpmn/MSOInfrastructureBPMN/pom.xml index f7cb61a512..0329f2883e 100644 --- a/bpmn/MSOInfrastructureBPMN/pom.xml +++ b/bpmn/MSOInfrastructureBPMN/pom.xml @@ -1,390 +1,383 @@ -<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">
- <parent>
- <groupId>org.onap.so</groupId>
- <artifactId>bpmn</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>MSOInfrastructureBPMN</artifactId>
- <packaging>war</packaging>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.3</version>
- <configuration>
- <failOnMissingWebXml>false</failOnMissingWebXml>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <id>default-jar</id>
- <phase>package</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- <configuration>
- <excludes>
- <exclude>org/openecomp/mso/bpmn/infrastructure/MSOInfrastructureApplication.class</exclude>
-<!-- <exclude>META-INF/</exclude> -->
- </excludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>3.0.0</version>
- <executions>
- <execution>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <artifacts>
- <artifact>
- <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
- <type>jar</type>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-codegen-plugin</artifactId>
- <version>2.5.2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-eclipse-plugin</artifactId>
- <version>2.8</version>
- <configuration>
- <additionalProjectnatures>
- <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
- </additionalProjectnatures>
- <sourceIncludes>
- <sourceInclude>**/*.groovy</sourceInclude>
- </sourceIncludes>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>compile</id>
- <phase>compile</phase>
- <configuration>
- <tasks>
- <mkdir dir="${basedir}/src/main/groovy" />
- <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
- <classpath refid="maven.compile.classpath" />
- </taskdef>
- <mkdir dir="${project.build.outputDirectory}" />
- <groovyc destdir="${project.build.outputDirectory}"
- srcdir="${basedir}/src/main/groovy/" listfiles="true">
- <classpath refid="maven.compile.classpath" />
- </groovyc>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- <execution>
- <id>test-compile</id>
- <phase>test-compile</phase>
- <configuration>
- <tasks>
- <mkdir dir="${basedir}/src/test/groovy" />
- <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
- <classpath refid="maven.test.classpath" />
- </taskdef>
- <mkdir dir="${project.build.testOutputDirectory}" />
- <groovyc destdir="${project.build.testOutputDirectory}"
- srcdir="${basedir}/src/test/groovy/" listfiles="true">
- <classpath refid="maven.test.classpath" />
- </groovyc>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-failsafe-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <!--This plugin's configuration is used to store Eclipse m2e settings
- only. It has no influence on the Maven build itself. -->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>
- org.apache.maven.plugins
- </groupId>
- <artifactId>
- maven-antrun-plugin
- </artifactId>
- <versionRange>
- [1.3,)
- </versionRange>
- <goals>
- <goal>run</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore></ignore>
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
- <dependencies>
- <dependency>
- <!-- process engine, in compile scope to include it in the war file -->
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine</artifactId>
- <scope>compile</scope>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <!-- Using the `DefaultEjbProcessApplication` result in: `java.sql.SQLException:
- You cannot commit during a managed transaction!` -->
- <dependency>
- <!-- CDI integration, needs to be included in WAR, otherwise CDI can not
- work correctly -->
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine-cdi</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>22.0</version> <!-- or 22.0-android for the Android flavor -->
- </dependency>
- <dependency>
- <!-- AssertJ Testing Library -->
- <groupId>org.camunda.bpm.extension</groupId>
- <artifactId>camunda-bpm-assert</artifactId>
- <version>1.2</version>
- <scope>test</scope>
- </dependency>
-
- <!-- Spin dataformat support, in compile scope to include it in the war
- file -->
- <dependency>
- <groupId>org.camunda.spin</groupId>
- <artifactId>camunda-spin-dataformat-all</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <artifactId>camunda-spin-dataformat-all</artifactId>
- <groupId>org.camunda.spin</groupId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine-plugin-spin</artifactId>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine-plugin-connect</artifactId>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <!-- Bootstrap for styling via Webjars project -->
- <groupId>org.webjars</groupId>
- <artifactId>bootstrap</artifactId>
- <version>2.3.2</version>
- </dependency>
- <dependency>
- <!-- Needed for InMemoryH2Test -->
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>com.fasterxml.uuid</groupId>
- <artifactId>java-uuid-generator</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.4</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>MSOCoreBPMN</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>MSOCommonBPMN</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>MSOCommonBPMN</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <!-- unit test utilities -->
- <groupId>org.onap.so</groupId>
- <artifactId>MSOCoreBPMN</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>2.0</version>
- </dependency>
- <!-- for encoding the url the same way A&AI does -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- <version>4.3.2.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>MSORESTClient</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.0.1</version>
- <scope>provided</scope>
- </dependency>
-
-
- <dependency>
- <groupId>org.camunda.bpm</groupId>
- <artifactId>camunda-engine-spring</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>4.3.2.RELEASE</version>
-</dependency>
-<dependency>
- <!-- Optional Plugin for Camunda BPM Workbench -->
- <groupId>org.camunda.bpm.workbench</groupId>
- <artifactId>camunda-workbench-dist-embeddable</artifactId>
- <version>1.0.0-alpha8</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.onap.msb.java-sdk</groupId>
- <artifactId>msb-java-sdk</artifactId>
- <version>1.0.0</version>
- <exclusions>
- <exclusion>
- <groupId>com.eclipsesource.jaxrs</groupId>
- <artifactId>jersey-all</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- bwj add; Jetty-util -->
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-util</artifactId>
- <version>9.4.8.v20171121</version>
- </dependency>
- <!-- bwj add; hibernate-validator -->
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- <version>5.4.2.Final</version>
- </dependency>
- <!-- bwj add; spring-test -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>4.3.14.RELEASE</version>
- </dependency>
- <!-- bwj add; libphonenumber -->
- <dependency>
- <groupId>com.googlecode.libphonenumber</groupId>
- <artifactId>libphonenumber</artifactId>
- <version>8.9.1</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- <scope>test</scope>
- </dependency>
-
- <!--for yang tools-->
-<!-- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>common</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.onap.sdnc.northbound</groupId>
- <artifactId>generic-resource-api.model</artifactId>
- <version>1.2.0</version>
- </dependency>-->
- </dependencies>
-</project>
+<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"> + <parent> + <groupId>org.onap.so</groupId> + <artifactId>bpmn</artifactId> + <version>1.2.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>MSOInfrastructureBPMN</artifactId> + <packaging>war</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>2.3</version> + <configuration> + <failOnMissingWebXml>false</failOnMissingWebXml> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.6</version> + <executions> + <execution> + <id>default-jar</id> + <phase>package</phase> + <goals> + <goal>jar</goal> + </goals> + <configuration> + <excludes> + <exclude>org/openecomp/mso/bpmn/infrastructure/MSOInfrastructureApplication.class</exclude> +<!-- <exclude>META-INF/</exclude> --> + </excludes> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.0.0</version> + <executions> + <execution> + <goals> + <goal>attach-artifact</goal> + </goals> + <phase>package</phase> + <configuration> + <artifacts> + <artifact> + <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file> + <type>jar</type> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-codegen-plugin</artifactId> + <version>2.5.2</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-eclipse-plugin</artifactId> + <version>2.8</version> + <configuration> + <additionalProjectnatures> + <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature> + </additionalProjectnatures> + <sourceIncludes> + <sourceInclude>**/*.groovy</sourceInclude> + </sourceIncludes> + </configuration> + </plugin> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>compile</id> + <phase>compile</phase> + <configuration> + <tasks> + <mkdir dir="${basedir}/src/main/groovy" /> + <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"> + <classpath refid="maven.compile.classpath" /> + </taskdef> + <mkdir dir="${project.build.outputDirectory}" /> + <groovyc destdir="${project.build.outputDirectory}" + srcdir="${basedir}/src/main/groovy/" listfiles="true"> + <classpath refid="maven.compile.classpath" /> + </groovyc> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + <execution> + <id>test-compile</id> + <phase>test-compile</phase> + <configuration> + <tasks> + <mkdir dir="${basedir}/src/test/groovy" /> + <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"> + <classpath refid="maven.test.classpath" /> + </taskdef> + <mkdir dir="${project.build.testOutputDirectory}" /> + <groovyc destdir="${project.build.testOutputDirectory}" + srcdir="${basedir}/src/test/groovy/" listfiles="true"> + <classpath refid="maven.test.classpath" /> + </groovyc> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + </plugin> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <version>2.6</version> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings + only. It has no influence on the Maven build itself. --> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId> + org.apache.maven.plugins + </groupId> + <artifactId> + maven-antrun-plugin + </artifactId> + <versionRange> + [1.3,) + </versionRange> + <goals> + <goal>run</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + + <dependencies> + <dependency> + <!-- process engine, in compile scope to include it in the war file --> + <groupId>org.camunda.bpm</groupId> + <artifactId>camunda-engine</artifactId> + <scope>compile</scope> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- Using the `DefaultEjbProcessApplication` result in: `java.sql.SQLException: + You cannot commit during a managed transaction!` --> + <dependency> + <!-- CDI integration, needs to be included in WAR, otherwise CDI can not + work correctly --> + <groupId>org.camunda.bpm</groupId> + <artifactId>camunda-engine-cdi</artifactId> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>22.0</version> <!-- or 22.0-android for the Android flavor --> + </dependency> + <dependency> + <!-- AssertJ Testing Library --> + <groupId>org.camunda.bpm.extension</groupId> + <artifactId>camunda-bpm-assert</artifactId> + <version>1.2</version> + <scope>test</scope> + </dependency> + + <!-- Spin dataformat support, in compile scope to include it in the war + file --> + <dependency> + <groupId>org.camunda.spin</groupId> + <artifactId>camunda-spin-dataformat-all</artifactId> + <scope>compile</scope> + </dependency> + <dependency> + <artifactId>camunda-spin-dataformat-all</artifactId> + <groupId>org.camunda.spin</groupId> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.camunda.bpm</groupId> + <artifactId>camunda-engine-plugin-spin</artifactId> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.camunda.bpm</groupId> + <artifactId>camunda-engine-plugin-connect</artifactId> + <scope>compile</scope> + </dependency> + + <dependency> + <!-- Bootstrap for styling via Webjars project --> + <groupId>org.webjars</groupId> + <artifactId>bootstrap</artifactId> + <version>2.3.2</version> + </dependency> + <dependency> + <!-- Needed for InMemoryH2Test --> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>com.fasterxml.uuid</groupId> + <artifactId>java-uuid-generator</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-all</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.4</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>MSOCoreBPMN</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>MSOCommonBPMN</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>MSOCommonBPMN</artifactId> + <version>${project.version}</version> + <classifier>tests</classifier> + <scope>test</scope> + </dependency> + <dependency> + <!-- unit test utilities --> + <groupId>org.onap.so</groupId> + <artifactId>MSOCoreBPMN</artifactId> + <version>${project.version}</version> + <classifier>tests</classifier> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>2.0</version> + </dependency> + <!-- for encoding the url the same way A&AI does --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>4.3.2.RELEASE</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>MSORESTClient</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.0.1</version> + <scope>provided</scope> + </dependency> + + + <dependency> + <groupId>org.camunda.bpm</groupId> + <artifactId>camunda-engine-spring</artifactId> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>4.3.2.RELEASE</version> +</dependency> +<dependency> + <!-- Optional Plugin for Camunda BPM Workbench --> + <groupId>org.camunda.bpm.workbench</groupId> + <artifactId>camunda-workbench-dist-embeddable</artifactId> + <version>1.0.0-alpha8</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.onap.msb.java-sdk</groupId> + <artifactId>msb-java-sdk</artifactId> + <version>1.0.0</version> + <exclusions> + <exclusion> + <groupId>com.eclipsesource.jaxrs</groupId> + <artifactId>jersey-all</artifactId> + </exclusion> + </exclusions> + </dependency> + + <!-- bwj add; Jetty-util --> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-util</artifactId> + <version>9.4.8.v20171121</version> + </dependency> + <!-- bwj add; hibernate-validator --> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-validator</artifactId> + <version>5.4.2.Final</version> + </dependency> + <!-- bwj add; spring-test --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-test</artifactId> + <version>4.3.14.RELEASE</version> + </dependency> + <!-- bwj add; libphonenumber --> + <dependency> + <groupId>com.googlecode.libphonenumber</groupId> + <artifactId>libphonenumber</artifactId> + <version>8.9.1</version> + </dependency> + + <!--for yang tools--> +<!-- <dependency> + <groupId>org.onap.so</groupId> + <artifactId>common</artifactId> + <version>1.1.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.onap.sdnc.northbound</groupId> + <artifactId>generic-resource-api.model</artifactId> + <version>1.2.0</version> + </dependency>--> + </dependencies> +</project> diff --git a/bpmn/MSORESTClient/pom.xml b/bpmn/MSORESTClient/pom.xml index 9c5ce1487e..6f2f007e5f 100644 --- a/bpmn/MSORESTClient/pom.xml +++ b/bpmn/MSORESTClient/pom.xml @@ -1,45 +1,37 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.so</groupId>
- <artifactId>bpmn</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>MSORESTClient</artifactId>
-
- <packaging>jar</packaging>
-
- <name>MSO REST Client API</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpmime</artifactId>
- <version>4.5</version>
- </dependency>
-
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <finalName>MSORESTClient</finalName>
- <plugins>
-
- </plugins>
-
- </build>
-</project>
+<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.onap.so</groupId> + <artifactId>bpmn</artifactId> + <version>1.2.0-SNAPSHOT</version> + </parent> + + <artifactId>MSORESTClient</artifactId> + + <packaging>jar</packaging> + + <name>MSO REST Client API</name> + + <dependencies> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpmime</artifactId> + <version>4.5</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + <build> + <finalName>MSORESTClient</finalName> + <plugins> + + </plugins> + + </build> +</project> diff --git a/common/pom.xml b/common/pom.xml index aeef257d48..adc102e150 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -53,12 +53,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <version>1.3</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.jboss.spec.javax.ejb</groupId> <artifactId>jboss-ejb-api_3.2_spec</artifactId> <version>1.0.0.Final</version> diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/CustomSetterMustExistRule.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/CustomSetterMustExistRule.java new file mode 100644 index 0000000000..fa24662d69 --- /dev/null +++ b/common/src/main/java/org/openecomp/mso/openpojo/rules/CustomSetterMustExistRule.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openpojo.rules; + +import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.anything; +import static org.hamcrest.CoreMatchers.not; + +import org.hamcrest.Matcher; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoField; +import com.openpojo.validation.affirm.Affirm; +import com.openpojo.validation.rule.Rule; + +public class CustomSetterMustExistRule implements Rule { + + private Matcher<PojoField>[] excludeMatchers = new Matcher[]{not(anything())}; + private Matcher<PojoField>[] includeMatchers = new Matcher[]{anything()}; + public CustomSetterMustExistRule() { + } + @Override + public void evaluate(final PojoClass pojoClass) { + for (PojoField fieldEntry : pojoClass.getPojoFields()) { + if (!anyOf(excludeMatchers).matches(fieldEntry) && anyOf(includeMatchers).matches(fieldEntry) && !fieldEntry.isFinal() && !fieldEntry.hasSetter()) { + Affirm.fail(String.format("[%s] is missing a setter", fieldEntry)); + } + } + } + public CustomSetterMustExistRule exclude(Matcher<PojoField>... excludeMatchers) { + this.excludeMatchers = excludeMatchers; + return this; + } + + public CustomSetterMustExistRule include(Matcher<PojoField>... includeMatchers) { + this.includeMatchers = includeMatchers; + return this; + } + +} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/EqualsAndHashCodeTester.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/EqualsAndHashCodeTester.java new file mode 100644 index 0000000000..f4192e6cc8 --- /dev/null +++ b/common/src/main/java/org/openecomp/mso/openpojo/rules/EqualsAndHashCodeTester.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openpojo.rules; + +import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.anything; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.persistence.Id; + +import org.hamcrest.Matcher; + +import com.openpojo.business.annotation.BusinessKey; +import com.openpojo.random.RandomFactory; +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoField; +import com.openpojo.validation.affirm.Affirm; +import com.openpojo.validation.test.Tester; +import com.openpojo.validation.utils.ValidationHelper; + +public class EqualsAndHashCodeTester implements Tester { + + + private final Matcher m; + public EqualsAndHashCodeTester() { + m = anything(); + } + + public EqualsAndHashCodeTester(Matcher m) { + this.m = m; + } + @Override + public void run(PojoClass pojoClass) { + Class<?> clazz = pojoClass.getClazz(); + if (anyOf(m).matches(clazz)) { + final Object classInstanceOne = ValidationHelper.getBasicInstance(pojoClass); + final Object classInstanceTwo = ValidationHelper.getBasicInstance(pojoClass); + Set<PojoField> identityFields = hasIdOrBusinessKey(pojoClass); + List<PojoField> otherFields = new ArrayList<>(pojoClass.getPojoFields()); + otherFields.removeAll(identityFields); + + for (PojoField field : identityFields) { + final Object value = RandomFactory.getRandomValue(field); + + field.invokeSetter(classInstanceOne, value); + field.invokeSetter(classInstanceTwo, value); + } + + for (PojoField field : otherFields) { + if (field.hasSetter()) { + final Object valueOne = RandomFactory.getRandomValue(field); + final Object valueTwo = RandomFactory.getRandomValue(field); + + field.invokeSetter(classInstanceOne, valueOne); + field.invokeSetter(classInstanceTwo, valueTwo); + } + } + + Affirm.affirmTrue("Equals test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.equals(classInstanceTwo)); + + Affirm.affirmTrue("Equals test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.equals( + classInstanceOne)); + + Affirm.affirmTrue("HashCode test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.hashCode() == classInstanceTwo.hashCode()); + + Affirm.affirmFalse("Expected false for comparison of two unlike objects", classInstanceOne.equals("test")); + } + } + + + private Set<PojoField> hasIdOrBusinessKey(PojoClass pojoClass) { + final Set<PojoField> fields = new HashSet<>(); + + fields.addAll(pojoClass.getPojoFieldsAnnotatedWith(BusinessKey.class)); + fields.addAll(pojoClass.getPojoFieldsAnnotatedWith(Id.class)); + + return fields; + + } + +} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationMatcher.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationMatcher.java new file mode 100644 index 0000000000..fdfb9695e7 --- /dev/null +++ b/common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationMatcher.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openpojo.rules; + +import static org.hamcrest.CoreMatchers.anything; + +import java.lang.annotation.Annotation; +import java.lang.reflect.AnnotatedElement; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeDiagnosingMatcher; + +public class HasAnnotationMatcher<T extends Annotation> extends TypeSafeDiagnosingMatcher<AnnotatedElement> { + private final Class<T> annotationType; + private final Matcher<? super T> annotationMatcher; + + public HasAnnotationMatcher(final Class<T> annotationType, final Matcher<? super T> annotationMatcher) { + this.annotationType = annotationType; + this.annotationMatcher = annotationMatcher; + } + + @Override + protected boolean matchesSafely(final AnnotatedElement item, final Description mismatchDescription) { + final T annotation = item.getAnnotation(this.annotationType); + if (annotation == null) { + mismatchDescription.appendText("does not have annotation ").appendText(this.annotationType.getName()); + return false; + } + + if (!this.annotationMatcher.matches(annotation)) { + this.annotationMatcher.describeMismatch(annotation, mismatchDescription); + return false; + } + + return true; + } + + @Override + public void describeTo(final Description description) { + // Intentionally left blank. + } + + public static Matcher<AnnotatedElement> hasAnnotation(final Class<? extends Annotation> annotationType) { + return hasAnnotation(annotationType, anything("")); + } + + public static <T extends Annotation> Matcher<AnnotatedElement> hasAnnotation(final Class<T> annotationType, final Matcher<? super T> annotationMatcher) { + return new HasAnnotationMatcher<T>(annotationType, annotationMatcher); + } +} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java new file mode 100644 index 0000000000..f0c1b18df2 --- /dev/null +++ b/common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openpojo.rules; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeDiagnosingMatcher; + +import com.openpojo.reflection.PojoField; + +public class HasAnnotationPropertyWithValueMatcher<T extends PojoField> extends TypeSafeDiagnosingMatcher<T> { + private final String attribute; + private final Matcher<?> annotationMatcher; + private final Class<? extends Annotation> annotationClass; + public HasAnnotationPropertyWithValueMatcher(Class<? extends Annotation> clazz, String attribute, final Matcher<?> annotationMatcher) { + this.attribute = attribute; + this.annotationMatcher = annotationMatcher; + this.annotationClass = clazz; + } + + @Override + protected boolean matchesSafely(T obj, final Description mismatchDescription) { + final PojoField temp = (PojoField)obj; + final Method method; + try { + Annotation a = temp.getAnnotation(this.annotationClass); + if (a == null) { + mismatchDescription.appendText("does not have annotation ").appendText(this.annotationClass.getSimpleName()); + return false; + } + method = a.getClass().getMethod(attribute); + final Object result = method.invoke(a); + if (!this.annotationMatcher.matches(result)) { + this.annotationMatcher.describeMismatch(result, mismatchDescription); + return false; + } + } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + mismatchDescription.appendText("does not have property ").appendText(attribute); + return false; + } + return true; + } + + @Override + public void describeTo(final Description description) { + // Intentionally left blank. + } + + public static <T extends PojoField> Matcher<T> hasAnnotationPropertyWithValue(Class<? extends Annotation> clazz, String attribute, final Matcher<?> annotationMatcher) { + return new HasAnnotationPropertyWithValueMatcher<T>(clazz, attribute, annotationMatcher); + } +} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/HasEqualsAndHashCodeRule.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/HasEqualsAndHashCodeRule.java new file mode 100644 index 0000000000..4ef560721f --- /dev/null +++ b/common/src/main/java/org/openecomp/mso/openpojo/rules/HasEqualsAndHashCodeRule.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openpojo.rules; + +import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.anything; + +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; + +import org.hamcrest.Matcher; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.validation.affirm.Affirm; +import com.openpojo.validation.rule.Rule; + +/** + * This rule ensures that classes have overriden the default equals and hashCode methods from Object + */ +public class HasEqualsAndHashCodeRule implements Rule { + + private final Matcher m; + public HasEqualsAndHashCodeRule() { + m = anything(); + } + + public HasEqualsAndHashCodeRule(Matcher m) { + this.m = m; + } + @Override + public void evaluate(PojoClass pojoClass) { + Class<?> clazz = pojoClass.getClazz(); + if (anyOf(m).matches(clazz)) { + boolean hasEquals = false; + boolean hasHashCode = false; + final String name = clazz.getSimpleName(); + final Method[] methods; + if (clazz.getSuperclass().equals(Object.class)) { + methods = clazz.getDeclaredMethods(); + } else { + methods = clazz.getMethods(); + } + for (Method method : methods) { + Parameter[] parameters = method.getParameters(); + if ("equals".equals(method.getName()) && boolean.class.equals(method.getReturnType()) && parameters.length == 1 && Object.class.equals(parameters[0].getType())) { + hasEquals = true; + } else if ("hashCode".equals(method.getName()) && int.class.equals(method.getReturnType())) { + hasHashCode = true; + } + } + + if (!hasEquals) { + Affirm.fail(String.format( + "[%s] does not override equals", name)); + } + if (!hasHashCode) { + Affirm.fail(String.format( + "[%s] does not override hashCode", name)); + } + } + } + +} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/HasToStringRule.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/HasToStringRule.java new file mode 100644 index 0000000000..f866650d66 --- /dev/null +++ b/common/src/main/java/org/openecomp/mso/openpojo/rules/HasToStringRule.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openpojo.rules; + +import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.anything; + +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; + +import org.hamcrest.Matcher; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.validation.affirm.Affirm; +import com.openpojo.validation.rule.Rule; + +public class HasToStringRule implements Rule { + + private final Matcher m; + public HasToStringRule() { + m = anything(); + } + + public HasToStringRule(Matcher m) { + this.m = m; + } + @Override + public void evaluate(PojoClass pojoClass) { + Class<?> clazz = pojoClass.getClazz(); + if (anyOf(m).matches(clazz)) { + boolean hasToString = false; + final String name = clazz.getSimpleName(); + final Method[] methods; + if (clazz.getSuperclass().equals(Object.class)) { + methods = clazz.getDeclaredMethods(); + } else { + methods = clazz.getMethods(); + } + for (Method method : methods) { + Parameter[] parameters = method.getParameters(); + if ("toString".equals(method.getName()) && String.class.equals(method.getReturnType()) && parameters.length == 0) { + hasToString = true; + break; + } + } + + if (!hasToString) { + Affirm.fail(String.format( + "[%s] does not override toString", name)); + } + } + } + +} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/ToStringTester.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/ToStringTester.java new file mode 100644 index 0000000000..bd582d45dc --- /dev/null +++ b/common/src/main/java/org/openecomp/mso/openpojo/rules/ToStringTester.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.openpojo.rules; + +import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.anything; + +import org.hamcrest.Matcher; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.validation.affirm.Affirm; +import com.openpojo.validation.test.Tester; +import com.openpojo.validation.utils.ValidationHelper; + +public class ToStringTester implements Tester { + + private final Matcher m; + public ToStringTester() { + m = anything(); + } + + public ToStringTester(Matcher m) { + this.m = m; + } + + @Override + public void run(PojoClass pojoClass) { + Class<?> clazz = pojoClass.getClazz(); + if (anyOf(m).matches(clazz)) { + final Object classInstance = ValidationHelper.getBasicInstance(pojoClass); + + Affirm.affirmFalse("Found default toString output", classInstance.toString().matches(Object.class.getName() + "@" + "\\w+")); + } + + } + +} @@ -436,13 +436,22 @@ <artifactId>resteasy-jackson2-provider</artifactId> <version>${resteasy.version}</version> </dependency> - <dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-core</artifactId> + <version>1.3</version> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <version>1.3</version> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> - <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> @@ -474,12 +483,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> - <version>1.3</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>com.github.tomakehurst</groupId> <artifactId>wiremock</artifactId> <version>1.56</version> @@ -565,12 +568,6 @@ <scope>compile</scope> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-core</artifactId> - <version>1.3</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> |