use of org.nhind.config.Address in project nhin-d by DirectProject.
the class RoutingResolverImplTest method testResolverWithConfigService.
/**
* Test the resolver with a configuration service backing.
*
* @throws Exception
*/
public void testResolverWithConfigService() throws Exception {
startService();
Address[] addrs = new Address[3];
List<String> smtpEndpoints = Arrays.asList("smtp@nologs.org");
List<String> xdEndpoints = Arrays.asList("xd@nologs.org");
List<String> emptyEndpoints = Arrays.asList("empty@nologs.org");
List<String> endpoints = new ArrayList<String>();
endpoints.addAll(smtpEndpoints);
endpoints.addAll(xdEndpoints);
endpoints.addAll(emptyEndpoints);
// SMTP
addrs[0] = new Address();
addrs[0].setEmailAddress(smtpEndpoints.get(0));
addrs[0].setDisplayName("displayName");
addrs[0].setType("SMTP");
addrs[0].setStatus(EntityStatus.ENABLED);
// XD
addrs[1] = new Address();
addrs[1].setEmailAddress(xdEndpoints.get(0));
addrs[1].setDisplayName("displayName");
addrs[1].setType("XD");
addrs[1].setEndpoint("xd_endpoint");
addrs[1].setStatus(EntityStatus.ENABLED);
// EMPTY
addrs[2] = new Address();
addrs[2].setEmailAddress(emptyEndpoints.get(0));
addrs[2].setDisplayName("displayName");
addrs[2].setStatus(EntityStatus.ENABLED);
Domain d = new Domain();
d.setDomainName("domainName");
d.setAddress(addrs);
proxy.addDomain(d);
RoutingResolver resolver = new RoutingResolverImpl(configServiceURL);
Collection<String> smtpResolved = resolver.getSmtpEndpoints(endpoints);
assertEquals("List does not match expected size", 2, smtpResolved.size());
assertEquals("List does not contain expected element", (new ArrayList<String>(smtpResolved)).get(0), smtpEndpoints.get(0));
assertEquals("List does not contain expected element", (new ArrayList<String>(emptyEndpoints)).get(0), emptyEndpoints.get(0));
Collection<String> xdResolved = resolver.getXdEndpoints(endpoints);
assertEquals("List does not match expected size", 1, xdResolved.size());
assertEquals("List does not contain expected element", (new ArrayList<String>(xdResolved)).get(0), xdEndpoints.get(0));
assertEquals("List does not match expected size", 1, xdResolved.size());
assertEquals("List does not contain expected element", (new ArrayList<String>(xdResolved)).get(0), xdEndpoints.get(0));
String endpoint = resolver.resolve(xdEndpoints.get(0));
assertEquals("Output does not match expected", addrs[1].getEndpoint(), endpoint);
stopService();
}
Aggregations