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)
}
private static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
+
@Inject
private AAIMicroServiceAuth auth;
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");
}
/**
- * 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);
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);
}