### Question:
SubjectByIdResponseResolver implements Function<UUID, Subject> { @Override public Subject apply(UUID id) { if (id == null) return null; return responseCache.computeIfAbsent(id, this::resolveUncached); } @Inject  SubjectByIdResponseResolver(SubjectResolver subjectResolver, Map<UUID, Subject> responseCache); @Override Subject apply(UUID id);  }### Answer:
@Test public void testConvertCachedSubject() { UUID id = UUID.randomUUID(); Subject model = Subject.builder().build(); responseCache.put(id, model); assertSame(model, converter.apply(id)); verifyNoInteractions(subjectResolver); }
@Test public void testConvertUncachedSubject() { UUID id = UUID.randomUUID(); Subject model = Subject.builder().build(); when(subjectResolver.resolveSubject(id)).thenReturn(model); assertSame(model, converter.apply(id)); verify(subjectResolver).resolveSubject(id); }
@Test public void testConvertUncachedSubjectNotAvailable() { UUID id = UUID.randomUUID(); Subject model = converter.apply(id); assertNotNull(model); assertEquals(id, model.getId()); assertEquals("N/A", model.getName()); verify(subjectResolver).resolveSubject(id); }
@Test public void testConvertNullReturnsNull() { assertNull(converter.apply(null)); }