1 | // License: GPL. For details, see LICENSE file. |
---|
2 | package org.openstreetmap.josm.gui.io; |
---|
3 | |
---|
4 | import static org.junit.Assert.assertEquals; |
---|
5 | |
---|
6 | import java.util.Arrays; |
---|
7 | import java.util.Collections; |
---|
8 | |
---|
9 | import org.junit.Rule; |
---|
10 | import org.junit.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 | public class ChangesetCommentModelTest { |
---|
19 | |
---|
20 | /** |
---|
21 | * Setup tests |
---|
22 | */ |
---|
23 | @Rule |
---|
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 | public 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(" #foo "); |
---|
43 | assertEquals(Arrays.asList("#foo"), model.findHashTags()); |
---|
44 | model.setComment(" #foo #bar baz"); |
---|
45 | assertEquals(Arrays.asList("#foo", "#bar"), model.findHashTags()); |
---|
46 | } |
---|
47 | } |
---|