### Question:
CoreTokenFieldTypes { public static void validateType(CoreTokenField field, Object value) throws CoreTokenException { if (value == null) { throw new CoreTokenException(MessageFormat.format( "\n" + CoreTokenConstants.DEBUG_HEADER + "Value field cannot be null!" + "Key: {0}:{1}", CoreTokenField.class.getSimpleName(), field.name())); } Class<?> expectedType; if (isString(field)) { expectedType = String.class; } else if (isInteger(field)) { expectedType = Integer.class; } else if (isCalendar(field)) { expectedType = Calendar.class; } else if (isByteArray(field)) { expectedType = byte[].class; } else { throw new IllegalStateException("Unknown field: " + field.name()); } if (!expectedType.isAssignableFrom(value.getClass())) { throw new CoreTokenException(MessageFormat.format( "\n" + CoreTokenConstants.DEBUG_HEADER + "Value was not the correct type:\n" + " Key: {0}:{1}\n" + "Required Class: {2}" + " Actual Class: {3}", CoreTokenField.class.getSimpleName(), field.name(), expectedType.getName(), value.getClass().getName())); } }  static void validateTypes(Map<CoreTokenField, Object> types); static void validateType(CoreTokenField field, Object value); static boolean isCalendar(CoreTokenField field); static boolean isInteger(CoreTokenField field); static boolean isString(CoreTokenField field); static boolean isByteArray(CoreTokenField field);  }### Answer:
@Test public void shouldValidateDateField() throws CoreTokenException { CoreTokenField key = CoreTokenField.DATE_ONE; Calendar value = getCalendarInstance(); CoreTokenFieldTypes.validateType(key, value); }
@Test public void shouldValidateIntegerField() throws CoreTokenException { CoreTokenField key = CoreTokenField.INTEGER_ONE; Integer value = 1234; CoreTokenFieldTypes.validateType(key, value); }
@Test public void shouldValidateStringField() throws CoreTokenException { CoreTokenField key = CoreTokenField.STRING_ONE; String value = "badger"; CoreTokenFieldTypes.validateType(key, value); }
@Test public void shouldValidateDateField() throws CoreTokenException { CoreTokenField key = CoreTokenField.DATE_ONE; Calendar value = Calendar.getInstance(); CoreTokenFieldTypes.validateType(key, value); }
@Test public void shouldValidateByteField() throws CoreTokenException { CoreTokenField key = CoreTokenField.BLOB; byte[] value = new byte[]{1, 2, 3, 4}; CoreTokenFieldTypes.validateType(key, value); }
@Test (expectedExceptions = CoreTokenException.class) public void shouldValidateInvalidType() throws CoreTokenException { CoreTokenField key = CoreTokenField.BLOB; Integer value = 1234; CoreTokenFieldTypes.validateType(key, value); }