CdiUtils { @SuppressWarnings("unchecked") public <T> T newBean(Class<T> clazz) { return newBean(beanManager, clazz); }  @SuppressWarnings("unchecked") T newBean(Class<T> clazz); static T newBean(BeanManager bm, Class<T> clazz); static void addAnnotatedTypes(BeforeBeanDiscovery beforeBean, BeanManager bm, Class<?>... types); static List<T> getApplicationBeans(Class<T> type, Annotation... qualifiers); static Optional<T> getApplicationBean(Class<T> type, Annotation... qualifiers); static BeanManager getApplicationBeanManager();  }
@Test public void testNewBean() throws Exception { CdiUtils utils = new CdiUtils(); Field bmField = utils.getClass().getDeclaredField("beanManager"); bmField.setAccessible(true); BeanManager bm = EasyMock.createMock(BeanManager.class); bmField.set(utils, bm); expect(bm.getBeans(CdiUtilsTest.class)).andReturn(null); expect(bm.resolve(null)).andReturn(null); expect(bm.createCreationalContext(null)).andReturn(null); expect(bm.getReference(null, CdiUtilsTest.class, null)).andReturn(null); replay(bm); assertNull(utils.newBean(CdiUtilsTest.class)); verify(bm); }