Fix docker image generation and tagging 62/94362/3
authorJimmy Forsyth <jf2512@att.com>
Tue, 27 Aug 2019 17:31:17 +0000 (13:31 -0400)
committerJimmy Forsyth <jf2512@att.com>
Tue, 27 Aug 2019 18:01:45 +0000 (14:01 -0400)
Issue-ID: AAI-2579
Signed-off-by: Jimmy Forsyth <jf2512@att.com>
Change-Id: I749e22447b48c92cf4f2ee0f991ff39146f7b45d

pom.xml
src/main/assembly/descriptor.xml [new file with mode: 0644]
src/main/docker/Dockerfile
src/test/java/org/onap/crud/event/response/GraphEventResponseHandlerTest.java
version.properties

diff --git a/pom.xml b/pom.xml
index e27155a..a801d4d 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -19,19 +19,19 @@ limitations under the License.
 ============LICENSE_END=========================================================
 -->
 <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">
+         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.oparent</groupId>
         <artifactId>oparent</artifactId>
         <version>2.0.0</version>
-        <relativePath />
+        <relativePath/>
     </parent>
 
     <groupId>org.onap.aai.gizmo</groupId>
     <artifactId>gizmo</artifactId>
-    <version>1.5.1-SNAPSHOT</version>
+    <version>1.5.2-SNAPSHOT</version>
     <name>aai-gizmo</name>
 
     <properties>
@@ -45,6 +45,16 @@ limitations under the License.
          coverage caused by new changes. Note that this figure cannot be lower than the ONAP requirement of 0.55 -->
         <jacoco.line.coverage.limit>0.60</jacoco.line.coverage.limit>
         <jacoco.report.directory>${project.build.directory}/code-coverage</jacoco.report.directory>
+        <!-- docker related properties -->
+        <docker.fabric.version>0.28.0</docker.fabric.version>
+        <aai.docker.version>1.0.0</aai.docker.version>
+        <aai.build.directory>${project.build.directory}/${project.artifactId}-build/
+        </aai.build.directory>
+        <aai.docker.namespace>onap</aai.docker.namespace>
+        <aai.base.image>alpine</aai.base.image>
+        <aai.base.image.version>1.6.0</aai.base.image.version>
+        <!-- This will be used for the docker images as the default format of maven build has issues -->
+        <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
     </properties>
 
     <dependencyManagement>
@@ -116,21 +126,21 @@ limitations under the License.
         </dependency>
 
 
-     <dependency>
-         <groupId>io.swagger</groupId>
-         <artifactId>swagger-jersey2-jaxrs</artifactId>
-         <version>1.5.8</version>
-      </dependency>
-      <dependency>
-         <groupId>io.springfox</groupId>
-         <artifactId>springfox-swagger2</artifactId>
-         <version>2.9.2</version>
-      </dependency>
-            <dependency>
-         <groupId>io.springfox</groupId>
-         <artifactId>springfox-swagger-ui</artifactId>
-         <version>2.9.2</version>
-      </dependency>
+        <dependency>
+            <groupId>io.swagger</groupId>
+            <artifactId>swagger-jersey2-jaxrs</artifactId>
+            <version>1.5.8</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.9.2</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>2.9.2</version>
+        </dependency>
 
 
         <!-- ONAP AAI-COMMON (incl. model) -->
@@ -145,8 +155,8 @@ limitations under the License.
             <version>${version.org.onap.aai.aai-schema-ingest}</version>
             <exclusions>
                 <exclusion>
-                  <groupId>org.powermock</groupId>
-                  <artifactId>*</artifactId>
+                    <groupId>org.powermock</groupId>
+                    <artifactId>*</artifactId>
                 </exclusion>
             </exclusions>
         </dependency>
@@ -165,7 +175,7 @@ limitations under the License.
         <dependency>
             <groupId>org.onap.aai.event-client</groupId>
             <artifactId>event-client-dmaap</artifactId>
