use of org.wso2.carbon.governance.api.exception.GovernanceException in project carbon-apimgt by wso2.
the class APIMapperTestCase method testPublisherAPIInfoToAPI.
@Test
public void testPublisherAPIInfoToAPI() throws GovernanceException, APIManagementException {
PublisherAPIInfo infoapi = new PublisherAPIInfo();
infoapi.setApiName("TestAPI");
infoapi.setVersion("1.0");
infoapi.setType("API");
infoapi.setStatus("PUBLISHED");
infoapi.setProviderName("admin");
infoapi.setDescription("Test API description");
API mappedAPI = APIMapper.INSTANCE.toApi(infoapi);
Assert.assertEquals("Mapped api name does not match", mappedAPI.getId().getName(), infoapi.getApiName());
Assert.assertEquals("Mapped api version does not match", mappedAPI.getId().getVersion(), infoapi.getVersion());
Assert.assertEquals("Mapped api state does not match", mappedAPI.getStatus(), infoapi.getStatus());
Assert.assertEquals("Mapped api description does not match", mappedAPI.getDescription(), infoapi.getDescription());
}
use of org.wso2.carbon.governance.api.exception.GovernanceException in project carbon-apimgt by wso2.
the class APIMapperTestCase method testDevPortalAPIInfoToAPI.
@Test
public void testDevPortalAPIInfoToAPI() throws GovernanceException, APIManagementException {
DevPortalAPIInfo infoapi = new DevPortalAPIInfo();
infoapi.setApiName("TestAPI");
infoapi.setVersion("1.0");
infoapi.setType("API");
infoapi.setStatus("PUBLISHED");
infoapi.setProviderName("admin");
infoapi.setDescription("Test API description");
API mappedAPI = APIMapper.INSTANCE.toApi(infoapi);
Assert.assertEquals("Mapped api name does not match", mappedAPI.getId().getName(), infoapi.getApiName());
Assert.assertEquals("Mapped api version does not match", mappedAPI.getId().getVersion(), infoapi.getVersion());
Assert.assertEquals("Mapped api state does not match", mappedAPI.getStatus(), infoapi.getStatus());
Assert.assertEquals("Mapped api description does not match", mappedAPI.getDescription(), infoapi.getDescription());
}
use of org.wso2.carbon.governance.api.exception.GovernanceException in project carbon-apimgt by wso2.
the class APIMapperTestCase method testAPItoPublisherApiAndBack.
@Test
public void testAPItoPublisherApiAndBack() throws GovernanceException, APIManagementException {
PublisherAPI pubAPI = APIMapper.INSTANCE.toPublisherApi(api);
Assert.assertEquals("API name does not match", api.getId().getName(), pubAPI.getApiName());
Assert.assertEquals("API uuid does not match", api.getUuid(), pubAPI.getId());
Assert.assertTrue("Mapped api does not have status", pubAPI.toString().contains(api.getStatus()));
API mappedAPI = APIMapper.INSTANCE.toApi(pubAPI);
Assert.assertEquals("Mapped api name does not match", mappedAPI.getId().getName(), api.getId().getName());
}
use of org.wso2.carbon.governance.api.exception.GovernanceException in project carbon-apimgt by wso2.
the class APIMapperTestCase method testAPIProductToPublisherAPIProductAndBack.
@Test
public void testAPIProductToPublisherAPIProductAndBack() throws GovernanceException, APIManagementException {
PublisherAPIProduct pubAPI = APIProductMapper.INSTANCE.toPublisherApiProduct(product);
Assert.assertEquals("API product uuid does not match", product.getUuid(), pubAPI.getId());
Assert.assertEquals("API product type does not match", product.getType(), pubAPI.getType());
APIProduct mappedProduct = APIProductMapper.INSTANCE.toApiProduct(pubAPI);
Assert.assertEquals("Mapped product uuid does not match", mappedProduct.getUuid(), product.getUuid());
}
use of org.wso2.carbon.governance.api.exception.GovernanceException in project carbon-apimgt by wso2.
the class APIProviderImplTest method testAddAPINameWithIllegalCharacters.
@Test
public void testAddAPINameWithIllegalCharacters() throws APIManagementException, GovernanceException {
APIIdentifier apiId = new APIIdentifier("admin", "API2&", "1.0.2");
API api = new API(apiId);
api.setContext("/test");
api.setStatus(APIConstants.CREATED);
APIProviderImplWrapper apiProvider = new APIProviderImplWrapper(apimgtDAO, scopesDAO);
Mockito.when(artifactManager.newGovernanceArtifact(any(QName.class))).thenReturn(artifact);
Mockito.when(APIUtil.createAPIArtifactContent(artifact, api)).thenReturn(artifact);
try {
apiProvider.addAPI(api);
Assert.fail("Exception was expected, but wasn't thrown");
} catch (APIManagementException e) {
Assert.assertTrue(e.getMessage().contains("API Name contains one or more illegal characters"));
}
}
Aggregations