### Question:
BinaryField implements FieldType<byte[]> { @Override public Types getType() { return type; } BinaryField(Types type);  BinaryField(Types type, String lengthString); @Override Types getType(); long getLength(); @Override byte[] getDefaultValue(); @Override boolean hasDefaultValue(); @Override byte[] convert(Object objValue); @Override JSONObject toJson();  }### Answer:
@Test public void testDefaultConsturctor() { System.out.println("BinaryField(Types)"); BinaryField instance; for (Types type : Types.values()) { try { new BinaryField(type); if (!(type == Types.BINARY_LARGE_OBJECT || type == Types.BLOB)) { fail("Incorrectly accepted " + type.getType() + " as a valid binary type"); } } catch (OperationException ex) { if (ex.getErrorCode() != ErrorCode.DATATYPE_MISMATCH) { fail("Incorrect error code reported for data type mismatch"); } if (type == Types.BINARY_LARGE_OBJECT || type == Types.BLOB) { fail("Incorrectly reported " + type.getType() + " as an invalid binary type"); } } } }
@Test public void testConstructor_type_string() { System.out.println("BinaryField(Types,String)"); BinaryField instance; for (Types type : Types.values()) { try { new BinaryField(type, "100"); if (!(type == Types.BINARY_LARGE_OBJECT || type == Types.BLOB)) { fail("Incorrectly accepted " + type.getType() + " as a valid binary type"); } } catch (OperationException ex) { if (ex.getErrorCode() != ErrorCode.DATATYPE_MISMATCH) { fail("Incorrect error code reported for data type mismatch"); } if (type == Types.BINARY_LARGE_OBJECT || type == Types.BLOB) { fail("Incorrectly reported " + type.getType() + " as an invalid binary type"); } } } try { new BinaryField(Types.BLOB, "100"); new BinaryField(Types.BLOB, "100K"); new BinaryField(Types.BLOB, "100M"); new BinaryField(Types.BLOB, "100G"); } catch (OperationException ex) { fail("Construct rejected valid length format"); } try { new BinaryField(Types.BLOB, "something"); new BinaryField(Types.BLOB, "A100"); new BinaryField(Types.BLOB, "K100"); new BinaryField(Types.BLOB, "100A"); new BinaryField(Types.BLOB, " 100"); new BinaryField(Types.BLOB, "100K "); new BinaryField(Types.BLOB, "100 K"); new BinaryField(Types.BLOB, ""); new BinaryField(Types.BLOB, null); } catch (OperationException ex) { if(ex.getErrorCode() != ErrorCode.INVALID_FIELD_LENGTH_FORMAT) { fail("Invalid field length format exception reported with incorrect error code of " + ex.getErrorCode()); } } }
@Test public void testGetType() throws OperationException { System.out.println("getQueryCode"); BinaryField instance; instance = new BinaryField(Types.BINARY_LARGE_OBJECT); assertEquals(Types.BINARY_LARGE_OBJECT, instance.getType()); instance = new BinaryField(Types.BLOB); assertEquals(Types.BLOB, instance.getType()); }