use of org.wso2.carbon.apimgt.core.models.DocumentInfo in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method testApisApiIdDocumentsDocumentIdContentGetInline.
@Test
public void testApisApiIdDocumentsDocumentIdContentGetInline() throws Exception {
String inlineContent = "INLINE CONTENT";
printTestMethodName();
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
APIPublisher apiPublisher = Mockito.mock(APIPublisherImpl.class);
PowerMockito.mockStatic(RestAPIPublisherUtil.class);
PowerMockito.when(RestAPIPublisherUtil.getApiPublisher(USER)).thenReturn(apiPublisher);
String api1Id = UUID.randomUUID().toString();
String documentId = UUID.randomUUID().toString();
DocumentInfo documentInfo = SampleTestObjectCreator.createDefaultDocumentationInfo().build();
DocumentContent documentContent = DocumentContent.newDocumentContent().inlineContent(inlineContent).documentInfo(documentInfo).build();
Mockito.doReturn(documentContent).doThrow(new IllegalArgumentException()).when(apiPublisher).getDocumentationContent(documentId);
Response response = apisApiService.apisApiIdDocumentsDocumentIdContentGet(api1Id, documentId, null, null, getRequest());
assertEquals(response.getStatus(), 200);
assertEquals(inlineContent, response.getEntity().toString());
}
use of org.wso2.carbon.apimgt.core.models.DocumentInfo in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method testApisApiIdDocumentsDocumentIdPutNotFound.
@Test
public void testApisApiIdDocumentsDocumentIdPutNotFound() throws Exception {
printTestMethodName();
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
APIPublisher apiPublisher = Mockito.mock(APIPublisherImpl.class);
DocumentInfo documentInfo = SampleTestObjectCreator.createDefaultDocumentationInfo().build();
DocumentDTO documentDTO = MappingUtil.toDocumentDTO(documentInfo);
PowerMockito.mockStatic(RestAPIPublisherUtil.class);
PowerMockito.when(RestAPIPublisherUtil.getApiPublisher(USER)).thenReturn(apiPublisher);
String documentId = UUID.randomUUID().toString();
String apiId = UUID.randomUUID().toString();
Mockito.doReturn(null).doThrow(new IllegalArgumentException()).when(apiPublisher).getDocumentationSummary(documentId);
Response response = apisApiService.apisApiIdDocumentsDocumentIdPut(apiId, documentId, documentDTO, null, null, getRequest());
assertEquals(response.getStatus(), 404);
assertTrue(response.getEntity().toString().contains("Error while getting document"));
}
Aggregations