source: josm/trunk/test/unit/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerTest.java@ 13846

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

fix unit test

  • Property svn:eol-style set to native
File size: 5.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.changeset;
3
4import static org.junit.Assert.assertNotNull;
5
6import java.util.Collections;
7import java.util.List;
8
9import org.junit.Rule;
10import org.junit.Test;
11import org.openstreetmap.josm.data.osm.Changeset;
12import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.CancelAction;
13import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.ChangesetDetailViewSynchronizer;
14import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.CloseSelectedChangesetsAction;
15import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.DownloadMyChangesets;
16import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.DownloadSelectedChangesetContentAction;
17import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.DownloadSelectedChangesetsAction;
18import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.QueryAction;
19import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.RemoveFromCacheAction;
20import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.ShowDetailAction;
21import org.openstreetmap.josm.testutils.JOSMTestRules;
22
23import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
24
25/**
26 * Unit tests of {@link ChangesetCacheManager} class.
27 */
28public class ChangesetCacheManagerTest {
29
30 /**
31 * Setup tests
32 */
33 @Rule
34 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
35 public JOSMTestRules test = new JOSMTestRules().preferences().platform();
36
37 /**
38 * Unit test of {@link ChangesetCacheManager#destroyInstance}.
39 */
40 @Test
41 public void testDestroyInstance() {
42 ChangesetCacheManager.destroyInstance();
43 }
44
45 /**
46 * Unit test of {@link ChangesetCacheManager#buildButtonPanel},
47 * {@link ChangesetCacheManager#buildToolbarPanel}.
48 * {@link ChangesetCacheManager#buildModel}.
49 */
50 @Test
51 public void testBuild() {
52 assertNotNull(ChangesetCacheManager.buildButtonPanel());
53 assertNotNull(ChangesetCacheManager.buildToolbarPanel());
54 assertNotNull(ChangesetCacheManager.buildModel());
55 }
56
57 /**
58 * Unit test of {@link ChangesetCacheManager.ChangesetDetailViewSynchronizer} class.
59 */
60 @Test
61 public void testChangesetDetailViewSynchronizer() {
62 new ChangesetDetailViewSynchronizer(new ChangesetCacheManagerModel(null) {
63 @Override
64 public List<Changeset> getSelectedChangesets() {
65 return Collections.emptyList();
66 }
67 }).valueChanged(null);
68
69 new ChangesetDetailViewSynchronizer(new ChangesetCacheManagerModel(null) {
70 @Override
71 public List<Changeset> getSelectedChangesets() {
72 return Collections.singletonList(new Changeset());
73 }
74 }).valueChanged(null);
75 }
76
77 /**
78 * Unit test of {@link ChangesetCacheManager.CancelAction} class.
79 */
80 @Test
81 public void testCancelAction() {
82 new CancelAction().actionPerformed(null);
83 }
84
85 /**
86 * Unit test of {@link ChangesetCacheManager.CloseSelectedChangesetsAction} class.
87 */
88 @Test
89 public void testCloseSelectedChangesetsAction() {
90 CloseSelectedChangesetsAction action = new CloseSelectedChangesetsAction(new ChangesetCacheManagerModel(null) {
91 @Override
92 public List<Changeset> getSelectedChangesets() {
93 return Collections.singletonList(new Changeset());
94 }
95 });
96 action.valueChanged(null);
97 action.actionPerformed(null);
98 }
99
100 /**
101 * Unit test of {@link ChangesetCacheManager.DownloadMyChangesets} class.
102 */
103 @Test
104 public void testDownloadMyChangesets() {
105 new DownloadMyChangesets().actionPerformed(null);
106 }
107
108 /**
109 * Unit test of {@link ChangesetCacheManager.DownloadSelectedChangesetContentAction} class.
110 */
111 @Test
112 public void testDownloadSelectedChangesetContentAction() {
113 DownloadSelectedChangesetContentAction action = new DownloadSelectedChangesetContentAction(ChangesetCacheManager.buildModel());
114 action.valueChanged(null);
115 action.actionPerformed(null);
116 }
117
118 /**
119 * Unit test of {@link ChangesetCacheManager.DownloadSelectedChangesetsAction} class.
120 */
121 @Test
122 public void testDownloadSelectedChangesetsAction() {
123 DownloadSelectedChangesetsAction action = new DownloadSelectedChangesetsAction(ChangesetCacheManager.buildModel());
124 action.valueChanged(null);
125 action.actionPerformed(null);
126 }
127
128 /**
129 * Unit test of {@link ChangesetCacheManager.QueryAction} class.
130 */
131 @Test
132 public void testQueryAction() {
133 new QueryAction().actionPerformed(null);
134 }
135
136 /**
137 * Unit test of {@link ChangesetCacheManager.RemoveFromCacheAction} class.
138 */
139 @Test
140 public void testRemoveFromCacheAction() {
141 RemoveFromCacheAction action = new RemoveFromCacheAction(ChangesetCacheManager.buildModel());
142 action.valueChanged(null);
143 action.actionPerformed(null);
144 }
145
146 /**
147 * Unit test of {@link ChangesetCacheManager.ShowDetailAction} class.
148 */
149 @Test
150 public void testShowDetailAction() {
151 new ShowDetailAction(ChangesetCacheManager.buildModel()).actionPerformed(null);
152 }
153}
Note: See TracBrowser for help on using the repository browser.