src/test/java/de/blau/android/osm/BasicStuffTest.java
/**
     * Remove an end node from a closed way
     */
Remove an end node from a closed way
Remove an end node from a closed way
@Test
    public void deleteEndNodeFromClosedWay() {
        try {
            final CountDownLatch signal = new CountDownLatch(1);
            Logic logic = App.getLogic();
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            InputStream is = loader.getResourceAsStream("closedways.osm");
            logic.readOsmFile(ApplicationProvider.getApplicationContext(), is, false, new SignalHandler(signal));
            try {
                signal.await(ApiTest.TIMEOUT, TimeUnit.SECONDS); 
            } catch (InterruptedException e) { 
                Assert.fail(e.getMessage());
            }
            StorageDelegator delegator = App.getDelegator();
            Way way0 = (Way) delegator.getOsmElement(Way.NAME, 1547L);
            Assert.assertNotNull(way0);
            Assert.assertEquals(5, way0.getNodes().size());
            delegator.removeNode(way0.getFirstNode());
            Assert.assertNotNull(way0);
            Assert.assertEquals(OsmElement.STATE_MODIFIED, way0.getState());
            Assert.assertTrue(way0.isClosed());
            Assert.assertEquals(4, way0.getNodes().size());
        } catch (Exception igit) {
            Assert.fail(igit.getMessage());
        }
    }
@ Test public void deleteEndNodeFromClosedWay ( ) { try { final CountDownLatch signal = new CountDownLatch ( 1 ) ; Logic logic = App . getLogic ( ) ; ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; InputStream is = loader . getResourceAsStream ( "closedways.osm" ) ; logic . readOsmFile ( ApplicationProvider . getApplicationContext ( ) , is , false , new SignalHandler ( signal ) ) ; try { signal . await ( ApiTest . TIMEOUT , TimeUnit . SECONDS ) ; } catch ( InterruptedException e ) { Assert . fail ( e . getMessage ( ) ) ; } StorageDelegator delegator = App . getDelegator ( ) ; Way way0 = ( Way ) delegator . getOsmElement ( Way . NAME , 1547L ) ; Assert . assertNotNull ( way0 ) ; Assert . assertEquals ( 5 , way0 . getNodes ( ) . size ( ) ) ; delegator . removeNode ( way0 . getFirstNode ( ) ) ; Assert . assertNotNull ( way0 ) ; Assert . assertEquals ( OsmElement . STATE_MODIFIED , way0 . getState ( ) ) ; Assert . assertTrue ( way0 . isClosed ( ) ) ; Assert . assertEquals ( 4 , way0 . getNodes ( ) . size ( ) ) ; } catch ( Exception igit ) { Assert . fail ( igit . getMessage ( ) ) ; } }
Remove an end node from a closed way
Remove an end node from a closed way
// NOSONAR // NOSONAR // 2 node closed way, 1 node will silently get deleted when parsing