new CoordinateBounds(5, 5, 7, 7), new CoordinateBounds(6, 6, 8, 8)));
secondProviderAgenciesAndCoverage.put("b2",
Arrays.asList(new CoordinateBounds(5, 2, 7, 4)));
providers.put(serviceB, secondProviderAgenciesAndCoverage);
FederatedServiceCollection registry = new FederatedServiceCollectionImpl(
providers);
Set<FederatedService> services = registry.getAllServices();
assertEquals(2, services.size());
assertTrue(services.contains(serviceA));
assertTrue(services.contains(serviceB));
assertEquals(serviceA, registry.getServiceForAgencyId("a1"));
assertEquals(serviceA, registry.getServiceForAgencyId("a2"));
assertEquals(serviceB, registry.getServiceForAgencyId("b1"));
assertEquals(serviceB, registry.getServiceForAgencyId("b2"));
try {
registry.getServiceForAgencyId("dne");
fail();
} catch (NoSuchAgencyServiceException ex) {
}
Set<String> agencyIds = new HashSet<String>();
agencyIds.add("a1");
assertEquals(serviceA, registry.getServiceForAgencyIds(agencyIds));
agencyIds.clear();
agencyIds.add("a1");
agencyIds.add("a2");
assertEquals(serviceA, registry.getServiceForAgencyIds(agencyIds));
agencyIds.clear();
agencyIds.add("b1");
agencyIds.add("b2");
assertEquals(serviceB, registry.getServiceForAgencyIds(agencyIds));
agencyIds.clear();
agencyIds.add("a1");
agencyIds.add("b2");
try {
registry.getServiceForAgencyIds(agencyIds);
fail();
} catch (MultipleServiceAreasServiceException ex) {
}
assertEquals(serviceA, registry.getServiceForBounds(1, 1, 4.5, 4.5));
assertEquals(serviceA, registry.getServiceForBounds(1, 1, 4.5, 9));
assertEquals(serviceB, registry.getServiceForBounds(5, 5, 5.5, 5.5));
assertEquals(serviceB, registry.getServiceForBounds(5.5, 1, 7.5, 3));
try {
registry.getServiceForBounds(2, 2, 6, 6);
fail();
} catch (MultipleServiceAreasServiceException ex) {
}
assertEquals(serviceA, registry.getServiceForLocation(1.5, 1.5));
assertEquals(serviceA, registry.getServiceForLocation(3, 5.5));
assertEquals(serviceB, registry.getServiceForLocation(5.5, 5.5));
assertEquals(serviceB, registry.getServiceForLocation(5.5, 3));
try {
registry.getServiceForLocation(0, 0);
fail();
} catch (OutOfServiceAreaServiceException ex) {
}