TextPatternValidationUtils { public static boolean validateSegmentValue( TextPatternSegment segment, String value ) { return segment.getMethod().getType().validateText( segment.getParameter(), value ); }  static boolean validateSegmentValue( TextPatternSegment segment, String value ); static boolean validateTextPatternValue( TextPattern textPattern, String value ); static long getTotalValuesPotential( TextPatternSegment generatedSegment ); static boolean validateValueType( TextPattern textPattern, ValueType valueType );  }
@Test public void testValidationUtilsValidateSegmentValue() { assertTrue( TextPatternValidationUtils.validateSegmentValue( textSegment, "FOOBAR" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( textSegment, "FOBAR" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( textSegment, "" ) ); assertTrue( TextPatternValidationUtils.validateSegmentValue( textSegmentWithSpecialCharacters, "0aA0" ) ); assertTrue( TextPatternValidationUtils.validateSegmentValue( textSegmentWithSpecialCharacters, "9zZa" ) ); assertTrue( TextPatternValidationUtils.validateSegmentValue( textSegmentWithSpecialCharacters, "0aAA" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( textSegmentWithSpecialCharacters, "aaA0" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( textSegmentWithSpecialCharacters, "01A0" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( textSegmentWithSpecialCharacters, "0a10" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( textSegmentWithSpecialCharacters, "12aA0" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( textSegmentWithSpecialCharacters, "0aA01" ) ); assertTrue( TextPatternValidationUtils.validateSegmentValue( randomSegment, "AAaa11" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( randomSegment, "11AAaa" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( randomSegment, "AAaa111" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( randomSegment, "Aa1" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( randomSegment, "" ) ); assertTrue( TextPatternValidationUtils.validateSegmentValue( sequentialSegment, "001" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( sequentialSegment, "1234" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( sequentialSegment, "01" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( sequentialSegment, "asd" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( sequentialSegment, "" ) ); assertTrue( TextPatternValidationUtils.validateSegmentValue( orgUnitCodeSegment, "ABC" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( orgUnitCodeSegment, "ABCD" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( orgUnitCodeSegment, "AB" ) ); assertFalse( TextPatternValidationUtils.validateSegmentValue( orgUnitCodeSegment, "" ) ); assertTrue( TextPatternValidationUtils.validateSegmentValue( currentDateSegment, "22/10/1990" ) ); }