### Question:
EmpiLinkDaoSvc { public EmpiLink save(EmpiLink theEmpiLink) { if (theEmpiLink.getCreated() == null) { theEmpiLink.setCreated(new Date()); } theEmpiLink.setUpdated(new Date()); return myEmpiLinkDao.save(theEmpiLink); }  @Transactional EmpiLink createOrUpdateLinkEntity(IBaseResource thePerson, IBaseResource theTarget, EmpiMatchOutcome theMatchOutcome, EmpiLinkSourceEnum theLinkSource, @Nullable EmpiTransactionContext theEmpiTransactionContext); @Nonnull EmpiLink getOrCreateEmpiLinkByPersonPidAndTargetPid(Long thePersonPid, Long theResourcePid); Optional<EmpiLink> getLinkByPersonPidAndTargetPid(Long thePersonPid, Long theTargetPid); List<EmpiLink> getEmpiLinksByTargetPidAndMatchResult(Long theTargetPid, EmpiMatchResultEnum theMatchResult); Optional<EmpiLink> getMatchedLinkForTargetPid(Long theTargetPid); Optional<EmpiLink> getMatchedLinkForTarget(IBaseResource theTarget); Optional<EmpiLink> getEmpiLinksByPersonPidTargetPidAndMatchResult(Long thePersonPid, Long theTargetPid, EmpiMatchResultEnum theMatchResult); List<EmpiLink> getPossibleDuplicates(); Optional<EmpiLink> findEmpiLinkByTarget(IBaseResource theTargetResource); @Transactional(propagation = Propagation.REQUIRES_NEW) void deleteLink(EmpiLink theEmpiLink); List<EmpiLink> findEmpiLinksByPerson(IBaseResource thePersonResource); @Transactional List<Long> deleteAllEmpiLinksAndReturnPersonPids(); List<Long> deleteAllEmpiLinksOfTypeAndReturnPersonPids(String theTargetType); EmpiLink save(EmpiLink theEmpiLink); List<EmpiLink> findEmpiLinkByExample(Example<EmpiLink> theExampleLink); List<EmpiLink> findEmpiLinksByTarget(IBaseResource theTargetResource); EmpiLink newEmpiLink();  }### Answer:
@Test public void testCreate() { EmpiLink empiLink = createResourcesAndBuildTestEmpiLink(); assertThat(empiLink.getCreated(), is(nullValue())); assertThat(empiLink.getUpdated(), is(nullValue())); myEmpiLinkDaoSvc.save(empiLink); assertThat(empiLink.getCreated(), is(notNullValue())); assertThat(empiLink.getUpdated(), is(notNullValue())); assertTrue(empiLink.getUpdated().getTime() - empiLink.getCreated().getTime() < 1000); }
@Test public void testUpdate() { EmpiLink createdLink = myEmpiLinkDaoSvc.save(createResourcesAndBuildTestEmpiLink()); assertThat(createdLink.getLinkSource(), is(EmpiLinkSourceEnum.MANUAL)); TestUtil.sleepOneClick(); createdLink.setLinkSource(EmpiLinkSourceEnum.AUTO); EmpiLink updatedLink = myEmpiLinkDaoSvc.save(createdLink); assertNotEquals(updatedLink.getCreated(), updatedLink.getUpdated()); }