Ignore:
Timestamp:
2017-05-01T21:41:20+02:00 (8 years ago)
Author:
Don-vip
Message:

add more unit tests, javadoc

Location:
trunk/test/unit/org/openstreetmap/josm/data/osm
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetTest.java

    r11440 r12036  
    22package org.openstreetmap.josm.data.osm;
    33
     4import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertTrue;
     6
    47import java.util.Arrays;
     8import java.util.HashSet;
    59import java.util.List;
    610
     
    5862
    5963    /**
     64     * Unit test of methods {@link DataSet#addChangeSetTag} / {@link DataSet#getChangeSetTags}.
     65     */
     66    @Test
     67    public void testChangesetTags() {
     68        final DataSet ds = new DataSet();
     69        assertTrue(ds.getChangeSetTags().isEmpty());
     70        ds.addChangeSetTag("foo", "bar");
     71        assertEquals("bar", ds.getChangeSetTags().get("foo"));
     72    }
     73
     74    /**
     75     * Unit test of methods {@link DataSet#allNonDeletedPrimitives}
     76     *                    / {@link DataSet#allNonDeletedCompletePrimitives}
     77     *                    / {@link DataSet#allNonDeletedPhysicalPrimitives}.
     78     */
     79    @Test
     80    public void testAllNonDeleted() {
     81        final DataSet ds = new DataSet();
     82        assertTrue(ds.allNonDeletedPrimitives().isEmpty());
     83        assertTrue(ds.allNonDeletedCompletePrimitives().isEmpty());
     84        assertTrue(ds.allNonDeletedPhysicalPrimitives().isEmpty());
     85
     86        Node n1 = new Node(1); n1.setCoor(LatLon.NORTH_POLE); n1.setDeleted(true); n1.setIncomplete(false); ds.addPrimitive(n1);
     87        Node n2 = new Node(2); n2.setCoor(LatLon.NORTH_POLE); n2.setDeleted(false); n2.setIncomplete(false); ds.addPrimitive(n2);
     88        Node n3 = new Node(3); n3.setCoor(LatLon.NORTH_POLE); n3.setDeleted(false); n3.setIncomplete(true); ds.addPrimitive(n3);
     89
     90        Way w1 = new Way(1); w1.setDeleted(true); w1.setIncomplete(false); ds.addPrimitive(w1);
     91        Way w2 = new Way(2); w2.setDeleted(false); w2.setIncomplete(false); ds.addPrimitive(w2);
     92        Way w3 = new Way(3); w3.setDeleted(false); w3.setIncomplete(true); ds.addPrimitive(w3);
     93
     94        Relation r1 = new Relation(1); r1.setDeleted(true); r1.setIncomplete(false); ds.addPrimitive(r1);
     95        Relation r2 = new Relation(2); r2.setDeleted(false); r2.setIncomplete(false); ds.addPrimitive(r2);
     96        Relation r3 = new Relation(3); r3.setDeleted(false); r3.setIncomplete(true); ds.addPrimitive(r3);
     97
     98        assertEquals(new HashSet<>(Arrays.asList(n2, n3, w2, w3, r2, r3)),
     99                new HashSet<>(ds.allNonDeletedPrimitives()));
     100        assertEquals(new HashSet<>(Arrays.asList(n2, w2, r2)),
     101                new HashSet<>(ds.allNonDeletedCompletePrimitives()));
     102        assertEquals(new HashSet<>(Arrays.asList(n2, w2)),
     103                new HashSet<>(ds.allNonDeletedPhysicalPrimitives()));
     104    }
     105
     106    /**
    60107     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/14186">Bug #14186</a>.
    61108     */
Note: See TracChangeset for help on using the changeset viewer.