EC2Discovery implements InstanceDiscovery { @Override public Collection<Instance> getInstanceList() throws Exception { return new ClusterList(this.config).get() .parallelStream() .map(cluster -> new InstanceList( cluster, this.config, this.provider ).get() ).flatMap(List::stream) .collect(Collectors.toList()); } EC2Discovery();  EC2Discovery(final Config config, final EC2ClientProvider provider); @Override Collection<Instance> getInstanceList();  }
@Test public void returnsEmptyList() throws Exception { Assertions.assertThat( new EC2Discovery(this.config, this.provider).getInstanceList() ).hasSize(0); }
@Test public void returnsInstances() throws Exception { Mockito.when(this.result.getReservations()).thenReturn( Arrays.asList( this.fakeReservation(), this.fakeReservation(), this.fakeReservation() ) ); Assertions.assertThat( new EC2Discovery(this.config, this.provider).getInstanceList() ).hasSize(3); }