-           <version>${event.client.version}</version>
+            <version>${event.client.version}</version>
             <exclusions>
                 <exclusion>
                     <groupId>org.slf4j</groupId>
@@ -176,7 +186,7 @@ limitations under the License.
         <dependency>
             <groupId>org.onap.aai.event-client</groupId>
             <artifactId>event-client-kafka</artifactId>
-           <version>${event.client.version}</version>
+            <version>${event.client.version}</version>
             <exclusions>
                 <exclusion>
                     <groupId>org.slf4j</groupId>
@@ -186,9 +196,9 @@ limitations under the License.
         </dependency>
 
         <dependency>
-           <groupId>org.onap.aai.event-client</groupId>
-           <artifactId>event-client-rabbitmq</artifactId>
-           <version>${event.client.version}</version>
+            <groupId>org.onap.aai.event-client</groupId>
+            <artifactId>event-client-rabbitmq</artifactId>
+            <version>${event.client.version}</version>
             <exclusions>
                 <exclusion>
                     <groupId>org.slf4j</groupId>
@@ -363,96 +373,159 @@ limitations under the License.
         </dependency>
     </dependencies>
 
+    <profiles>
+        <!-- Docker profile to be used for building docker image and pushing to nexus -->
+        <profile>
+            <id>docker</id>
+            <build>
+                <plugins>
+                  <plugin>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>build-helper-maven-plugin</artifactId>
+                    <version>3.0.0</version>
+                    <executions>
+                      <execution>
+                        <phase>pre-clean</phase>
+                        <id>parse-version</id>
+                        <goals>
+                          <goal>parse-version</goal>
+                        </goals>
+                      </execution>
+                    </executions>
+                  </plugin>
+                  <plugin>
+                    <groupId>org.codehaus.groovy.maven</groupId>
+                    <artifactId>gmaven-plugin</artifactId>
+                    <version>1.0</version>
+                    <executions>
+                      <execution>
+                        <phase>pre-clean</phase>
+                        <goals>
+                          <goal>execute</goal>
+                        </goals>
+                        <configuration>
+                          <source>
+                            def userAaiBaseImage = session.userProperties['aai.base.image']
+                            def userAaiCommonVersion = session.userProperties['aai.base.image.version']
+                            if (userAaiCommonVersion != null) {
+                               project.properties['aai.base.image.version'] = userAaiCommonVersion
+                            }
+                            if (userAaiBaseImage != null) {
+                               project.properties['aai.base.image'] = userAaiBaseImage
+                            }
+                            log.info 'Base image flavour: ' + project.properties['aai.base.image']
+                            log.info 'Base image version: ' + project.properties['aai.base.image.version']
+                  </source>
+                </configuration>
+              </execution>
+            </executions>
+            </plugin>
+            <plugin>
+              <groupId>io.fabric8</groupId>
+              <artifactId>docker-maven-plugin</artifactId>
+              <version>${docker.fabric.version}</version>
+              <configuration>
+                <verbose>true</verbose>
+                <apiVersion>1.23</apiVersion>
+                <images>
+                  <image>
+                    <name>${docker.push.registry}/${aai.docker.namespace}/${project.artifactId}:%l
+                    </name>
+                    <build>
+                      <filter>@</filter>
+                      <tags>
+                        <tag>latest</tag>
+                        <tag>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest</tag>
+                        <tag>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-${maven.build.timestamp}</tag>
+                      </tags>
+                      <cleanup>try</cleanup>
+                      <dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>
+                      <assembly>
+                        <inline>
+                          <fileSets>
+                            <fileSet>
+                              <directory>${aai.build.directory}</directory>
+                              <outputDirectory>/${project.artifactId}</outputDirectory>
+                            </fileSet>
+                          </fileSets>
+                        </inline>
+                      </assembly>
+                    </build>
+                  </image>
+                </images>
+              </configuration>
+              <executions>
+                <execution>
+                  <id>clean-images</id>
+                  <phase>pre-clean</phase>
+                  <goals>
+                    <goal>remove</goal>
+                  </goals>
+                  <configuration>
+                    <removeAll>true</removeAll>
+                  </configuration>
+                </execution>
+                <execution>
+                  <id>generate-images</id>
+                  <phase>package</phase>
+                  <goals>
+                    <goal>build</goal>
+                  </goals>
+                </execution>
+                <execution>
+                  <id>push-images</id>
+                  <phase>deploy</phase>
+                  <goals>
+                    <goal>push</goal>
+                  </goals>
+                </execution>
+              </executions>
+            </plugin>
+          </plugins>
+        </build>
+      </profile>
+    </profiles>
+
     <build>
         <finalName>${project.artifactId}</finalName>
