### Question:
IntegerType implements Type, Serializable { @Override public Object cast(Object obj) { Long value = null; if (obj != null) { if (obj instanceof Number) { value = ((Number) obj).longValue(); } else if (obj instanceof Boolean) { value = ((Boolean) obj) ? Long.valueOf(1) : Long.valueOf(0); } else { try { value = Long.valueOf(obj.toString()); } catch (NumberFormatException e) { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } } return value; } private  IntegerType(); @Override String getName(); @Override boolean supportsEq(); @Override boolean supportsOrdering(); @Override JsonNode toJson(JsonNodeFactory factory, Object obj); @Override Object fromJson(JsonNode node); @Override Object cast(Object obj); @SuppressWarnings({"rawtypes", "unchecked"}) @Override int compare(Object v1, Object v2); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static final Type TYPE; static final String NAME; }### Answer:
@Test public void testCastNull() { assertNull(integerType.cast(null)); }
@Test public void testCastBigInteger() { assertTrue(integerType.cast(Integer.MAX_VALUE) instanceof Long); }
@Test public void testCastLong() { assertTrue(integerType.cast(Long.MAX_VALUE) instanceof Long); }
@Test public void testCastBooleanTrue() { assertTrue(integerType.cast(Boolean.TRUE) instanceof Long); }
@Test public void testCastBooleanFalse() { assertTrue(integerType.cast(Boolean.FALSE) instanceof Long); }
@Test public void testCastGoodString() { assertTrue(integerType.cast(String.valueOf(Long.MAX_VALUE)) instanceof Long); }
@Test(expected = Error.class) public void testCastBadString() { integerType.cast("badstring"); }
@Test(expected = Error.class) public void testCastOther() { Object object = new Object(); integerType.cast(object); }