### Question:
ObjectTypeByIdResponseResolver implements Function<UUID, ObjectType> { @Override public ObjectType apply(UUID id) { if (id == null) return null; return responseCache.computeIfAbsent(id, this::resolveUncached); } @Inject  ObjectTypeByIdResponseResolver(ObjectManager objectManager,
                                        ObjectTypeResponseConverter objectTypeResponseConverter,
                                        Map<UUID, ObjectType> responseCache); @Override ObjectType apply(UUID id);  }### Answer:
@Test public void testConvertCachedObjectType() { UUID id = UUID.randomUUID(); ObjectType model = ObjectType.builder().build(); responseCache.put(id, model); assertSame(model, converter.apply(id)); verifyNoInteractions(objectManager); verifyNoInteractions(objectTypeResponseConverter); }
@Test public void testConvertUncachedObjectType() { UUID id = UUID.randomUUID(); ObjectTypeEntity entity = new ObjectTypeEntity(); ObjectType model = ObjectType.builder().build(); when(objectManager.getObjectType(id)).thenReturn(entity); when(objectTypeResponseConverter.apply(entity)).thenReturn(model); assertSame(model, converter.apply(id)); verify(objectManager).getObjectType(id); verify(objectTypeResponseConverter).apply(entity); }
@Test public void testConvertUncachedObjectTypeNotAvailable() { UUID id = UUID.randomUUID(); ObjectType model = converter.apply(id); assertNotNull(model); assertEquals(id, model.getId()); assertEquals("N/A", model.getName()); verify(objectManager).getObjectType(id); verifyNoInteractions(objectTypeResponseConverter); }
@Test public void testConvertNullReturnsNull() { assertNull(converter.apply(null)); }