Fix sonar issues
[aai/babel.git] / src / test / java / org / onap / aai / babel / service / TestGenerateArtifactsServiceImpl.java
index d011ba6..a76b296 100644 (file)
@@ -41,8 +41,10 @@ import javax.ws.rs.core.MultivaluedHashMap;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 import org.mockito.Mockito;
 import org.onap.aai.auth.AAIAuthException;
 import org.onap.aai.auth.AAIMicroServiceAuth;
@@ -103,6 +105,56 @@ public class TestGenerateArtifactsServiceImpl {
         assertThat(response.toString(), response.getStatus(), is(Response.Status.OK.getStatusCode()));
         assertThat(response.getEntity(), is(getResponseJson("response.json")));
     }
+    
+    /**
+     * Test with a valid request without Minor Artifact version.
+     *
+     * @throws URISyntaxException
+     *             if the URI cannot be created
+     * @throws IOException
+     *             if the resource cannot be loaded
+     */
+    @Test
+    public void testGenerateArtifactsWithoutMinorArtifactVersion() throws URISyntaxException, IOException {
+        Response response = invokeService(CsarTest.VNF_VENDOR_CSAR.getJsonRequestWithArtifactVersion("1"),
+                       Optional.of("transaction-id"), auth);
+        assertThat(response.toString(), response.getStatus(), is(Response.Status.OK.getStatusCode()));
+        assertThat(response.getEntity(), is(getResponseJson("response.json")));
+    }
+    
+    /**
+     * Test with a valid request without Minor Artifact version.
+     *
+     * @throws URISyntaxException
+     *             if the URI cannot be created
+     * @throws IOException
+     *             if the resource cannot be loaded
+     */
+    @Test
+    public void testGenerateArtifactsWithInvalidArtifactVersion() throws URISyntaxException, IOException {
+        Response response = invokeService(CsarTest.VNF_VENDOR_CSAR.getJsonRequestWithArtifactVersion("a"),
+                       Optional.of("transaction-id"), auth);
+        assertThat(response.toString(), response.getStatus(), is(Response.Status.OK.getStatusCode()));
+        assertThat(response.getEntity(), is(getResponseJson("response.json")));
+    }
+    
+    
+    /**
+     * Test with a valid request with Artifact version less than 1.
+     *
+     * @throws URISyntaxException
+     *             if the URI cannot be created
+     * @throws IOException
+     *             if the resource cannot be loaded
+     */
+    @Test
+    public void testGenerateArtifactsWithArtifactVerLessThan1() throws URISyntaxException, IOException {
+        Response response = invokeService(CsarTest.VNF_VENDOR_CSAR.getJsonRequestWithArtifactVersion("0.1"),
+                       Optional.of("transaction-id"), auth);
+        assertThat(response.toString(), response.getStatus(), is(Response.Status.OK.getStatusCode()));
+        assertThat(response.getEntity(), is(getResponseJson("responseWithVersionLessThan1.json")));
+    }
+
 
     /**
      * Test with a valid request, using a CSAR file that has no VNF configuration present.