Additional junit tests for artifact generation
[aai/babel.git] / src / test / java / org / onap / aai / babel / service / TestGenerateArtifactsServiceImpl.java
index b5063dd..c770c60 100644 (file)
@@ -48,7 +48,7 @@ import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 /**
- * Direct invocation of the generate artifacts service implementation
+ * Direct invocation of the generate artifacts service implementation.
  *
  */
 @RunWith(SpringJUnit4ClassRunner.class)
@@ -63,6 +63,7 @@ public class TestGenerateArtifactsServiceImpl {
     }
 
     private static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
+
     @Inject
     private AAIMicroServiceAuth auth;
 
@@ -72,6 +73,13 @@ public class TestGenerateArtifactsServiceImpl {
                 new ArtifactTestUtils().getResourcePath(ARTIFACT_GENERATOR_CONFIG));
     }
 
+    @Test
+    public void testGenerateArtifacts() throws Exception {
+        Response response = processJsonRequest("success_request_vnf_catalog.json");
+        assertThat(response.getStatus(), is(Response.Status.OK.getStatusCode()));
+        assertThat(response.getEntity(), is(getResponseJson("response.json")));
+    }
+
     @Test
     public void testInvalidCsarFile() throws URISyntaxException, IOException {
         Response response = processJsonRequest("invalid_csar_request.json");
@@ -108,12 +116,12 @@ public class TestGenerateArtifactsServiceImpl {
     }
 
     /**
-     * Create a (mocked) HTTPS request and invoke the Babel generate artifacts API
+     * Create a (mocked) HTTPS request and invoke the Babel generate artifacts API.
      *
      * @param resource path to the incoming JSON request
      * @return the Response from the HTTP API
-     * @throws URISyntaxException
-     * @throws IOException
+     * @throws URISyntaxException if the URI cannot be created
+     * @throws IOException if the resource cannot be loaded
      */
     private Response processJsonRequest(String resource) throws URISyntaxException, IOException {
         UriInfo mockUriInfo = Mockito.mock(UriInfo.class);
@@ -156,6 +164,10 @@ public class TestGenerateArtifactsServiceImpl {
         return new ArtifactTestUtils().getRequestJson(resource);
     }
 
+    private String getResponseJson(String jsonResponse) throws IOException, URISyntaxException {
+        return new ArtifactTestUtils().getResponseJson(jsonResponse);
+    }
+
     private List<String> createSingletonList(String listItem) {
         return Collections.<String>singletonList(listItem);
     }