src/test/java/de/blau/android/presets/PresetTest.java
/**
     * Matching test including / excluding PresetItems based on country
     */
Matching test including / excluding PresetItems based on country
Matching test including / excluding PresetItems based on country
@Test
    public void includeExcludeCountryMatching() {
        try {
            File testPresetFile = JavaResources.copyFileFromResources(ApplicationProvider.getApplicationContext(), "test_preset1.xml", null, "test_preset");
            Preset testPreset = new Preset(ApplicationProvider.getApplicationContext(), testPresetFile.getParentFile(), null, false);
            Map<String, String> tags = new HashMap<>();
            tags.put(Tags.KEY_HIGHWAY, Tags.VALUE_MOTORWAY_LINK);
            PresetItem us = Preset.findBestMatch(new Preset[] { testPreset }, tags, "US");
            assertNotNull(us);
            assertEquals("Motorway Link (US)", us.getName());
            PresetItem ch = Preset.findBestMatch(new Preset[] { testPreset }, tags, "CH");
            assertNotNull(ch);
            assertEquals("Motorway Link", ch.getName());
        } catch (IOException | NoSuchAlgorithmException | ParserConfigurationException | SAXException e) {
            fail(e.getMessage());
        }
    }
@ Test public void includeExcludeCountryMatching ( ) { try { File testPresetFile = JavaResources . copyFileFromResources ( ApplicationProvider . getApplicationContext ( ) , "test_preset1.xml" , null , "test_preset" ) ; Preset testPreset = new Preset ( ApplicationProvider . getApplicationContext ( ) , testPresetFile . getParentFile ( ) , null , false ) ; Map < String , String > tags = new HashMap < > ( ) ; tags . put ( Tags . KEY_HIGHWAY , Tags . VALUE_MOTORWAY_LINK ) ; PresetItem us = Preset . findBestMatch ( new Preset [ ] { testPreset } , tags , "US" ) ; assertNotNull ( us ) ; assertEquals ( "Motorway Link (US)" , us . getName ( ) ) ; PresetItem ch = Preset . findBestMatch ( new Preset [ ] { testPreset } , tags , "CH" ) ; assertNotNull ( ch ) ; assertEquals ( "Motorway Link" , ch . getName ( ) ) ; } catch ( IOException | NoSuchAlgorithmException | ParserConfigurationException | SAXException e ) { fail ( e . getMessage ( ) ) ; } }
Matching test including / excluding PresetItems based on country
Matching test including / excluding PresetItems based on country