Skip to content

Commit a7b1f1c

Browse files
committed
Fix remaining assertion parameter order errors in navigator tests
Complete the JUnit 4 to JUnit 5 assertion parameter order migration: - SorterTest.java: Fix 1 assertEquals call - WorkingSetTest.java: Fix 11 assertTrue and assertEquals calls - JstPipelineTest.java: Fix 2 assertEquals and 1 assertTrue call - FoldersAsProjectsContributionTest.java: Fix 6 assertFalse and 2 assertTrue calls - NestedResourcesTests.java: Fix 3 assertTrue calls - PathComparatorTest.java: Fix 1 assertTrue call - ResourceMgmtActionProviderTests.java: Fix 1 assertTrue call All assertions now follow JUnit 5 convention with message parameter last. This resolves all remaining compilation errors in PR eclipse-platform#3500.
1 parent 2c25088 commit a7b1f1c

File tree

7 files changed

+53
-55
lines changed

7 files changed

+53
-55
lines changed

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/SorterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void testSorterMissing() throws Exception {
7575

7676
// We should not get any notification because of the way that
7777
// sorters are found
78-
assertEquals("Status Count: " + _statusCount, 0, _statusCount);
78+
assertEquals(0, _statusCount, "Status Count: " + _statusCount);
7979
}
8080

8181
// bug 231855 [CommonNavigator] CommonViewerSorter does not support

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/WorkingSetTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void testEmptyWindowWorkingSet() throws Exception {
7676
l.propertyChange(event);
7777

7878
TreeItem[] items = _viewer.getTree().getItems();
79-
assertTrue("There should be some items.", items.length > 0);
79+
assertTrue(items.length > 0, "There should be some items.");
8080
assertEquals(null, _commonNavigator.getWorkingSetLabel());
8181
}
8282

@@ -107,7 +107,7 @@ public void testMissingProjectsInWorkingSet() throws Exception {
107107
TreeItem[] items = _viewer.getTree().getItems();
108108
// The bug is here where the first item is a IFile, not the enclosing
109109
// project
110-
assertEquals("First item needs to be project", _p1, items[0].getData());
110+
assertEquals(_p1, items[0].getData(), "First item needs to be project");
111111
assertEquals("ws1", _commonNavigator.getWorkingSetLabel());
112112
}
113113

@@ -138,7 +138,7 @@ public void testTopLevelWorkingSet() throws Exception {
138138
TreeItem[] items = _viewer.getTree().getItems();
139139
// The bug is here where the first item is a IFile, not the enclosing
140140
// project
141-
assertEquals("First item needs to be working set", workingSet, items[0].getData());
141+
assertEquals(workingSet, items[0].getData(), "First item needs to be working set");
142142
assertEquals("ws1", _commonNavigator.getWorkingSetLabel());
143143

144144
// bug 268250 [CommonNavigator] Project labels missing in Project
@@ -181,19 +181,19 @@ public void testTopLevelChange() throws Exception {
181181

182182
TreeItem[] items = _viewer.getTree().getItems();
183183

184-
assertEquals("First item needs to be working set", workingSet, items[0].getData());
184+
assertEquals(workingSet, items[0].getData(), "First item needs to be working set");
185185

186186
extensionStateModel.setBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, false);
187187
refreshViewer();
188188

189189
items = _viewer.getTree().getItems();
190-
assertEquals("First item needs to be project", _p1, items[0].getData());
190+
assertEquals(_p1, items[0].getData(), "First item needs to be project");
191191

192192
extensionStateModel.setBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, true);
193193
refreshViewer();
194194

195195
items = _viewer.getTree().getItems();
196-
assertEquals("First item needs to be working set", workingSet, items[0].getData());
196+
assertEquals(workingSet, items[0].getData(), "First item needs to be working set");
197197

198198
// Restore active working sets
199199
activePage.setWorkingSets(activeWorkingSets);
@@ -265,7 +265,7 @@ public void testWorkingSetFilter() throws Exception {
265265
break;
266266
}
267267
}
268-
assertTrue("Working set filter is gone, oh my!", found);
268+
assertTrue(found, "Working set filter is gone, oh my!");
269269
}
270270