-        <plugins>
-            <!--
+        <!--
             Using https://code.revelc.net/formatter-maven-plugin/ for Eclipse formatter
             Using https://github.com/diffplug/spotless/tree/master/plugin-maven for import order
             Use in combination to rewrite code and imports, then checkstyle
 
             mvn formatter:format spotless:apply process-sources
-            -->
-            <plugin>
-                 <groupId>net.revelc.code.formatter</groupId>
-                 <artifactId>formatter-maven-plugin</artifactId>
-                 <version>2.8.1</version>
-                 <configuration>
+        -->
+       <plugins>
+          <plugin>
+                <groupId>net.revelc.code.formatter</groupId>
+                <artifactId>formatter-maven-plugin</artifactId>
+                <version>2.8.1</version>
+                <configuration>
                     <configFile>${project.basedir}/onap-java-formatter.xml</configFile>
-                 </configuration>
-                 <!-- https://code.revelc.net/formatter-maven-plugin/
-                      use mvn formatter:format to rewrite source files
-                      use mvn formatter:validate to validate source files -->
-             </plugin>
-            <plugin>
-              <groupId>com.diffplug.spotless</groupId>
-              <artifactId>spotless-maven-plugin</artifactId>
-              <version>1.18.0</version>
-              <configuration>
-                <java>
-                 <importOrder>
-                   <order>com,java,javax,org</order>
-                 </importOrder>
-                </java>
-              </configuration>
-            <!-- https://github.com/diffplug/spotless/tree/master/plugin-maven
-                 use mvn spotless:apply to rewrite source files
-                 use mvn spotless:check to validate source files -->
-            </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}</directory>
-                                    <filtering>true</filtering>
-                                    <includes>
-                                        <include>bundleconfig-local/**</include>
-                                    </includes>
-                                </resource>
-                                <resource>
-                                    <directory>${basedir}/src/main/bin/</directory>
-                                </resource>
-                            </resources>
-                        </configuration>
-                    </execution>
-                </executions>
+                </configuration>
+                <!-- https://code.revelc.net/formatter-maven-plugin/
+                     use mvn formatter:format to rewrite source files
+                     use mvn formatter:validate to validate source files -->
             </plugin>
-
+           <plugin>
+             <groupId>org.codehaus.groovy.maven</groupId>
+             <artifactId>gmaven-plugin</artifactId>
+           </plugin>
             <plugin>
-                <groupId>com.spotify</groupId>
-                <artifactId>docker-maven-plugin</artifactId>
-                <version>0.4.11</version>
+                <groupId>com.diffplug.spotless</groupId>
+                <artifactId>spotless-maven-plugin</artifactId>
+                <version>1.18.0</version>
                 <configuration>
-                    <verbose>true</verbose>
-                    <serverId>docker-hub</serverId>
-                    <imageName>${docker.push.registry}/onap/${project.artifactId}</imageName>
-                    <dockerDirectory>${docker.location}</dockerDirectory>
-                    <imageTags>
-                        <imageTag>latest</imageTag>
-                    </imageTags>
-                    <forceTags>true</forceTags>
+                    <java>
+                        <importOrder>
+                            <order>com,java,javax,org</order>
+                        </importOrder>
+                    </java>
                 </configuration>
+                <!-- https://github.com/diffplug/spotless/tree/master/plugin-maven
+                     use mvn spotless:apply to rewrite source files
+                     use mvn spotless:check to validate source files -->
             </plugin>
-
             <!-- license plugin -->
             <!-- Uncomment this to add a license header to every source file -->
             <plugin>
@@ -516,6 +589,23 @@ limitations under the License.
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <configuration>
+                    <descriptors>
+                        <descriptor>src/main/assembly/descriptor.xml</descriptor>
+                    </descriptors>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>make-assembly</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-dependency-plugin</artifactId>
@@ -534,7 +624,7 @@ limitations under the License.
                                     <version>${version.org.onap.aai.aai-schema}</version>
                                     <type>jar</type>
                                     <includes>onap/**/</includes>
