Search in sources :

Example 16 with DocumentDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.dto.DocumentDTO 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"));
}
Also used : WorkflowResponse(org.wso2.carbon.apimgt.core.api.WorkflowResponse) GeneralWorkflowResponse(org.wso2.carbon.apimgt.core.workflow.GeneralWorkflowResponse) Response(javax.ws.rs.core.Response) DocumentDTO(org.wso2.carbon.apimgt.rest.api.publisher.dto.DocumentDTO) APIPublisher(org.wso2.carbon.apimgt.core.api.APIPublisher) DocumentInfo(org.wso2.carbon.apimgt.core.models.DocumentInfo) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

DocumentInfo (org.wso2.carbon.apimgt.core.models.DocumentInfo)13 DocumentDTO (org.wso2.carbon.apimgt.rest.api.publisher.dto.DocumentDTO)12 APIPublisher (org.wso2.carbon.apimgt.core.api.APIPublisher)11 Response (javax.ws.rs.core.Response)9 Test (org.junit.Test)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)9 GeneralWorkflowResponse (org.wso2.carbon.apimgt.core.workflow.GeneralWorkflowResponse)9 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)5 HashMap (java.util.HashMap)3 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)3 DocumentDTO (org.wso2.carbon.apimgt.rest.api.store.dto.DocumentDTO)3 Test (org.testng.annotations.Test)1 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)1 DocumentListDTO (org.wso2.carbon.apimgt.rest.api.store.dto.DocumentListDTO)1