### Question:
BinaryType implements Type, Serializable { @Override public Object cast(Object obj) { byte[] ret = null; if (obj != null) { if (obj.getClass().isArray()) { Class<?> component = obj.getClass().getComponentType(); if (component.equals(byte.class)) { ret = (byte[]) obj; } else { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } else { throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString()); } } return ret; } private  BinaryType(); @Override String getName(); @Override boolean supportsEq(); @Override boolean supportsOrdering(); @Override int compare(Object v1, Object v2); @Override Object cast(Object obj); @Override JsonNode toJson(JsonNodeFactory factory, Object obj); @Override Object fromJson(JsonNode node); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static final Type TYPE; static final String NAME; }### Answer:
@Test public void testCast() { assertNull(binaryType.cast(null)); }
@Test(expected = Error.class) public void testCastIncompatible() { binaryType.cast(new Object()); }
@Test(expected = Error.class) public void testCastNonByte() { binaryType.cast(new String[1]); }