@Test
public void testRefreshExistingFact() {

  FactRecord factToSave = new FactRecord()
          .setId(UUID.randomUUID())
          .setAccessMode(FactRecord.AccessMode.Public)
          .setOrganizationID(UUID.randomUUID());
  mockSaveFact();
  // Mock fetching of existing Fact.
  FactRecord existingFact = new FactRecord()
          .setId(UUID.randomUUID())
          .setAccessMode(FactRecord.AccessMode.RoleBased)
          .setOrganizationID(UUID.randomUUID());
  when(objectFactDao.retrieveExistingFacts(factToSave))
          .thenReturn(ResultContainer.<FactRecord>builder().setValues(list(existingFact).iterator()).build());
  when(securityContext.hasReadPermission(existingFact)).thenReturn(true);
  // Mock stuff needed for refreshing Fact.
  when(objectFactDao.refreshFact(existingFact)).thenReturn(existingFact);
  List<UUID> subjectIds = list(UUID.randomUUID());
  handler.saveFact(factToSave, "some comment", subjectIds);
  verify(objectFactDao).refreshFact(argThat(fact -> {
    assertEquals(existingFact, fact);
    assertEquals(set("some comment"), set(fact.getComments(), FactCommentRecord::getComment));
    assertEquals(set(subjectIds), set(fact.getAcl(), FactAclEntryRecord::getSubjectID));
    return true;
  }));
  verify(objectFactDao, never()).storeFact(any());
  verify(factResponseConverter).apply(same(existingFact));
}