1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertFalse;
|
---|
6 | import static org.junit.Assert.assertTrue;
|
---|
7 | import static org.junit.Assert.fail;
|
---|
8 |
|
---|
9 | import java.util.Date;
|
---|
10 | import java.util.Iterator;
|
---|
11 |
|
---|
12 | import org.junit.Rule;
|
---|
13 | import org.junit.Test;
|
---|
14 | import org.openstreetmap.josm.TestUtils;
|
---|
15 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
16 | import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetDataSetEntry;
|
---|
17 | import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType;
|
---|
18 | import org.openstreetmap.josm.data.osm.history.HistoryNode;
|
---|
19 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
20 | import org.openstreetmap.josm.tools.Logging;
|
---|
21 |
|
---|
22 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Unit tests for class {@link ChangesetDataSet}.
|
---|
26 | */
|
---|
27 | public class ChangesetDataSetTest {
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Setup test.
|
---|
31 | */
|
---|
32 | @Rule
|
---|
33 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
34 | public JOSMTestRules test = new JOSMTestRules();
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Unit test of method {@link ChangesetDataSet#iterator}.
|
---|
38 | */
|
---|
39 | @Test
|
---|
40 | public void testIterator() {
|
---|
41 | final ChangesetDataSet cds = new ChangesetDataSet();
|
---|
42 | HistoryNode prim1 = new HistoryNode(1, 1, true, User.getAnonymous(), 1, new Date(), LatLon.ZERO);
|
---|
43 | cds.put(prim1, ChangesetModificationType.CREATED);
|
---|
44 | Iterator<ChangesetDataSetEntry> it = cds.iterator();
|
---|
45 | assertTrue(it.hasNext());
|
---|
46 | ChangesetDataSetEntry cdse = it.next();
|
---|
47 | assertEquals(ChangesetModificationType.CREATED, cdse.getModificationType());
|
---|
48 | assertEquals(prim1, cdse.getPrimitive());
|
---|
49 | assertFalse(it.hasNext());
|
---|
50 | try {
|
---|
51 | it.remove();
|
---|
52 | fail("remove should throw UnsupportedOperationException");
|
---|
53 | } catch (UnsupportedOperationException e) {
|
---|
54 | Logging.trace(e.getMessage());
|
---|
55 | }
|
---|
56 | }
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * Unit test of {@link ChangesetModificationType} enum.
|
---|
60 | */
|
---|
61 | @Test
|
---|
62 | public void testEnumChangesetModificationType() {
|
---|
63 | TestUtils.superficialEnumCodeCoverage(ChangesetModificationType.class);
|
---|
64 | }
|
---|
65 | }
|
---|