DefaultTextPatternService implements TextPatternService { @Override public String resolvePattern( TextPattern pattern, Map<String, String> values ) throws TextPatternGenerationException { StringBuilder resolvedPattern = new StringBuilder(); for ( TextPatternSegment segment : pattern.getSegments() ) { if ( isRequired( segment ) ) { resolvedPattern.append( handleRequiredValue( segment, getSegmentValue( segment, values ) ) ); } else if ( isOptional( segment ) ) { resolvedPattern.append( handleOptionalValue( segment, getSegmentValue( segment, values ) ) ); } else { resolvedPattern.append( handleFixedValues( segment ) ); } } return resolvedPattern.toString(); }  @Override String resolvePattern( TextPattern pattern, Map<String, String> values ); @Override Map<String, List<String>> getRequiredValues( TextPattern pattern ); @Override boolean validate( TextPattern textPattern, String text );  }
@Test public void testResolvePattern() throws Exception { String result = textPatternService.resolvePattern( pattern, values ); assertEquals( "TEXTOSL1" + (new SimpleDateFormat( "YYYY" ).format( new Date() )), result ); }