-                                    <outputDirectory>${project.build.directory}/bundleconfig-local/etc</outputDirectory>
+                                    <outputDirectory>${aai.build.directory}/bundleconfig/etc</outputDirectory>
                                 </artifactItem>
                             </artifactItems>
                         </configuration>
@@ -569,7 +659,8 @@ limitations under the License.
                     </execution>
                 </executions>
             </plugin>
-         </plugins>
+
+       </plugins>
     </build>
 
     <distributionManagement>
diff --git a/src/main/assembly/descriptor.xml b/src/main/assembly/descriptor.xml
new file mode 100644 (file)
index 0000000..e3a83ed
--- /dev/null
@@ -0,0 +1,36 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+  <id>build</id>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <formats>
+    <format>dir</format>
+  </formats>
+  <fileSets>
+    <fileSet>
+      <directory>${project.basedir}/bundleconfig-local</directory>
+      <outputDirectory>/bundleconfig</outputDirectory>
+      <includes>
+       <include>**/*</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>${project.basedir}/src/main/bin</directory>
+      <outputDirectory>/bin</outputDirectory>
+      <includes>
+       <include>**/*</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>${project.build.directory}</directory>
+      <outputDirectory>/</outputDirectory>
+      <includes>
+       <include>*.jar</include>
+      </includes>
+      <excludes>
+       <exclude>Dockerfile</exclude>
+       <exclude>*.sh</exclude>
+      </excludes>
+    </fileSet>
+  </fileSets>
+</assembly>
index b164907..3823a6c 100644 (file)
@@ -1,51 +1,26 @@
-FROM ubuntu:14.04
+FROM @aai.docker.namespace@/aai-common-@aai.base.image@:@aai.base.image.version@
 
 ARG MICRO_HOME=/opt/app/crud-api
 ARG BIN_HOME=$MICRO_HOME/bin
+ARG USERS_HOME=/opt/aaihome
 
