src/test/java/de/blau/android/osm/StorageDelegatorTest.java
/**
     * Split / merge way with metric tag
     */
Split / merge way with metric tag
Split / merge way with metric tag
@Test
    public void splitMergeWithMetric() {
        StorageDelegator d = new StorageDelegator();
        Way w = DelegatorUtil.addWayToStorage(d, false);
        Way temp = (Way) d.getOsmElement(Way.NAME, w.getOsmId());
        assertNotNull(temp);
        Node n = w.getNodes().get(2);
        Map<String, String> tags = new TreeMap<>(w.getTags());
        tags.put(Tags.KEY_STEP_COUNT, "7");
        tags.put(Tags.KEY_DURATION, "15");
        w.setTags(tags);
        List<Result> splitResult = d.splitAtNode(w, n);
        assertNotNull(splitResult);
        assertFalse(splitResult.isEmpty());
        Result first = splitResult.get(0);
        assertNotNull(first.getIssues());
        assertEquals(1, first.getIssues().size());
        assertTrue(first.getIssues().contains(SplitIssue.SPLIT_METRIC));
        Way newWay = (Way) first.getElement();
        assertEquals("5", w.getTagWithKey(Tags.KEY_STEP_COUNT));
        assertEquals("2", newWay.getTagWithKey(Tags.KEY_STEP_COUNT));
        assertEquals("00:10:07", w.getTagWithKey(Tags.KEY_DURATION));
        assertEquals("00:04:53", newWay.getTagWithKey(Tags.KEY_DURATION));
        MergeAction action = new MergeAction(d, newWay, w);
        List<Result> results = action.mergeWays();
        assertNotNull(results);
        assertEquals(1, results.size());
        assertNotNull(results.get(0).getIssues());
        assertTrue(results.get(0).getIssues().contains(MergeIssue.MERGEDMETRIC));
        w = (Way) results.get(0).getElement();
        assertEquals("7", w.getTagWithKey(Tags.KEY_STEP_COUNT));
        assertEquals("15", w.getTagWithKey(Tags.KEY_DURATION));
    }
@ Test public void splitMergeWithMetric ( ) { StorageDelegator d = new StorageDelegator ( ) ; Way w = DelegatorUtil . addWayToStorage ( d , false ) ; Way temp = ( Way ) d . getOsmElement ( Way . NAME , w . getOsmId ( ) ) ; assertNotNull ( temp ) ; Node n = w . getNodes ( ) . get ( 2 ) ; Map < String , String > tags = new TreeMap < > ( w . getTags ( ) ) ; tags . put ( Tags . KEY_STEP_COUNT , "7" ) ; tags . put ( Tags . KEY_DURATION , "15" ) ; w . setTags ( tags ) ; List < Result > splitResult = d . splitAtNode ( w , n ) ; assertNotNull ( splitResult ) ; assertFalse ( splitResult . isEmpty ( ) ) ; Result first = splitResult . get ( 0 ) ; assertNotNull ( first . getIssues ( ) ) ; assertEquals ( 1 , first . getIssues ( ) . size ( ) ) ; assertTrue ( first . getIssues ( ) . contains ( SplitIssue . SPLIT_METRIC ) ) ; Way newWay = ( Way ) first . getElement ( ) ; assertEquals ( "5" , w . getTagWithKey ( Tags . KEY_STEP_COUNT ) ) ; assertEquals ( "2" , newWay . getTagWithKey ( Tags . KEY_STEP_COUNT ) ) ; assertEquals ( "00:10:07" , w . getTagWithKey ( Tags . KEY_DURATION ) ) ; assertEquals ( "00:04:53" , newWay . getTagWithKey ( Tags . KEY_DURATION ) ) ; MergeAction action = new MergeAction ( d , newWay , w ) ; List < Result > results = action . mergeWays ( ) ; assertNotNull ( results ) ; assertEquals ( 1 , results . size ( ) ) ; assertNotNull ( results . get ( 0 ) . getIssues ( ) ) ; assertTrue ( results . get ( 0 ) . getIssues ( ) . contains ( MergeIssue . MERGEDMETRIC ) ) ; w = ( Way ) results . get ( 0 ) . getElement ( ) ; assertEquals ( "7" , w . getTagWithKey ( Tags . KEY_STEP_COUNT ) ) ; assertEquals ( "15" , w . getTagWithKey ( Tags . KEY_DURATION ) ) ; }
Split / merge way with metric tag
Split / merge way with metric tag
// split // merge