### Question:
ObjectFactDaoFacade implements ObjectFactDao { @Override public ObjectRecord storeObject(ObjectRecord record) { if (record == null) return null; if (record.getId() == null) { record.setId(UUID.randomUUID()); } objectManager.saveObject(objectRecordConverter.toEntity(record)); return record; } @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 testStoreObjectWithNull() { assertNull(dao.storeObject(null)); }
@Test public void testStoreObjectSavesEntity() { ObjectRecord record = new ObjectRecord().setId(UUID.randomUUID()); ObjectEntity entity = new ObjectEntity().setId(record.getId()); when(objectRecordConverter.toEntity(record)).thenReturn(entity); assertSame(record, dao.storeObject(record)); verify(objectRecordConverter).toEntity(argThat(r -> r.getId() == record.getId())); verify(objectManager).saveObject(entity); }
@Test public void testStoreObjectSetsId() { ObjectRecord record = new ObjectRecord(); ObjectEntity entity = new ObjectEntity(); when(objectRecordConverter.toEntity(record)).thenReturn(entity); assertSame(record, dao.storeObject(record)); verify(objectRecordConverter).toEntity(argThat(r -> r.getId() != null)); verify(objectManager).saveObject(entity); }