source: josm/trunk/test/unit/org/openstreetmap/josm/gui/io/ChangesetCommentModelTest.java@ 17536

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

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.io;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5
6import java.util.Arrays;
7import java.util.Collections;
8
9import org.junit.jupiter.api.extension.RegisterExtension;
10import org.junit.jupiter.api.Test;
11import org.openstreetmap.josm.testutils.JOSMTestRules;
12
13import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
14
15/**
16 * Unit tests of {@link ChangesetCommentModel} class.
17 */
18class ChangesetCommentModelTest {
19
20 /**
21 * Setup tests
22 */
23 @RegisterExtension
24 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
25 public JOSMTestRules test = new JOSMTestRules();
26
27 /**
28 * Test of {@link ChangesetCommentModel#findHashTags}.
29 */
30 @Test
31 void testFindHashTags() {
32 ChangesetCommentModel model = new ChangesetCommentModel();
33 assertEquals(Collections.emptyList(), model.findHashTags());
34 model.setComment(" ");
35 assertEquals(Collections.emptyList(), model.findHashTags());
36 model.setComment(" #");
37 assertEquals(Collections.emptyList(), model.findHashTags());
38 model.setComment(" # ");
39 assertEquals(Collections.emptyList(), model.findHashTags());
40 model.setComment(" https://example.com/#map ");
41 assertEquals(Collections.emptyList(), model.findHashTags());
42 model.setComment("#59606086");
43 assertEquals(Collections.emptyList(), model.findHashTags());
44 model.setComment(" #foo ");
45 assertEquals(Arrays.asList("#foo"), model.findHashTags());
46 model.setComment(" #foo #bar baz");
47 assertEquals(Arrays.asList("#foo", "#bar"), model.findHashTags());
48 model.setComment(" #foo, #bar, baz");
49 assertEquals(Arrays.asList("#foo", "#bar"), model.findHashTags());
50 model.setComment(" #foo; #bar; baz");
51 assertEquals(Arrays.asList("#foo", "#bar"), model.findHashTags());
52 model.setComment("#hotosm-project-4773 #DRONEBIRD #OsakaQuake2018 #AOYAMAVISION");
53 assertEquals(Arrays.asList("#hotosm-project-4773", "#DRONEBIRD", "#OsakaQuake2018", "#AOYAMAVISION"), model.findHashTags());
54 }
55}
Note: See TracBrowser for help on using the repository browser.