Skip to content

Commit

Permalink
Fix tests in LaunchConfigurationTabGroupViewerTest eclipse-platform#1075
Browse files Browse the repository at this point in the history


- Remove invalid usages of java.util.function.Predicate.not
- Change assertions in testOnlyDefaultTabInOtherConfigIsActivated and
reactivate the test
- Replace calls to assertj's "matches" method with calls to
isTrue/isFalse to improve readability (also, some calls were wrong)

Fixes eclipse-platform#1075
  • Loading branch information
fedejeanne committed Mar 27, 2024
1 parent f17f1a1 commit 26d3650
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

package org.eclipse.debug.tests.ui;

import static java.util.function.Predicate.not;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.Arrays;
Expand All @@ -31,7 +30,6 @@
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
import org.eclipse.swt.widgets.Display;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

public class LaunchConfigurationTabGroupViewerTest {
Expand Down Expand Up @@ -71,7 +69,7 @@ public void testAllTabsAreInitializedByDefault() {
final ILaunchConfigurationTab[] tabs = runOnDialog(createAndSelect1LaunchConfig);

for (int i = 0; i < tabs.length; i++) {
assertThat(((SpyTab) tabs[i])).withFailMessage("tab %s was not initialized", i).matches(SpyTab::isInitialized);
assertThat(((SpyTab) tabs[i]).isInitialized()).withFailMessage("tab %s was not initialized", i).isTrue();
}
}

Expand All @@ -83,7 +81,7 @@ public void testFirstTabIsActivatedByDefault() {
};

final ILaunchConfigurationTab[] tabs = runOnDialog(createAndSelect1LaunchConfig);
assertThat(((SpyTab) tabs[0])).matches(SpyTab::isActivated, "is activated");
assertThat(((SpyTab) tabs[0]).isActivated()).withFailMessage("tab was not activated").isTrue();
}

@Test
Expand All @@ -104,12 +102,11 @@ public void testOtherTabInOtherConfigIsActivated() {

final ILaunchConfigurationTab[] tabs = runOnDialog(setActiveTab);

assertThat((SpyTab) tabs[0]).withFailMessage("the 1st tab of the other launch configuration shouldn't have been activated").matches(not(SpyTab::isActivated));
assertThat((SpyTab) tabs[secondTabIndex]).matches(SpyTab::isActivated, "is activated");
assertThat(((SpyTab) tabs[0]).isActivated()).withFailMessage("the 1st tab of the other launch configuration shouldn't have been activated").isFalse();
assertThat(((SpyTab) tabs[secondTabIndex]).isActivated()).withFailMessage("the other tab of the other launch configuration should have been activated").isTrue();
}

@Test
@Ignore("https://github.com/eclipse-platform/eclipse.platform/issues/1075")
public void testOnlyDefaultTabInOtherConfigIsActivated() {
int overflowTabIndex = Integer.MAX_VALUE;

Expand All @@ -127,11 +124,11 @@ public void testOnlyDefaultTabInOtherConfigIsActivated() {

final ILaunchConfigurationTab[] tabs = runOnDialog(setActiveTab);

assertThat(((SpyTab) tabs[0])).withFailMessage("the 1st tab of the other launch configuration should have been activated").matches(SpyTab::isActivated);
assertThat(((SpyTab) tabs[0]).isActivated()).withFailMessage("the 1st tab of the other launch configuration should have been activated").isTrue();

// All other tabs should not have been initialized
// All other tabs should not have been activated
for (int i = 1; i < tabs.length; i++) {
assertThat((SpyTab) tabs[i]).withFailMessage("tab %s should not have been initialized", i).matches(not(SpyTab::isInitialized));
assertThat(((SpyTab) tabs[i]).isActivated()).withFailMessage("tab %s should not have been activated", i).isFalse();
}
}

Expand All @@ -149,7 +146,7 @@ public void testOtherTabIsActivated() {

final ILaunchConfigurationTab[] tabs = runOnDialog(setActiveTab);

assertThat((SpyTab) tabs[secondTabIndex]).matches(SpyTab::isActivated, "is activated");
assertThat(((SpyTab) tabs[secondTabIndex]).isActivated()).withFailMessage("tab %s should have been activated", secondTabIndex).isTrue();
}

private ILaunchConfigurationWorkingCopy createLaunchConfigurationInstance() throws CoreException {
Expand Down

0 comments on commit 26d3650

Please sign in to comment.