ServiceData { public Endpoint getEndpoint(final String name) { synchronized (syncObject) { for (final String epName : endpoints.keySet()) { if (epName.equals(name)) { return endpoints.get(name); } } } return null; } ServiceData();   ServiceData(final List<Endpoint> endpointList); Endpoint getEndpoint(final String name); boolean addEndpoint(final Endpoint endpoint); boolean removeEndpoint(final Endpoint endpoint);  }
@Test public void testCreation() { final Endpoint ep1 = new Endpoint("foo", "bar", 1); final Endpoint ep2 = new Endpoint("bar", "baz", 1); final ServiceData data = new ServiceData(Arrays.asList(ep1, ep2)); assertThat(data.getEndpoint("foo"), is(equalTo(ep1))); assertThat(data.getEndpoint("bar"), is(equalTo(ep2))); assertThat(data.getEndpoint("baz"), is(nullValue())); }