### Question:
IntegerSchema extends PrimitiveNumericSchema<Integer> { @Override public Object convert(Object value) { if (value instanceof Integer) { return (Integer) value; } else if (value instanceof String) { try { return Integer.parseInt((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException)new IllegalArgumentException(value + " cannot be parsed to an integer").initCause(nfe); } } throw new IllegalArgumentException(value + " is not an integer"); } IntegerSchema(); @Override Object convert(Object value);  }### Answer:
@Test public void testConvert() throws Exception { int value = 12345; Object convertedValue = this.schema.convert("" + value); assertTrue(convertedValue instanceof Integer); Integer convertedInput = (Integer) convertedValue; assertTrue(convertedInput.intValue() == value); }
@Test(expected = IllegalArgumentException.class) public void testBadConvert() { this.schema.convert("INVALID INPUT"); }
@Test public void testNonConvert() { Object convertedValue = this.schema.convert(12); assertTrue(convertedValue instanceof Integer); }
@Test public void testIntegerConverter() { int data = 123; assertTrue("Failure returning same object", this.schema.convert(data).equals(data)); assertTrue("Failure parsing int data", this.schema.convert("" + data).equals(data)); }
@Test(expected = IllegalArgumentException.class) public void testInvalidStringThrowsException() throws IllegalArgumentException { this.schema.convert("INVALID INPUT"); }
@Test(expected = IllegalArgumentException.class) public void testUnsupportedObjectTypeThrowsException() throws IllegalArgumentException { this.schema.convert(new Object()); }