### Question:
RightPadder implements Padder { public String unpad(String paddedData) { int len = paddedData.length(); for (int i = len; i > 0; i--) { if (paddedData.charAt(i - 1) != pad) { return paddedData.substring(0, i); } } return ""; } RightPadder(char pad); String pad(String data, int maxLength); String unpad(String paddedData); static final RightPadder SPACE_PADDER; }### Answer:
@Test public void testUnpad1() throws Exception { assertEquals("123", padder.unpad("123000")); }
@Test public void testUnpad2() throws Exception { assertEquals("123", padder.unpad("123")); }
@Test public void testUnpad3() throws Exception { assertEquals("1203", padder.unpad("1203000")); }
@Test public void testUnpadAllPadding() throws Exception { assertEquals("", padder.unpad("000")); }