-RUN apt-get update
-
-# Install and setup java8
-RUN apt-get update && apt-get install -y software-properties-common
-## sudo -E is required to preserve the environment. If you remove that line, it will most like freeze at this step
-RUN sudo -E add-apt-repository ppa:openjdk-r/ppa && apt-get update && apt-get install -y openjdk-8-jdk
-## Setup JAVA_HOME, this is useful for docker commandline
-ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
-RUN export JAVA_HOME
-
-# Build up the deployment folder structure
-RUN mkdir -p $MICRO_HOME
-RUN mkdir -p $MICRO_HOME/bundleconfig/etc
-COPY gizmo.jar $MICRO_HOME/
-RUN mkdir -p $BIN_HOME
-COPY *.sh $BIN_HOME
-COPY bundleconfig-local $MICRO_HOME/bundleconfig
-COPY bundleconfig-local/etc/logback.xml $MICRO_HOME/bundleconfig/etc
-RUN chmod 755 $BIN_HOME/*
-
-# Changes related to:AAI-2177
-# Change aai gizmo container processes to run as non-root on the host
+# AAI-2177: Change aai gizmo container processes to run as non-root on the host
 
 #Note:The group id and user id used below (492382 & 341790 respectively) are chosen arbitarily based on assumption that
 # these are not used elsewhere. Please see  https://jira.onap.org/browse/AAI-2172 for more background on this.
 
-RUN mkdir /opt/aaihome && \
-     groupadd -g 492382 aaiadmin && \
-     useradd -r -u 341790  -g 492382 -ms /bin/sh -d /opt/aaihome/aaiadmin aaiadmin && \
-     
-      ##The following 2 lines are added to add the user to the sudoers group
-      ##The script src\main\bin\start.sh could then optionally run the process as sudo user if an environment variable is set
-      ## By default the sudo mode is disabled.
-      usermod -aG sudo aaiadmin  &&\
-      echo  'aaiadmin  ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \      
-     chown -R aaiadmin:aaiadmin $MICRO_HOME &&\
-     mkdir /logs && \
-     chown -R aaiadmin:aaiadmin  /logs
+RUN mkdir -p $MICRO_HOME $USERS_HOME /logs \
+    && groupadd -g 492382 aaiadmin \
+    && useradd -r -u 341790  -g 492382 -ms /bin/sh -d $USERS_HOME/aaiadmin aaiadmin
+WORKDIR $MICRO_HOME
+COPY /maven/gizmo/ .
+RUN chmod 755 $BIN_HOME/* \
+    && ln -snf /logs $MICRO_HOME/logs \
+    && chown -R aaiadmin:aaiadmin $MICRO_HOME /logs
 
 USER aaiadmin
 
-RUN ln -s /logs $MICRO_HOME/logs
-
 EXPOSE 9520 9520
 
 CMD ["/opt/app/crud-api/bin/start.sh"]
+
index 5f9194f..6fc390e 100644 (file)
  * ============LICENSE_END=========================================================
  */
 package org.onap.crud.event.response;
-import static org.assertj.core.api.Assertions.assertThat;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonParser;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.crud.OXMModelLoaderSetup;
 import org.onap.crud.event.GraphEvent;
 import org.onap.crud.event.GraphEvent.GraphEventOperation;
 import org.onap.crud.event.envelope.GraphEventEnvelope;
@@ -31,82 +36,79 @@ import org.onap.crud.exception.CrudException;
 import org.onap.crud.util.TestUtil;
 import org.onap.schema.EdgeRulesLoader;
 import org.onap.schema.OxmModelLoader;
