Ignore:
Timestamp:
2017-04-22T15:23:07+02:00 (7 years ago)
Author:
Don-vip
Message:

add unit tests

File:
1 edited

Legend:

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

    r11878 r11973  
    22package org.openstreetmap.josm.data.osm;
    33
     4import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertFalse;
     6import static org.junit.Assert.assertTrue;
     7import static org.junit.Assert.fail;
     8
    49import java.util.Date;
     10import java.util.Iterator;
    511import java.util.Set;
    612
    7 import org.junit.Assert;
    813import org.junit.Rule;
    914import org.junit.Test;
    1015import org.openstreetmap.josm.Main;
    1116import org.openstreetmap.josm.data.coor.LatLon;
     17import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetDataSetEntry;
    1218import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType;
    1319import org.openstreetmap.josm.data.osm.history.HistoryNode;
     
    3844        try {
    3945            cds.getPrimitivesByModificationType(null);
    40             Assert.fail("Should have thrown an IllegalArgumentException as we gave a null argument.");
     46            fail("Should have thrown an IllegalArgumentException as we gave a null argument.");
    4147        } catch (IllegalArgumentException e) {
    4248            Main.trace(e);
     
    4551
    4652        // empty object, a modification type => empty list
    47         Assert.assertTrue(
     53        assertTrue(
    4854            "Empty data set should produce an empty list.",
    4955            cds.getPrimitivesByModificationType(
     
    6167        Set<HistoryOsmPrimitive> result = cds.getPrimitivesByModificationType(
    6268                    ChangesetModificationType.CREATED);
    63         Assert.assertEquals("We should have found only one item.", 1, result.size());
    64         Assert.assertTrue("The item found is prim1.", result.contains(prim1));
     69        assertEquals("We should have found only one item.", 1, result.size());
     70        assertTrue("The item found is prim1.", result.contains(prim1));
     71    }
     72
     73    /**
     74     * Unit test of method {@link ChangesetDataSet#iterator}.
     75     */
     76    @Test
     77    public void testIterator() {
     78        final ChangesetDataSet cds = new ChangesetDataSet();
     79        HistoryNode prim1 = new HistoryNode(1, 1, true, User.getAnonymous(), 1, new Date(), LatLon.ZERO);
     80        cds.put(prim1, ChangesetModificationType.CREATED);
     81        Iterator<ChangesetDataSetEntry> it = cds.iterator();
     82        assertTrue(it.hasNext());
     83        ChangesetDataSetEntry cdse = it.next();
     84        assertEquals(ChangesetModificationType.CREATED, cdse.getModificationType());
     85        assertEquals(prim1, cdse.getPrimitive());
     86        assertFalse(it.hasNext());
    6587    }
    6688}
Note: See TracChangeset for help on using the changeset viewer.