### Question:
Injector { public <T> T inject(final T object) { notNull(object); if (!Context.isContextSet()) { throw new WroRuntimeException("No Context Set"); } if (!injectedObjects.containsKey(computeKey(object))) { injectedObjects.put(computeKey(object), true); processInjectAnnotation(object); } return object; } Injector(final Map<Class<?>, Object> map); T inject(final T object);  }### Answer:
@Test(expected = WroRuntimeException.class) public void cannotInjectUnsupportedAndUnitializedType() { initializeValidInjector(); final Object inner = new Object() { @Inject private Object object; }; victim.inject(inner); }
@Test public void shouldBeThreadSafe() throws Exception { initializeValidInjector(); WroTestUtils.runConcurrently(new ContextPropagatingCallable<Void>(new Callable<Void>() { public Void call() throws Exception { victim.inject(new GroupsProcessor()); return null; } })); }
@Test public void shouldInjectSupportedType() throws Exception { initializeValidInjector(); final Callable<?> inner = new Callable<Void>() { @Inject private LifecycleCallbackRegistry object; public Void call() throws Exception { Assert.assertNotNull(object); return null; } }; victim.inject(inner); inner.call(); }
@Test public void shouldInjectContext() throws Exception { final Callable<?> inner = new Callable<Void>() { @Inject private ReadOnlyContext object; public Void call() throws Exception { assertNotNull(object); return null; } }; victim.inject(inner); inner.call(); }
@Test public void shouldInjectWroConfiguration() throws Exception { final Callable<?> inner = new Callable<Void>() { @Inject private WroConfiguration object; public Void call() throws Exception { Assert.assertNotNull(object); return null; } }; victim.inject(inner); inner.call(); }
@Test public void shouldInjectDecoratedProcessor() { final TestProcessor testProcessor = new TestProcessor(); final ResourcePreProcessor processor = CopyrightKeeperProcessorDecorator.decorate(testProcessor); final Injector injector = InjectorBuilder.create(new BaseWroManagerFactory()).build(); injector.inject(processor); assertNotNull(testProcessor.context); }
@Test(expected = WroRuntimeException.class) public void shouldNotInjectUnsupportedAndInitializedTypes() { final String initialValue = "initial"; final Callable<?> object = new Callable<Void>() { @Inject String unsupportedInitializedType = initialValue; public Void call() throws Exception { assertEquals(initialValue, unsupportedInitializedType); return null; } }; victim.inject(object); }
@Test(expected = WroRuntimeException.class) public void cannotInjectUnsupportedInnerObject() throws Exception { final Callable<?> outer = new Callable<Void>() { @Inject private final Callable<?> inner = new Callable<Void>() { @Inject UriLocatorFactory locatorFactory; public Void call() throws Exception { Assert.assertNotNull(locatorFactory); return null; } }; public Void call() throws Exception { inner.call(); return null; } }; victim.inject(outer); outer.call(); }
@Test(expected = WroRuntimeException.class) public void cannotInjectOutsideOfContext() { Context.unset(); victim.inject(new TestProcessor()); }