### Question:
FhirToDhisOptionSetUtils { @Nonnull public static List<String> resolveIntegerOptionCodes( @Nonnull OptionSet optionSet, @Nullable Pattern pattern ) throws TransformerScriptException { final Pattern resultingPattern = (pattern == null) ? ALL : pattern; final SortedMap<Integer, String> options = new TreeMap<>(); for ( final Option option : optionSet.getOptions() ) { final String code, value; if ( pattern == null ) { code = value = option.getCode(); } else { code = option.getCode(); value = getIntegerOptionCode( code, resultingPattern ); } if ( value != null ) { try { if ( options.put( Integer.parseInt( value ), code ) != null ) { throw new TransformerScriptException( "Pattern to resolveRule integer options results in duplicate integer value " + value + ": " + resultingPattern.pattern() ); } } catch ( NumberFormatException e ) { throw new TransformerScriptException( "Pattern to resolveRule integer options results in non-integer value \"" + value + "\": " + resultingPattern.pattern() ); } } } validateAscendingIntegerOptions( options, resultingPattern ); return new ArrayList<>( options.values() ); } private  FhirToDhisOptionSetUtils(); @Nullable static String getIntegerOptionCode( @Nullable String code, @Nullable Pattern pattern ); @Nonnull static List<String> resolveIntegerOptionCodes( @Nonnull OptionSet optionSet, @Nullable Pattern pattern );  }### Answer:
@Test public void resolveIntegerOption() { final WritableOptionSet optionSet = new WritableOptionSet(); optionSet.setOptions( Arrays.asList( new WritableOption( "2", "Test X" ), new WritableOption( "1", "Test Y" ), new WritableOption( "3", "Test Z" ) ) ); final List<String> codes = FhirToDhisOptionSetUtils.resolveIntegerOptionCodes( optionSet, null ); Assert.assertThat( codes, Matchers.contains( "1", "2", "3" ) ); }
@Test public void resolveIntegerOptionPattern() { final WritableOptionSet optionSet = new WritableOptionSet(); optionSet.setOptions( Arrays.asList( new WritableOption( "Test 2", "Test X" ), new WritableOption( "Test 1", "Test Y" ), new WritableOption( "Other 4", "Test A" ), new WritableOption( "Test 3", "Test Z" ) ) ); final List<String> codes = FhirToDhisOptionSetUtils.resolveIntegerOptionCodes( optionSet, Pattern.compile( "Test (\\d+)" ) ); Assert.assertThat( codes, Matchers.contains( "Test 1", "Test 2", "Test 3" ) ); }