src/test/java/de/blau/android/osm/StorageDelegatorTest.java
/**
     * Unjoin a closed way from another one
     */
Unjoin a closed way from another one
Unjoin a closed way from another one
@Test
    public void unjoinClosedWays() {
        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);
        final Node n3 = w.getNodes().get(3);
        d.addNodeToWay(n3, w2);
        d.addNodeToWay(n1, w2); 
        assertEquals(2, d.getApiWayCount());
        assertEquals(w.nodeCount(), d.getApiNodeCount());
        assertTrue(w2.isClosed());
        d.unjoinWay(null, w2, false);
        assertNotEquals(n1, w2.getFirstNode());
        assertNotEquals(n2, w2.getNodes().get(1));
        assertNotEquals(n3, w2.getNodes().get(3));
        assertTrue(w2.isClosed());
        assertEquals(2, d.getApiWayCount());
        assertEquals(w.nodeCount() + 3, d.getApiNodeCount());
    }
@ Test public void unjoinClosedWays ( ) { 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 ) ; final Node n3 = w . getNodes ( ) . get ( 3 ) ; d . addNodeToWay ( n3 , w2 ) ; d . addNodeToWay ( n1 , w2 ) ; assertEquals ( 2 , d . getApiWayCount ( ) ) ; assertEquals ( w . nodeCount ( ) , d . getApiNodeCount ( ) ) ; assertTrue ( w2 . isClosed ( ) ) ; d . unjoinWay ( null , w2 , false ) ; assertNotEquals ( n1 , w2 . getFirstNode ( ) ) ; assertNotEquals ( n2 , w2 . getNodes ( ) . get ( 1 ) ) ; assertNotEquals ( n3 , w2 . getNodes ( ) . get ( 3 ) ) ; assertTrue ( w2 . isClosed ( ) ) ; assertEquals ( 2 , d . getApiWayCount ( ) ) ; assertEquals ( w . nodeCount ( ) + 3 , d . getApiNodeCount ( ) ) ; }
Unjoin a closed way from another one
Unjoin a closed way from another one
// close