### Question:
ObjectFactDaoFacade implements ObjectFactDao { @Override public FactAclEntryRecord storeFactAclEntry(FactRecord fact, FactAclEntryRecord aclEntry) { if (fact == null || aclEntry == null) return null; saveAclEntry(fact, aclEntry); reindexFact(fact.getId()); return aclEntry; } @Inject  ObjectFactDaoFacade(ObjectManager objectManager,
                             FactManager factManager,
                             FactSearchManager factSearchManager,
                             ObjectRecordConverter objectRecordConverter,
                             FactRecordConverter factRecordConverter,
                             FactAclEntryRecordConverter factAclEntryRecordConverter,
                             FactCommentRecordConverter factCommentRecordConverter,
                             Consumer<FactRecord> dcReplicationConsumer); @Override ObjectRecord getObject(UUID id); @Override ObjectRecord getObject(String type, String value); @Override ObjectRecord storeObject(ObjectRecord record); @Override ObjectStatisticsContainer calculateObjectStatistics(ObjectStatisticsCriteria criteria); @Override ResultContainer<ObjectRecord> searchObjects(FactSearchCriteria criteria); @Override FactRecord getFact(UUID id); @Override FactRecord storeFact(FactRecord record); @Override FactRecord refreshFact(FactRecord record); @Override FactRecord retractFact(FactRecord record); @Override ResultContainer<FactRecord> retrieveExistingFacts(FactRecord record); @Override ResultContainer<FactRecord> searchFacts(FactSearchCriteria criteria); @Override FactAclEntryRecord storeFactAclEntry(FactRecord fact, FactAclEntryRecord aclEntry); @Override FactCommentRecord storeFactComment(FactRecord fact, FactCommentRecord comment);  }### Answer:
@Test public void testStoreFactAclEntryWithNull() { assertNull(dao.storeFactAclEntry(new FactRecord(), null)); assertNull(dao.storeFactAclEntry(null, new FactAclEntryRecord())); }
@Test public void testStoreFactAclEntrySavesEntity() { FactRecord fact = new FactRecord().setId(UUID.randomUUID()); FactAclEntryRecord entry = new FactAclEntryRecord().setId(UUID.randomUUID()); when(factAclEntryRecordConverter.toEntity(entry, fact.getId())).thenReturn(new FactAclEntity()); assertSame(entry, dao.storeFactAclEntry(fact, entry)); verify(factManager).saveFactAclEntry(notNull()); verify(factAclEntryRecordConverter).toEntity(argThat(r -> r.getId() == entry.getId()), eq(fact.getId())); }
@Test public void testStoreFactAclEntrySetsId() { FactRecord fact = new FactRecord().setId(UUID.randomUUID()); FactAclEntryRecord entry = new FactAclEntryRecord(); when(factAclEntryRecordConverter.toEntity(entry, fact.getId())).thenReturn(new FactAclEntity()); assertSame(entry, dao.storeFactAclEntry(fact, entry)); verify(factManager).saveFactAclEntry(notNull()); verify(factAclEntryRecordConverter).toEntity(argThat(r -> r.getId() != null), eq(fact.getId())); }
@Test public void testStoreFactAclEntryReindexFact() { FactRecord fact = new FactRecord().setId(UUID.randomUUID()); mockReindexingOfFact(fact); dao.storeFactAclEntry(fact, new FactAclEntryRecord()); verifyReindexingOfFact(fact); }