use of org.wso2.carbon.apimgt.core.util.EndPointComparator 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());
}
use of org.wso2.carbon.apimgt.core.util.EndPointComparator in project carbon-apimgt by wso2.
the class EndpointComparatorTestCase method testEndpointComparison.
@Test
public void testEndpointComparison() {
EndPointComparator endPointComparator = new EndPointComparator();
String testUUID = UUID.randomUUID().toString();
Endpoint ep1 = new Endpoint.Builder().endpointConfig("{'type':'http','url':'http://localhost:8280'}").id(testUUID).maxTps(1000L).security("{'enabled':false}").name("Endpoint1").applicableLevel(APIMgtConstants.GLOBAL_ENDPOINT).type("http").build();
Endpoint ep2 = new Endpoint.Builder().endpointConfig("{'type':'http','url':'http://localhost:8280'}").id(testUUID).maxTps(1000L).security("{'enabled':false}").name("Endpoint1").applicableLevel(APIMgtConstants.GLOBAL_ENDPOINT).type("http").build();
Endpoint ep3 = new Endpoint.Builder().endpointConfig("{'type':'http','url':'http://localhost:8280'}").id(UUID.randomUUID().toString()).maxTps(2000L).security("{'enabled':true}").name("Endpoint1").applicableLevel(APIMgtConstants.GLOBAL_ENDPOINT).type("http").build();
Endpoint ep4 = new Endpoint.Builder().endpointConfig("{'type':'http','url':'http://localhost:8280'}").id(UUID.randomUUID().toString()).maxTps(1000L).security("{'enabled':false}").name("Endpoint1").applicableLevel(APIMgtConstants.GLOBAL_ENDPOINT).type("http").build();
Endpoint ep5 = new Endpoint.Builder().endpointConfig("{'type':'http','url':'http://localhost:6060'}").id(UUID.randomUUID().toString()).maxTps(1000L).security("{'enabled':false}").name("Endpoint1").applicableLevel(APIMgtConstants.GLOBAL_ENDPOINT).type("http").build();
int endpointComparison1 = endPointComparator.compare(ep1, ep2);
int endpointComparison2 = endPointComparator.compare(ep2, ep3);
int endpointComparison3 = endPointComparator.compare(ep1, ep4);
int endpointComparison4 = endPointComparator.compare(ep1, ep5);
Assert.assertEquals(endpointComparison1, 0, "Endpoints are not equal. ");
Assert.assertNotEquals(endpointComparison2, 0, "Endpoints are equal. ");
Assert.assertEquals(endpointComparison3, 0, "Endpoints are not equal. ");
Assert.assertNotEquals(endpointComparison4, 0, "Endpoints are equal. ");
}
Aggregations