source: josm/trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetDataSetTest.java@ 14946

Last change on this file since 14946 was 14946, checked in by GerdP, 5 years ago

see #17459: remove duplicated code in reverter corehacks
Step 1: Add needed code to core methods.
Major changes:
1) If a changeset contains multiple versions for a primitive, class ChangesetDataSet keeps the first and the last version (not just the last) and provides methods to access them, unused method getPrimitivesByModificationType() was removed
2) The changeset reader classes have a new field useAnonymousUser. If set, the user found in a changeset is replaced by the anonymous user.

File size: 2.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
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
9import java.util.Date;
10import java.util.Iterator;
11
12import org.junit.Rule;
13import org.junit.Test;
14import org.openstreetmap.josm.TestUtils;
15import org.openstreetmap.josm.data.coor.LatLon;
16import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetDataSetEntry;
17import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType;
18import org.openstreetmap.josm.data.osm.history.HistoryNode;
19import org.openstreetmap.josm.testutils.JOSMTestRules;
20import org.openstreetmap.josm.tools.Logging;
21
22import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
23
24/**
25 * Unit tests for class {@link ChangesetDataSet}.
26 */
27public 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}
Note: See TracBrowser for help on using the repository browser.