/** * Returns true if the information in this link should take * precedence over the information in the other link. */ public boolean overrides(Link other) { if (other.getStatus() == LinkStatus.ASSERTED && status != LinkStatus.ASSERTED) return false; else if (status == LinkStatus.ASSERTED && other.getStatus() != LinkStatus.ASSERTED) return true; // the two links are from equivalent sources of information, so we // believe the most recent return timestamp > other.getTimestamp(); }
@Test public void testSingleRecordIdempotent() { // we want to verify that seeing the same link twice doesn't cause // the timestamp to be updated in the link database Record r1 = makeRecord("id", "1"); Record r2 = makeRecord("id", "2"); listener.startProcessing(); listener.batchReady(1); listener.matches(r1, r2, 0.95); listener.batchDone(); listener.endProcessing(); Collection<Link> all = linkdb.getAllLinks(); assertEquals(1, all.size()); Link original = all.iterator().next(); TestUtils.verifySame(new Link("1", "2", LinkStatus.INFERRED, LinkKind.SAME, 0.95), original); listener.startProcessing(); listener.batchReady(1); listener.matches(r1, r2, 0.947); listener.batchDone(); listener.endProcessing(); all = linkdb.getAllLinks(); assertEquals(1, all.size()); Link newlink = all.iterator().next(); TestUtils.verifySame(new Link("1", "2", LinkStatus.INFERRED, LinkKind.SAME, 0.95), newlink); assertEquals(original.getTimestamp(), newlink.getTimestamp()); }
/** * Returns true if the information in this link should take * precedence over the information in the other link. */ public boolean overrides(Link other) { if (other.getStatus() == LinkStatus.ASSERTED && status != LinkStatus.ASSERTED) return false; else if (status == LinkStatus.ASSERTED && other.getStatus() != LinkStatus.ASSERTED) return true; // the two links are from equivalent sources of information, so we // believe the most recent return timestamp > other.getTimestamp(); }