### Question:
FactManager implements LifecycleAspect { public FactTypeEntity getFactType(UUID id) { if (id == null) return null; try { return factTypeByIdCache.get(id); } catch (ExecutionException ignored) { return null; } } @Inject  FactManager(ClusterManager clusterManager); @Override void startComponent(); @Override void stopComponent(); FactTypeEntity getFactType(UUID id); FactTypeEntity getFactType(String name); List<FactTypeEntity> fetchFactTypes(); FactTypeEntity saveFactType(FactTypeEntity type); FactEntity getFact(UUID id); Iterator<FactEntity> getFacts(List<UUID> id); FactEntity saveFact(FactEntity fact); FactEntity refreshFact(UUID id); FactEntity retractFact(UUID id); List<FactAclEntity> fetchFactAcl(UUID id); FactAclEntity saveFactAclEntry(FactAclEntity entry); List<FactCommentEntity> fetchFactComments(UUID id); FactCommentEntity saveFactComment(FactCommentEntity comment); List<MetaFactBindingEntity> fetchMetaFactBindings(UUID id); MetaFactBindingEntity saveMetaFactBinding(MetaFactBindingEntity binding);  }### Answer:
@Test public void testSaveAndGetFactTypeById() { FactTypeEntity entity = createAndSaveFactType(); assertFactType(entity, getFactManager().getFactType(entity.getId())); }
@Test public void testGetFactTypeWithUnknownIdReturnsNull() { assertNull(getFactManager().getFactType((UUID) null)); assertNull(getFactManager().getFactType(UUID.randomUUID())); }
@Test public void testGetFactTypeByIdTwiceReturnsSameInstance() { FactTypeEntity entity = createAndSaveFactType(); FactTypeEntity type1 = getFactManager().getFactType(entity.getId()); FactTypeEntity type2 = getFactManager().getFactType(entity.getId()); assertSame(type1, type2); }
@Test public void testSaveAndGetFactTypeByName() { FactTypeEntity entity = createAndSaveFactType(); assertFactType(entity, getFactManager().getFactType(entity.getName())); }
@Test public void testGetFactTypeWithUnknownNameReturnsNull() { assertNull(getFactManager().getFactType((String) null)); assertNull(getFactManager().getFactType("")); assertNull(getFactManager().getFactType("Unknown")); }
@Test public void testGetFactTypeByNameTwiceReturnsSameInstance() { FactTypeEntity entity = createAndSaveFactType(); FactTypeEntity type1 = getFactManager().getFactType(entity.getName()); FactTypeEntity type2 = getFactManager().getFactType(entity.getName()); assertSame(type1, type2); }