### Question:
InjectionClassLoader extends ClassLoader { public Map<String, Class<?>> defineClasses(Map<String, byte[]> typeDefinitions) throws ClassNotFoundException { if (sealed) { throw new IllegalStateException("Cannot inject classes into a sealed class loader"); } return doDefineClasses(typeDefinitions); } protected  InjectionClassLoader(ClassLoader parent, boolean sealed); boolean isSealed(); Class<?> defineClass(String name, byte[] binaryRepresentation); Map<String, Class<?>> defineClasses(Map<String, byte[]> typeDefinitions);  }### Answer:
@Test @SuppressWarnings("unchecked") public void testInjection() throws Exception { InjectionClassLoader classLoader = mock(InjectionClassLoader.class); TypeDescription typeDescription = mock(TypeDescription.class); byte[] binaryRepresentation = new byte[0]; when(typeDescription.getName()).thenReturn(FOO); when(classLoader.defineClasses(Collections.singletonMap(FOO, binaryRepresentation))) .thenReturn((Map) Collections.singletonMap(FOO, Object.class)); assertThat(InjectionClassLoader.Strategy.INSTANCE.load(classLoader, Collections.singletonMap(typeDescription, binaryRepresentation)), is(Collections.<TypeDescription, Class<?>>singletonMap(typeDescription, Object.class))); verify(classLoader).defineClasses(Collections.singletonMap(FOO, binaryRepresentation)); verifyNoMoreInteractions(classLoader); }
@Test(expected = IllegalStateException.class) public void testInjectionException() throws Exception { InjectionClassLoader classLoader = mock(InjectionClassLoader.class); TypeDescription typeDescription = mock(TypeDescription.class); byte[] binaryRepresentation = new byte[0]; when(typeDescription.getName()).thenReturn(FOO); when(classLoader.defineClasses(Collections.singletonMap(FOO, binaryRepresentation))).thenThrow(new ClassNotFoundException(FOO)); InjectionClassLoader.Strategy.INSTANCE.load(classLoader, Collections.singletonMap(typeDescription, binaryRepresentation)); }