### Question:
LongSchema extends PrimitiveNumericSchema<Long> { @Override public Object convert(Object value) { if (value instanceof Integer) { return ((Integer) value).longValue(); } else if (value instanceof Long) { return (Long) value; } else if (value instanceof String) { try { return Long.parseLong((String) value); } catch (NumberFormatException nfe) { throw (IllegalArgumentException) new IllegalArgumentException(value + " cannot be parsed to a long").initCause(nfe); } } throw new IllegalArgumentException(value + " is not a long"); } LongSchema(); @Override Object convert(Object value);  }### Answer:
@Test public void testConvert() throws Exception { long value = 10L; Object convertedValue = this.schema.convert("" + value); assertTrue(convertedValue instanceof Long); Long convertedInput = (Long) convertedValue; assertTrue(convertedInput.longValue() == value); }
@Test(expected = IllegalArgumentException.class) public void testBadConvert() { this.schema.convert("INVALID INPUT"); }
@Test public void testNonConvert() { Object convertedValue = this.schema.convert(12345L); assertTrue(convertedValue instanceof Long); }
@Test public void testLongConverter() { long data = 12345L; int intData = (int) data; assertTrue("Failure returning same object", this.schema.convert(data).equals(data)); assertTrue("Failure parsing long from integer", this.schema.convert(intData).equals(data)); assertTrue("Failure parsing long 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()); }