Skip to content

Commit

Permalink
use static import in the all places
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Musienko committed Sep 25, 2017
1 parent cb85518 commit 43ae545
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@
*/
package org.eclipse.che.selenium.testrunner;

import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_DROP_DAWN_ITEM;
import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED;
import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.IGNORED;
import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED;
import static org.testng.Assert.assertTrue;

import com.google.inject.Inject;
import java.nio.file.Paths;

import org.eclipse.che.api.workspace.server.DtoConverter;
import org.eclipse.che.selenium.core.client.TestCommandServiceClient;
import org.eclipse.che.selenium.core.client.TestProjectServiceClient;
Expand All @@ -35,10 +27,19 @@
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.intelligent.CommandsPalette;
import org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.nio.file.Paths;

import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_DROP_DAWN_ITEM;
import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED;
import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.IGNORED;
import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED;
import static org.testng.Assert.assertTrue;

/** @author Dmytro Nochevnov */
public class JavaTestPluginJunit4Test {

Expand All @@ -52,18 +53,18 @@ public class JavaTestPluginJunit4Test {

public static final String APP_TEST_ONE_FAIL_OUTPUT_TEMPLATE =
"java.lang.AssertionError\n"
+ " at org.junit.Assert.fail(Assert.java:86)\n"
+ " at org.junit.Assert.assertTrue(Assert.java:41)\n"
+ " at org.junit.Assert.assertFalse(Assert.java:64)\n"
+ " at org.junit.Assert.assertFalse(Assert.java:74)\n"
+ " at org.junit. fail( java:86)\n"
+ " at org.junit. assertTrue( java:41)\n"
+ " at org.junit. assertFalse( java:64)\n"
+ " at org.junit. assertFalse( java:74)\n"
+ " at org.eclipse.che.examples.AppOneTest.shouldFailOfAppOne(AppOneTest.java:33)";

public static final String APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE =
"java.lang.AssertionError\n"
+ " at org.junit.Assert.fail(Assert.java:86)\n"
+ " at org.junit.Assert.assertTrue(Assert.java:41)\n"
+ " at org.junit.Assert.assertFalse(Assert.java:64)\n"
+ " at org.junit.Assert.assertFalse(Assert.java:74)\n"
+ " at org.junit. fail( java:86)\n"
+ " at org.junit. assertTrue( java:41)\n"
+ " at org.junit. assertFalse( java:64)\n"
+ " at org.junit. assertFalse( java:74)\n"
+ " at org.eclipse.che.examples.AppAnotherTest.shouldFailOfAppAnother(AppAnotherTest.java:34)";

@Inject private JavaTestRunnerPluginConsole pluginConsole;
Expand Down Expand Up @@ -123,9 +124,9 @@ public void shouldExecuteJUnit4TestClassWithDifferentStatuses() throws Interrupt
pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppOne");
pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppOne");
pluginConsole.waitMethodMarkedAsIgnored("shouldBeIgnoredOfAppOne");
Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1);
Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1);
Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(IGNORED).size() == 1);
assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1);
assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1);
assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(IGNORED).size() == 1);
String testErrorMessage = pluginConsole.getTestErrorMessage();
assertTrue(
testErrorMessage.startsWith(APP_TEST_ONE_FAIL_OUTPUT_TEMPLATE),
Expand All @@ -147,14 +148,14 @@ public void shouldExecuteJUnit4MethodWithDifferentStatuses() throws InterruptedE
// then
pluginConsole.waitFqnOfTesClassInResultTree("org.eclipse.che.examples.AppAnotherTest");
pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppAnother");
Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1);
assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1);
// then

editor.setCursorToDefinedLineAndChar(32, 5);
menu.runCommand(RUN_MENU, TEST, TEST_DROP_DAWN_ITEM);
notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully.");
pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppAnother");
Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1);
assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1);
String testErrorMessage = pluginConsole.getTestErrorMessage();
assertTrue(
testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE),
Expand All @@ -164,6 +165,6 @@ public void shouldExecuteJUnit4MethodWithDifferentStatuses() throws InterruptedE
menu.runCommand(RUN_MENU, TEST, TEST_DROP_DAWN_ITEM);
notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully.");
pluginConsole.waitMethodMarkedAsIgnored("shouldBeIgnoredOfAppAnother");
Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(IGNORED).size() == 1);
assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(IGNORED).size() == 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@
*/
package org.eclipse.che.selenium.testrunner;

import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_NG_TEST_DROP_DAWN_ITEM;
import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED;
import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED;
import static org.testng.Assert.assertTrue;

import com.google.inject.Inject;
import java.net.URL;
import java.nio.file.Paths;

import org.eclipse.che.api.workspace.server.DtoConverter;
import org.eclipse.che.selenium.core.client.TestCommandServiceClient;
import org.eclipse.che.selenium.core.client.TestProjectServiceClient;
Expand All @@ -38,10 +30,19 @@
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.intelligent.CommandsPalette;
import org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.net.URL;
import java.nio.file.Paths;

import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_NG_TEST_DROP_DAWN_ITEM;
import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED;
import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED;
import static org.testng.Assert.assertTrue;

/** @author Dmytro Nochevnov */
public class JavaTestPluginTestNgTest {

Expand Down Expand Up @@ -122,8 +123,8 @@ public void shouldExecuteTestClassSuccessfully() throws InterruptedException {
notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully.");
pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppOne");
pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppOne");
Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1);
Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1);
assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1);
assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1);
String testErrorMessage = pluginConsole.getTestErrorMessage();
assertTrue(
testErrorMessage.startsWith(APP_TEST_ONE_FAIL_OUTPUT_TEMPLATE),
Expand All @@ -141,11 +142,11 @@ public void shouldExecuteTestMethodsSuccessfully() throws InterruptedException {
menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM);
notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully.");
pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppAnother");
Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1);
assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1);
editor.setCursorToDefinedLineAndChar(30, 17);
menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM);
pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppAnother");
Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1);
assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1);
String testErrorMessage = pluginConsole.getTestErrorMessage();
assertTrue(
testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE),
Expand All @@ -165,11 +166,11 @@ public void shouldExecuteAlltets() throws InterruptedException {
menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM);
notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully.");
pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppAnother");
Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1);
assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1);
editor.setCursorToDefinedLineAndChar(30, 17);
menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM);
pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppAnother");
Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1);
assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1);
String testErrorMessage = pluginConsole.getTestErrorMessage();
assertTrue(
testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE),
Expand Down

0 comments on commit 43ae545

Please sign in to comment.