src/test/java/de/blau/android/osm/StorageDelegatorTest.java
/**
     * Unjoin two similar ways - nothing should happen - change tags unjoin should happen
     */
Unjoin two similar ways - nothing should happen - change tags unjoin should happen
Unjoin two similar ways - nothing should happen - change tags unjoin should happen
@Test
    public void unjoinSimilarWay() {
        StorageDelegator d = new StorageDelegator();
        Way w = DelegatorUtil.addWayToStorage(d, false);
        final Node n1 = w.getNodes().get(1);
        Way w2 = d.createAndInsertWay(n1);
        final Node n2 = w.getNodes().get(2);
        d.addNodeToWay(n2, w2);
        assertEquals(2, d.getApiWayCount());
        assertEquals(w.nodeCount(), d.getApiNodeCount());
        Map<String, String> tags = new HashMap<>();
        tags.put(Tags.KEY_HIGHWAY, "service");
        w.setTags(tags);
        w2.setTags(tags);
        d.unjoinWay(null, w2, true);
        assertEquals(n1, w2.getFirstNode());
        final Node lastNode = w2.getLastNode();
        assertEquals(n2, lastNode);
        assertEquals(2, d.getApiWayCount());
        assertEquals(w.nodeCount(), d.getApiNodeCount());
        tags.clear();
        tags.put(Tags.KEY_WATERWAY, "wet");
        w2.setTags(tags);
        d.unjoinWay(null, w2, true);
        assertNotEquals(n1, w2.getFirstNode());
        assertNotEquals(n2, w2.getLastNode());
        assertEquals(2, d.getApiWayCount());
        assertEquals(w.nodeCount() + 2, d.getApiNodeCount());
    }
@ Test public void unjoinSimilarWay ( ) { StorageDelegator d = new StorageDelegator ( ) ; Way w = DelegatorUtil . addWayToStorage ( d , false ) ; final Node n1 = w . getNodes ( ) . get ( 1 ) ; Way w2 = d . createAndInsertWay ( n1 ) ; final Node n2 = w . getNodes ( ) . get ( 2 ) ; d . addNodeToWay ( n2 , w2 ) ; assertEquals ( 2 , d . getApiWayCount ( ) ) ; assertEquals ( w . nodeCount ( ) , d . getApiNodeCount ( ) ) ; Map < String , String > tags = new HashMap < > ( ) ; tags . put ( Tags . KEY_HIGHWAY , "service" ) ; w . setTags ( tags ) ; w2 . setTags ( tags ) ; d . unjoinWay ( null , w2 , true ) ; assertEquals ( n1 , w2 . getFirstNode ( ) ) ; final Node lastNode = w2 . getLastNode ( ) ; assertEquals ( n2 , lastNode ) ; assertEquals ( 2 , d . getApiWayCount ( ) ) ; assertEquals ( w . nodeCount ( ) , d . getApiNodeCount ( ) ) ; tags . clear ( ) ; tags . put ( Tags . KEY_WATERWAY , "wet" ) ; w2 . setTags ( tags ) ; d . unjoinWay ( null , w2 , true ) ; assertNotEquals ( n1 , w2 . getFirstNode ( ) ) ; assertNotEquals ( n2 , w2 . getLastNode ( ) ) ; assertEquals ( 2 , d . getApiWayCount ( ) ) ; assertEquals ( w . nodeCount ( ) + 2 , d . getApiNodeCount ( ) ) ; }
Unjoin two similar ways - nothing should happen - change tags unjoin should happen
Unjoin two similar ways - nothing should happen - change tags unjoin should happen