+ /**
+ * Test for a valid request with invalid CSAR file content.
+ *
+ * @throws URISyntaxException
+ * if the URI cannot be created
+ * @throws IOException
+ * if the resource cannot be loaded
+ */
+ @Test
+ public void testGenerateArtifactsInvalidCsar() throws IOException, URISyntaxException {
+ Response response = processJsonRequest(CsarTest.MULTIPLE_VNF_CSAR, auth);
+ assertThat(response.getStatus(), is(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()));
+ assertThat(response.getEntity().toString(), containsString("VNF catalog"));
+ }
+
+ @Test
+ public void testUninitializedService() throws IOException, URISyntaxException, AAIAuthException {
+ AAIMicroServiceAuth uninitializedAuth = Mockito.mock(AAIMicroServiceAuth.class);
+ Mockito.when(uninitializedAuth.validateRequest(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
+ .thenThrow(new AAIAuthException("test"));
+ Response response = processJsonRequest(CsarTest.NO_VNF_CONFIG_CSAR, uninitializedAuth);
+ assertThat(response.getStatus(), is(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()));
+ assertThat(response.getEntity().toString(), containsString("check the Babel service logs"));
+ }
+
+ @Test
+ public void testUnauthorizedRequest() throws IOException, URISyntaxException, AAIAuthException {
+ AAIMicroServiceAuth uninitializedAuth = Mockito.mock(AAIMicroServiceAuth.class);
+ Mockito.when(uninitializedAuth.validateRequest(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
+ .thenReturn(false);
+ Response response = processJsonRequest(CsarTest.NO_VNF_CONFIG_CSAR, uninitializedAuth);
+ assertThat(response.getStatus(), is(Response.Status.UNAUTHORIZED.getStatusCode()));
+ assertThat(response.getEntity().toString(), containsString("User not authorized"));
+ }
+