271271
// Bug 224703 - Project explorer doesn't show recreated working set
@@ -343,14 +343,14 @@ public void testOtherProjectWorkingSet() throws Exception {
343343
_viewer.expandAll();
344344

345345
TreeItem[] items = _viewer.getTree().getItems();
346-
assertEquals("Missing working set or 'other projects'", 2, items.length);
346+
assertEquals(2, items.length, "Missing working set or 'other projects'");
347347

348-
assertEquals("First item needs to be working set", workingSet, items[0].getData());
348+
assertEquals(workingSet, items[0].getData(), "First item needs to be working set");
349349
assertEquals(workingSet, items[0].getData());
350350
assertEquals(_p1, items[0].getItem(0).getData());
351351

352-
assertEquals("Last item needs to be 'other project'", WorkingSetsContentProvider.OTHERS_WORKING_SET,
353-
items[1].getData());
352+
assertEquals(WorkingSetsContentProvider.OTHERS_WORKING_SET, items[1].getData(),
353+
"Last item needs to be 'other project'");
354354
assertEquals(_p1.getWorkspace().getRoot().getProjects().length - 1, items[1].getItemCount());
355355

356356
// Put all projects in same working set to disable "others"
@@ -361,7 +361,7 @@ public void testOtherProjectWorkingSet() throws Exception {
361361
_viewer.expandAll();
362362

363363
items = _viewer.getTree().getItems();
364-
assertEquals("Should be the single working set", 1, items.length);
364+
assertEquals(1, items.length, "Should be the single working set");
365365
assertEquals(workingSet, items[0].getData());
366366

367367
// Remove project from ws to make "other projects" reappear
@@ -372,14 +372,14 @@ public void testOtherProjectWorkingSet() throws Exception {
372372
_viewer.expandAll();
373373

374374
items = _viewer.getTree().getItems();
375-
assertEquals("Missing working set or 'other projects'", 2, items.length);
375+
assertEquals(2, items.length, "Missing working set or 'other projects'");
376376

377-
assertEquals("First item needs to be working set", workingSet, items[0].getData());
377+
assertEquals(workingSet, items[0].getData(), "First item needs to be working set");
378378
assertEquals(workingSet, items[0].getData());
379379
assertEquals(_p1, items[0].getItem(0).getData());
380380

381-
assertEquals("Last item needs to be 'other project'", WorkingSetsContentProvider.OTHERS_WORKING_SET,
382-
items[1].getData());
381+
assertEquals(WorkingSetsContentProvider.OTHERS_WORKING_SET, items[1].getData(),
382+
"Last item needs to be 'other project'");
383383
assertEquals(_p1.getWorkspace().getRoot().getProjects().length - 1, items[1].getItemCount());
384384
}
385385

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/jst/JstPipelineTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public void testJstPipeline() throws Exception {
6565

6666
// Note this test will fail showing only one if the JDT stuff
6767
// is not included in the executing bundles (which it normally is)
68-
assertEquals("There should be 3 visible extensions for the pipeline viewer.", 3,
69-
_contentService.getVisibleExtensionIds().length);
68+
assertEquals(3, _contentService.getVisibleExtensionIds().length,
69+
"There should be 3 visible extensions for the pipeline viewer.");
7070

7171
_contentService.getActivationService().activateExtensions(
7272
new String[] { COMMON_NAVIGATOR_RESOURCE_EXT, COMMON_NAVIGATOR_JAVA_EXT, TEST_CONTENT_JST }, true);
@@ -78,10 +78,10 @@ public void testJstPipeline() throws Exception {
7878

7979
TreeItem[] rootItems = _viewer.getTree().getItems();
8080

81-
assertEquals("There should be " + _projectCount + " item(s).", _projectCount, rootItems.length); //$NON-NLS-1$
81+
assertEquals(_projectCount, rootItems.length, "There should be " + _projectCount + " item(s)."); //$NON-NLS-1$
8282

83-
assertTrue("The root object should be an IJavaProject, which is IAdaptable.", //$NON-NLS-1$
84-
rootItems[0].getData() instanceof IAdaptable);
83+
assertTrue(rootItems[0].getData() instanceof IAdaptable, //$NON-NLS-1$
84+
"The root object should be an IJavaProject, which is IAdaptable.");
8585

8686
IProject adaptedProject = ((IAdaptable) rootItems[_projectInd].getData()).getAdapter(IProject.class);
8787
assertEquals(_project, adaptedProject);

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/resources/FoldersAsProjectsContributionTest.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ public void notAFolder() {
6262
String notAFolder = "Some string";
6363
IMenuManager manager = menuManager();
6464
provider(new StructuredSelection(notAFolder)).fillContextMenu(manager);
65-
assertFalse("SelectProjectForFolderAction contributions were added on not an adaptable-to-IFolder selection",
66-
contributionAdded(manager, SelectProjectForFolderAction.class));
67-
assertFalse("OpenFolderAsProjectAction contributions were added on not an adaptable-to-IFolder selection",
68-
contributionAdded(manager, OpenFolderAsProjectAction.class));
65+
assertFalse(contributionAdded(manager, SelectProjectForFolderAction.class),
66+
"SelectProjectForFolderAction contributions were added on not an adaptable-to-IFolder selection");
67+
assertFalse(contributionAdded(manager, OpenFolderAsProjectAction.class),
68+
"OpenFolderAsProjectAction contributions were added on not an adaptable-to-IFolder selection");
6969
}
7070

7171
@Test
7272
public void noDescription() {
7373
IFolder justAFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path("some/folder"));
7474
IMenuManager manager = menuManager();
7575
provider(new StructuredSelection(justAFolder)).fillContextMenu(manager);
76-
assertFalse("SelectProjectForFolderAction contributions were added on an IFolder without project description",
77-
contributionAdded(manager, SelectProjectForFolderAction.class));
78-
assertFalse("OpenFolderAsProjectAction contributions were added on an IFolder without project description",
79-
contributionAdded(manager, OpenFolderAsProjectAction.class));
76+
assertFalse(contributionAdded(manager, SelectProjectForFolderAction.class),
77+
"SelectProjectForFolderAction contributions were added on an IFolder without project description");
78+
assertFalse(contributionAdded(manager, OpenFolderAsProjectAction.class),
79+
"OpenFolderAsProjectAction contributions were added on an IFolder without project description");
8080
}
8181

8282
@Test
@@ -103,10 +103,9 @@ public void alreadyAdded() throws IOException, CoreException {
103103
provider(new StructuredSelection(
104104
Arrays.asList(outer.getFolder(inner1.getName()), outer.getFolder(inner2.getName()))))
105105
.fillContextMenu(manager);
106-
assertTrue(
106+
assertTrue(contributionAdded(manager, SelectProjectForFolderAction.class),
107107
NLS.bind("A SelectProjectForFolderAction contribution was not added. Contribution List is: {0}",
108-
contributionsList(manager)),
109-
contributionAdded(manager, SelectProjectForFolderAction.class));
108+
contributionsList(manager)));
110109
} finally {
111110
clear(projects);
112111
}
@@ -139,8 +138,9 @@ public void notYetImported() throws IOException, CoreException {
139138
provider(new StructuredSelection(
140139
Arrays.asList(outer.getFolder(inner1.getName()), outer.getFolder(inner2.getName()))))
141140
.fillContextMenu(manager);
142-
assertTrue(NLS.bind("A OpenFolderAsProjectAction contribution was not added. Contribution List is: {0}",
143-
contributionsList(manager)), contributionAdded(manager, OpenFolderAsProjectAction.class));
141+
assertTrue(contributionAdded(manager, OpenFolderAsProjectAction.class),
142+
NLS.bind("A OpenFolderAsProjectAction contribution was not added. Contribution List is: {0}",
143+
contributionsList(manager)));
144144
} finally {
145145
clear(projects);
146146
}
@@ -168,12 +168,10 @@ public void ambiguity() throws CoreException, IOException {
168168
provider(new StructuredSelection(
169169
Arrays.asList(outer.getFolder(inner1.getName()), outer.getFolder(inner2.getName()))))
170170
.fillContextMenu(manager);
171-
assertFalse(
172-
"There were both imported and not-imported projects in selection, but SelectProjectForFolderAction contributions were added",
173-
contributionAdded(manager, SelectProjectForFolderAction.class));
174-
assertFalse(
175-
"There were both imported and not-imported projects in selection, but OpenFolderAsProjectAction contributions were added",
176-
contributionAdded(manager, OpenFolderAsProjectAction.class));
171+
assertFalse(contributionAdded(manager, SelectProjectForFolderAction.class),
172+
"There were both imported and not-imported projects in selection, but SelectProjectForFolderAction contributions were added");
173+
assertFalse(contributionAdded(manager, OpenFolderAsProjectAction.class),
174+
"There were both imported and not-imported projects in selection, but OpenFolderAsProjectAction contributions were added");
177175
} finally {
178176
clear(projects);
179177
}
@@ -239,7 +237,7 @@ private void ensureFileExists(IFile description, String name) throws IOException
239237
// If project description does not exist after creation (for whatever reason),
240238
// create it explicitly with empty content
241239
Files.createFile(Paths.get(description.getLocationURI()));
242-
assertTrue(String.format("Project description for %s does not exist", name), description.exists());
240+
assertTrue(description.exists(), String.format("Project description for %s does not exist", name));
243241
}
244242

245243
}

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/resources/NestedResourcesTests.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,28 @@ public void testProjectHierarchy() throws Exception {
8282
testProjects.add(projectABB);
8383

8484
// Wait for NestedProjectManager to process all resource changes
85-
assertTrue("NestedProjectManager did not update children for projectA",
86-
DisplayHelper.waitForCondition(Display.getDefault(), TIMEOUT,
87-
() -> NestedProjectManager.getInstance().getDirectChildrenProjects(projectA).length == 1));
85+
assertTrue(DisplayHelper.waitForCondition(Display.getDefault(), TIMEOUT,
86+
() -> NestedProjectManager.getInstance().getDirectChildrenProjects(projectA).length == 1),
87+
"NestedProjectManager did not update children for projectA");
8888

8989
IProject[] childrenOfProjectA = NestedProjectManager.getInstance().getDirectChildrenProjects(projectA);
9090
Assert.assertEquals(projectAB, childrenOfProjectA[0]);
9191
Assert.assertNull(NestedProjectManager.getInstance().getMostDirectOpenContainer(projectA));
9292

9393
// Wait for NestedProjectManager to process projectAAA
94-
assertTrue("NestedProjectManager did not update children for folderAA",
95-
DisplayHelper.waitForCondition(Display.getDefault(), TIMEOUT,
96-
() -> NestedProjectManager.getInstance().getDirectChildrenProjects(folderAA).length == 1));
94+
assertTrue(DisplayHelper.waitForCondition(Display.getDefault(), TIMEOUT,
95+
() -> NestedProjectManager.getInstance().getDirectChildrenProjects(folderAA).length == 1),
96+
"NestedProjectManager did not update children for folderAA");
9797

9898
IProject[] childrenOfFolderAA = NestedProjectManager.getInstance().getDirectChildrenProjects(folderAA);
9999
Assert.assertEquals("aaa", childrenOfFolderAA[0].getName());
100100
Assert.assertEquals(folderAA,
101101
NestedProjectManager.getInstance().getMostDirectOpenContainer(childrenOfFolderAA[0]));
102102

103103
// Wait for NestedProjectManager to process both projectABA and projectABB
104-
assertTrue("NestedProjectManager did not update children for projectAB",
105-
DisplayHelper.waitForCondition(Display.getDefault(), TIMEOUT,
106-
() -> NestedProjectManager.getInstance().getDirectChildrenProjects(projectAB).length == 2));
104+
assertTrue(DisplayHelper.waitForCondition(Display.getDefault(), TIMEOUT,
105+
() -> NestedProjectManager.getInstance().getDirectChildrenProjects(projectAB).length == 2),
106+
"NestedProjectManager did not update children for projectAB");
107107
}
108108

