Code cleanup: IDEA's warnings fixed

This commit is contained in:
Oleg Sukhodolsky
2012-07-09 17:32:07 +04:00
parent d896318f45
commit 0f4f43e91b
3 changed files with 122 additions and 65 deletions
@@ -16,6 +16,7 @@
package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.testframework.AbstractTestProxy;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.execution.testframework.sm.Marker;
import com.intellij.execution.testframework.sm.runner.events.*;
@@ -29,6 +30,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeModel;
import java.util.List;
import java.util.Set;
/**
* @author Roman Chernyatchik
@@ -131,37 +133,44 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
final String fullName = myEventsProcessor.getFullTestName("some_test");
final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName);
assertNotNull(proxy);
assertTrue(proxy.isDefect());
assertFalse(proxy.isInProgress());
}
public void testOnTestComparisionFailure() {
public void testOnTestComparisonFailure() {
onTestStarted("some_test");
myEventsProcessor.onTestFailure(new TestFailedEvent("some_test", "", "", false, "actual", "expected"));
final String fullName = myEventsProcessor.getFullTestName("some_test");
final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName);
assertNotNull(proxy);
assertTrue(proxy.isDefect());
assertFalse(proxy.isInProgress());
}
public void testOnTestFailure_Twice() {
onTestStarted("some_test");
myEventsProcessor.onTestFailure(new TestFailedEvent("some_test", "", "", false, null, null));
myEventsProcessor.onTestFailure(new TestFailedEvent("some_test", "", "", false, null, null));
myEventsProcessor.onTestFailure(new TestFailedEvent("some_test", "msg 1", "trace 1", false, null, null));
myEventsProcessor.onTestFailure(new TestFailedEvent("some_test", "msg 2", "trace 2", false, null, null));
assertEquals(1, myEventsProcessor.getRunningTestsQuantity());
assertEquals(1, myEventsProcessor.getFailedTestsSet().size());
final Set<AbstractTestProxy> failedTests = myEventsProcessor.getFailedTestsSet();
assertEquals(1, failedTests.size());
for (final AbstractTestProxy test : failedTests) {
assertEquals("some_test", test.getName());
}
}
public void testOnTestError() {
public void testOnTestError() {
onTestStarted("some_test");
myEventsProcessor.onTestFailure(new TestFailedEvent("some_test", "", "", true, null, null));
final String fullName = myEventsProcessor.getFullTestName("some_test");
final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName);
assertNotNull(proxy);
assertTrue(proxy.isDefect());
assertFalse(proxy.isInProgress());
}
@@ -173,6 +182,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
final String fullName = myEventsProcessor.getFullTestName("some_test");
final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName);
assertNotNull(proxy);
assertTrue(proxy.isDefect());
assertFalse(proxy.isInProgress());
}
@@ -186,7 +196,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
assertEquals(0, myEventsProcessor.getRunningTestsQuantity());
assertEquals(0, myEventsProcessor.getFailedTestsSet().size());
assertNotNull(proxy);
assertFalse(proxy.isDefect());
assertFalse(proxy.isInProgress());
@@ -292,6 +302,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
onTestStarted("test1");
final SMTestProxy test1 =
myEventsProcessor.getProxyByFullTestName(myEventsProcessor.getFullTestName("test1"));
assertNotNull(test1);
assertEquals("suite1", test1.getParent().getName());
//lets check that new suits have righ parent
@@ -300,6 +311,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
onTestStarted("test2");
final SMTestProxy test2 =
myEventsProcessor.getProxyByFullTestName(myEventsProcessor.getFullTestName("test2"));
assertNotNull(test2);
assertEquals("suite3", test2.getParent().getName());
assertEquals("suite2", test2.getParent().getParent().getName());
@@ -310,6 +322,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
onTestStarted("test3");
final SMTestProxy test3 =
myEventsProcessor.getProxyByFullTestName(myEventsProcessor.getFullTestName("test3"));
assertNotNull(test3);
assertEquals("suite2", test3.getParent().getName());
//clean up
@@ -325,6 +338,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
final SMTestProxy test1 =
myEventsProcessor.getProxyByFullTestName(myEventsProcessor.getFullTestName("test1"));
assertNotNull(test1);
assertEquals("file://some/file.rb:1", test1.getParent().getLocationUrl());
assertEquals("file://some/file.rb:4", test1.getLocationUrl());
}
@@ -349,6 +363,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
myEventsProcessor.onTestFinished(new TestFinishedEvent("suite2.test1", 10));
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite2"));
assertNotNull(test1);
assertEquals("suite1", test1.getParent().getName());
final List<? extends SMTestProxy> children =
@@ -29,6 +29,7 @@ import com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm
import com.intellij.execution.testframework.ui.TestsOutputConsolePrinter;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.openapi.util.Disposer;
import org.jetbrains.annotations.NotNull;
/**
* @author Roman Chernyatchik
@@ -492,16 +493,17 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
assertAllOutputs(myMockResetablePrinter, "stdout", "stderr", "system");
}
public void assertStdOutput(final MockPrinter printer, final String out) {
public static void assertStdOutput(final MockPrinter printer, final String out) {
assertAllOutputs(printer, out, "", "");
}
public void assertStdErr(final MockPrinter printer, final String out) {
public static void assertStdErr(final MockPrinter printer, final String out) {
assertAllOutputs(printer, "", out, "");
}
public void assertAllOutputs(final MockPrinter printer,
final String out, final String err, final String sys) {
public static void assertAllOutputs(final MockPrinter printer,
final String out, final String err, final String sys)
{
assertTrue(printer.hasPrinted());
assertEquals(out, printer.getStdOut());
assertEquals(err, printer.getStdErr());
@@ -536,15 +538,17 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
assertAllOutputs(myMockResetablePrinter, "preved", "","Empty test suite.\n");
}
@NotNull
private SMTestProxy startTestWithPrinter(final String testName) {
myEventsProcessor.onTestStarted(new TestStartedEvent(testName, null));
final SMTestProxy proxy =
myEventsProcessor.getProxyByFullTestName(myEventsProcessor.getFullTestName(testName));
assertNotNull(proxy);
proxy.setPrinter(myMockResetablePrinter);
return proxy;
}
private void sendToTestProxyStdOut(final SMTestProxy proxy, final String text) {
private static void sendToTestProxyStdOut(final SMTestProxy proxy, final String text) {
proxy.addLast(new Printable() {
@Override
public void printOn(final Printer printer) {
@@ -18,7 +18,6 @@ package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.testframework.Filter;
import static com.intellij.execution.testframework.sm.runner.states.TestStateInfo.Magnitude;
import static com.intellij.execution.testframework.sm.runner.states.TestStateInfo.Magnitude.*;
/**
* @author Roman Chernyatchik
@@ -178,7 +177,7 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
}
public void testTestFailed_ComparisionAssertion() {
public void testTestFailed_ComparisonAssertion() {
mySimpleTest.setStarted();
mySimpleTest.setTestComparisonFailed("", "", "", "");
@@ -458,50 +457,50 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
}
public void testMagnitude() {
assertEquals(NOT_RUN_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.NOT_RUN_INDEX.getValue(), mySuite.getMagnitude());
final SMTestProxy passedTest = createTestProxy("passed");
final SMTestProxy failedTest = createTestProxy("failed");
mySuite.addChild(passedTest);
mySuite.addChild(failedTest);
assertEquals(NOT_RUN_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(NOT_RUN_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(NOT_RUN_INDEX.getValue(), failedTest.getMagnitude());
assertEquals(Magnitude.NOT_RUN_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.NOT_RUN_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(Magnitude.NOT_RUN_INDEX.getValue(), failedTest.getMagnitude());
mySuite.setStarted();
assertEquals(RUNNING_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(NOT_RUN_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(NOT_RUN_INDEX.getValue(), failedTest.getMagnitude());
assertEquals(Magnitude.RUNNING_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.NOT_RUN_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(Magnitude.NOT_RUN_INDEX.getValue(), failedTest.getMagnitude());
passedTest.setStarted();
assertEquals(RUNNING_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(RUNNING_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(NOT_RUN_INDEX.getValue(), failedTest.getMagnitude());
assertEquals(Magnitude.RUNNING_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.RUNNING_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(Magnitude.NOT_RUN_INDEX.getValue(), failedTest.getMagnitude());
passedTest.setFinished();
assertEquals(RUNNING_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(PASSED_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(NOT_RUN_INDEX.getValue(), failedTest.getMagnitude());
assertEquals(Magnitude.RUNNING_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.PASSED_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(Magnitude.NOT_RUN_INDEX.getValue(), failedTest.getMagnitude());
failedTest.setStarted();
assertEquals(RUNNING_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(PASSED_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(RUNNING_INDEX.getValue(), failedTest.getMagnitude());
assertEquals(Magnitude.RUNNING_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.PASSED_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(Magnitude.RUNNING_INDEX.getValue(), failedTest.getMagnitude());
failedTest.setTestFailed("", "", false);
assertEquals(RUNNING_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(PASSED_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(FAILED_INDEX.getValue(), failedTest.getMagnitude());
assertEquals(Magnitude.RUNNING_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.PASSED_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(Magnitude.FAILED_INDEX.getValue(), failedTest.getMagnitude());
mySuite.setFinished();
assertEquals(FAILED_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(PASSED_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(FAILED_INDEX.getValue(), failedTest.getMagnitude());
assertEquals(Magnitude.FAILED_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.PASSED_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(Magnitude.FAILED_INDEX.getValue(), failedTest.getMagnitude());
}
public void testMagnitude_Error() {
assertEquals(NOT_RUN_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.NOT_RUN_INDEX.getValue(), mySuite.getMagnitude());
final SMTestProxy passedTest = createTestProxy("passed");
final SMTestProxy failedTest = createTestProxy("failed");
@@ -520,32 +519,32 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
errorTest.setTestFailed("", "", true);
errorTest.setFinished();
assertEquals(RUNNING_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(PASSED_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(FAILED_INDEX.getValue(), failedTest.getMagnitude());
assertEquals(ERROR_INDEX.getValue(), errorTest.getMagnitude());
assertEquals(Magnitude.RUNNING_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.PASSED_INDEX.getValue(), passedTest.getMagnitude());
assertEquals(Magnitude.FAILED_INDEX.getValue(), failedTest.getMagnitude());
assertEquals(Magnitude.ERROR_INDEX.getValue(), errorTest.getMagnitude());
}
public void testMagnitude_Terminated() {
assertEquals(NOT_RUN_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.NOT_RUN_INDEX.getValue(), mySuite.getMagnitude());
final SMTestProxy testProxy = createTestProxy("failed");
mySuite.addChild(testProxy);
assertEquals(NOT_RUN_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(NOT_RUN_INDEX.getValue(), testProxy.getMagnitude());
assertEquals(Magnitude.NOT_RUN_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.NOT_RUN_INDEX.getValue(), testProxy.getMagnitude());
mySuite.setStarted();
mySuite.setTerminated();
assertEquals(TERMINATED_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(TERMINATED_INDEX.getValue(), testProxy.getMagnitude());
assertEquals(Magnitude.TERMINATED_INDEX.getValue(), mySuite.getMagnitude());
assertEquals(Magnitude.TERMINATED_INDEX.getValue(), testProxy.getMagnitude());
}
public void testMagnitude_suiteWithoutTests() {
final SMTestProxy noTests = createSuiteProxy("emptySuite");
noTests.setStarted();
noTests.setFinished();
assertEquals(COMPLETE_INDEX.getValue(), noTests.getMagnitude());
assertEquals(Magnitude.COMPLETE_INDEX.getValue(), noTests.getMagnitude());
}
public void testMagnitude_PassedSuite() {
@@ -556,7 +555,7 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
passedSuiteTest.setStarted();
passedSuiteTest.setFinished();
passedSuite.setFinished();
assertEquals(PASSED_INDEX.getValue(), passedSuite.getMagnitude());
assertEquals(Magnitude.PASSED_INDEX.getValue(), passedSuite.getMagnitude());
}
public void testLocation() {
@@ -569,11 +568,14 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
}
public void testNavigatable() {
//noinspection NullableProblems
assertNull(mySuite.getDescriptor(null, null));
mySuite.addChild(mySimpleTest);
//noinspection NullableProblems
assertNull(mySuite.getDescriptor(null, null));
//noinspection NullableProblems
assertNull(mySimpleTest.getDescriptor(null, null));
}
@@ -645,11 +647,13 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
}
public void testFilter() {
//noinspection unchecked
assertEmpty(mySuite.getChildren(Filter.NO_FILTER));
assertEmpty(mySuite.getChildren(null));
mySuite.addChild(mySimpleTest);
//noinspection unchecked
assertEquals(1, mySuite.getChildren(Filter.NO_FILTER).size());
assertEquals(1, mySuite.getChildren(null).size());
}
@@ -693,13 +697,19 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
assertNull(mySimpleTest.getDuration());
mySimpleTest.setDuration(0);
assertEquals(0, mySimpleTest.getDuration().intValue());
Integer duration = mySimpleTest.getDuration();
assertNotNull(duration);
assertEquals(0, duration.intValue());
mySimpleTest.setDuration(10);
assertEquals(10, mySimpleTest.getDuration().intValue());
duration = mySimpleTest.getDuration();
assertNotNull(duration);
assertEquals(10, duration.intValue());
mySimpleTest.setDuration(5);
assertEquals(5, mySimpleTest.getDuration().intValue());
duration = mySimpleTest.getDuration();
assertNotNull(duration);
assertEquals(5, duration.intValue());
mySimpleTest.setDuration(-2);
assertNull(mySimpleTest.getDuration());
@@ -717,7 +727,9 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
final SMTestProxy test = createTestProxy("test", mySuite);
test.setDuration(2);
mySuite.setDuration(5);
assertEquals(2, mySuite.getDuration().intValue());
final Integer duration = mySuite.getDuration();
assertNotNull(duration);
assertEquals(2, duration.intValue());
}
public void testDuration_ForSuiteWithTests() {
@@ -728,10 +740,14 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
assertNull(suite.getDuration());
test1.setDuration(5);
assertEquals(5, suite.getDuration().intValue());
Integer duration = suite.getDuration();
assertNotNull(duration);
assertEquals(5, duration.intValue());
test2.setDuration(6);
assertEquals(11, suite.getDuration().intValue());
duration = suite.getDuration();
assertNotNull(duration);
assertEquals(11, duration.intValue());
}
public void testDuration_OnFinished() {
@@ -741,16 +757,24 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
assertNull(suite.getDuration());
test.setDuration(5);
assertEquals(5, suite.getDuration().intValue());
Integer duration = suite.getDuration();
assertNotNull(duration);
assertEquals(5, duration.intValue());
test.setDuration(7);
assertEquals(7, suite.getDuration().intValue());
duration = suite.getDuration();
assertNotNull(duration);
assertEquals(7, duration.intValue());
suite.setFinished();
assertEquals(7, suite.getDuration().intValue());
duration = suite.getDuration();
assertNotNull(duration);
assertEquals(7, duration.intValue());
test.setDuration(8);
assertEquals(8, suite.getDuration().intValue());
duration = suite.getDuration();
assertNotNull(duration);
assertEquals(8, duration.intValue());
}
public void testDuration_OnTerminated() {
@@ -760,16 +784,24 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
assertNull(suite.getDuration());
test.setDuration(5);
assertEquals(5, suite.getDuration().intValue());
Integer duration = suite.getDuration();
assertNotNull(duration);
assertEquals(5, duration.intValue());
test.setDuration(7);
assertEquals(7, suite.getDuration().intValue());
duration = suite.getDuration();
assertNotNull(duration);
assertEquals(7, duration.intValue());
suite.setTerminated();
assertEquals(7, suite.getDuration().intValue());
duration = suite.getDuration();
assertNotNull(duration);
assertEquals(7, duration.intValue());
test.setDuration(8);
assertEquals(8, suite.getDuration().intValue());
duration = suite.getDuration();
assertNotNull(duration);
assertEquals(8, duration.intValue());
}
public void testDuration_ForSuiteWithSuites() {
@@ -782,13 +814,19 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
final SMTestProxy test21 = createTestProxy("test21", suite2);
test11.setDuration(5);
assertEquals(5, root.getDuration().intValue());
Integer duration = root.getDuration();
assertNotNull(duration);
assertEquals(5, duration.intValue());
test12.setDuration(6);
assertEquals(11, root.getDuration().intValue());
duration = root.getDuration();
assertNotNull(duration);
assertEquals(11, duration.intValue());
test21.setDuration(9);
assertEquals(20, root.getDuration().intValue());
duration = root.getDuration();
assertNotNull(duration);
assertEquals(20, duration.intValue());
}
public void testMagnitudeWeight() {
@@ -916,7 +954,7 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
assertFalse(root.isEmptySuite());
}
protected void assertWeightsOrder(final Magnitude previous, final Magnitude next) {
protected static void assertWeightsOrder(final Magnitude previous, final Magnitude next) {
assertTrue(previous.getSortWeight() < next.getSortWeight());
}
}