### Question:
MergeInfo implements Writable { public boolean overlaps(KeyExtent otherExtent) { boolean result = this.extent.overlaps(otherExtent); if (!result && needsToBeChopped(otherExtent)) return true; return result; } MergeInfo();  MergeInfo(KeyExtent range, Operation op); @Override void readFields(DataInput in); @Override void write(DataOutput out); MergeState getState(); KeyExtent getExtent(); Operation getOperation(); void setState(MergeState state); boolean isDelete(); boolean needsToBeChopped(KeyExtent otherExtent); boolean overlaps(KeyExtent otherExtent); @Override String toString();  }### Answer:
@Test public void testOverlaps_ExtentsOverlap() { KeyExtent keyExtent2 = createMock(KeyExtent.class); expect(keyExtent.overlaps(keyExtent2)).andReturn(true); replay(keyExtent); mi = new MergeInfo(keyExtent, MergeInfo.Operation.MERGE); assertTrue(mi.overlaps(keyExtent2)); }
@Test public void testOverlaps_DoesNotNeedChopping() { KeyExtent keyExtent2 = createMock(KeyExtent.class); expect(keyExtent.overlaps(keyExtent2)).andReturn(false); expect(keyExtent.tableId()).andReturn(TableId.of("table1")); replay(keyExtent); expect(keyExtent2.tableId()).andReturn(TableId.of("table2")); replay(keyExtent2); mi = new MergeInfo(keyExtent, MergeInfo.Operation.MERGE); assertFalse(mi.overlaps(keyExtent2)); }
@Test public void testOverlaps_NeedsChopping() { KeyExtent keyExtent2 = createMock(KeyExtent.class); expect(keyExtent.overlaps(keyExtent2)).andReturn(false); expect(keyExtent.tableId()).andReturn(TableId.of("table1")); expect(keyExtent.endRow()).andReturn(new Text("prev")); replay(keyExtent); expect(keyExtent2.tableId()).andReturn(TableId.of("table1")); expect(keyExtent2.prevEndRow()).andReturn(new Text("prev")); expectLastCall().anyTimes(); replay(keyExtent2); mi = new MergeInfo(keyExtent, MergeInfo.Operation.DELETE); assertTrue(mi.overlaps(keyExtent2)); }