forked from eclipse-che/che
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java Testing support Bug fixes and Enhancements - Step 2 (eclipse-che…
…#4481) * Show all tests in the result view, but allow filtering successful tests * Fix various navigation bugs from test view to source code * Remove the invalid command preview added by default * Fix https://issues.jboss.org/browse/CHE-149 Some Java Editor action were added in the explorer context menu, which led to strange behaviors. * Correctly propagate sevrer errors to the client status notifications * Change contextual test menu to `Run Test` Fixes [CHE-157](https://issues.jboss.org/browse/CHE-157) * Compilation error after the *Intelligent Commands* changes Signed-off-by: David Festal <[email protected]> Conflicts: plugins/plugin-testing-java/plugin-testing-junit/che-plugin-testing-junit-server/pom.xml plugins/plugin-testing/che-plugin-testing-ide/src/main/java/org/eclipse/che/plugin/testing/ide/view/TestResultViewImpl.java
- Loading branch information
1 parent
e745192
commit 34e3028
Showing
42 changed files
with
1,527 additions
and
551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
...rc/main/java/org/eclipse/che/plugin/testing/junit/ide/action/RunAllContextTestAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.plugin.testing.junit.ide.action; | ||
|
||
import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
import org.eclipse.che.ide.api.action.AbstractPerspectiveAction; | ||
import org.eclipse.che.ide.api.action.ActionEvent; | ||
import org.eclipse.che.ide.api.app.AppContext; | ||
import org.eclipse.che.ide.api.notification.NotificationManager; | ||
import org.eclipse.che.ide.api.resources.Container; | ||
import org.eclipse.che.ide.api.resources.Project; | ||
import org.eclipse.che.ide.api.selection.Selection; | ||
import org.eclipse.che.ide.api.selection.SelectionAgent; | ||
import org.eclipse.che.ide.resources.tree.ContainerNode; | ||
import org.eclipse.che.ide.resources.tree.FileNode; | ||
import org.eclipse.che.plugin.testing.ide.TestServiceClient; | ||
import org.eclipse.che.plugin.testing.ide.action.RunTestActionDelegate; | ||
import org.eclipse.che.plugin.testing.ide.view.TestResultPresenter; | ||
import org.eclipse.che.plugin.testing.junit.ide.JUnitTestLocalizationConstant; | ||
import org.eclipse.che.plugin.testing.junit.ide.JUnitTestResources; | ||
|
||
import com.google.inject.Inject; | ||
|
||
/** | ||
* @author Mirage Abeysekara | ||
* @author David Festal | ||
*/ | ||
public class RunAllContextTestAction extends AbstractPerspectiveAction | ||
implements RunTestActionDelegate.Source { | ||
|
||
private final NotificationManager notificationManager; | ||
private final TestResultPresenter presenter; | ||
private final TestServiceClient service; | ||
private final AppContext appContext; | ||
private final SelectionAgent selectionAgent; | ||
private final RunTestActionDelegate delegate; | ||
|
||
@Inject | ||
public RunAllContextTestAction(JUnitTestResources resources, | ||
NotificationManager notificationManager, | ||
AppContext appContext, | ||
TestResultPresenter presenter, | ||
TestServiceClient service, | ||
SelectionAgent selectionAgent, | ||
JUnitTestLocalizationConstant localization) { | ||
super(Arrays.asList(PROJECT_PERSPECTIVE_ID), localization.actionRunAllTitle(), | ||
localization.actionRunAllDescription(), null, resources.testAllIcon()); | ||
this.notificationManager = notificationManager; | ||
this.presenter = presenter; | ||
this.service = service; | ||
this.appContext = appContext; | ||
this.selectionAgent = selectionAgent; | ||
this.delegate = new RunTestActionDelegate(this); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
final Selection< ? > selection = selectionAgent.getSelection(); | ||
final Object possibleNode = selection.getHeadElement(); | ||
if (possibleNode instanceof ContainerNode) { | ||
Container container = ((ContainerNode)possibleNode).getData(); | ||
Project project = container.getProject(); | ||
if (project != null) { | ||
Map<String, String> parameters = new HashMap<>(); | ||
delegate.doRunTests(e, parameters); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void updateInPerspective(@NotNull ActionEvent e) { | ||
e.getPresentation().setVisible(true); | ||
if ((appContext.getRootProject() == null)) { | ||
e.getPresentation().setEnabled(false); | ||
return; | ||
} | ||
final Selection< ? > selection = selectionAgent.getSelection(); | ||
if (selection == null || selection.isEmpty()) { | ||
e.getPresentation().setEnabled(false); | ||
return; | ||
} | ||
if (selection.isMultiSelection()) { | ||
e.getPresentation().setEnabled(false); | ||
return; | ||
} | ||
final Object possibleNode = selection.getHeadElement(); | ||
if (possibleNode instanceof FileNode) { | ||
e.getPresentation().setVisible(false); | ||
} | ||
if (possibleNode instanceof ContainerNode) { | ||
Container container = ((ContainerNode)possibleNode).getData(); | ||
Project project = container.getProject(); | ||
if (project != null) { | ||
String projectType = project.getType(); | ||
boolean enable = "maven".equals(projectType); | ||
e.getPresentation().setEnabled(enable); | ||
return; | ||
} | ||
} | ||
e.getPresentation().setEnabled(false); | ||
} | ||
|
||
@Override | ||
public NotificationManager getNotificationManager() { | ||
return notificationManager; | ||
} | ||
|
||
@Override | ||
public AppContext getAppContext() { | ||
return appContext; | ||
} | ||
|
||
@Override | ||
public TestServiceClient getService() { | ||
return service; | ||
} | ||
|
||
@Override | ||
public TestResultPresenter getPresenter() { | ||
return presenter; | ||
} | ||
|
||
@Override | ||
public String getTestingFramework() { | ||
return "junit"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.