### Question:
InstanceIdentifierCodec extends AbstractModuleStringInstanceIdentifierCodec implements EffectiveModelContextListener { @Override protected String prefixForNamespace(final URI namespace) { return context.findModules(namespace).stream().map(Module::getName).findFirst().orElse(null); } InstanceIdentifierCodec(DOMSchemaService schemaService,
            BindingNormalizedNodeSerializer bindingNormalizedNodeSerializer); @Override void onModelContextUpdated(EffectiveModelContext schemaContext); String serialize(InstanceIdentifier<?> iid); YangInstanceIdentifier getYangInstanceIdentifier(InstanceIdentifier<?> iid); InstanceIdentifier<?> bindingDeserializer(String iidString); InstanceIdentifier<?> bindingDeserializer(YangInstanceIdentifier yangIID); InstanceIdentifier<?> bindingDeserializerOrNull(String iidString);  }### Answer:
@Test public void testPrefixForNamespace() throws URISyntaxException { Module module = mock(Module.class); final String prefix = "prefix"; when(module.getName()).thenReturn(prefix); URI namespace = new URI("foo"); when(context.findModules(namespace)).thenReturn(Collections.emptySet()); assertNull(instanceIdCodec.prefixForNamespace(namespace)); doReturn(ImmutableSet.of(module)).when(context).findModules(namespace); assertEquals("Found prefix", prefix, instanceIdCodec.prefixForNamespace(namespace)); doReturn(ImmutableSet.of(module, mock(Module.class))).when(context).findModules(namespace); assertEquals("Found prefix", prefix, instanceIdCodec.prefixForNamespace(namespace)); }