use of org.wso2.carbon.apimgt.rest.api.admin.NotFoundException in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method apisApiIdSdksLanguageGetNullApiId.
@Test
public void apisApiIdSdksLanguageGetNullApiId() throws APIManagementException, ApiStoreSdkGenerationException, NotFoundException {
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
Request request = getRequest();
Response response = apisApiService.apisApiIdSdksLanguageGet(null, correctLanguage, request);
Assert.assertEquals(400, response.getStatus());
}
use of org.wso2.carbon.apimgt.rest.api.admin.NotFoundException in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method apisApiIdSdksLanguageGetIncorrectLanguage.
@Test
public void apisApiIdSdksLanguageGetIncorrectLanguage() throws APIManagementException, ApiStoreSdkGenerationException, NotFoundException {
String apiId = UUID.randomUUID().toString();
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
Request request = getRequest();
Response response = apisApiService.apisApiIdSdksLanguageGet(apiId, incorrectLanguage, request);
Assert.assertEquals(400, response.getStatus());
}
use of org.wso2.carbon.apimgt.rest.api.admin.NotFoundException in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method testApisApiIdDocumentsDocumentIdGet.
@Test
public void testApisApiIdDocumentsDocumentIdGet() throws APIManagementException, NotFoundException {
printTestMethodName();
String apiId = UUID.randomUUID().toString();
String documentId = UUID.randomUUID().toString();
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
APIStore apiStore = Mockito.mock(APIStoreImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getConsumer(USER)).thenReturn(apiStore);
Request request = getRequest();
PowerMockito.when(RestApiUtil.getLoggedInUsername(request)).thenReturn(USER);
DocumentInfo documentInfoFile = TestUtil.createAPIDoc(documentId, "documentInfo", "", "API1 documentation file", DocumentInfo.DocType.HOWTO, "other type", DocumentInfo.SourceType.FILE, "", DocumentInfo.Visibility.PRIVATE);
Mockito.when(apiStore.getDocumentationSummary(documentId)).thenReturn(documentInfoFile);
Response response = apisApiService.apisApiIdDocumentsDocumentIdGet(apiId, documentId, null, null, request);
Assert.assertEquals(200, response.getStatus());
}
use of org.wso2.carbon.apimgt.rest.api.admin.NotFoundException in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method testApisGet.
@Test
public void testApisGet() throws APIManagementException, NotFoundException {
printTestMethodName();
String apiId = UUID.randomUUID().toString();
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
APIStore apiStore = Mockito.mock(APIStoreImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getConsumer(USER)).thenReturn(apiStore);
Request request = getRequest();
PowerMockito.when(RestApiUtil.getLoggedInUsername(request)).thenReturn(USER);
Endpoint api1SandBoxEndpointId = new Endpoint.Builder().id(UUID.randomUUID().toString()).applicableLevel(APIMgtConstants.API_SPECIFIC_ENDPOINT).name("abcd").build();
Endpoint api1ProdEndpointId = new Endpoint.Builder().id(UUID.randomUUID().toString()).applicableLevel(APIMgtConstants.API_SPECIFIC_ENDPOINT).name("cdef").build();
API api = TestUtil.createApi("provider1", apiId, "testapi1", "1.0.0", "Test API 1 - version 1.0.0", TestUtil.createEndpointTypeToIdMap(api1SandBoxEndpointId, api1ProdEndpointId)).build();
List<API> apiList = new ArrayList<>();
apiList.add(api);
Mockito.when(apiStore.searchAPIsByStoreLabels("", 0, 1, new ArrayList<>())).thenReturn(apiList);
Response response = apisApiService.apisGet(10, 0, "", null, null, request);
Assert.assertEquals(200, response.getStatus());
}
use of org.wso2.carbon.apimgt.rest.api.admin.NotFoundException in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method testApisApiIdCommentsCommentIdDeleteIfMatchStringExistingFingerprintCheck.
@Test
public void testApisApiIdCommentsCommentIdDeleteIfMatchStringExistingFingerprintCheck() throws APIManagementException, NotFoundException {
printTestMethodName();
String apiId = UUID.randomUUID().toString();
String commentId = UUID.randomUUID().toString();
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
APIStore apiStore = Mockito.mock(APIStoreImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getConsumer(USER)).thenReturn(apiStore);
Request request = getRequest();
PowerMockito.when(RestApiUtil.getLoggedInUsername(request)).thenReturn(USER);
String existingFingerprint = "existingFingerprint";
Mockito.when(apisApiService.apisApiIdCommentsCommentIdDeleteFingerprint(commentId, apiId, "test", "test", request)).thenReturn(existingFingerprint);
Mockito.doNothing().doThrow(new IllegalArgumentException()).when(apiStore).deleteComment(commentId, apiId, USER);
Response response = apisApiService.apisApiIdCommentsCommentIdDelete(commentId, apiId, "test", "test", request);
assertEquals(response.getStatus(), 412);
}
Aggregations