use of org.wso2.carbon.apimgt.core.models.Endpoint in project carbon-apimgt by wso2.
the class ApiDAOImplIT method testAddDeleteGetEndpoint.
@Test
public void testAddDeleteGetEndpoint() throws Exception {
ApiDAO apiDAO = DAOFactory.getApiDAO();
Endpoint endpoint = SampleTestObjectCreator.createMockEndpoint();
apiDAO.addEndpoint(endpoint);
apiDAO.deleteEndpoint(endpoint.getId());
Endpoint retrieved = apiDAO.getEndpoint(endpoint.getId());
Assert.assertNull(retrieved);
}
use of org.wso2.carbon.apimgt.core.models.Endpoint in project carbon-apimgt by wso2.
the class ApiDAOImplIT method testGetEndpointByName.
@Test(description = "Test getting endpoint by name")
public void testGetEndpointByName() throws Exception {
ApiDAO apiDAO = DAOFactory.getApiDAO();
Endpoint endpoint = SampleTestObjectCreator.createMockEndpoint();
apiDAO.addEndpoint(endpoint);
Endpoint retrieved = apiDAO.getEndpointByName(endpoint.getName());
Assert.assertEquals(endpoint, retrieved, TestUtil.printDiff(endpoint, retrieved));
}
use of org.wso2.carbon.apimgt.core.models.Endpoint in project carbon-apimgt by wso2.
the class ApiDAOImplIT method testAddUpdateGetEndpoint.
@Test
public void testAddUpdateGetEndpoint() throws Exception {
ApiDAO apiDAO = DAOFactory.getApiDAO();
apiDAO.addEndpoint(SampleTestObjectCreator.createMockEndpoint());
Endpoint updatedEndpoint = SampleTestObjectCreator.createUpdatedEndpoint();
apiDAO.updateEndpoint(updatedEndpoint);
Endpoint retrieved = apiDAO.getEndpoint(updatedEndpoint.getId());
Assert.assertEquals(updatedEndpoint, retrieved);
}
use of org.wso2.carbon.apimgt.core.models.Endpoint in project carbon-apimgt by wso2.
the class ApiDAOImplIT method testAddApiAndResourceSpecificEndpointToApi.
@Test
public void testAddApiAndResourceSpecificEndpointToApi() throws APIMgtDAOException {
Endpoint apiSpecificEndpoint = new Endpoint.Builder(SampleTestObjectCreator.createMockEndpoint()).applicableLevel(APIMgtConstants.API_SPECIFIC_ENDPOINT).build();
Endpoint urlSpecificEndpoint = new Endpoint.Builder(SampleTestObjectCreator.createMockEndpoint()).id(UUID.randomUUID().toString()).applicableLevel(APIMgtConstants.API_SPECIFIC_ENDPOINT).name("URI1").build();
Endpoint endpointToInsert = SampleTestObjectCreator.createAlternativeEndpoint();
Endpoint globalEndpoint = new Endpoint.Builder().applicableLevel(APIMgtConstants.GLOBAL_ENDPOINT).id(endpointToInsert.getId()).build();
Map<String, Endpoint> apiEndpointMap = new HashMap();
apiEndpointMap.put(APIMgtConstants.PRODUCTION_ENDPOINT, apiSpecificEndpoint);
apiEndpointMap.put(APIMgtConstants.SANDBOX_ENDPOINT, globalEndpoint);
Map<String, Endpoint> uriTemplateEndpointMap = new HashMap();
uriTemplateEndpointMap.put(APIMgtConstants.PRODUCTION_ENDPOINT, urlSpecificEndpoint);
Map<String, UriTemplate> uriTemplateMap = SampleTestObjectCreator.getMockUriTemplates();
uriTemplateMap.forEach((k, v) -> {
UriTemplate uriTemplate = new UriTemplate.UriTemplateBuilder(v).endpoint(uriTemplateEndpointMap).build();
uriTemplateMap.replace(k, uriTemplate);
});
ApiDAO apiDAO = DAOFactory.getApiDAO();
API api = SampleTestObjectCreator.createDefaultAPI().apiDefinition(SampleTestObjectCreator.apiDefinition).endpoint(apiEndpointMap).uriTemplates(uriTemplateMap).build();
apiDAO.addEndpoint(endpointToInsert);
apiDAO.addAPI(api);
Map<String, Endpoint> retrievedApiEndpoint = apiDAO.getAPI(api.getId()).getEndpoint();
Assert.assertTrue(apiDAO.isEndpointAssociated(globalEndpoint.getId()));
Assert.assertEquals(apiEndpointMap, retrievedApiEndpoint);
apiDAO.deleteAPI(api.getId());
Endpoint retrievedGlobal = apiDAO.getEndpoint(globalEndpoint.getId());
Assert.assertNotNull(retrievedGlobal);
Assert.assertEquals(endpointToInsert, retrievedGlobal);
}
use of org.wso2.carbon.apimgt.core.models.Endpoint in project carbon-apimgt by wso2.
the class ApiDAOImplIT method testAddGetAllEndPointsAndUUIDs.
@Test
public void testAddGetAllEndPointsAndUUIDs() throws Exception {
ApiDAO apiDAO = DAOFactory.getApiDAO();
Endpoint endpoint1 = SampleTestObjectCreator.createMockEndpoint();
Endpoint endpoint2 = SampleTestObjectCreator.createAlternativeEndpoint();
Endpoint apiSpecificEndpoint = new Endpoint.Builder(SampleTestObjectCreator.createAlternativeEndpoint()).name("APISpecific").applicableLevel(APIMgtConstants.API_SPECIFIC_ENDPOINT).id(UUID.randomUUID().toString()).build();
apiDAO.addEndpoint(endpoint1);
apiDAO.addEndpoint(endpoint2);
apiDAO.addEndpoint(apiSpecificEndpoint);
List<Endpoint> endpointListAdd = new ArrayList<>();
endpointListAdd.add(endpoint1);
endpointListAdd.add(endpoint2);
List<Endpoint> endpointList = apiDAO.getEndpoints();
// verifying global endpoints
List<String> globalEndpointUuidList = apiDAO.getUUIDsOfGlobalEndpoints();
Assert.assertEquals(globalEndpointUuidList.size(), 2);
Assert.assertTrue(globalEndpointUuidList.contains(endpoint1.getId()));
Assert.assertTrue(globalEndpointUuidList.contains(endpoint2.getId()));
// verifying all endpoints
Assert.assertNotEquals(3, endpointList.size());
APIUtils.isListsEqualIgnoreOrder(endpointListAdd, endpointList, new EndPointComparator());
}
Aggregations