diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/encoding/CharacterEncodingExamplesUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/encoding/CharacterEncodingExamplesUnitTest.java index d87eafcee9..a8cee6881d 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/encoding/CharacterEncodingExamplesUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/encoding/CharacterEncodingExamplesUnitTest.java @@ -76,37 +76,37 @@ public class CharacterEncodingExamplesUnitTest { @Test public void givenUTF8String_decodeByUS_ASCII_ReplaceMalformedInputSequence() throws IOException { String input = "The façade pattern is a software design pattern."; - Assertions.assertEquals(CharacterEncodingExamples.decodeText(input, StandardCharsets.US_ASCII, CodingErrorAction.REPLACE), - "The fa��ade pattern is a software design pattern."); + Assertions.assertEquals("The fa��ade pattern is a software design pattern.", + CharacterEncodingExamples.decodeText(input, StandardCharsets.US_ASCII, CodingErrorAction.REPLACE)); } @Test public void givenUTF8String_decodeByUS_ASCII_IgnoreMalformedInputSequence() throws IOException { String input = "The façade pattern is a software design pattern."; Assertions.assertEquals( - CharacterEncodingExamples.decodeText(input, StandardCharsets.US_ASCII, CodingErrorAction.IGNORE), - "The faade pattern is a software design pattern."); + "The faade pattern is a software design pattern.", + CharacterEncodingExamples.decodeText(input, StandardCharsets.US_ASCII, CodingErrorAction.IGNORE)); } @Test public void givenUTF8String_decodeByUS_ASCII_ReportMalformedInputSequence() { String input = "The façade pattern is a software design pattern."; Assertions.assertThrows(MalformedInputException.class, - () -> CharacterEncodingExamples.decodeText(input, StandardCharsets.US_ASCII, CodingErrorAction.REPORT)); + () -> CharacterEncodingExamples.decodeText(input, StandardCharsets.US_ASCII, CodingErrorAction.REPORT)); } @Test public void givenTextFile_FindSuitableCandidateEncodings() { Path path = Paths.get("src/test/resources/encoding.txt"); - List allCandidateCharSets = Arrays.asList(StandardCharsets.US_ASCII, StandardCharsets.UTF_8, StandardCharsets.ISO_8859_1); + List allCandidateCharSets = Arrays.asList( + StandardCharsets.US_ASCII, StandardCharsets.UTF_8, StandardCharsets.ISO_8859_1); List suitableCharsets = new ArrayList<>(); allCandidateCharSets.forEach(charset -> { try { CharsetDecoder charsetDecoder = charset.newDecoder().onMalformedInput(CodingErrorAction.REPORT); Reader reader = new InputStreamReader(Files.newInputStream(path), charsetDecoder); BufferedReader bufferedReader = new BufferedReader(reader); - while (bufferedReader.readLine() != null) { - } + bufferedReader.readLine(); suitableCharsets.add(charset); } catch (MalformedInputException ignored) { } catch (IOException ex) {