DateFormatValidatorFactory { public static DateFormatValidator forTypes(final Type sourceType, final Type targetType) { DateFormatValidator dateFormatValidator; if ( isJavaUtilDateSupposed( sourceType, targetType ) ) { dateFormatValidator = new SimpleDateFormatValidator(); } else if ( isXmlGregorianCalendarSupposedToBeMapped( sourceType, targetType ) ) { dateFormatValidator = new SimpleDateFormatValidator(); } else if ( isJava8DateTimeSupposed( sourceType, targetType ) ) { dateFormatValidator = new JavaDateTimeDateFormatValidator(); } else if ( isJodaDateTimeSupposed( sourceType, targetType ) ) { dateFormatValidator = new JodaTimeDateFormatValidator(); } else { dateFormatValidator = new DateFormatValidator() { @Override public DateFormatValidationResult validate(String dateFormat) { return new DateFormatValidationResult( true, Message.GENERAL_UNSUPPORTED_DATE_FORMAT_CHECK, sourceType, targetType ); } }; } return dateFormatValidator; } private  DateFormatValidatorFactory(); static DateFormatValidator forTypes(final Type sourceType, final Type targetType);  }
@Test public void testUnsupportedTypes() { Type sourceType = typeWithFQN( JAVA_LANG_STRING ); Type targetType = typeWithFQN( JAVA_LANG_STRING ); DateFormatValidator dateFormatValidator = DateFormatValidatorFactory.forTypes( sourceType, targetType ); assertThat( dateFormatValidator.validate( "XXXX" ).isValid() ).isTrue(); }