src/test/java/de/blau/android/osm/StorageDelegatorTest.java
/**
     * Load some data modify a way and a node, then merge some data
     */
Load some data modify a way and a node, then merge some data
Load some data modify a way and a node then merge some data
@Test
    public void mergeData() {
        StorageDelegator d = new StorageDelegator();
        d.setCurrentStorage(PbfTest.read());
        assertEquals(0, d.getApiElementCount());
        final int nodeCount = 258905;
        assertEquals(nodeCount, d.getCurrentStorage().getNodeCount());
        final int wayCount = 26454;
        assertEquals(wayCount, d.getCurrentStorage().getWayCount());
        assertEquals(751, d.getCurrentStorage().getRelationCount());
        Way w = (Way) d.getOsmElement(Way.NAME, 571067343L);
        assertNotNull(w);
        SortedMap<String, String> tags = new TreeMap<>(w.getTags());
        tags.put("test", "merge");
        d.getUndo().createCheckpoint("merge");
        d.setTags(w, tags);
        assertEquals(1, d.getApiElementCount());
        Node n = (Node) d.getOsmElement(Node.NAME, 761534749L);
        assertNotNull(n);
        n.setLat(toE7(47.1187142));
        n.setLon(toE7(9.5430107));
        d.insertElementSafe(n);
        StorageDelegator d2 = new StorageDelegator();
        Way w2 = DelegatorUtil.addWayToStorage(d2, true);
        d.mergeData(d2.getCurrentStorage(), null);
        assertNotNull(d.getOsmElement(Way.NAME, 571067343L));
        assertNotNull(d.getOsmElement(Way.NAME, w2.getOsmId()));
        assertNotNull(d.getOsmElement(Node.NAME, 761534749L));
        assertEquals(nodeCount + 4L, d.getCurrentStorage().getNodeCount());
        assertEquals(wayCount + 1L, d.getCurrentStorage().getWayCount());
    }
@ Test public void mergeData ( ) { StorageDelegator d = new StorageDelegator ( ) ; d . setCurrentStorage ( PbfTest . read ( ) ) ; assertEquals ( 0 , d . getApiElementCount ( ) ) ; final int nodeCount = 258905 ; assertEquals ( nodeCount , d . getCurrentStorage ( ) . getNodeCount ( ) ) ; final int wayCount = 26454 ; assertEquals ( wayCount , d . getCurrentStorage ( ) . getWayCount ( ) ) ; assertEquals ( 751 , d . getCurrentStorage ( ) . getRelationCount ( ) ) ; Way w = ( Way ) d . getOsmElement ( Way . NAME , 571067343L ) ; assertNotNull ( w ) ; SortedMap < String , String > tags = new TreeMap < > ( w . getTags ( ) ) ; tags . put ( "test" , "merge" ) ; d . getUndo ( ) . createCheckpoint ( "merge" ) ; d . setTags ( w , tags ) ; assertEquals ( 1 , d . getApiElementCount ( ) ) ; Node n = ( Node ) d . getOsmElement ( Node . NAME , 761534749L ) ; assertNotNull ( n ) ; n . setLat ( toE7 ( 47.1187142 ) ) ; n . setLon ( toE7 ( 9.5430107 ) ) ; d . insertElementSafe ( n ) ; StorageDelegator d2 = new StorageDelegator ( ) ; Way w2 = DelegatorUtil . addWayToStorage ( d2 , true ) ; d . mergeData ( d2 . getCurrentStorage ( ) , null ) ; assertNotNull ( d . getOsmElement ( Way . NAME , 571067343L ) ) ; assertNotNull ( d . getOsmElement ( Way . NAME , w2 . getOsmId ( ) ) ) ; assertNotNull ( d . getOsmElement ( Node . NAME , 761534749L ) ) ; assertEquals ( nodeCount + 4L , d . getCurrentStorage ( ) . getNodeCount ( ) ) ; assertEquals ( wayCount + 1L , d . getCurrentStorage ( ) . getWayCount ( ) ) ; }
Load some data modify a way and a node, then merge some data
Load some data modify a way and a node then merge some data