SyslogHosts implements Hosts { @Override public Set<Domain> domains(final User user) throws IOException { return this.hosts.domains(user); } SyslogHosts(final Hosts hsts); @Override void close(); @Override Host find(final String domain); @Override Set<Domain> domains(final User user);  }
@Test public void returnsUnderlyingDomains() throws Exception { final Hosts hosts = Mockito.mock(Hosts.class); final Domain first = new DomainMocker().mock(); final Domain second = new DomainMocker().mock(); final Set<Domain> domains = new HashSet<Domain>(); domains.addAll(Arrays.asList(new Domain[]{first, second})); final User user = new UserMocker().mock(); Mockito.doReturn(domains).when(hosts).domains(user); @SuppressWarnings("resource") final SyslogHosts syslog = new SyslogHosts(hosts); MatcherAssert.assertThat( syslog.domains(user), Matchers.containsInAnyOrder(first, second) ); }