use of org.wso2.carbon.apimgt.api.model.APIPublisher in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testGetThumbnailImage.
@Test(description = "Get thumbnail image for API")
public void testGetThumbnailImage() throws APIManagementException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO);
API api = SampleTestObjectCreator.createDefaultAPI().build();
String uuid = api.getId();
Mockito.when(apiDAO.getImage(uuid)).thenReturn(null);
apiPublisher.getThumbnailImage(uuid);
Mockito.verify(apiDAO, Mockito.times(1)).getImage(uuid);
}
use of org.wso2.carbon.apimgt.api.model.APIPublisher in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testUploadDocumentationFile.
@Test(description = "Upload Documentation File")
public void testUploadDocumentationFile() throws APIManagementException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO);
apiPublisher.uploadDocumentationFile(DOC_ID, null, "text/plain");
Mockito.verify(apiDAO, Mockito.times(1)).addDocumentFileContent(DOC_ID, null, "text/plain", USER);
}
use of org.wso2.carbon.apimgt.api.model.APIPublisher in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testUpdateDocumentationInfoJsonParseException.
@Test(description = "Parse exception when updating documentation info", expectedExceptions = APIManagementException.class)
public void testUpdateDocumentationInfoJsonParseException() throws APIManagementException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
DocumentInfo documentInfo = new DocumentInfo.Builder().fileName("sample_doc.pdf").name("howto_guide").id("").permission("data").build();
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO);
apiPublisher.updateDocumentation(API_ID, documentInfo);
}
use of org.wso2.carbon.apimgt.api.model.APIPublisher in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testUpdateEndpoint.
@Test(description = "Update endpoint")
public void testUpdateEndpoint() throws APIManagementException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
GatewaySourceGenerator gatewaySourceGenerator = Mockito.mock(GatewaySourceGenerator.class);
APIGateway gateway = Mockito.mock(APIGateway.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiDAO, gatewaySourceGenerator, gateway);
Endpoint endpoint = new Endpoint.Builder(SampleTestObjectCreator.createMockEndpoint()).build();
Mockito.when(apiDAO.updateEndpoint(endpoint)).thenReturn(true);
apiPublisher.updateEndpoint(endpoint);
Mockito.verify(apiDAO, Mockito.times(1)).updateEndpoint(endpoint);
// Error path
Mockito.when(apiDAO.updateEndpoint(endpoint)).thenThrow(APIMgtDAOException.class);
try {
apiPublisher.updateEndpoint(endpoint);
} catch (APIManagementException e) {
Assert.assertEquals(e.getMessage(), "Failed to update Endpoint : " + endpoint.getName());
}
}
use of org.wso2.carbon.apimgt.api.model.APIPublisher in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testRemovePendingLifecycleWorkflowTaskForAPI.
@Test(description = "Remove api pending lc status change request")
public void testRemovePendingLifecycleWorkflowTaskForAPI() throws APIManagementException, LifecycleException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
WorkflowDAO workflowDAO = Mockito.mock(WorkflowDAO.class);
APILifecycleManager apiLifecycleManager = Mockito.mock(APILifecycleManager.class);
APIGateway gateway = Mockito.mock(APIGateway.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiLifecycleManager, apiDAO, workflowDAO, gateway);
APIBuilder builder = SampleTestObjectCreator.createDefaultAPI();
builder.workflowStatus(APILCWorkflowStatus.PENDING.toString());
API api = builder.build();
String uuid = api.getId();
String externalRef = UUID.randomUUID().toString();
Mockito.when(apiDAO.getAPI(uuid)).thenReturn(api);
Mockito.when(workflowDAO.getExternalWorkflowReferenceForPendingTask(uuid, WorkflowConstants.WF_TYPE_AM_API_STATE)).thenReturn(Optional.of(externalRef));
apiPublisher.removePendingLifecycleWorkflowTaskForAPI(uuid);
Mockito.verify(apiDAO, Mockito.times(1)).updateAPIWorkflowStatus(uuid, APILCWorkflowStatus.APPROVED);
Mockito.verify(workflowDAO, Mockito.times(1)).getExternalWorkflowReferenceForPendingTask(uuid, WorkflowConstants.WF_TYPE_AM_API_STATE);
}
Aggregations