ListServicesCommand extends OsgiCommandSupport { @VisibleForTesting void setOut(PrintStream out) { this.out = checkNotNull(out, "out is null"); } ListServicesCommand(List<Provisionr> services);   }
@Test public void testListServices() throws Exception { List<Provisionr> services = ImmutableList.of( newProvisionrMockWithId("p1"), newProvisionrMockWithId("p2") ); ListServicesCommand command = new ListServicesCommand(services); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(outputStream); command.setOut(out); CommandSession session = mock(CommandSession.class); command.execute(session); out.close(); for (Provisionr service : services) { verify(service).getId(); } assertThat(outputStream.toString()).isEqualTo("Services: p1, p2\n"); }