source: josm/trunk/test/unit/org/openstreetmap/josm/gui/history/HistoryBrowserDialogTest.java@ 9602

Last change on this file since 9602 was 9602, checked in by Don-vip, 8 years ago

HistoryBrowserDialog: fix Sonar/Coverity issues + add basic unit test

File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.history;
3
4import static org.junit.Assert.assertEquals;
5
6import java.util.Date;
7
8import org.junit.Test;
9import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
10import org.openstreetmap.josm.data.osm.User;
11import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
12import org.openstreetmap.josm.data.osm.history.HistoryNode;
13import org.openstreetmap.josm.data.osm.history.HistoryRelation;
14import org.openstreetmap.josm.data.osm.history.HistoryWay;
15import org.openstreetmap.josm.tools.date.DateUtils;
16
17/**
18 * Unit tests of {@link HistoryBrowserDialog} class.
19 */
20public class HistoryBrowserDialogTest {
21
22 /**
23 * Test for {@link HistoryBrowserDialog#buildTitle}.
24 */
25 @Test
26 public void testBuildTitle() {
27 HistoryDataSet hds = new HistoryDataSet();
28 User user = User.createOsmUser(1, "");
29 Date date = DateUtils.fromString("2016-01-01");
30 hds.put(new HistoryNode(1, 1, true, user, 1, date, null));
31 assertEquals("History for node 1", HistoryBrowserDialog.buildTitle(hds.getHistory(1, OsmPrimitiveType.NODE)));
32 hds.put(new HistoryWay(1, 1, true, user, 1, date));
33 assertEquals("History for way 1", HistoryBrowserDialog.buildTitle(hds.getHistory(1, OsmPrimitiveType.WAY)));
34 hds.put(new HistoryRelation(1, 1, true, user, 1, date));
35 assertEquals("History for relation 1", HistoryBrowserDialog.buildTitle(hds.getHistory(1, OsmPrimitiveType.RELATION)));
36 }
37}
Note: See TracBrowser for help on using the repository browser.