src/test/java/de/blau/android/presets/PresetTest.java
/**
     * Test that we match the expected PresetItem
     */
Test that we match the expected PresetItem
Test that we match the expected PresetItem
@Test
    public void matching() {
        Map<String, String> tags = new HashMap<>();
        tags.put("amenity", "restaurant");
        PresetItem restaurant = Preset.findBestMatch(presets, tags, null);
        assertEquals("Restaurant", restaurant.getName());
         Splitting
        List<String> values = new ArrayList<>();
        values.add("chinese;fondue");
        values.add("japenese,steak");
        List<String> result = Preset.splitValues(values, restaurant, "cuisine");
        assertEquals(3, result.size());
        assertTrue(result.contains("chinese"));
        assertTrue(result.contains("fondue"));
        assertTrue(result.contains("japenese,steak"));
        assertNull(Preset.splitValues(null, restaurant, "cuisine"));
        values.add(null);
        assertEquals(3, Preset.splitValues(values, restaurant, "cuisine").size());
        assertTrue(restaurant.hasKeyValue("cuisine", "anything"));  that this works doesn't make sense
        assertTrue(restaurant.hasKeyValue("takeaway", "only"));
        assertTrue(restaurant.hasKeyValue("self_service", ""));
         lanes uses |
        PresetItem lanes = presets[0].getItemByName("Single direction roads", null);
        assertNotNull(lanes);
        values.clear();
        values.add("left|right");
        result = Preset.splitValues(values, lanes, "turn:lanes");
        assertEquals(2, result.size());
        assertTrue(result.contains("left"));
        assertTrue(result.contains("right"));
    }
@ Test public void matching ( ) { Map < String , String > tags = new HashMap < > ( ) ; tags . put ( "amenity" , "restaurant" ) ; PresetItem restaurant = Preset . findBestMatch ( presets , tags , null ) ; assertEquals ( "Restaurant" , restaurant . getName ( ) ) ; List < String > values = new ArrayList < > ( ) ; values . add ( "chinese;fondue" ) ; values . add ( "japenese,steak" ) ; List < String > result = Preset . splitValues ( values , restaurant , "cuisine" ) ; assertEquals ( 3 , result . size ( ) ) ; assertTrue ( result . contains ( "chinese" ) ) ; assertTrue ( result . contains ( "fondue" ) ) ; assertTrue ( result . contains ( "japenese,steak" ) ) ; assertNull ( Preset . splitValues ( null , restaurant , "cuisine" ) ) ; values . add ( null ) ; assertEquals ( 3 , Preset . splitValues ( values , restaurant , "cuisine" ) . size ( ) ) ; assertTrue ( restaurant . hasKeyValue ( "cuisine" , "anything" ) ) ; assertTrue ( restaurant . hasKeyValue ( "takeaway" , "only" ) ) ; assertTrue ( restaurant . hasKeyValue ( "self_service" , "" ) ) ; PresetItem lanes = presets [ 0 ] . getItemByName ( "Single direction roads" , null ) ; assertNotNull ( lanes ) ; values . clear ( ) ; values . add ( "left|right" ) ; result = Preset . splitValues ( values , lanes , "turn:lanes" ) ; assertEquals ( 2 , result . size ( ) ) ; assertTrue ( result . contains ( "left" ) ) ; assertTrue ( result . contains ( "right" ) ) ; }
Test that we match the expected PresetItem
Test that we match the expected PresetItem
// // Splitting // that this works doesn't make sense // lanes uses |