From c10f3569f6d470aaa4b2189653f4baab15a2309e Mon Sep 17 00:00:00 2001 From: Brindrajsinh-Chauhan Date: Tue, 9 Apr 2024 23:40:12 -0400 Subject: [PATCH] fix spotless Signed-off-by: Brindrajsinh-Chauhan --- .../cli/subcommands/rlp/RLPSubCommand.java | 4 +- .../subcommands/rlp/RLPSubCommandTest.java | 51 ++++++++----------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/rlp/RLPSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/rlp/RLPSubCommand.java index 77d6fbca56d..774b94f9c9b 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/rlp/RLPSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/rlp/RLPSubCommand.java @@ -281,9 +281,7 @@ private void readInput() { try (Scanner scanner = new Scanner(parentCommand.in, UTF_8.name())) { inputData = scanner.nextLine(); } catch (NoSuchElementException e) { - throw new ParameterException( - spec.commandLine(), - "Unable to read input data." + e); + throw new ParameterException(spec.commandLine(), "Unable to read input data." + e); } } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/subcommands/rlp/RLPSubCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/subcommands/rlp/RLPSubCommandTest.java index 6671382ebd7..27dcdc16f63 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/subcommands/rlp/RLPSubCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/subcommands/rlp/RLPSubCommandTest.java @@ -264,8 +264,8 @@ public void encodeWithEmptyStdInputMustRaiseAnError() throws Exception { public void decodeWithoutPathMustWriteToStandardOutput() { final String inputData = - "0xf853a00000000000000000000000000000000000000000000000000000000000000000ea94be068f726a13c8d" - + "46c44be6ce9d275600e1735a4945ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193808400000000c0"; + "0xf853a00000000000000000000000000000000000000000000000000000000000000000ea94be068f726a13c8d" + + "46c44be6ce9d275600e1735a4945ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193808400000000c0"; // set stdin final ByteArrayInputStream stdIn = new ByteArrayInputStream(inputData.getBytes(UTF_8)); @@ -273,7 +273,7 @@ public void decodeWithoutPathMustWriteToStandardOutput() { parseCommand(stdIn, RLP_SUBCOMMAND_NAME, RLP_DECODE_SUBCOMMAND_NAME); final String expectedValidatorString = - "[0xbe068f726a13c8d46c44be6ce9d275600e1735a4, 0x5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193]"; + "[0xbe068f726a13c8d46c44be6ce9d275600e1735a4, 0x5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193]"; assertThat(commandOutput.toString(UTF_8)).contains(expectedValidatorString); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); } @@ -282,8 +282,8 @@ public void decodeWithoutPathMustWriteToStandardOutput() { public void decodeQBFTWithoutPathMustWriteToStandardOutput() { final String inputData = - "0xf84fa00000000000000000000000000000000000000000000000000000000000000000ea94241f804efb46f71acaa" - + "5be94a62f7798e89c3724946cdf72da457453063ea92e7fa5ac30afbcec28cdc080c0"; + "0xf84fa00000000000000000000000000000000000000000000000000000000000000000ea94241f804efb46f71acaa" + + "5be94a62f7798e89c3724946cdf72da457453063ea92e7fa5ac30afbcec28cdc080c0"; // set stdin final ByteArrayInputStream stdIn = new ByteArrayInputStream(inputData.getBytes(UTF_8)); @@ -291,7 +291,7 @@ public void decodeQBFTWithoutPathMustWriteToStandardOutput() { parseCommand(stdIn, RLP_SUBCOMMAND_NAME, RLP_DECODE_SUBCOMMAND_NAME, "--type", RLP_QBFT_TYPE); final String expectedValidatorString = - "[0x241f804efb46f71acaa5be94a62f7798e89c3724, 0x6cdf72da457453063ea92e7fa5ac30afbcec28cd]"; + "[0x241f804efb46f71acaa5be94a62f7798e89c3724, 0x6cdf72da457453063ea92e7fa5ac30afbcec28cd]"; assertThat(commandOutput.toString(UTF_8)).contains(expectedValidatorString); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); } @@ -302,8 +302,8 @@ public void decodeWithOutputFileMustWriteInThisFile() throws Exception { final File file = File.createTempFile("ibftValidators", "rlp"); final String inputData = - "0xf853a00000000000000000000000000000000000000000000000000000000000000000ea94be068f726a13c8d" - + "46c44be6ce9d275600e1735a4945ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193808400000000c0"; + "0xf853a00000000000000000000000000000000000000000000000000000000000000000ea94be068f726a13c8d" + + "46c44be6ce9d275600e1735a4945ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193808400000000c0"; // set stdin final ByteArrayInputStream stdIn = new ByteArrayInputStream(inputData.getBytes(UTF_8)); @@ -311,7 +311,7 @@ public void decodeWithOutputFileMustWriteInThisFile() throws Exception { parseCommand(stdIn, RLP_SUBCOMMAND_NAME, RLP_DECODE_SUBCOMMAND_NAME, "--to", file.getPath()); final String expectedValidatorString = - "[0xbe068f726a13c8d46c44be6ce9d275600e1735a4, 0x5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193]"; + "[0xbe068f726a13c8d46c44be6ce9d275600e1735a4, 0x5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193]"; assertThat(contentOf(file)).contains(expectedValidatorString); @@ -326,7 +326,7 @@ public void decodeWithInputFilePathMustReadFromThisFile(final @TempDir Path dir) try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile, UTF_8)) { fileWriter.write( - "0xf853a00000000000000000000000000000000000000000000000000000000000000000ea94be068f726a13c8d46c44be6ce9d275600e1735a4945ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193808400000000c0"); + "0xf853a00000000000000000000000000000000000000000000000000000000000000000ea94be068f726a13c8d46c44be6ce9d275600e1735a4945ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193808400000000c0"); fileWriter.flush(); @@ -337,7 +337,7 @@ public void decodeWithInputFilePathMustReadFromThisFile(final @TempDir Path dir) tempJsonFile.toFile().getAbsolutePath()); final String expectedValidatorString = - "[0xbe068f726a13c8d46c44be6ce9d275600e1735a4, 0x5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193]"; + "[0xbe068f726a13c8d46c44be6ce9d275600e1735a4, 0x5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193]"; assertThat(commandOutput.toString(UTF_8)).contains(expectedValidatorString); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); @@ -345,14 +345,13 @@ public void decodeWithInputFilePathMustReadFromThisFile(final @TempDir Path dir) } @Test - public void decodeWithInputFilePathToOutputFile(final @TempDir Path dir) - throws Exception { + public void decodeWithInputFilePathToOutputFile(final @TempDir Path dir) throws Exception { final Path tempInputFile = Files.createTempFile(dir, "input", "json"); final File tempOutputFile = File.createTempFile("ibftValidators", "rlp"); try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempInputFile, UTF_8)) { fileWriter.write( - "0xf853a00000000000000000000000000000000000000000000000000000000000000000ea94be068f726a13c8d46c44be6ce9d275600e1735a4945ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193808400000000c0"); + "0xf853a00000000000000000000000000000000000000000000000000000000000000000ea94be068f726a13c8d46c44be6ce9d275600e1735a4945ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193808400000000c0"); fileWriter.flush(); @@ -362,12 +361,11 @@ public void decodeWithInputFilePathToOutputFile(final @TempDir Path dir) "--from", tempInputFile.toFile().getAbsolutePath(), "--to", - tempOutputFile.getPath() - ); + tempOutputFile.getPath()); final String expectedValidatorString = - "[0xbe068f726a13c8d46c44be6ce9d275600e1735a4, 0x5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193]"; - + "[0xbe068f726a13c8d46c44be6ce9d275600e1735a4, 0x5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193]"; + assertThat(contentOf(tempOutputFile)).contains(expectedValidatorString); assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); @@ -384,26 +382,19 @@ public void decodeWithEmptyStdInputMustRaiseAnError() throws Exception { parseCommand(stdIn, RLP_SUBCOMMAND_NAME, RLP_DECODE_SUBCOMMAND_NAME); assertThat(commandOutput.toString(UTF_8)).isEmpty(); - assertThat(commandErrorOutput.toString(UTF_8)) - .startsWith("Unable to read input data."); + assertThat(commandErrorOutput.toString(UTF_8)).startsWith("Unable to read input data."); } @Test public void decodeWithInputFilePathMustThrowErrorFileNotExist(final @TempDir Path dir) throws Exception { - final String nonExistingFileName = "/incorrectPath/wrongFile.json"; + final String nonExistingFileName = "/incorrectPath/wrongFile.json"; - parseCommand( - RLP_SUBCOMMAND_NAME, - RLP_DECODE_SUBCOMMAND_NAME, - "--from", - nonExistingFileName); + parseCommand(RLP_SUBCOMMAND_NAME, RLP_DECODE_SUBCOMMAND_NAME, "--from", nonExistingFileName); - assertThat(commandOutput.toString(UTF_8)).isEmpty(); - assertThat(commandErrorOutput.toString(UTF_8)) - .contains( - "Unable to read input file"); + assertThat(commandOutput.toString(UTF_8)).isEmpty(); + assertThat(commandErrorOutput.toString(UTF_8)).contains("Unable to read input file"); } @Test