Flip misordered assertEquals parameters. #1555

Fixes `MisorderedAssertEqualsParameters` inspection violation in test code.

Description:
>Reports any calls to JUnit assertEquals() which have a non-literal as the expected result argument and a literal as the actual result argument. Such calls will behave fine for assertions which pass, but may give confusing error reports if their expected and actual arguments differ.
This commit is contained in:
Michal Kordas 2015-08-16 22:58:56 +02:00 committed by Roman Ivanov
parent e6faf188e2
commit de8f91ad67
4 changed files with 7 additions and 7 deletions

View File

@ -178,7 +178,7 @@ public class CheckerTest {
final String[] fileExtensions = {"java", "xml", "properties"};
c.setFileExtensions(fileExtensions);
final int counter = c.process(files);
assertEquals(counter, 1); // comparing to 1 as there is only one legal file in input
assertEquals(1, counter); // comparing to 1 as there is only one legal file in input
}
@SuppressWarnings("deprecation")

View File

@ -303,7 +303,7 @@ public class JavadocTagInfoTest {
@Test
public void testCoverage() {
assertEquals(JavadocTagInfo.VERSION.getType(), JavadocTagInfo.Type.BLOCK);
assertEquals(JavadocTagInfo.Type.BLOCK, JavadocTagInfo.VERSION.getType());
assertEquals("text [@version] name [version] type [BLOCK]", JavadocTagInfo.VERSION.toString());

View File

@ -81,7 +81,7 @@ public class UniquePropertiesCheckTest extends BaseFileSetCheckTestSupport {
final int stringNumber =
UniquePropertiesCheck.getLineNumber(testStrings,
"some key");
Assert.assertEquals(stringNumber, 0);
Assert.assertEquals(0, stringNumber);
}
/**
@ -97,12 +97,12 @@ public class UniquePropertiesCheckTest extends BaseFileSetCheckTestSupport {
final SortedSet<LocalizedMessage> messages =
check.process(file, Collections.<String>emptyList());
Assert.assertEquals("Wrong messages count: " + messages.size(),
messages.size(), 1);
1, messages.size());
final LocalizedMessage message = messages.iterator().next();
final String retrievedMessage = messages.iterator().next().getKey();
Assert.assertEquals("Message key '" + retrievedMessage
+ "' is not valid", retrievedMessage,
"unable.open.cause");
+ "' is not valid", "unable.open.cause",
retrievedMessage);
Assert.assertEquals("Message '" + message.getMessage()
+ "' is not valid", message.getMessage(),
getCheckMessage(IO_EXCEPTION_KEY, fileName, getFileNotFoundDetail(file)));

View File

@ -90,7 +90,7 @@ public class CommentsIndentationCheckTest extends BaseCheckTestSupport {
}
catch (IllegalArgumentException e) {
final String msg = e.getMessage();
Assert.assertEquals(msg, "Unexpected token type: methodStub");
Assert.assertEquals("Unexpected token type: methodStub", msg);
}
}
}