### Question:
OpenmrsMetadataSaveHandler implements SaveHandler<OpenmrsMetadata> { @Override public void handle(OpenmrsMetadata object, User creator, Date dateCreated, String other) { if (object.getName() != null) { object.setName(object.getName().trim()); } if (object.getDescription() != null) { object.setDescription(object.getDescription().trim()); } }  @Override void handle(OpenmrsMetadata object, User creator, Date dateCreated, String other);  }### Answer:
@Test public void handle_shouldTrimWhitespaceFromName() { String NAME = "the location name"; OpenmrsMetadataSaveHandler handler = new OpenmrsMetadataSaveHandler(); Location loc = new Location(); loc.setName(" " + NAME + " "); handler.handle(loc, null, null, null); Assert.assertEquals(NAME, loc.getName()); }
@Test public void handle_shouldTrimWhitespaceFromDescription() { String DESC = "the location desc"; OpenmrsMetadataSaveHandler handler = new OpenmrsMetadataSaveHandler(); Location loc = new Location(); loc.setName("a name"); loc.setDescription(" " + DESC + " "); handler.handle(loc, null, null, null); Assert.assertEquals(DESC, loc.getDescription()); }
@Test @Verifies(value = "should trim whitespace from name", method = "handle(OpenmrsMetadata,User,Date,String)") public void handle_shouldTrimWhitespaceFromName() throws Exception { String NAME = "the location name"; OpenmrsMetadataSaveHandler handler = new OpenmrsMetadataSaveHandler(); Location loc = new Location(); loc.setName(" " + NAME + " "); handler.handle(loc, null, null, null); Assert.assertEquals(NAME, loc.getName()); }
@Test @Verifies(value = "should trim whitespace from description", method = "handle(OpenmrsMetadata,User,Date,String)") public void handle_shouldTrimWhitespaceFromDescription() throws Exception { String DESC = "the location desc"; OpenmrsMetadataSaveHandler handler = new OpenmrsMetadataSaveHandler(); Location loc = new Location(); loc.setName("a name"); loc.setDescription(" " + DESC + " "); handler.handle(loc, null, null, null); Assert.assertEquals(DESC, loc.getDescription()); }