From e9c8f97d2498bbcdb4061e633f8d9badcb2fe6b5 Mon Sep 17 00:00:00 2001 From: Matthew de Detrich Date: Sun, 28 May 2023 20:53:24 +0200 Subject: [PATCH] Apply sbt-java-formatter --- .github/workflows/java-format.yml | 5 +- .../pjfanning/pekkohttpspi/s3/S3Test.java | 51 ++++++++++++------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/.github/workflows/java-format.yml b/.github/workflows/java-format.yml index 974dbb0..57a0100 100644 --- a/.github/workflows/java-format.yml +++ b/.github/workflows/java-format.yml @@ -22,7 +22,6 @@ jobs: - name: Cache Coursier cache uses: coursier/cache-action@v6.4.0 - - name: Check headers + - name: Check java code is formatted run: |- - sbt \ - +javafmtCheck + sbt javafmtCheckAll diff --git a/src/test/java/com/github/pjfanning/pekkohttpspi/s3/S3Test.java b/src/test/java/com/github/pjfanning/pekkohttpspi/s3/S3Test.java index c7ba83d..aa23f1d 100644 --- a/src/test/java/com/github/pjfanning/pekkohttpspi/s3/S3Test.java +++ b/src/test/java/com/github/pjfanning/pekkohttpspi/s3/S3Test.java @@ -48,7 +48,8 @@ public class S3Test extends JUnitSuite { private static SecureRandom rnd = new SecureRandom(); @Rule - public GenericContainer s3mock = new GenericContainer<>("adobe/s3mock:2.1.24").withExposedPorts(9090); + public GenericContainer s3mock = + new GenericContainer<>("adobe/s3mock:2.1.24").withExposedPorts(9090); @Test public void testS3() throws Exception { @@ -58,9 +59,10 @@ public void testS3() throws Exception { try { pekkoClient = new PekkoHttpAsyncHttpService().createAsyncHttpClientFactory().build(); - client = S3AsyncClient - .builder() - .serviceConfiguration(S3Configuration.builder().checksumValidationEnabled(false).build()) + client = + S3AsyncClient.builder() + .serviceConfiguration( + S3Configuration.builder().checksumValidationEnabled(false).build()) .credentialsProvider(AnonymousCredentialsProvider.create()) .endpointOverride(new URI("http://localhost:" + s3mock.getMappedPort(9090))) .region(Region.of("s3")) @@ -81,11 +83,16 @@ public void testS3WithExistingActorSystem() throws Exception { S3AsyncClient client = null; try { - pekkoClient = new PekkoHttpAsyncHttpService().createAsyncHttpClientFactory().withActorSystem(system).build(); + pekkoClient = + new PekkoHttpAsyncHttpService() + .createAsyncHttpClientFactory() + .withActorSystem(system) + .build(); - client = S3AsyncClient - .builder() - .serviceConfiguration(S3Configuration.builder().checksumValidationEnabled(false).build()) + client = + S3AsyncClient.builder() + .serviceConfiguration( + S3Configuration.builder().checksumValidationEnabled(false).build()) .credentialsProvider(AnonymousCredentialsProvider.create()) .endpointOverride(new URI("http://localhost:" + s3mock.getMappedPort(9090))) .region(Region.of("s3")) @@ -108,19 +115,29 @@ private void createBucketAndAssert(S3AsyncClient client) throws IOException { FileWriter fileWriter = new FileWriter(randomFile); fileWriter.write(fileContent); fileWriter.flush(); - client.putObject(PutObjectRequest.builder().bucket("foo").key("my-file").contentType("text/plain").build(), randomFile.toPath()).join(); - - ResponseBytes result = client.getObject(GetObjectRequest.builder().bucket("foo").key("my-file").build(), - AsyncResponseTransformer.toBytes()).join(); + client + .putObject( + PutObjectRequest.builder() + .bucket("foo") + .key("my-file") + .contentType("text/plain") + .build(), + randomFile.toPath()) + .join(); + + ResponseBytes result = + client + .getObject( + GetObjectRequest.builder().bucket("foo").key("my-file").build(), + AsyncResponseTransformer.toBytes()) + .join(); assertEquals(fileContent, result.asUtf8String()); } String randomString(int len) { - StringBuilder sb = new StringBuilder( len ); - for( int i = 0; i < len; i++ ) - sb.append( AB.charAt( rnd.nextInt(AB.length()) ) ); - return sb.toString(); + StringBuilder sb = new StringBuilder(len); + for (int i = 0; i < len; i++) sb.append(AB.charAt(rnd.nextInt(AB.length()))); + return sb.toString(); } - }