109109
@Test

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/resources/PathComparatorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ private static void assertConsistentWithEquals(IPath p1, IPath p2) {
3838

3939
private static void assertLessThan(IPath p1, IPath p2) {
4040
int compare = COMPARATOR.compare(p1, p2);
41-
assertTrue(PathComparator.class.getName() + ".compare() returned " + compare
41+
assertTrue(compare < 0, PathComparator.class.getName() + ".compare() returned " + compare
4242
+ " expected less than zero for paths '" + p1 + "' and '"
43-
+ p2 + "'", compare < 0);
43+
+ p2 + "'");
4444
}
4545

4646
@Test

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/resources/ResourceMgmtActionProviderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ private void checkMenuHasCorrectContributions(boolean... actions) {
188188
for (String thisAction : new String[] { "org.eclipse.ui.BuildAction", "org.eclipse.ui.RefreshAction",
189189
"org.eclipse.ui.OpenResourceAction", "org.eclipse.ui.CloseResourceAction",
190190
"org.eclipse.ui.CloseUnrelatedProjectsAction" }) {
191-
assertTrue(String.format("Unexpected menu membership for %s (%b)", thisAction, !actions[index]),
192-
actions[index] == menuHasContribution(thisAction));
191+
assertTrue(actions[index] == menuHasContribution(thisAction),
192+
String.format("Unexpected menu membership for %s (%b)", thisAction, !actions[index]));
193193
index++;
194194
}
195195
}

0 commit comments

Comments
 (0)