From 9b4704fe3d3fd9b928373df34b0b2c9c4945cee1 Mon Sep 17 00:00:00 2001 From: AlexisLeDain Date: Thu, 9 Apr 2026 16:00:56 +0200 Subject: [PATCH] fix: resolve compile errors in quarkus code examples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add missing @Slf4j and bucketName field to FileStorageService - Fix PaginatedList → List type mismatch (Panache returns List) - Fix executorService.submit → execute mock (supplyAsync uses execute) - Update S3 failure test to throw from putObject instead of failed future Applied to English + all 3 locale copies (tr, ja-JP, zh-CN). --- docs/ja-JP/skills/quarkus-patterns/SKILL.md | 7 ++++-- docs/tr/skills/quarkus-patterns/SKILL.md | 7 ++++-- docs/tr/skills/quarkus-tdd/SKILL.md | 26 +++++++++++-------- docs/zh-CN/skills/quarkus-patterns/SKILL.md | 5 +++- skills/quarkus-patterns/SKILL.md | 6 ++++- skills/quarkus-tdd/SKILL.md | 28 ++++++++++++--------- 6 files changed, 50 insertions(+), 29 deletions(-) diff --git a/docs/ja-JP/skills/quarkus-patterns/SKILL.md b/docs/ja-JP/skills/quarkus-patterns/SKILL.md index 3e521aa8..7f59ca92 100644 --- a/docs/ja-JP/skills/quarkus-patterns/SKILL.md +++ b/docs/ja-JP/skills/quarkus-patterns/SKILL.md @@ -340,7 +340,7 @@ public class DocumentResource { public Response list( @QueryParam("page") @DefaultValue("0") int page, @QueryParam("size") @DefaultValue("20") int size) { - PaginatedList documents = documentService.list(page, size); + List documents = documentService.list(page, size); return Response.ok(documents).build(); } @@ -415,7 +415,7 @@ public class DocumentService { return repo.findByIdOptional(id); } - public PaginatedList list(int page, int size) { + public List list(int page, int size) { return repo.findAll() .page(page, size) .list(); @@ -474,12 +474,15 @@ public class GenericExceptionMapper implements ExceptionMapper { ## CompletableFuture非同期操作 ```java +@Slf4j @ApplicationScoped @RequiredArgsConstructor public class FileStorageService { private final S3Client s3Client; private final ExecutorService executorService; + @ConfigProperty(name = "storage.bucket-name") String bucketName; + public CompletableFuture uploadOriginalFile( InputStream inputStream, long size, diff --git a/docs/tr/skills/quarkus-patterns/SKILL.md b/docs/tr/skills/quarkus-patterns/SKILL.md index a209680c..936ea281 100644 --- a/docs/tr/skills/quarkus-patterns/SKILL.md +++ b/docs/tr/skills/quarkus-patterns/SKILL.md @@ -340,7 +340,7 @@ public class DocumentResource { public Response list( @QueryParam("page") @DefaultValue("0") int page, @QueryParam("size") @DefaultValue("20") int size) { - PaginatedList documents = documentService.list(page, size); + List documents = documentService.list(page, size); return Response.ok(documents).build(); } @@ -415,7 +415,7 @@ public class DocumentService { return repo.findByIdOptional(id); } - public PaginatedList list(int page, int size) { + public List list(int page, int size) { return repo.findAll() .page(page, size) .list(); @@ -474,12 +474,15 @@ public class GenericExceptionMapper implements ExceptionMapper { ## CompletableFuture Async İşlemleri ```java +@Slf4j @ApplicationScoped @RequiredArgsConstructor public class FileStorageService { private final S3Client s3Client; private final ExecutorService executorService; + @ConfigProperty(name = "storage.bucket-name") String bucketName; + public CompletableFuture uploadOriginalFile( InputStream inputStream, long size, diff --git a/docs/tr/skills/quarkus-tdd/SKILL.md b/docs/tr/skills/quarkus-tdd/SKILL.md index 2ebb9d3f..f01a2de1 100644 --- a/docs/tr/skills/quarkus-tdd/SKILL.md +++ b/docs/tr/skills/quarkus-tdd/SKILL.md @@ -528,10 +528,10 @@ class FileStorageServiceTest { @DisplayName("Dosyayı başarıyla yüklemeli ve belge bilgisi döndürmeli") void givenValidFile_whenUpload_thenReturnsDocumentInfo() throws Exception { // ARRANGE - when(executorService.submit(any(Callable.class))).thenAnswer(invocation -> { - Callable callable = invocation.getArgument(0); - return CompletableFuture.completedFuture(callable.call()); - }); + doAnswer(invocation -> { + ((Runnable) invocation.getArgument(0)).run(); + return null; + }).when(executorService).execute(any(Runnable.class)); when(s3Client.putObject(any(PutObjectRequest.class), any(RequestBody.class))) .thenReturn(PutObjectResponse.builder().build()); @@ -556,9 +556,13 @@ class FileStorageServiceTest { @DisplayName("S3 yükleme başarısızlığını ele almalı") void givenS3Failure_whenUpload_thenCompletableFutureFails() { // ARRANGE - when(executorService.submit(any(Callable.class))).thenAnswer(invocation -> { - return CompletableFuture.failedFuture(new StorageException("S3 unavailable")); - }); + doAnswer(invocation -> { + ((Runnable) invocation.getArgument(0)).run(); + return null; + }).when(executorService).execute(any(Runnable.class)); + + when(s3Client.putObject(any(PutObjectRequest.class), any(RequestBody.class))) + .thenThrow(new StorageException("S3 unavailable")); // ACT CompletableFuture future = @@ -578,11 +582,11 @@ class FileStorageServiceTest { // ARRANGE AtomicReference capturedContext = new AtomicReference<>(); - when(executorService.submit(any(Callable.class))).thenAnswer(invocation -> { - Callable callable = invocation.getArgument(0); + doAnswer(invocation -> { capturedContext.set(CustomLog.getCurrentContext()); - return CompletableFuture.completedFuture(callable.call()); - }); + ((Runnable) invocation.getArgument(0)).run(); + return null; + }).when(executorService).execute(any(Runnable.class)); // ACT fileStorageService.uploadOriginalFile(testInputStream, 1024L, diff --git a/docs/zh-CN/skills/quarkus-patterns/SKILL.md b/docs/zh-CN/skills/quarkus-patterns/SKILL.md index 735cded0..56161a68 100644 --- a/docs/zh-CN/skills/quarkus-patterns/SKILL.md +++ b/docs/zh-CN/skills/quarkus-patterns/SKILL.md @@ -320,7 +320,7 @@ public class DocumentResource { public Response list( @QueryParam("page") @DefaultValue("0") int page, @QueryParam("size") @DefaultValue("20") int size) { - PaginatedList documents = documentService.list(page, size); + List documents = documentService.list(page, size); return Response.ok(documents).build(); } @@ -448,12 +448,15 @@ public class GenericExceptionMapper implements ExceptionMapper { ## CompletableFuture异步操作 ```java +@Slf4j @ApplicationScoped @RequiredArgsConstructor public class FileStorageService { private final S3Client s3Client; private final ExecutorService executorService; + @ConfigProperty(name = "storage.bucket-name") String bucketName; + public CompletableFuture uploadOriginalFile( InputStream inputStream, long size, diff --git a/skills/quarkus-patterns/SKILL.md b/skills/quarkus-patterns/SKILL.md index 3e54d196..2bb6a770 100644 --- a/skills/quarkus-patterns/SKILL.md +++ b/skills/quarkus-patterns/SKILL.md @@ -343,7 +343,7 @@ public class DocumentResource { public Response list( @QueryParam("page") @DefaultValue("0") int page, @QueryParam("size") @DefaultValue("20") int size) { - PaginatedList documents = documentService.list(page, size); + List documents = documentService.list(page, size); return Response.ok(documents).build(); } @@ -477,12 +477,16 @@ public class GenericExceptionMapper implements ExceptionMapper { ## CompletableFuture Async Operations ```java +@Slf4j @ApplicationScoped @RequiredArgsConstructor public class FileStorageService { private final S3Client s3Client; private final ExecutorService executorService; + @ConfigProperty(name = "storage.bucket-name") + String bucketName; + public CompletableFuture uploadOriginalFile( InputStream inputStream, long size, diff --git a/skills/quarkus-tdd/SKILL.md b/skills/quarkus-tdd/SKILL.md index 08aa7774..b6cd88cf 100644 --- a/skills/quarkus-tdd/SKILL.md +++ b/skills/quarkus-tdd/SKILL.md @@ -531,10 +531,10 @@ class FileStorageServiceTest { @DisplayName("Should successfully upload file and return document info") void givenValidFile_whenUpload_thenReturnsDocumentInfo() throws Exception { // ARRANGE - when(executorService.submit(any(Callable.class))).thenAnswer(invocation -> { - Callable callable = invocation.getArgument(0); - return CompletableFuture.completedFuture(callable.call()); - }); + doAnswer(invocation -> { + ((Runnable) invocation.getArgument(0)).run(); + return null; + }).when(executorService).execute(any(Runnable.class)); when(s3Client.putObject(any(PutObjectRequest.class), any(RequestBody.class))) .thenReturn(PutObjectResponse.builder().build()); @@ -558,10 +558,14 @@ class FileStorageServiceTest { @Test @DisplayName("Should handle S3 upload failure") void givenS3Failure_whenUpload_thenCompletableFutureFails() { - // ARRANGE - when(executorService.submit(any(Callable.class))).thenAnswer(invocation -> { - return CompletableFuture.failedFuture(new StorageException("S3 unavailable")); - }); + // ARRANGE — run synchronously so exception propagates through the future + doAnswer(invocation -> { + ((Runnable) invocation.getArgument(0)).run(); + return null; + }).when(executorService).execute(any(Runnable.class)); + + when(s3Client.putObject(any(PutObjectRequest.class), any(RequestBody.class))) + .thenThrow(new StorageException("S3 unavailable")); // ACT CompletableFuture future = @@ -581,11 +585,11 @@ class FileStorageServiceTest { // ARRANGE AtomicReference capturedContext = new AtomicReference<>(); - when(executorService.submit(any(Callable.class))).thenAnswer(invocation -> { - Callable callable = invocation.getArgument(0); + doAnswer(invocation -> { capturedContext.set(CustomLog.getCurrentContext()); - return CompletableFuture.completedFuture(callable.call()); - }); + ((Runnable) invocation.getArgument(0)).run(); + return null; + }).when(executorService).execute(any(Runnable.class)); // ACT fileStorageService.uploadOriginalFile(testInputStream, 1024L,