-import com.google.gson.Gson;
-import com.google.gson.JsonParser;
 
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.crud.OXMModelLoaderSetup;
+import static org.assertj.core.api.Assertions.assertThat;
 
 @RunWith(MockitoJUnitRunner.Silent.class)
 public class GraphEventResponseHandlerTest extends OXMModelLoaderSetup {
     private static boolean setUpIsNotDone = true;
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
+        @Before
+        public void setUpOnce() throws CrudException {
+            if (setUpIsNotDone) {
+                System.setProperty("CONFIG_HOME", "src/test/resources");
+                System.setProperty("AJSC_HOME", ".");
+                System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
 
-    @Before
-    public void setUpOnce() throws Exception {
-        if (setUpIsNotDone) { 
-            System.setProperty("CONFIG_HOME", "src/test/resources");
-            System.setProperty("AJSC_HOME", ".");
-            System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+                OxmModelLoader.loadModels();
+                EdgeRulesLoader.loadModels();
 
-            OxmModelLoader.loadModels();
-            EdgeRulesLoader.loadModels();
-            setUpIsNotDone = false;
+                setUpIsNotDone = false;
+            }
         }
-    }
 
-    @Test
-    public void testPolicyViolationsNotDetected() throws Exception {
-        String expectedEnvelope = TestUtil.getFileAsString("event/event-envelope-sentinel-no-violations.json");
-        Gson gson = new Gson();
-        GraphEventEnvelope envelope = gson.fromJson(expectedEnvelope, GraphEventEnvelope.class);
+        @Rule
+        public ExpectedException expectedException = ExpectedException.none();
 
-        GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
-        assertThat(graphEventResponseHandler.hasPolicyViolations(envelope)).isFalse();
-    }
+        @Test
+        public void testPolicyViolationsNotDetected() throws Exception {
+            String expectedEnvelope = TestUtil.getFileAsString("event/event-envelope-sentinel-no-violations.json");
+            Gson gson = new Gson();
+            GraphEventEnvelope envelope = gson.fromJson(expectedEnvelope, GraphEventEnvelope.class);
 
-    @Test
-    public void testPolicyViolationsDetected() throws Exception {
-        String expectedEnvelope = TestUtil.getFileAsString("event/event-envelope-sentinel.json");
-        Gson gson = new Gson();
-        GraphEventEnvelope envelope = gson.fromJson(expectedEnvelope, GraphEventEnvelope.class);
+            GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
+            assertThat(graphEventResponseHandler.hasPolicyViolations(envelope)).isFalse();
+        }
 
-        GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
-        assertThat(graphEventResponseHandler.hasPolicyViolations(envelope)).isTrue();
-    }
+        @Test
+        public void testPolicyViolationsDetected() throws Exception {
+            String expectedEnvelope = TestUtil.getFileAsString("event/event-envelope-sentinel.json");
+            Gson gson = new Gson();
+            GraphEventEnvelope envelope = gson.fromJson(expectedEnvelope, GraphEventEnvelope.class);
 
-    @Test
-    public void testHandleVertexResponse() throws Exception {
-        String graphEvent = TestUtil.getFileAsString("event/graph-vertex-event.json");
-        String champResult = TestUtil.getFileAsString("event/champ-vertex-event.json");
-        Gson gson = new Gson();
-        GraphEvent event = gson.fromJson(graphEvent, GraphEvent.class);
-        GraphEventEnvelope result = gson.fromJson(champResult, GraphEventEnvelope.class);
+            GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
+            assertThat(graphEventResponseHandler.hasPolicyViolations(envelope)).isTrue();
+        }
 
-        GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
-        String response = graphEventResponseHandler.handleVertexResponse("v13", event, result);
+        @Test
+        public void testHandleVertexResponse() throws Exception {
+            String graphEvent = TestUtil.getFileAsString("event/graph-vertex-event.json");
+            String champResult = TestUtil.getFileAsString("event/champ-vertex-event.json");
+            Gson gson = new Gson();
+            GraphEvent event = gson.fromJson(graphEvent, GraphEvent.class);
+            GraphEventEnvelope result = gson.fromJson(champResult, GraphEventEnvelope.class);
 
-        assertThat(new JsonParser().parse(response).getAsJsonObject().get("url").getAsString())
+            GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
+            String response = graphEventResponseHandler.handleVertexResponse("v13", event, result);
+
+            assertThat(new JsonParser().parse(response).getAsJsonObject().get("url").getAsString())
                 .isEqualTo("services/inventory/v13/pserver/890c8b3f-892f-48e3-85cd-748ebf0426a5");
-    }
+        }
 
-    @Test
-    public void testHandleVertexResponseWithError() throws Exception {
-        expectedException.expect(CrudException.class);
-        expectedException.expectMessage("test error");
+        @Test
+        public void testHandleVertexResponseWithError() throws Exception {
+            expectedException.expect(CrudException.class);
+            expectedException.expectMessage("test error");
 
-        String graphEvent = TestUtil.getFileAsString("event/graph-vertex-event.json");
-        String champResult = TestUtil.getFileAsString("event/champ-vertex-event-error.json");
-        Gson gson = new Gson();
-        GraphEvent event = gson.fromJson(graphEvent, GraphEvent.class);
-        GraphEventEnvelope result = gson.fromJson(champResult, GraphEventEnvelope.class);
+            String graphEvent = TestUtil.getFileAsString("event/graph-vertex-event.json");
+            String champResult = TestUtil.getFileAsString("event/champ-vertex-event-error.json");
+            Gson gson = new Gson();
+            GraphEvent event = gson.fromJson(graphEvent, GraphEvent.class);
+            GraphEventEnvelope result = gson.fromJson(champResult, GraphEventEnvelope.class);
 
-        GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
-        graphEventResponseHandler.handleVertexResponse("v13", event, result);
-    }
+            GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
+            graphEventResponseHandler.handleVertexResponse("v13", event, result);
+        }
 
     @Test(expected = CrudException.class)
     public void testHandleVertexResponseWithViolations() throws Exception {
@@ -121,33 +123,33 @@ public class GraphEventResponseHandlerTest extends OXMModelLoaderSetup {
         graphEventResponseHandler.handleVertexResponse("v13", event, result);
     }
 
-    @Test
-    public void testHandleEdgeResponse() throws Exception {
-        String graphEvent = TestUtil.getFileAsString("event/graph-edge-event.json");
-        String champResult = TestUtil.getFileAsString("event/champ-edge-event.json");
-        Gson gson = new Gson();
-        GraphEvent event = gson.fromJson(graphEvent, GraphEvent.class);
-        GraphEventEnvelope result = gson.fromJson(champResult, GraphEventEnvelope.class);
+        @Test
+        public void testHandleEdgeResponse() throws Exception {
+            String graphEvent = TestUtil.getFileAsString("event/graph-edge-event.json");
+            String champResult = TestUtil.getFileAsString("event/champ-edge-event.json");
+            Gson gson = new Gson();
+            GraphEvent event = gson.fromJson(graphEvent, GraphEvent.class);
+            GraphEventEnvelope result = gson.fromJson(champResult, GraphEventEnvelope.class);
 
-        GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
-        String response = graphEventResponseHandler.handleEdgeResponse("v10", event, result);
+            GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
+            String response = graphEventResponseHandler.handleEdgeResponse("v10", event, result);
 
-        String id = new JsonParser().parse(response).getAsJsonObject().get("id").getAsString();
-        assertThat(id).isEqualTo("test-key");
-    }
+            String id = new JsonParser().parse(response).getAsJsonObject().get("id").getAsString();
+            assertThat(id).isEqualTo("test-key");
+        }
 
-    @Test
-    public void testHandleDeletionResponse() throws Exception {
-        GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
-        GraphEvent event = GraphEvent.builder(GraphEventOperation.DELETE).build();
-        String response = graphEventResponseHandler.handleDeletionResponse(event, new GraphEventEnvelope(event));
-        assertThat(response).isEqualTo("");
-    }
+        @Test
+        public void testHandleDeletionResponse() throws Exception {
+            GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
+            GraphEvent event = GraphEvent.builder(GraphEventOperation.DELETE).build();
+            String response = graphEventResponseHandler.handleDeletionResponse(event, new GraphEventEnvelope(event));
+            assertThat(response).isEqualTo("");
+        }
 
-    @Test
-    public void testHandleBulkEventResponse() throws Exception {
-        GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
-        GraphEvent event = GraphEvent.builder(GraphEventOperation.CREATE).build();
-        graphEventResponseHandler.handleBulkEventResponse(event, new GraphEventEnvelope(event));
-    }
+        @Test
+        public void testHandleBulkEventResponse() throws Exception {
+            GraphEventResponseHandler graphEventResponseHandler = new GraphEventResponseHandler();
+            GraphEvent event = GraphEvent.builder(GraphEventOperation.CREATE).build();
+            graphEventResponseHandler.handleBulkEventResponse(event, new GraphEventEnvelope(event));
+        }
 }
index f78f30b..45a2df9 100644 (file)
@@ -4,7 +4,7 @@
 
 major=1
 minor=5
-patch=1
+patch=2
 
 base_version=${major}.${minor}.${patch}