Replace assert by simpler but equivalent calls. (#159)

This commit is contained in:
Arturo Bernal 2021-07-08 01:19:52 +02:00 committed by GitHub
parent a4237345a1
commit c34e969d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 23 deletions

View File

@ -45,6 +45,7 @@ import java.sql.SQLException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
@ -61,8 +62,8 @@ public class CSVFormatTest {
} }
private static void assertNotEquals(final Object right, final Object left) { private static void assertNotEquals(final Object right, final Object left) {
assertFalse(right.equals(left)); Assertions.assertNotEquals(right, left);
assertFalse(left.equals(right)); Assertions.assertNotEquals(left, right);
} }
private static CSVFormat copy(final CSVFormat format) { private static CSVFormat copy(final CSVFormat format) {
@ -151,8 +152,8 @@ public class CSVFormatTest {
final CSVFormat right = CSVFormat.DEFAULT; final CSVFormat right = CSVFormat.DEFAULT;
final CSVFormat left = copy(right); final CSVFormat left = copy(right);
assertFalse(right.equals(null)); Assertions.assertNotEquals(null, right);
assertFalse(right.equals("A String Instance")); Assertions.assertNotEquals("A String Instance", right);
assertEquals(right, right); assertEquals(right, right);
assertEquals(right, left); assertEquals(right, left);
@ -509,7 +510,7 @@ public class CSVFormatTest {
assertFalse(csvFormatTwo.isCommentMarkerSet()); assertFalse(csvFormatTwo.isCommentMarkerSet());
assertNotSame(csvFormatTwo, csvFormatOne); assertNotSame(csvFormatTwo, csvFormatOne);
assertFalse(csvFormatTwo.equals(csvFormatOne)); Assertions.assertNotEquals(csvFormatTwo, csvFormatOne);
assertEquals('\\', (char)csvFormatOne.getEscapeCharacter()); assertEquals('\\', (char)csvFormatOne.getEscapeCharacter());
assertNull(csvFormatOne.getQuoteMode()); assertNull(csvFormatOne.getQuoteMode());
@ -568,10 +569,10 @@ public class CSVFormatTest {
assertNotSame(csvFormatOne, csvFormatTwo); assertNotSame(csvFormatOne, csvFormatTwo);
assertNotSame(csvFormatTwo, csvFormatOne); assertNotSame(csvFormatTwo, csvFormatOne);
assertFalse(csvFormatOne.equals(csvFormatTwo)); Assertions.assertNotEquals(csvFormatOne, csvFormatTwo);
assertFalse(csvFormatTwo.equals(csvFormatOne)); Assertions.assertNotEquals(csvFormatTwo, csvFormatOne);
assertFalse(csvFormatTwo.equals(csvFormatOne)); Assertions.assertNotEquals(csvFormatTwo, csvFormatOne);
} }
@ -749,7 +750,7 @@ public class CSVFormatTest {
assertEquals('\"', (char)csvFormat.getQuoteCharacter()); assertEquals('\"', (char)csvFormat.getQuoteCharacter());
assertTrue(csvFormat.isNullStringSet()); assertTrue(csvFormat.isNullStringSet());
assertFalse(csvFormat.equals( null)); Assertions.assertNotEquals(null, csvFormat);
} }
@ -833,7 +834,7 @@ public class CSVFormatTest {
assertTrue(csvFormatTwo.getIgnoreHeaderCase()); // now different assertTrue(csvFormatTwo.getIgnoreHeaderCase()); // now different
assertFalse(csvFormatTwo.getTrailingDelimiter()); assertFalse(csvFormatTwo.getTrailingDelimiter());
assertFalse(csvFormatTwo.equals(csvFormat)); // CSV-244 - should not be equal Assertions.assertNotEquals(csvFormatTwo, csvFormat); // CSV-244 - should not be equal
assertFalse(csvFormatTwo.getAllowMissingColumnNames()); assertFalse(csvFormatTwo.getAllowMissingColumnNames());
assertFalse(csvFormatTwo.getTrim()); assertFalse(csvFormatTwo.getTrim());
@ -1026,12 +1027,12 @@ public class CSVFormatTest {
@Test @Test
public void testRFC4180() { public void testRFC4180() {
assertEquals(null, RFC4180.getCommentMarker()); assertNull(RFC4180.getCommentMarker());
assertEquals(',', RFC4180.getDelimiter()); assertEquals(',', RFC4180.getDelimiter());
assertEquals(null, RFC4180.getEscapeCharacter()); assertNull(RFC4180.getEscapeCharacter());
assertFalse(RFC4180.getIgnoreEmptyLines()); assertFalse(RFC4180.getIgnoreEmptyLines());
assertEquals(Character.valueOf('"'), RFC4180.getQuoteCharacter()); assertEquals(Character.valueOf('"'), RFC4180.getQuoteCharacter());
assertEquals(null, RFC4180.getQuoteMode()); assertNull(RFC4180.getQuoteMode());
assertEquals("\r\n", RFC4180.getRecordSeparator()); assertEquals("\r\n", RFC4180.getRecordSeparator());
} }
@ -1161,7 +1162,7 @@ public class CSVFormatTest {
assertNotSame(csvFormat, csvFormatTwo); assertNotSame(csvFormat, csvFormatTwo);
assertNotSame(csvFormatTwo, csvFormat); assertNotSame(csvFormatTwo, csvFormat);
assertFalse(csvFormatTwo.equals(csvFormat)); Assertions.assertNotEquals(csvFormatTwo, csvFormat);
assertNull(csvFormat.getEscapeCharacter()); assertNull(csvFormat.getEscapeCharacter());
assertTrue(csvFormat.isQuoteCharacterSet()); assertTrue(csvFormat.isQuoteCharacterSet());
@ -1220,9 +1221,9 @@ public class CSVFormatTest {
assertNotSame(csvFormat, csvFormatTwo); assertNotSame(csvFormat, csvFormatTwo);
assertNotSame(csvFormatTwo, csvFormat); assertNotSame(csvFormatTwo, csvFormat);
assertFalse(csvFormat.equals(csvFormatTwo)); Assertions.assertNotEquals(csvFormat, csvFormatTwo);
assertFalse(csvFormatTwo.equals(csvFormat)); Assertions.assertNotEquals(csvFormatTwo, csvFormat);
assertEquals("Delimiter=<,> QuoteChar=<\"> CommentStart=<n> " + assertEquals("Delimiter=<,> QuoteChar=<\"> CommentStart=<n> " +
"RecordSeparator=<\r\n> EmptyLines:ignored SkipHeaderRecord:false" "RecordSeparator=<\r\n> EmptyLines:ignored SkipHeaderRecord:false"
, csvFormatTwo.toString()); , csvFormatTwo.toString());
@ -1283,7 +1284,7 @@ public class CSVFormatTest {
@Test @Test
public void testWithEmptyEnum() { public void testWithEmptyEnum() {
final CSVFormat formatWithHeader = CSVFormat.DEFAULT.withHeader(EmptyEnum.class); final CSVFormat formatWithHeader = CSVFormat.DEFAULT.withHeader(EmptyEnum.class);
assertTrue(formatWithHeader.getHeader().length == 0); assertEquals(0, formatWithHeader.getHeader().length);
} }
@ -1304,7 +1305,7 @@ public class CSVFormatTest {
public void testWithFirstRecordAsHeader() { public void testWithFirstRecordAsHeader() {
final CSVFormat formatWithFirstRecordAsHeader = CSVFormat.DEFAULT.withFirstRecordAsHeader(); final CSVFormat formatWithFirstRecordAsHeader = CSVFormat.DEFAULT.withFirstRecordAsHeader();
assertTrue(formatWithFirstRecordAsHeader.getSkipHeaderRecord()); assertTrue(formatWithFirstRecordAsHeader.getSkipHeaderRecord());
assertTrue(formatWithFirstRecordAsHeader.getHeader().length == 0); assertEquals(0, formatWithFirstRecordAsHeader.getHeader().length);
} }
@Test @Test
@ -1408,7 +1409,7 @@ public class CSVFormatTest {
assertNotSame(csvFormat, csvFormatTwo); assertNotSame(csvFormat, csvFormatTwo);
assertNotSame(csvFormatTwo, csvFormat); assertNotSame(csvFormatTwo, csvFormat);
assertFalse(csvFormatTwo.equals(csvFormat)); // CSV-244 - should not be equal Assertions.assertNotEquals(csvFormatTwo, csvFormat); // CSV-244 - should not be equal
final String string = csvFormatTwo.format(objectArray); final String string = csvFormatTwo.format(objectArray);
@ -1470,9 +1471,9 @@ public class CSVFormatTest {
assertNotSame(csvFormatTwo, csvFormat); assertNotSame(csvFormatTwo, csvFormat);
assertNotNull(string); assertNotNull(string);
assertFalse(csvFormat.equals(csvFormatTwo)); // CSV-244 - should not be equal Assertions.assertNotEquals(csvFormat, csvFormatTwo); // CSV-244 - should not be equal
assertFalse(csvFormatTwo.equals(csvFormat)); // CSV-244 - should not be equal Assertions.assertNotEquals(csvFormatTwo, csvFormat); // CSV-244 - should not be equal
assertEquals(",,,,,,,", string); assertEquals(",,,,,,,", string);
} }

View File

@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
@ -1001,7 +1002,7 @@ public class CSVPrinterTest {
final Iterator<CSVRecord> iterator = iterable.iterator(); final Iterator<CSVRecord> iterator = iterable.iterator();
final CSVRecord record = iterator.next(); final CSVRecord record = iterator.next();
assertEquals("a", record.get(0)); assertEquals("a", record.get(0));
assertEquals(null, record.get(1)); assertNull(record.get(1));
assertEquals("b", record.get(2)); assertEquals("b", record.get(2));
assertFalse(iterator.hasNext()); assertFalse(iterator.hasNext());
} }

View File

@ -325,6 +325,6 @@ public class CSVRecordTest {
assertEquals("A", map.get("first")); assertEquals("A", map.get("first"));
assertEquals("B", map.get("second")); assertEquals("B", map.get("second"));
assertEquals("C", map.get("third")); assertEquals("C", map.get("third"));
assertEquals(null, map.get("fourth")); assertNull(map.get("fourth"));
} }
} }