Search in sources :

Example 16 with DocumentContent

use of org.wso2.carbon.apimgt.core.models.DocumentContent 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());
}
Also used : WorkflowResponse(org.wso2.carbon.apimgt.core.api.WorkflowResponse) GeneralWorkflowResponse(org.wso2.carbon.apimgt.core.workflow.GeneralWorkflowResponse) Response(javax.ws.rs.core.Response) DocumentContent(org.wso2.carbon.apimgt.core.models.DocumentContent) 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

DocumentContent (org.wso2.carbon.apimgt.core.models.DocumentContent)16 DocumentInfo (org.wso2.carbon.apimgt.core.models.DocumentInfo)16 API (org.wso2.carbon.apimgt.core.models.API)9 Endpoint (org.wso2.carbon.apimgt.core.models.Endpoint)9 APIPublisher (org.wso2.carbon.apimgt.core.api.APIPublisher)7 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)7 APIDetails (org.wso2.carbon.apimgt.core.models.APIDetails)7 HashMap (java.util.HashMap)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Test (org.testng.annotations.Test)4 InputStream (java.io.InputStream)3 Response (javax.ws.rs.core.Response)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)3 IOException (java.io.IOException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 Map (java.util.Map)2