diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit5AssertionsConverterInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit5AssertionsConverterInspection.java index 4594f347e1d6..6313a048c205 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit5AssertionsConverterInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit5AssertionsConverterInspection.java @@ -109,7 +109,7 @@ public class JUnit5AssertionsConverterInspection extends BaseInspection { String methodName = psiMethod.getName(); registerMethodCallError(expression, name, getNewAssertClassName(methodName), - "fail".equals(methodName) && psiMethod.getParameterList().getParametersCount() == 0); + absentInJUnit5(psiMethod, methodName)); break; } } @@ -117,6 +117,22 @@ public class JUnit5AssertionsConverterInspection extends BaseInspection { } } + + private boolean absentInJUnit5(PsiMethod psiMethod, String methodName) { + if ("fail".equals(methodName)) { + return psiMethod.getParameterList().getParametersCount() == 0; + } + if ("assertNotEquals".equals(methodName)) { + PsiParameter[] parameters = psiMethod.getParameterList().getParameters(); + if (parameters.length > 0) { + int lastParamIdx = parameters[0].getType().equalsToText(CommonClassNames.JAVA_LANG_STRING) ? 3 : 2; + if (parameters.length > lastParamIdx && parameters[lastParamIdx].getType() instanceof PsiPrimitiveType) { + return true; + } + } + } + return false; + } } private static String getNewAssertClassName(String methodName) { diff --git a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/MoveParameterLeftAction.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/junit/junit5_assertions_converter/AssertNotEqualsWithDelta.java similarity index 69% rename from platform/lang-impl/src/com/intellij/refactoring/changeSignature/MoveParameterLeftAction.java rename to plugins/InspectionGadgets/test/com/siyeh/igfixes/junit/junit5_assertions_converter/AssertNotEqualsWithDelta.java index c380d37274d9..c9154b4023c7 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/MoveParameterLeftAction.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/junit/junit5_assertions_converter/AssertNotEqualsWithDelta.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.refactoring.changeSignature; +import static org.junit.Assert.*; -/** - * User: anna - * Date: Sep 10, 2010 - */ -public class MoveParameterLeftAction extends MoveParameterAction { - public MoveParameterLeftAction() { - super(true); +class Test1 { + + @org.junit.jupiter.api.Test + public void test_first() throws Exception { + assertNotEquals(1, 1, 1); } } diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/junit/Junit5AssertionsConverterFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/junit/Junit5AssertionsConverterFixTest.java index 4c7b2ac1e285..fd726b3957f1 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/junit/Junit5AssertionsConverterFixTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/junit/Junit5AssertionsConverterFixTest.java @@ -26,6 +26,9 @@ public class Junit5AssertionsConverterFixTest extends IGQuickFixesTestCase { public void testAssertArrayEqualsMessage() { doTestAssertions();} public void testAssertEquals() { doTestAssertions();} public void testAssertTrue() { doTestAssertions();} + public void testAssertNotEqualsWithDelta() { + assertQuickfixNotAvailable(InspectionGadgetsBundle.message("junit5.assertions.converter.quickfix", JUnitCommonClassNames.ORG_JUNIT_JUPITER_API_ASSERTIONS)); + } public void testAssertThat() { doTest(InspectionGadgetsBundle.message("junit5.assertions.converter.quickfix", JUnitCommonClassNames.ORG_HAMCREST_MATCHER_ASSERT)); @@ -59,6 +62,7 @@ public class Junit5AssertionsConverterFixTest extends IGQuickFixesTestCase { " public static void assertEquals(Object expected, Object actual) {}" + " public static void fail(String message) {}" + " public static void assertThat(String reason, T actual, org.hamcrest.Matcher matcher) {}" + + " public static void assertNotEquals(double unexpected, double actual, double delta){}" + "}"); myFixture.addClass("package org.junit.jupiter.api;\n" +