### Question:
BaseUnretireHandler implements UnretireHandler<Retireable> { @Override public void handle(Retireable retireableObject, User retiringUser, Date origParentRetiredDate, String unused) { if (retireableObject.getRetired() && (origParentRetiredDate == null || origParentRetiredDate.equals(retireableObject.getDateRetired()))) { retireableObject.setRetired(false); retireableObject.setRetiredBy(null); retireableObject.setDateRetired(null); retireableObject.setRetireReason(null); } }  @Override void handle(Retireable retireableObject, User retiringUser, Date origParentRetiredDate, String unused);  }### Answer:
@Test public void handle_shouldUnsetTheRetiredBit() { UnretireHandler<Retireable> handler = new BaseUnretireHandler(); Retireable retireable = new Location(); retireable.setRetired(true); handler.handle(retireable, null, null, null); Assert.assertFalse(retireable.getRetired()); }
@Test public void handle_shouldUnsetTheRetirer() { UnretireHandler<Retireable> handler = new BaseUnretireHandler(); Retireable retireable = new Location(); retireable.setRetired(true); retireable.setRetiredBy(new User(1)); handler.handle(retireable, null, null, null); Assert.assertNull(retireable.getRetiredBy()); }
@Test public void handle_shouldUnsetTheDateRetired() { UnretireHandler<Retireable> handler = new BaseUnretireHandler(); Retireable retireable = new Location(); retireable.setRetired(true); retireable.setDateRetired(new Date()); handler.handle(retireable, null, null, null); Assert.assertNull(retireable.getDateRetired()); }
@Test public void handle_shouldUnsetTheRetireReason() { UnretireHandler<Retireable> handler = new BaseUnretireHandler(); Retireable retireable = new Location(); retireable.setRetired(true); retireable.setRetireReason("SOME REASON"); handler.handle(retireable, null, null, null); Assert.assertNull(retireable.getRetireReason()); }
@Test public void handle_shouldNotActOnAlreadyUnretiredObjects() { UnretireHandler<Retireable> handler = new BaseUnretireHandler(); Retireable retireable = new Location(); retireable.setRetired(false); handler.handle(retireable, null, null, "SOME REASON"); Assert.assertNull(retireable.getRetireReason()); }
@Test public void handle_shouldNotActOnRetiredObjectsWithADifferentDateRetired() { Date d = new Date(new Date().getTime() - 1000); UnretireHandler<Retireable> handler = new BaseUnretireHandler(); Retireable retireable = new Location(); retireable.setRetired(true); retireable.setDateRetired(d); handler.handle(retireable, null, new Date(), "SOME REASON"); Assert.assertTrue(retireable.getRetired()); }