SuspendablesProvider { public List<Suspendable> getSuspendables() { return beanManager.getBeans(Suspendable.class).stream() .map(Bean::getBeanClass) .map(this::getInstance) .collect(toList()); }  List<Suspendable> getSuspendables();  }
@Test public void shouldFindAllInstancesOfShutteringExecutorInCDI() throws Exception { final Bean<Suspendable_1> shutteringExecutorBean_1 = of(Suspendable_1.class); final Bean<Suspendable_2> shutteringExecutorBean_2 = of(Suspendable_2.class); final Bean<Suspendable_3> shutteringExecutorBean_3 = of(Suspendable_3.class); final Suspendable_1 shutteringExecutor_1 = new Suspendable_1(); final Suspendable_2 shutteringExecutor_2 = new Suspendable_2(); final Suspendable_3 shutteringExecutor_3 = new Suspendable_3(); final Set<Bean<?>> beans = newHashSet( shutteringExecutorBean_1, shutteringExecutorBean_2, shutteringExecutorBean_3); when(beanManager.getBeans(Suspendable.class)).thenReturn(beans); when(cdiInstanceResolver.getInstanceOf(Suspendable_1.class, beanManager)).thenReturn(shutteringExecutor_1); when(cdiInstanceResolver.getInstanceOf(Suspendable_2.class, beanManager)).thenReturn(shutteringExecutor_2); when(cdiInstanceResolver.getInstanceOf(Suspendable_3.class, beanManager)).thenReturn(shutteringExecutor_3); final List<Suspendable> suspendables = suspendablesProvider.getSuspendables(); assertThat(suspendables.size(), is(3)); assertThat(suspendables, hasItem(shutteringExecutor_1)); assertThat(suspendables, hasItem(shutteringExecutor_2)); assertThat(suspendables, hasItem(shutteringExecutor_3)); }