### Question:
MergeInfo implements Writable { public boolean needsToBeChopped(KeyExtent otherExtent) { if (!otherExtent.tableId().equals(extent.tableId())) return false; if (isDelete()) return otherExtent.prevEndRow() != null && otherExtent.prevEndRow().equals(extent.endRow()); else return this.extent.overlaps(otherExtent); } 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 testNeedsToBeChopped_DifferentTables() { expect(keyExtent.tableId()).andReturn(TableId.of("table1")); replay(keyExtent); KeyExtent keyExtent2 = createMock(KeyExtent.class); expect(keyExtent2.tableId()).andReturn(TableId.of("table2")); replay(keyExtent2); mi = new MergeInfo(keyExtent, MergeInfo.Operation.MERGE); assertFalse(mi.needsToBeChopped(keyExtent2)); }
@Test public void testNeedsToBeChopped() { MergeInfo info = new MergeInfo(ke("x", "b", "a"), MergeInfo.Operation.DELETE); assertTrue(info.needsToBeChopped(ke("x", "c", "b"))); assertTrue(info.overlaps(ke("x", "c", "b"))); assertFalse(info.needsToBeChopped(ke("y", "c", "b"))); assertFalse(info.needsToBeChopped(ke("x", "c", "bb"))); assertFalse(info.needsToBeChopped(ke("x", "b", "a"))); info = new MergeInfo(ke("x", "b", "a"), MergeInfo.Operation.MERGE); assertTrue(info.needsToBeChopped(ke("x", "c", "a"))); assertTrue(info.needsToBeChopped(ke("x", "aa", "a"))); assertTrue(info.needsToBeChopped(ke("x", null, null))); assertFalse(info.needsToBeChopped(ke("x", "c", "b"))); assertFalse(info.needsToBeChopped(ke("y", "c", "b"))); assertFalse(info.needsToBeChopped(ke("x", "c", "bb"))); assertTrue(info.needsToBeChopped(ke("x", "b", "a"))); }