1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.history;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 |
|
---|
6 | import java.util.Date;
|
---|
7 |
|
---|
8 | import org.junit.BeforeClass;
|
---|
9 | import org.junit.Test;
|
---|
10 | import org.openstreetmap.josm.JOSMFixture;
|
---|
11 | import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
|
---|
12 | import org.openstreetmap.josm.data.osm.User;
|
---|
13 | import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
|
---|
14 | import org.openstreetmap.josm.data.osm.history.HistoryNode;
|
---|
15 | import org.openstreetmap.josm.data.osm.history.HistoryRelation;
|
---|
16 | import org.openstreetmap.josm.data.osm.history.HistoryWay;
|
---|
17 | import org.openstreetmap.josm.tools.date.DateUtils;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Unit tests of {@link HistoryBrowserDialog} class.
|
---|
21 | */
|
---|
22 | public class HistoryBrowserDialogTest {
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Setup test.
|
---|
26 | */
|
---|
27 | @BeforeClass
|
---|
28 | public static void setUpBeforeClass() {
|
---|
29 | JOSMFixture.createUnitTestFixture().init();
|
---|
30 | }
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Test for {@link HistoryBrowserDialog#buildTitle}.
|
---|
34 | */
|
---|
35 | @Test
|
---|
36 | public void testBuildTitle() {
|
---|
37 | HistoryDataSet hds = new HistoryDataSet();
|
---|
38 | User user = User.createOsmUser(1, "");
|
---|
39 | Date date = DateUtils.fromString("2016-01-01");
|
---|
40 | hds.put(new HistoryNode(1, 1, true, user, 1, date, null));
|
---|
41 | assertEquals("History for node 1", HistoryBrowserDialog.buildTitle(hds.getHistory(1, OsmPrimitiveType.NODE)));
|
---|
42 | hds.put(new HistoryWay(1, 1, true, user, 1, date));
|
---|
43 | assertEquals("History for way 1", HistoryBrowserDialog.buildTitle(hds.getHistory(1, OsmPrimitiveType.WAY)));
|
---|
44 | hds.put(new HistoryRelation(1, 1, true, user, 1, date));
|
---|
45 | assertEquals("History for relation 1", HistoryBrowserDialog.buildTitle(hds.getHistory(1, OsmPrimitiveType.RELATION)));
|
---|
46 | }
|
---|
47 | }
|
---|