### Question:
CDIBeanService { public <T> T getCDIBean(final Class<T> clazz) { BeanManager manager = getBeanManager(); if (manager != null) { Bean<T> bean = (Bean<T>) manager.getBeans(clazz).iterator().next(); CreationalContext<T> ctx = manager.createCreationalContext(bean); return (T) manager.getReference(bean, clazz, ctx); } else { try { return clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { LOGGER.warning("Could not create instance of class <" + clazz + ">."); } return null; } } private  CDIBeanService(); static CDIBeanService getInstance(); T getCDIBean(final Class<T> clazz); T getCDIBeanByName(final String name, Class<T> clazz); void injectManual(Object obj);  }### Answer:
@Test public void getCDIBean() throws Exception { final CDIBeanService cut = CDIBeanService.getInstance(); final CDITestBean cdiTestBean = cut.getCDIBean(CDITestBean.class); final CDITestBean cdiTestBean2 = cut.getCDIBean(CDITestBean.class); assertThat(cdiTestBean, notNullValue()); assertThat(cdiTestBean == cdiTestBean2, is(true)); assertThat(cdiTestBean.getName(), is("I am a singleton bean")); assertThat(cdiTestBean.getCdiTestInjected(), notNullValue()); assertThat(cdiTestBean.getCdiTestInjected().getLabel(), is("I am a manuel injected bean")); }