### Question:
StringField implements FieldType<String> { @Override public String convert(Object objValue) throws OperationException { if (objValue == null) { throw new OperationException(ErrorCode.DATATYPE_MISMATCH); } final String str = objValue.toString(); if (length > 0 && str.length() > length) { throw new OperationException(ErrorCode.DATATYPE_CONSTRAINT_VIOLATION, "Maximum permitted length is " + length + " but found content with length " + str.length()); } return str; } StringField(final Types type);  StringField(final String defaultValue, final Types type);  StringField(final Types type, final String length);  StringField(final Types type, final String length, final String defaultValue); @Override Types getType(); long getLength(); @Override String getDefaultValue(); @Override boolean hasDefaultValue(); @Override String convert(Object objValue); @Override JSONObject toJson();  }### Answer:
@Test public void testConvert() throws Exception { System.out.println("convert"); StringField instance; instance = new StringField(Types.STRING, "36"); UUID expectedResult = UUID.randomUUID(); assertEquals(expectedResult.toString(), instance.convert(expectedResult)); assertEquals(expectedResult.toString(), instance.convert(expectedResult.toString())); instance = new StringField(Types.STRING, "35"); try { instance.convert(expectedResult.toString()); fail("StringField failed to do constraint check"); } catch (OperationException ex) { assertEquals(ErrorCode.DATATYPE_CONSTRAINT_VIOLATION, ex.getErrorCode()); } }