1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.io;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 |
|
---|
6 | import java.util.Arrays;
|
---|
7 | import java.util.Collections;
|
---|
8 |
|
---|
9 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
10 | import org.junit.jupiter.api.Test;
|
---|
11 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
12 |
|
---|
13 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Unit tests of {@link ChangesetCommentModel} class.
|
---|
17 | */
|
---|
18 | class 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 | }
|
---|