source: josm/trunk/test/unit/org/openstreetmap/josm/gui/io/UploadDialogModelTest.java@ 18173

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

fix #20690 - fix #21240 - Refactoring of UploadDialog, HistoryComboBox and AutoCompletingComboBox (patch by marcello)

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.io;
3
4import static org.junit.jupiter.api.Assertions.assertNotNull;
5import static org.junit.jupiter.api.Assertions.assertNull;
6import static org.junit.jupiter.api.Assertions.assertEquals;
7
8import org.junit.jupiter.api.extension.RegisterExtension;
9import org.junit.jupiter.api.Test;
10
11import org.openstreetmap.josm.data.osm.DataSet;
12import org.openstreetmap.josm.testutils.JOSMTestRules;
13
14/**
15 * Unit tests of {@link UploadDialogModel} class.
16 */
17public class UploadDialogModelTest {
18 /**
19 * Setup tests
20 */
21 @RegisterExtension
22 public JOSMTestRules test = new JOSMTestRules().preferences().main();
23
24 /**
25 * Test of {@link UploadDialogModel}.
26 */
27 @Test
28 void testUploadDialogModel() {
29 assertNotNull(new UploadDialogModel());
30 }
31
32 @Test
33 void testFindHashTags() {
34 UploadDialogModel model = new UploadDialogModel();
35
36 assertNull(model.findHashTags(" "));
37 assertNull(model.findHashTags(" #"));
38 assertNull(model.findHashTags(" # "));
39 assertNull(model.findHashTags(" https://example.com/#map "));
40 assertNull(model.findHashTags("#59606086"));
41 assertEquals("#foo", model.findHashTags(" #foo "));
42 assertEquals("#foo;#bar", model.findHashTags(" #foo #bar baz"));
43 assertEquals("#foo;#bar", model.findHashTags(" #foo, #bar, baz"));
44 assertEquals("#foo;#bar", model.findHashTags(" #foo; #bar; baz"));
45 assertEquals("#hotosm-project-4773;#DRONEBIRD;#OsakaQuake2018;#AOYAMAVISION",
46 model.findHashTags("#hotosm-project-4773 #DRONEBIRD #OsakaQuake2018 #AOYAMAVISION"));
47 }
48
49 @Test
50 void testCommentWithHashtags() {
51 UploadDialogModel model = new UploadDialogModel();
52 model.add("comment", "comment with a #hashtag");
53 assertEquals("#hashtag", model.getValue("hashtags"));
54 }
55
56 @Test
57 void testGetCommentWithDataSetHashTag() {
58 assertEquals("", UploadDialogModel.addHashTagsFromDataSet(null, null));
59 DataSet ds = new DataSet();
60 assertEquals("foo", UploadDialogModel.addHashTagsFromDataSet("foo", ds));
61 ds.getChangeSetTags().put("hashtags", "bar");
62 assertEquals("foo #bar", UploadDialogModel.addHashTagsFromDataSet("foo", ds));
63 ds.getChangeSetTags().put("hashtags", "bar;baz;#bar");
64 assertEquals("foo #bar #baz", UploadDialogModel.addHashTagsFromDataSet("foo", ds));
65 }
66
67}
Note: See TracBrowser for help on using the repository browser.