### Question:
FactManager implements LifecycleAspect { public FactEntity saveFact(FactEntity fact) { if (fact == null) return null; if (getFactType(fact.getTypeID()) == null) throw new IllegalArgumentException(String.format("FactType with id = %s does not exist.", fact.getTypeID())); if (getFact(fact.getId()) != null) throw new ImmutableViolationException("It is not allowed to update a Fact"); factDao.save(fact); return fact; } @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(expected = IllegalArgumentException.class) public void testSaveFactWithNonExistingFactType() { getFactManager().saveFact(createFact()); }
@Test(expected = ImmutableViolationException.class) public void testSaveFactTwiceThrowsException() { FactEntity entity = createFact(createAndSaveFactType().getId()); getFactManager().saveFact(entity); getFactManager().saveFact(entity); }
@Test public void testSaveFactReturnsSameEntity() { FactEntity entity = createFact(createAndSaveFactType().getId()); assertSame(entity, getFactManager().saveFact(entity)); }
@Test public void testSaveFactReturnsNullOnNullInput() { assertNull(getFactManager().saveFact(null)); }