[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73191GXT2BNZX8JB9DP3MRM":3,"skill-same:01M73191GXT2BNZX8JB9DP3MRM":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M73191GXT2BNZX8JB9DP3MRM","quarkus-tdd",null,"Test-driven development for Quarkus 3.x LTS using JUnit 5, Mockito, REST Assured, Camel testing, and JaCoCo. Use when adding features, fixing bugs, or refactoring event-driven services.","SriramGandhiS\u002FSkills","SriramGandhiS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F211849986?v=4","01M72WQCW12BYX71C6WN584TTA","Sriram S","01M72WQCWTJ2RD0ET1X31AF1RC",1,"MIT","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fskills\u002Fquarkus-tdd\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: quarkus-tdd\ndescription: Test-driven development for Quarkus 3.x LTS using JUnit 5, Mockito, REST Assured, Camel testing, and JaCoCo. Use when adding features, fixing bugs, or refactoring event-driven services.\norigin: ECC\n---\n\n# Quarkus TDD Workflow\n\nTDD guidance for Quarkus 3.x services with 80%+ coverage (unit + integration). Optimized for event-driven architectures with Apache Camel.\n\n## When to Use\n\n- New features or REST endpoints\n- Bug fixes or refactors\n- Adding data access logic, security rules, or reactive streams\n- Testing Apache Camel routes and event handlers\n- Testing event-driven services with RabbitMQ\n- Testing conditional flow logic\n- Validating CompletableFuture async operations\n- Testing LogContext propagation\n\n## Workflow\n\n1. Write tests first (they should fail)\n2. Implement minimal code to pass\n3. Refactor with tests green\n4. Enforce coverage with JaCoCo (80%+ target)\n\n## Unit Tests with @Nested Organization\n\nFollow this structured approach for comprehensive, readable tests:\n\n```java\n@ExtendWith(MockitoExtension.class)\n@DisplayName(\"OrderService Unit Tests\")\nclass OrderServiceTest {\n  \n  @Mock\n  private OrderRepository orderRepository;\n  \n  @Mock\n  private EventService eventService;\n  \n  @Mock\n  private FulfillmentPublisher fulfillmentPublisher;\n  \n  @InjectMocks\n  private OrderService orderService;\n  \n  private CreateOrderCommand validCommand;\n\n  @BeforeEach\n  void setUp() {\n    validCommand = new CreateOrderCommand(\n        \"customer-123\",\n        List.of(new OrderLine(\"sku-123\", 2))\n    );\n  }\n\n  @Nested\n  @DisplayName(\"Tests for createOrder\")\n  class CreateOrder {\n    \n    @Test\n    @DisplayName(\"Should persist order and publish fulfillment event\")\n    void givenValidCommand_whenCreateOrder_thenPersistsAndPublishes() {\n      \u002F\u002F ARRANGE\n      doNothing().when(orderRepository).persist(any(Order.class));\n      \n      \u002F\u002F ACT\n      OrderReceipt receipt = orderService.createOrder(validCommand);\n      \n      \u002F\u002F ASSERT\n      assertThat(receipt).isNotNull();\n      assertThat(receipt.customerId()).isEqualTo(\"customer-123\");\n      verify(orderRepository).persist(any(Order.class));\n      verify(fulfillmentPublisher).publishAsync(receipt);\n      verify(eventService).createSuccessEvent(receipt, \"ORDER_CREATED\");\n    }\n\n    @Test\n    @DisplayName(\"Should reject missing customer id\")\n    void givenMissingCustomerId_whenCreateOrder_thenThrowsBadRequest() {\n      \u002F\u002F ARRANGE\n      CreateOrderCommand invalid = new CreateOrderCommand(\"\", validCommand.lines());\n      \n      \u002F\u002F ACT & ASSERT\n      WebApplicationException exception = assertThrows(\n          WebApplicationException.class,\n          () -> orderService.createOrder(invalid)\n      );\n\n      assertThat(exception.getResponse().getStatus()).isEqualTo(400);\n      verify(orderRepository, never()).persist(any(Order.class));\n      verify(fulfillmentPublisher, never()).publishAsync(any());\n    }\n\n    @Test\n    @DisplayName(\"Should record error event when persistence fails\")\n    void givenPersistenceFailure_whenCreateOrder_thenRecordsErrorEvent() {\n      \u002F\u002F ARRANGE\n      doThrow(new PersistenceException(\"database unavailable\"))\n          .when(orderRepository).persist(any(Order.class));\n      \n      \u002F\u002F ACT & ASSERT\n      PersistenceException exception = assertThrows(\n          PersistenceException.class,\n          () -> orderService.createOrder(validCommand)\n      );\n      \n      assertThat(exception.getMessage()).contains(\"database unavailable\");\n      verify(eventService).createErrorEvent(\n          eq(validCommand),\n          eq(\"ORDER_CREATE_FAILED\"),\n          contains(\"database unavailable\")\n      );\n      verify(fulfillmentPublisher, never()).publishAsync(any());\n    }\n\n    @Test\n    @DisplayName(\"Should reject null commands\")\n    void givenNullCommand_whenCreateOrder_thenThrowsNullPointerException() {\n      \u002F\u002F ACT & ASSERT\n      assertThrows(\n          NullPointerException.class,\n          () -> orderService.createOrder(null)\n      );\n      \n      verify(orderRepository, never()).persist(any(Order.class));\n    }\n  }\n}\n```\n\n### Key Testing Patterns\n\n1. **@Nested Classes**: Group tests by method being tested\n2. **@DisplayName**: Provide readable test descriptions for test reports\n3. **Naming Convention**: `givenX_whenY_thenZ` for clarity\n4. **AAA Pattern**: Explicit `\u002F\u002F ARRANGE`, `\u002F\u002F ACT`, `\u002F\u002F ASSERT` comments\n5. **@BeforeEach**: Setup common test data to reduce duplication\n6. **assertDoesNotThrow**: Test success scenarios without catching exceptions\n7. **assertThrows**: Test exception scenarios with message validation using AssertJ\n8. **Comprehensive Coverage**: Test happy paths, null inputs, edge cases, exceptions\n9. **Verify Interactions**: Use Mockito `verify()` to ensure methods are called correctly\n10. **Never Verify**: Use `never()` to ensure methods are NOT called in error scenarios\n\n## Testing Camel Routes\n\n```java\n@QuarkusTest\n@DisplayName(\"Business Rules Camel Route Tests\")\nclass BusinessRulesRouteTest {\n\n  @Inject\n  CamelContext camelContext;\n\n  @Inject\n  ProducerTemplate producerTemplate;\n\n  @InjectMock\n  EventService eventService;\n\n  @InjectMock\n  DocumentValidator documentValidator;\n\n  private BusinessRulesPayload testPayload;\n\n  @BeforeEach\n  void setUp() {\n    \u002F\u002F ARRANGE - Test data\n    testPayload = new BusinessRulesPayload();\n    testPayload.setDocumentId(1L);\n    testPayload.setFlowProfile(FlowProfile.BASIC);\n  }\n\n  @Nested\n  @DisplayName(\"Tests for business-rules-publisher route\")\n  class BusinessRulesPublisher {\n\n    @Test\n    @DisplayName(\"Should successfully publish message to RabbitMQ\")\n    void givenValidPayload_whenPublish_thenMessageSentToQueue() throws Exception {\n      \u002F\u002F ARRANGE\n      MockEndpoint mockRabbitMQ = camelContext.getEndpoint(\"mock:rabbitmq\", MockEndpoint.class);\n      mockRabbitMQ.expectedMessageCount(1);\n      \n      \u002F\u002F Replace real endpoint with mock for testing\n      camelContext.getRouteController().stopRoute(\"business-rules-publisher\");\n      AdviceWith.adviceWith(camelContext, \"business-rules-publisher\", advice -> {\n        advice.replaceFromWith(\"direct:business-rules-publisher\");\n        advice.weaveByToString(\".*spring-rabbitmq.*\").replace().to(\"mock:rabbitmq\");\n      });\n      camelContext.getRouteController().startRoute(\"business-rules-publisher\");\n      \n      \u002F\u002F ACT\n      producerTemplate.sendBody(\"direct:business-rules-publisher\", testPayload);\n      \n      \u002F\u002F ASSERT — body is a JSON String after .marshal().json(JsonLibrary.Jackson)\n      mockRabbitMQ.assertIsSatisfied(5000);\n      \n      assertThat(mockRabbitMQ.getExchanges()).hasSize(1);\n      String body = mockRabbitMQ.getExchanges().get(0).getIn().getBody(String.class);\n      assertThat(body).contains(\"\\\"documentId\\\":1\");\n    }\n\n    @Test\n    @DisplayName(\"Should handle marshalling to JSON\")\n    void givenPayload_whenPublish_thenMarshalledToJson() throws Exception {\n      \u002F\u002F ARRANGE\n      MockEndpoint mockMarshal = new MockEndpoint(\"mock:marshal\");\n      camelContext.addEndpoint(\"mock:marshal\", mockMarshal);\n      mockMarshal.expectedMessageCount(1);\n      \n      camelContext.getRouteController().stopRoute(\"business-rules-publisher\");\n      AdviceWith.adviceWith(camelContext, \"business-rules-publisher\", advice -> {\n        advice.weaveAddLast().to(\"mock:marshal\");\n      });\n      camelContext.getRouteController().startRoute(\"business-rules-publisher\");\n      \n      \u002F\u002F ACT\n      producerTemplate.sendBody(\"direct:business-rules-publisher\", testPayload);\n      \n      \u002F\u002F ASSERT\n      mockMarshal.assertIsSatisfied(5000);\n      \n      String body = mockMarshal.getExchanges().get(0).getIn().getBody(String.class);\n      assertThat(body).contains(\"\\\"documentId\\\":1\");\n      assertThat(body).contains(\"\\\"flowProfile\\\":\\\"BASIC\\\"\");\n    }\n  }\n\n  @Nested\n  @DisplayName(\"Tests for document-processing route\")\n  class DocumentProcessing {\n\n    @Test\n    @DisplayName(\"Should route invoice to correct processor\")\n    void givenInvoiceType_whenProcess_thenRoutesToInvoiceProcessor() throws Exception {\n      \u002F\u002F ARRANGE\n      MockEndpoint mockInvoice = camelContext.getEndpoint(\"mock:invoice\", MockEndpoint.class);\n      mockInvoice.expectedMessageCount(1);\n      \n      camelContext.getRouteController().stopRoute(\"document-processing\");\n      AdviceWith.adviceWith(camelContext, \"document-processing\", advice -> {\n        advice.weaveByToString(\".*direct:process-invoice.*\").replace().to(\"mock:invoice\");\n      });\n      camelContext.getRouteController().startRoute(\"document-processing\");\n      \n      \u002F\u002F ACT\n      producerTemplate.sendBodyAndHeader(\"direct:process-document\", \n          testPayload, \"documentType\", \"INVOICE\");\n      \n      \u002F\u002F ASSERT\n      mockInvoice.assertIsSatisfied(5000);\n    }\n\n    @Test\n    @DisplayName(\"Should handle validation errors gracefully\")\n    void givenValidationError_whenProcess_thenRoutesToErrorHandler() throws Exception {\n      \u002F\u002F ARRANGE\n      MockEndpoint mockError = camelContext.getEndpoint(\"mock:error\", MockEndpoint.class);\n      mockError.expectedMessageCount(1);\n      \n      camelContext.getRouteController().stopRoute(\"document-processing\");\n      AdviceWith.adviceWith(camelContext, \"document-processing\", advice -> {\n        advice.weaveByToString(\".*direct:validation-error-handler.*\")\n            .replace().to(\"mock:error\");\n      });\n      camelContext.getRouteController().startRoute(\"document-processing\");\n      \n      \u002F\u002F Mock validator bean to throw exception\n      when(documentValidator.validate(any())).thenThrow(new ValidationException(\"Invalid document\"));\n      \n      \u002F\u002F ACT\n      producerTemplate.sendBody(\"direct:process-document\", testPayload);\n      \n      \u002F\u002F ASSERT\n      mockError.assertIsSatisfied(5000);\n      \n      Exception exception = mockError.getExchanges().get(0).getException();\n      assertThat(exception).isInstanceOf(ValidationException.class);\n      assertThat(exception.getMessage()).contains(\"Invalid document\");\n    }\n  }\n}\n```\n\n## Testing Event Services\n\n```java\n@ExtendWith(MockitoExtension.class)\n@DisplayName(\"EventService Unit Tests\")\nclass EventServiceTest {\n\n  @Mock\n  private EventRepository eventRepository;\n  \n  @Mock\n  private ObjectMapper objectMapper;\n  \n  @InjectMocks\n  private EventService eventService;\n  \n  private BusinessRulesPayload testPayload;\n\n  @BeforeEach\n  void setUp() {\n    \u002F\u002F ARRANGE\n    testPayload = new BusinessRulesPayload();\n    testPayload.setDocumentId(1L);\n  }\n\n  @Nested\n  @DisplayName(\"Tests for createSuccessEvent\")\n  class CreateSuccessEvent {\n    \n    @Test\n    @DisplayName(\"Should create success event with correct attributes\")\n    void givenValidPayload_whenCreateSuccessEvent_thenEventPersisted() throws Exception {\n      \u002F\u002F ARRANGE\n      when(objectMapper.writeValueAsString(testPayload)).thenReturn(\"{\\\"documentId\\\":1}\");\n      \n      \u002F\u002F ACT\n      assertDoesNotThrow(() -> \n          eventService.createSuccessEvent(testPayload, \"DOCUMENT_PROCESSED\"));\n      \n      \u002F\u002F ASSERT\n      verify(eventRepository).persist(argThat(event -> \n          event.getType().equals(\"DOCUMENT_PROCESSED\") &&\n          event.getStatus() == EventStatus.SUCCESS &&\n          event.getPayload().equals(\"{\\\"documentId\\\":1}\") &&\n          event.getTimestamp() != null\n      ));\n    }\n\n    @Test\n    @DisplayName(\"Should throw exception when payload is null\")\n    void givenNullPayload_whenCreateSuccessEvent_thenThrowsException() {\n      \u002F\u002F ARRANGE\n      Object nullPayload = null;\n      \n      \u002F\u002F ACT & ASSERT\n      NullPointerException exception = assertThrows(\n          NullPointerException.class,\n          () -> eventService.createSuccessEvent(nullPayload, \"EVENT_TYPE\")\n      );\n      \n      assertThat(exception.getMessage()).isEqualTo(\"Payload cannot be null\");\n      verify(eventRepository, never()).persist(any());\n    }\n  }\n\n  @Nested\n  @DisplayName(\"Tests for createErrorEvent\")\n  class CreateErrorEvent {\n    \n    @Test\n    @DisplayName(\"Should create error event with error message\")\n    void givenError_whenCreateErrorEvent_thenEventPersistedWithMessage() throws Exception {\n      \u002F\u002F ARRANGE\n      String errorMessage = \"Processing failed\";\n      when(objectMapper.writeValueAsString(testPayload)).thenReturn(\"{\\\"documentId\\\":1}\");\n      \n      \u002F\u002F ACT\n      assertDoesNotThrow(() -> \n          eventService.createErrorEvent(testPayload, \"PROCESSING_ERROR\", errorMessage));\n      \n      \u002F\u002F ASSERT\n      verify(eventRepository).persist(argThat(event -> \n          event.getType().equals(\"PROCESSING_ERROR\") &&\n          event.getStatus() == EventStatus.ERROR &&\n          event.getErrorMessage().equals(errorMessage) &&\n          event.getPayload().equals(\"{\\\"documentId\\\":1}\")\n      ));\n    }\n\n    @ParameterizedTest\n    @DisplayName(\"Should reject invalid error messages\")\n    @ValueSource(strings = {\"\", \" \"})\n    void givenBlankErrorMessage_whenCreateErrorEvent_thenThrowsException(String blankMessage) {\n      \u002F\u002F ACT & ASSERT\n      IllegalArgumentException exception = assertThrows(\n          IllegalArgumentException.class,\n          () -> eventService.createErrorEvent(testPayload, \"ERROR\", blankMessage)\n      );\n      \n      assertThat(exception.getMessage()).contains(\"Error message cannot be blank\");\n    }\n  }\n}\n```\n\n## Testing CompletableFuture\n\n```java\n@ExtendWith(MockitoExtension.class)\n@DisplayName(\"FileStorageService Unit Tests\")\nclass FileStorageServiceTest {\n\n  @Mock\n  private S3Client s3Client;\n  \n  @Mock\n  private ExecutorService executorService;\n  \n  @InjectMocks\n  private FileStorageService fileStorageService;\n  \n  private InputStream testInputStream;\n  private LogContext testLogContext;\n\n  @BeforeEach\n  void setUp() {\n    \u002F\u002F ARRANGE\n    testInputStream = new ByteArrayInputStream(\"test content\".getBytes());\n    testLogContext = new LogContext();\n    testLogContext.put(\"traceId\", \"trace-123\");\n  }\n\n  @Nested\n  @DisplayName(\"Tests for uploadOriginalFile\")\n  class UploadOriginalFile {\n    \n    @Test\n    @DisplayName(\"Should successfully upload file and return document info\")\n    void givenValidFile_whenUpload_thenReturnsDocumentInfo() throws Exception {\n      \u002F\u002F ARRANGE\n      doAnswer(invocation -> {\n        ((Runnable) invocation.getArgument(0)).run();\n        return null;\n      }).when(executorService).execute(any(Runnable.class));\n      \n      when(s3Client.putObject(any(PutObjectRequest.class), any(RequestBody.class)))\n          .thenReturn(PutObjectResponse.builder().build());\n      \n      \u002F\u002F ACT\n      CompletableFuture\u003CStoredDocumentInfo> future = \n          fileStorageService.uploadOriginalFile(testInputStream, 1024L, \n              testLogContext, InvoiceFormat.UBL);\n      \n      StoredDocumentInfo result = future.join();\n      \n      \u002F\u002F ASSERT\n      assertThat(result).isNotNull();\n      assertThat(result.getPath()).isNotBlank();\n      assertThat(result.getSize()).isEqualTo(1024L);\n      assertThat(result.getUploadedAt()).isNotNull();\n      \n      verify(s3Client).putObject(any(PutObjectRequest.class), any(RequestBody.class));\n    }\n\n    @Test\n    @DisplayName(\"Should handle S3 upload failure\")\n    void givenS3Failure_whenUpload_thenCompletableFutureFails() {\n      \u002F\u002F ARRANGE — run synchronously so exception propagates through the future\n      doAnswer(invocation -> {\n        ((Runnable) invocation.getArgument(0)).run();\n        return null;\n      }).when(executorService).execute(any(Runnable.class));\n      \n      when(s3Client.putObject(any(PutObjectRequest.class), any(RequestBody.class)))\n          .thenThrow(new StorageException(\"S3 unavailable\"));\n      \n      \u002F\u002F ACT\n      CompletableFuture\u003CStoredDocumentInfo> future = \n          fileStorageService.uploadOriginalFile(testInputStream, 1024L, \n              testLogContext, InvoiceFormat.UBL);\n      \n      \u002F\u002F ASSERT\n      assertThatThrownBy(() -> future.join())\n          .isInstanceOf(CompletionException.class)\n          .hasCauseInstanceOf(StorageException.class)\n          .hasMessageContaining(\"S3 unavailable\");\n    }\n\n    @Test\n    @DisplayName(\"Should propagate LogContext to async operation\")\n    void givenLogContext_whenUpload_thenContextPropagated() throws Exception {\n      \u002F\u002F ARRANGE\n      AtomicReference\u003CLogContext> capturedContext = new AtomicReference\u003C>();\n      \n      doAnswer(invocation -> {\n        capturedContext.set(CustomLog.getCurrentContext());\n        ((Runnable) invocation.getArgument(0)).run();\n        return null;\n      }).when(executorService).execute(any(Runnable.class));\n      \n      \u002F\u002F ACT\n      fileStorageService.uploadOriginalFile(testInputStream, 1024L, \n          testLogContext, InvoiceFormat.UBL).join();\n      \n      \u002F\u002F ASSERT\n      assertThat(capturedContext.get()).isNotNull();\n      assertThat(capturedContext.get().get(\"traceId\")).isEqualTo(\"trace-123\");\n    }\n  }\n}\n```\n\n## Resource Layer Tests (REST Assured)\n\n```java\n@QuarkusTest\n@DisplayName(\"DocumentResource API Tests\")\nclass DocumentResourceTest {\n\n  @InjectMock\n  DocumentService documentService;\n\n  @Nested\n  @DisplayName(\"Tests for GET \u002Fapi\u002Fdocuments\")\n  class ListDocuments {\n\n    @Test\n    @DisplayName(\"Should return list of documents\")\n    void givenDocumentsExist_whenList_thenReturnsOk() {\n      \u002F\u002F ARRANGE\n      List\u003CDocument> documents = List.of(createDocument(1L, \"DOC-001\"));\n      when(documentService.list(0, 20)).thenReturn(documents);\n\n      \u002F\u002F ACT & ASSERT\n      given()\n          .when().get(\"\u002Fapi\u002Fdocuments\")\n          .then()\n          .statusCode(200)\n          .body(\"$.size()\", is(1))\n          .body(\"[0].referenceNumber\", equalTo(\"DOC-001\"));\n    }\n  }\n\n  @Nested\n  @DisplayName(\"Tests for POST \u002Fapi\u002Fdocuments\")\n  class CreateDocument {\n\n    @Test\n    @DisplayName(\"Should create document and return 201\")\n    void givenValidRequest_whenCreate_thenReturns201() {\n      \u002F\u002F ARRANGE\n      Document document = createDocument(1L, \"DOC-001\");\n      when(documentService.create(any())).thenReturn(document);\n\n      \u002F\u002F ACT & ASSERT\n      given()\n          .contentType(ContentType.JSON)\n          .body(\"\"\"\n              {\n                \"referenceNumber\": \"DOC-001\",\n                \"description\": \"Test document\",\n                \"validUntil\": \"2030-01-01T00:00:00Z\",\n                \"categories\": [\"test\"]\n              }\n              \"\"\")\n          .when().post(\"\u002Fapi\u002Fdocuments\")\n          .then()\n          .statusCode(201)\n          .header(\"Location\", containsString(\"\u002Fapi\u002Fdocuments\u002F1\"))\n          .body(\"referenceNumber\", equalTo(\"DOC-001\"));\n    }\n\n    @Test\n    @DisplayName(\"Should return 400 for invalid input\")\n    void givenInvalidRequest_whenCreate_thenReturns400() {\n      \u002F\u002F ACT & ASSERT\n      given()\n          .contentType(ContentType.JSON)\n          .body(\"\"\"\n              {\n                \"referenceNumber\": \"\",\n                \"description\": \"Test\"\n              }\n              \"\"\")\n          .when().post(\"\u002Fapi\u002Fdocuments\")\n          .then()\n          .statusCode(400);\n    }\n  }\n\n  private Document createDocument(Long id, String referenceNumber) {\n    Document document = new Document();\n    document.setId(id);\n    document.setReferenceNumber(referenceNumber);\n    document.setStatus(DocumentStatus.PENDING);\n    return document;\n  }\n}\n```\n\n## Integration Tests with Real Database\n\n```java\n@QuarkusTest\n@TestProfile(IntegrationTestProfile.class)\n@DisplayName(\"Document Integration Tests\")\nclass DocumentIntegrationTest {\n\n  @Test\n  @Transactional\n  @DisplayName(\"Should create and retrieve document via API\")\n  void givenNewDocument_whenCreateAndRetrieve_thenSuccessful() {\n    \u002F\u002F ACT - Create via API\n    Long id = given()\n        .contentType(ContentType.JSON)\n        .body(\"\"\"\n            {\n              \"referenceNumber\": \"INT-001\",\n              \"description\": \"Integration test\",\n              \"validUntil\": \"2030-01-01T00:00:00Z\",\n              \"categories\": [\"test\"]\n            }\n            \"\"\")\n        .when().post(\"\u002Fapi\u002Fdocuments\")\n        .then()\n        .statusCode(201)\n        .extract().path(\"id\");\n\n    \u002F\u002F ASSERT - Retrieve via API\n    given()\n        .when().get(\"\u002Fapi\u002Fdocuments\u002F\" + id)\n        .then()\n        .statusCode(200)\n        .body(\"referenceNumber\", equalTo(\"INT-001\"));\n  }\n}\n```\n\n## Coverage with JaCoCo\n\n### Maven Configuration (Complete)\n\n```xml\n\u003Cplugin>\n  \u003CgroupId>org.jacoco\u003C\u002FgroupId>\n  \u003CartifactId>jacoco-maven-plugin\u003C\u002FartifactId>\n  \u003Cversion>0.8.13\u003C\u002Fversion>\n  \u003Cexecutions>\n    \u003C!-- Prepare agent for test execution -->\n    \u003Cexecution>\n      \u003Cid>prepare-agent\u003C\u002Fid>\n      \u003Cgoals>\n        \u003Cgoal>prepare-agent\u003C\u002Fgoal>\n      \u003C\u002Fgoals>\n    \u003C\u002Fexecution>\n    \n    \u003C!-- Generate coverage report -->\n    \u003Cexecution>\n      \u003Cid>report\u003C\u002Fid>\n      \u003Cphase>verify\u003C\u002Fphase>\n      \u003Cgoals>\n        \u003Cgoal>report\u003C\u002Fgoal>\n      \u003C\u002Fgoals>\n    \u003C\u002Fexecution>\n    \n    \u003C!-- Enforce coverage thresholds -->\n    \u003Cexecution>\n      \u003Cid>check\u003C\u002Fid>\n      \u003Cgoals>\n        \u003Cgoal>check\u003C\u002Fgoal>\n      \u003C\u002Fgoals>\n      \u003Cconfiguration>\n        \u003Crules>\n          \u003Crule>\n            \u003Celement>BUNDLE\u003C\u002Felement>\n            \u003Climits>\n              \u003Climit>\n                \u003Ccounter>LINE\u003C\u002Fcounter>\n                \u003Cvalue>COVEREDRATIO\u003C\u002Fvalue>\n                \u003Cminimum>0.80\u003C\u002Fminimum>\n              \u003C\u002Flimit>\n              \u003Climit>\n                \u003Ccounter>BRANCH\u003C\u002Fcounter>\n                \u003Cvalue>COVEREDRATIO\u003C\u002Fvalue>\n                \u003Cminimum>0.70\u003C\u002Fminimum>\n              \u003C\u002Flimit>\n            \u003C\u002Flimits>\n          \u003C\u002Frule>\n        \u003C\u002Frules>\n      \u003C\u002Fconfiguration>\n    \u003C\u002Fexecution>\n  \u003C\u002Fexecutions>\n\u003C\u002Fplugin>\n```\n\nRun tests with coverage:\n```bash\nmvn clean test\nmvn jacoco:report\nmvn jacoco:check\n\n# Report at: target\u002Fsite\u002Fjacoco\u002Findex.html\n```\n\n## Test Dependencies\n\n```xml\n\u003Cdependencies>\n    \u003C!-- Quarkus Testing -->\n    \u003Cdependency>\n        \u003CgroupId>io.quarkus\u003C\u002FgroupId>\n        \u003CartifactId>quarkus-junit5\u003C\u002FartifactId>\n        \u003Cscope>test\u003C\u002Fscope>\n    \u003C\u002Fdependency>\n    \u003Cdependency>\n        \u003CgroupId>io.quarkus\u003C\u002FgroupId>\n        \u003CartifactId>quarkus-junit5-mockito\u003C\u002FartifactId>\n        \u003Cscope>test\u003C\u002Fscope>\n    \u003C\u002Fdependency>\n    \n    \u003C!-- Mockito -->\n    \u003Cdependency>\n        \u003CgroupId>org.mockito\u003C\u002FgroupId>\n        \u003CartifactId>mockito-core\u003C\u002FartifactId>\n        \u003Cscope>test\u003C\u002Fscope>\n    \u003C\u002Fdependency>\n    \n    \u003C!-- AssertJ (preferred over JUnit assertions) -->\n    \u003Cdependency>\n        \u003CgroupId>org.assertj\u003C\u002FgroupId>\n        \u003CartifactId>assertj-core\u003C\u002FartifactId>\n        \u003Cversion>3.24.2\u003C\u002Fversion>\n        \u003Cscope>test\u003C\u002Fscope>\n    \u003C\u002Fdependency>\n    \n    \u003C!-- REST Assured -->\n    \u003Cdependency>\n        \u003CgroupId>io.rest-assured\u003C\u002FgroupId>\n        \u003CartifactId>rest-assured\u003C\u002FartifactId>\n        \u003Cscope>test\u003C\u002Fscope>\n    \u003C\u002Fdependency>\n    \n    \u003C!-- Camel Testing -->\n    \u003Cdependency>\n        \u003CgroupId>org.apache.camel.quarkus\u003C\u002FgroupId>\n        \u003CartifactId>camel-quarkus-junit5\u003C\u002FartifactId>\n        \u003Cscope>test\u003C\u002Fscope>\n    \u003C\u002Fdependency>\n\u003C\u002Fdependencies>\n```\n\n## Best Practices\n\n### Test Organization\n- Use `@Nested` classes to group tests by method being tested\n- Use `@DisplayName` for readable test descriptions visible in reports\n- Follow `givenX_whenY_thenZ` naming convention for test methods\n- Use `@BeforeEach` for common test data setup to reduce duplication\n\n### Test Structure\n- Follow AAA pattern with explicit comments (`\u002F\u002F ARRANGE`, `\u002F\u002F ACT`, `\u002F\u002F ASSERT`)\n- Use `assertDoesNotThrow` for success scenarios\n- Use `assertThrows` for exception scenarios with message validation\n- Verify exception messages match expected values using AssertJ `contains()` or `isEqualTo()`\n\n### Test Coverage\n- Test happy paths for all public methods\n- Test null input handling\n- Test edge cases (empty collections, boundary values, negative IDs, blank strings)\n- Test exception scenarios comprehensively\n- Mock all external dependencies (repositories, services, Camel endpoints)\n- Aim for 80%+ line coverage, 70%+ branch coverage\n\n### Assertions\n- **Prefer AssertJ** (`assertThat`) over JUnit assertions for value checks\n- Use fluent AssertJ API for readability: `assertThat(list).hasSize(3).contains(item)`\n- For exceptions: use JUnit `assertThrows` to capture, then AssertJ to validate the message\n- For non-throwing success paths: use JUnit `assertDoesNotThrow`\n- For collections: `extracting()`, `filteredOn()`, `containsExactly()`\n\n### Testing Integration\n- Use `@QuarkusTest` for integration tests\n- Use `@InjectMock` to mock dependencies in Quarkus tests\n- Prefer REST Assured for API testing\n- Use `@TestProfile` for test-specific configuration\n\n### Event-Driven Testing\n- Test Camel routes with `AdviceWith` and `MockEndpoint`\n- Use `@CamelQuarkusTest` annotation (if using standalone Camel tests)\n- Verify message content, headers, and routing logic\n- Test error handling routes separately\n- Mock external systems (RabbitMQ, S3, databases) in unit tests\n\n### Camel Route Testing\n- Use `MockEndpoint` for asserting message flow\n- Use `AdviceWith` to modify routes for testing (replace endpoints with mocks)\n- Test message transformation and marshalling\n- Test exception handling and dead letter queues\n\n### Testing Async Operations\n- Test CompletableFuture success and failure scenarios\n- Use `.join()` in tests to wait for async completion\n- Test exception propagation from CompletableFuture\n- Verify LogContext propagation to async operations\n\n### Performance\n- Keep tests fast and isolated\n- Run tests in continuous mode: `mvn quarkus:test`\n- Use parameterized tests (`@ParameterizedTest`) for input variations\n- Build reusable test data builders or factory methods\n\n### Quarkus-Specific\n- Stay on latest LTS version (Quarkus 3.x)\n- Test native compilation compatibility periodically\n- Use Quarkus test profiles for different scenarios\n- Leverage Quarkus dev services for local testing\n- Use `@InjectMock` instead of `@MockBean` (Quarkus-specific)\n\n### Verification Best Practices\n- Always verify interactions on mocked dependencies\n- Use `verify(mock, never())` to ensure methods are NOT called in error scenarios\n- Use `argThat()` for complex argument matching\n- Verify the order of calls when it matters: `InOrder` from Mockito\n","# Quarkus TDD Workflow\n\nTDD guidance for Quarkus 3.x services with 80%+ coverage (unit + integration). Optimized for event-driven architectures with Apache Camel.\n\n## When to Use\n\n- New features or REST endpoints\n- Bug fixes or refactors\n- Adding data access logic, security rules, or reactive streams\n- Testing Apache Camel routes and event handlers\n- Testing event-driven services with RabbitMQ\n- Testing conditional flow logic\n- Validating CompletableFuture async operations\n- Testing LogContext propagation\n\n## Workflow\n\n1. Write tests first (they should fail)\n2. Implement minimal code to pass\n3. Refactor with tests green\n4. Enforce coverage with JaCoCo (80%+ target)\n\n## Unit Tests with @Nested Organization\n\nFollow this structured approach for comprehensive, readable tests:\n\n```java\n@ExtendWith(MockitoExtension.class)\n@DisplayName(\"OrderService Unit Tests\")\nclass OrderServiceTest {\n  \n  @Mock\n  private OrderRepository orderRepository;\n  \n  @Mock\n  private EventService eventService;\n  \n  @Mock\n  private FulfillmentPublisher fulfillmentPublisher;\n  \n  @InjectMocks\n  private OrderService orderService;\n  \n  private CreateOrderCommand validCommand;\n\n  @BeforeEach\n  void setUp() {\n    validCommand = new CreateOrderCommand(\n        \"customer-123\",\n        List.of(new OrderLine(\"sku-123\", 2))\n    );\n  }\n\n  @Nested\n  @DisplayName(\"Tests for createOrder\")\n  class CreateOrder {\n    \n    @Test\n    @DisplayName(\"Should persist order and publish fulfillment event\")\n    void givenValidCommand_whenCreateOrder_thenPersistsAndPublishes() {\n      \u002F\u002F ARRANGE\n      doNothing().when(orderRepository).persist(any(Order.class));\n      \n      \u002F\u002F ACT\n      OrderReceipt receipt = orderService.createOrder(validCommand);\n      \n      \u002F\u002F ASSERT\n      assertThat(receipt).isNotNull();\n      assertThat(receipt.customerId()).isEqualTo(\"customer-123\");\n      verify(orderRepository).persist(any(Order.class));\n      verify(fulfillmentPublisher).publishAsync(receipt);\n      verify(eventService).createSuccessEvent(receipt, \"ORDER_CREATED\");\n    }\n\n    @Test\n    @DisplayName(\"Should reject missing customer id\")\n    void givenMissingCustomerId_whenCreateOrder_thenThrowsBadRequest() {\n      \u002F\u002F ARRANGE\n      CreateOrderCommand invalid = new CreateOrderCommand(\"\", validCommand.lines());\n      \n      \u002F\u002F ACT & ASSERT\n      WebApplicationException exception = assertThrows(\n          WebApplicationException.class,\n          () -> orderService.createOrder(invalid)\n      );\n\n      assertThat(exception.getResponse().getStatus()).isEqualTo(400);\n      verify(orderRepository, never()).persist(any(Order.class));\n      verify(fulfillmentPublisher, never()).publishAsync(any());\n    }\n\n    @Test\n    @DisplayName(\"Should record error event when persistence fails\")\n    void givenPersistenceFailure_whenCreateOrder_thenRecordsErrorEvent() {\n      \u002F\u002F ARRANGE\n      doThrow(new PersistenceException(\"database unavailable\"))\n          .when(orderRepository).persist(any(Order.class));\n      \n      \u002F\u002F ACT & ASSERT\n      PersistenceException exception = assertThrows(\n          PersistenceException.class,\n          () -> orderService.createOrder(validCommand)\n      );\n      \n      assertThat(exception.getMessage()).contains(\"database unavailable\");\n      verify(eventService).createErrorEvent(\n          eq(validCommand),\n          eq(\"ORDER_CREATE_FAILED\"),\n          contains(\"database unavailable\")\n      );\n      verify(fulfillmentPublisher, never()).publishAsync(any());\n    }\n\n    @Test\n    @DisplayName(\"Should reject null commands\")\n    void givenNullCommand_whenCreateOrder_thenThrowsNullPointerException() {\n      \u002F\u002F ACT & ASSERT\n      assertThrows(\n          NullPointerException.class,\n          () -> orderService.createOrder(null)\n      );\n      \n      verify(orderRepository, never()).persist(any(Order.class));\n    }\n  }\n}\n```\n\n### Key Testing Patterns\n\n1. **@Nested Classes**: Group tests by method being tested\n2. **@DisplayName**: Provide readable test descriptions for test reports\n3. **Naming Convention**: `givenX_whenY_thenZ` for clarity\n4. **AAA Pattern**: Explicit `\u002F\u002F ARRANGE`, `\u002F\u002F ACT`, `\u002F\u002F ASSERT` comments\n5. **@BeforeEach**: Setup common test data to reduce duplication\n6. **assertDoesNotThrow**: Test success scenarios without catching exceptions\n7. **assertThrows**: Test exception scenarios with message validation using AssertJ\n8. **Comprehensive Coverage**: Test happy paths, null inputs, edge cases, exceptions\n9. **Verify Interactions**: Use Mockito `verify()` to ensure methods are called correctly\n10. **Never Verify**: Use `never()` to ensure methods are NOT called in error scenarios\n\n## Testing Camel Routes\n\n```java\n@QuarkusTest\n@DisplayName(\"Business Rules Camel Route Tests\")\nclass BusinessRulesRouteTest {\n\n  @Inject\n  CamelContext camelContext;\n\n  @Inject\n  ProducerTemplate producerTemplate;\n\n  @InjectMock\n  EventService eventService;\n\n  @InjectMock\n  DocumentValidator documentValidator;\n\n  private BusinessRulesPayload testPayload;\n\n  @BeforeEach\n  void setUp() {\n    \u002F\u002F ARRANGE - Test data\n    testPayload = new BusinessRulesPayload();\n    testPayload.setDocumentId(1L);\n    testPayload.setFlowProfile(FlowProfile.BASIC);\n  }\n\n  @Nested\n  @DisplayName(\"Tests for business-rules-publisher route\")\n  class BusinessRulesPublisher {\n\n    @Test\n    @DisplayName(\"Should successfully publish message to RabbitMQ\")\n    void givenValidPayload_whenPublish_thenMessageSentToQueue() throws Exception {\n      \u002F\u002F ARRANGE\n      MockEndpoint mockRabbitMQ = camelContext.getEndpoint(\"mock:rabbitmq\", MockEndpoint.class);\n      mockRabbitMQ.expectedMessageCount(1);\n      \n      \u002F\u002F Replace real endpoint with mock for testing\n      camelContext.getRouteController().stopRoute(\"business-rules-publisher\");\n      AdviceWith.adviceWith(camelContext, \"business-rules-publisher\", advice -> {\n        advice.replaceFromWith(\"direct:business-rules-publisher\");\n        advice.weaveByToString(\".*spring-rabbitmq.*\").replace().to(\"mock:rabbitmq\");\n      });\n      camelContext.getRouteController().startRoute(\"business-rules-publisher\");\n      \n      \u002F\u002F ACT\n      producerTemplate.sendBody(\"direct:business-rules-publisher\", testPayload);\n      \n      \u002F\u002F ASSERT — body is a JSON String after .marshal().json(JsonLibrary.Jackson)\n      mockRabbitMQ.assertIsSatisfied(5000);\n      \n      assertThat(mockRabbitMQ.getExchanges()).hasSize(1);\n      String body = mockRabbitMQ.getExchanges().get(0).getIn().getBody(String.class);\n      assertThat(body).contains(\"\\\"documentId\\\":1\");\n    }\n\n    @Test\n    @DisplayName(\"Should handle marshalling to JSON\")\n    void givenPayload_whenPublish_thenMarshalledToJson() throws Exception {\n      \u002F\u002F ARRANGE\n      MockEndpoint mockMarshal = new MockEndpoint(\"mock:marshal\");\n      camelContext.addEndpoint(\"mock:marshal\", mockMarshal);\n      mockMarshal.expectedMessageCount(1);\n      \n      camelContext.getRouteController().stopRoute(\"business-rules-publisher\");\n      AdviceWith.adviceWith(camelContext, \"business-rules-publisher\", advice -> {\n        advice.weaveAddLast().to(\"mock:marshal\");\n      });\n      camelContext.getRouteController().startRoute(\"business-rules-publisher\");\n      \n      \u002F\u002F ACT\n      producerTemplate.sendBody(\"direct:business-rules-publisher\", testPayload);\n      \n      \u002F\u002F ASSERT\n      mockMarshal.assertIsSatisfied(5000);\n      \n      String body = mockMarshal.getExchanges().get(0).getIn().getBody(String.class);\n      assertThat(body).contains(\"\\\"documentId\\\":1\");\n      assertThat(body).contains(\"\\\"flowProfile\\\":\\\"BASIC\\\"\");\n    }\n  }\n\n  @Nested\n  @DisplayName(\"Tests for document-processing route\")\n  class DocumentProcessing {\n\n    @Test\n    @DisplayName(\"Should route invoice to correct processor\")\n    void givenInvoiceType_whenProcess_thenRoutesToInvoiceProcessor() throws Exception {\n      \u002F\u002F ARRANGE\n      MockEndpoint mockInvoice = camelContext.getEndpoint(\"mock:invoice\", MockEndpoint.class);\n      mockInvoice.expectedMessageCount(1);\n      \n      camelContext.getRouteController().stopRoute(\"document-processing\");\n      AdviceWith.adviceWith(camelContext, \"document-processing\", advice -> {\n        advice.weaveByToString(\".*direct:process-invoice.*\").replace().to(\"mock:invoice\");\n      });\n      camelContext.getRouteController().startRoute(\"document-processing\");\n      \n      \u002F\u002F ACT\n      producerTemplate.sendBodyAndHeader(\"direct:process-document\", \n          testPayload, \"documentType\", \"INVOICE\");\n      \n      \u002F\u002F ASSERT\n      mockInvoice.assertIsSatisfied(5000);\n    }\n\n    @Test\n    @DisplayName(\"Should handle validation errors gracefully\")\n    void givenValidationError_whenProcess_thenRoutesToErrorHandler() throws Exception {\n      \u002F\u002F ARRANGE\n      MockEndpoint mockError = camelContext.getEndpoint(\"mock:error\", MockEndpoint.class);\n      mockError.expectedMessageCount(1);\n      \n      camelContext.getRouteController().stopRoute(\"document-processing\");\n      AdviceWith.adviceWith(camelContext, \"document-processing\", advice -> {\n        advice.weaveByToString(\".*direct:validation-error-handler.*\")\n            .replace().to(\"mock:error\");\n      });\n      camelContext.getRouteController().startRoute(\"document-processing\");\n      \n      \u002F\u002F Mock validator bean to throw exception\n      when(documentValidator.validate(any())).thenThrow(new ValidationException(\"Invalid document\"));\n      \n      \u002F\u002F ACT\n      producerTemplate.sendBody(\"direct:process-document\", testPayload);\n      \n      \u002F\u002F ASSERT\n      mockError.assertIsSatisfied(5000);\n      \n      Exception exception = mockError.getExchanges().get(0).getException();\n      assertThat(exception).isInstanceOf(ValidationException.class);\n      assertThat(exception.getMessage()).contains(\"Invalid document\");\n    }\n  }\n}\n```\n\n## Testing Event Services\n\n```java\n@ExtendWith(MockitoExtension.class)\n@DisplayName(\"EventService Unit Tests\")\nclass EventServiceTest {\n\n  @Mock\n  private EventRepository eventRepository;\n  \n  @Mock\n  private ObjectMapper objectMapper;\n  \n  @InjectMocks\n  private EventService eventService;\n  \n  private BusinessRulesPayload testPayload;\n\n  @BeforeEach\n  void setUp() {\n    \u002F\u002F ARRANGE\n    testPayload = new BusinessRulesPayload();\n    testPayload.setDocumentId(1L);\n  }\n\n  @Nested\n  @DisplayName(\"Tests for createSuccessEvent\")\n  class CreateSuccessEvent {\n    \n    @Test\n    @DisplayName(\"Should create success event with correct attributes\")\n    void givenValidPayload_whenCreateSuccessEvent_thenEventPersisted() throws Exception {\n      \u002F\u002F ARRANGE\n      when(objectMapper.writeValueAsString(testPayload)).thenReturn(\"{\\\"documentId\\\":1}\");\n      \n      \u002F\u002F ACT\n      assertDoesNotThrow(() -> \n          eventService.createSuccessEvent(testPayload, \"DOCUMENT_PROCESSED\"));\n      \n      \u002F\u002F ASSERT\n      verify(eventRepository).persist(argThat(event -> \n          event.getType().equals(\"DOCUMENT_PROCESSED\") &&\n          event.getStatus() == EventStatus.SUCCESS &&\n          event.getPayload().equals(\"{\\\"documentId\\\":1}\") &&\n          event.getTimestamp() != null\n      ));\n    }\n\n    @Test\n    @DisplayName(\"Should throw exception when payload is null\")\n    void givenNullPayload_whenCreateSuccessEvent_thenThrowsException() {\n      \u002F\u002F ARRANGE\n      Object nullPayload = null;\n      \n      \u002F\u002F ACT & ASSERT\n      NullPointerException exception = assertThrows(\n          NullPointerException.class,\n          () -> eventService.createSuccessEvent(nullPayload, \"EVENT_TYPE\")\n      );\n      \n      assertThat(exception.getMessage()).isEqualTo(\"Payload cannot be null\");\n      verify(eventRepository, never()).persist(any());\n    }\n  }\n\n  @Nested\n  @DisplayName(\"Tests for createErrorEvent\")\n  class CreateErrorEvent {\n    \n    @Test\n    @DisplayName(\"Should create error event with error message\")\n    void givenError_whenCreateErrorEvent_thenEventPersistedWithMessage() throws Exception {\n      \u002F\u002F ARRANGE\n      String errorMessage = \"Processing failed\";\n      when(objectMapper.writeValueAsString(testPayload)).thenReturn(\"{\\\"documentId\\\":1}\");\n      \n      \u002F\u002F ACT\n      assertDoesNotThrow(() -> \n          eventService.createErrorEvent(testPayload, \"PROCESSING_ERROR\", errorMessage));\n      \n      \u002F\u002F ASSERT\n      verify(eventRepository).persist(argThat(event -> \n          event.getType().equals(\"PROCESSING_ERROR\") &&\n          event.getStatus() == EventStatus.ERROR &&\n          event.getErrorMessage().equals(errorMessage) &&\n          event.getPayload().equals(\"{\\\"documentId\\\":1}\")\n      ));\n    }\n\n    @ParameterizedTest\n    @DisplayName(\"Should reject invalid error messages\")\n    @ValueSource(strings = {\"\", \" \"})\n    void givenBlankErrorMessage_whenCreateErrorEvent_thenThrowsException(String blankMessage) {\n      \u002F\u002F ACT & ASSERT\n      IllegalArgumentException exception = assertThrows(\n          IllegalArgumentException.class,\n          () -> eventService.createErrorEvent(testPayload, \"ERROR\", blankMessage)\n      );\n      \n      assertThat(exception.getMessage()).contains(\"Error message cannot be blank\");\n    }\n  }\n}\n```\n\n## Testing CompletableFuture\n\n```java\n@ExtendWith(MockitoExtension.class)\n@DisplayName(\"FileStorageService Unit Tests\")\nclass FileStorageServiceTest {\n\n  @Mock\n  private S3Client s3Client;\n  \n  @Mock\n  private ExecutorService executorService;\n  \n  @InjectMocks\n  private FileStorageService fileStorageService;\n  \n  private InputStream testInputStream;\n  private LogContext testLogContext;\n\n  @BeforeEach\n  void setUp() {\n    \u002F\u002F ARRANGE\n    testInputStream = new ByteArrayInputStream(\"test content\".getBytes());\n    testLogContext = new LogContext();\n    testLogContext.put(\"traceId\", \"trace-123\");\n  }\n\n  @Nested\n  @DisplayName(\"Tests for uploadOriginalFile\")\n  class UploadOriginalFile {\n    \n    @Test\n    @DisplayName(\"Should successfully upload file and return document info\")\n    void givenValidFile_whenUpload_thenReturnsDocumentInfo() throws Exception {\n      \u002F\u002F ARRANGE\n      doAnswer(invocation -> {\n        ((Runnable) invocation.getArgument(0)).run();\n        return null;\n      }).when(executorService).execute(any(Runnable.class));\n      \n      when(s3Client.putObject(any(PutObjectRequest.class), any(RequestBody.class)))\n          .thenReturn(PutObjectResponse.builder().build());\n      \n      \u002F\u002F ACT\n      CompletableFuture\u003CStoredDocumentInfo> future = \n          fileStorageService.uploadOriginalFile(testInputStream, 1024L, \n              testLogContext, InvoiceFormat.UBL);\n      \n      StoredDocumentInfo result = future.join();\n      \n      \u002F\u002F ASSERT\n      assertThat(result).isNotNull();\n      assertThat(result.getPath()).isNotBlank();\n      assertThat(result.getSize()).isEqualTo(1024L);\n      assertThat(result.getUploadedAt()).isNotNull();\n      \n      verify(s3Client).putObject(any(PutObjectRequest.class), any(RequestBody.class));\n    }\n\n    @Test\n    @DisplayName(\"Should handle S3 upload failure\")\n    void givenS3Failure_whenUpload_thenCompletableFutureFails() {\n      \u002F\u002F ARRANGE — run synchronously so exception propagates through the future\n      doAnswer(invocation -> {\n        ((Runnable) invocation.getArgument(0)).run();\n        return null;\n      }).when(executorService).execute(any(Runnable.class));\n      \n      when(s3Client.putObject(any(PutObjectRequest.class), any(RequestBody.class)))\n          .thenThrow(new StorageException(\"S3 unavailable\"));\n      \n      \u002F\u002F ACT\n      CompletableFuture\u003CStoredDocumentInfo> future = \n          fileStorageService.uploadOriginalFile(testInputStream, 1024L, \n              testLogContext, InvoiceFormat.UBL);\n      \n      \u002F\u002F ASSERT\n      assertThatThrownBy(() -> future.join())\n          .isInstanceOf(CompletionException.class)\n          .hasCauseInstanceOf(StorageException.class)\n          .hasMessageContaining(\"S3 unavailable\");\n    }\n\n    @Test\n    @DisplayName(\"Should propagate LogContext to async operation\")\n    void givenLogContext_whenUpload_thenContextPropagated() throws Exception {\n      \u002F\u002F ARRANGE\n      AtomicReference\u003CLogContext> capturedContext = new AtomicReference\u003C>();\n      \n      doAnswer(invocation -> {\n        capturedContext.set(CustomLog.getCurrentContext());\n        ((Runnable) invocation.getArgument(0)).run();\n        return null;\n      }).when(executorService).execute(any(Runnable.class));\n      \n      \u002F\u002F ACT\n      fileStorageService.uploadOriginalFile(testInputStream, 1024L, \n          testLogContext, InvoiceFormat.UBL).join();\n      \n      \u002F\u002F ASSERT\n      assertThat(capturedContext.get()).isNotNull();\n      assertThat(capturedContext.get().get(\"traceId\")).isEqualTo(\"trace-123\");\n    }\n  }\n}\n```\n\n## Resource Layer Tests (REST Assured)\n\n```java\n@QuarkusTest\n@DisplayName(\"DocumentResource API Tests\")\nclass DocumentResourceTest {\n\n  @InjectMock\n  DocumentService documentService;\n\n  @Nested\n  @DisplayName(\"Tests for GET \u002Fapi\u002Fdocuments\")\n  class ListDocuments {\n\n    @Test\n    @DisplayName(\"Should return list of documents\")\n    void givenDocumentsExist_whenList_thenReturnsOk() {\n      \u002F\u002F ARRANGE\n      List\u003CDocument> documents = List.of(createDocument(1L, \"DOC-001\"));\n      when(documentService.list(0, 20)).thenReturn(documents);\n\n      \u002F\u002F ACT & ASSERT\n      given()\n          .when().get(\"\u002Fapi\u002Fdocuments\")\n          .then()\n          .statusCode(200)\n          .body(\"$.size()\", is(1))\n          .body(\"[0].referenceNumber\", equalTo(\"DOC-001\"));\n    }\n  }\n\n  @Nested\n  @DisplayName(\"Tests for POST \u002Fapi\u002Fdocuments\")\n  class CreateDocument {\n\n    @Test\n    @DisplayName(\"Should create document and return 201\")\n    void givenValidRequest_whenCreate_thenReturns201() {\n      \u002F\u002F ARRANGE\n      Document document = createDocument(1L, \"DOC-001\");\n      when(documentService.create(any())).thenReturn(document);\n\n      \u002F\u002F ACT & ASSERT\n      given()\n          .contentType(ContentType.JSON)\n          .body(\"\"\"\n              {\n                \"referenceNumber\": \"DOC-001\",\n                \"description\": \"Test document\",\n                \"validUntil\": \"2030-01-01T00:00:00Z\",\n                \"categories\": [\"test\"]\n              }\n              \"\"\")\n          .when().post(\"\u002Fapi\u002Fdocuments\")\n          .then()\n          .statusCode(201)\n          .header(\"Location\", containsString(\"\u002Fapi\u002Fdocuments\u002F1\"))\n          .body(\"referenceNumber\", equalTo(\"DOC-001\"));\n    }\n\n    @Test\n    @DisplayName(\"Should return 400 for invalid input\")\n    void givenInvalidRequest_whenCreate_thenReturns400() {\n      \u002F\u002F ACT & ASSERT\n      given()\n          .contentType(ContentType.JSON)\n          .body(\"\"\"\n              {\n                \"referenceNumber\": \"\",\n                \"description\": \"Test\"\n              }\n              \"\"\")\n          .when().post(\"\u002Fapi\u002Fdocuments\")\n          .then()\n          .statusCode(400);\n    }\n  }\n\n  private Document createDocument(Long id, String referenceNumber) {\n    Document document = new Document();\n    document.setId(id);\n    document.setReferenceNumber(referenceNumber);\n    document.setStatus(DocumentStatus.PENDING);\n    return document;\n  }\n}\n```\n\n## Integration Tests with Real Database\n\n```java\n@QuarkusTest\n@TestProfile(IntegrationTestProfile.class)\n@DisplayName(\"Document Integration Tests\")\nclass DocumentIntegrationTest {\n\n  @Test\n  @Transactional\n  @DisplayName(\"Should create and retrieve document via API\")\n  void givenNewDocument_whenCreateAndRetrieve_thenSuccessful() {\n    \u002F\u002F ACT - Create via API\n    Long id = given()\n        .contentType(ContentType.JSON)\n        .body(\"\"\"\n            {\n              \"referenceNumber\": \"INT-001\",\n              \"description\": \"Integration test\",\n              \"validUntil\": \"2030-01-01T00:00:00Z\",\n              \"categories\": [\"test\"]\n            }\n            \"\"\")\n        .when().post(\"\u002Fapi\u002Fdocuments\")\n        .then()\n        .statusCode(201)\n        .extract().path(\"id\");\n\n    \u002F\u002F ASSERT - Retrieve via API\n    given()\n        .when().get(\"\u002Fapi\u002Fdocuments\u002F\" + id)\n        .then()\n        .statusCode(200)\n        .body(\"referenceNumber\", equalTo(\"INT-001\"));\n  }\n}\n```\n\n## Coverage with JaCoCo\n\n### Maven Configuration (Complete)\n\n```xml\n\u003Cplugin>\n  \u003CgroupId>org.jacoco\u003C\u002FgroupId>\n  \u003CartifactId>jacoco-maven-plugin\u003C\u002FartifactId>\n  \u003Cversion>0.8.13\u003C\u002Fversion>\n  \u003Cexecutions>\n    \u003C!-- Prepare agent for test execution -->\n    \u003Cexecution>\n      \u003Cid>prepare-agent\u003C\u002Fid>\n      \u003Cgoals>\n        \u003Cgoal>prepare-agent\u003C\u002Fgoal>\n      \u003C\u002Fgoals>\n    \u003C\u002Fexecution>\n    \n    \u003C!-- Generate coverage report -->\n    \u003Cexecution>\n      \u003Cid>report\u003C\u002Fid>\n      \u003Cphase>verify\u003C\u002Fphase>\n      \u003Cgoals>\n        \u003Cgoal>report\u003C\u002Fgoal>\n      \u003C\u002Fgoals>\n    \u003C\u002Fexecution>\n    \n    \u003C!-- Enforce coverage thresholds -->\n    \u003Cexecution>\n      \u003Cid>check\u003C\u002Fid>\n      \u003Cgoals>\n        \u003Cgoal>check\u003C\u002Fgoal>\n      \u003C\u002Fgoals>\n      \u003Cconfiguration>\n        \u003Crules>\n          \u003Crule>\n            \u003Celement>BUNDLE\u003C\u002Felement>\n            \u003Climits>\n              \u003Climit>\n                \u003Ccounter>LINE\u003C\u002Fcounter>\n                \u003Cvalue>COVEREDRATIO\u003C\u002Fvalue>\n                \u003Cminimum>0.80\u003C\u002Fminimum>\n              \u003C\u002Flimit>\n              \u003Climit>\n                \u003Ccounter>BRANCH\u003C\u002Fcounter>\n                \u003Cvalue>COVEREDRATIO\u003C\u002Fvalue>\n                \u003Cminimum>0.70\u003C\u002Fminimum>\n              \u003C\u002Flimit>\n            \u003C\u002Flimits>\n          \u003C\u002Frule>\n        \u003C\u002Frules>\n      \u003C\u002Fconfiguration>\n    \u003C\u002Fexecution>\n  \u003C\u002Fexecutions>\n\u003C\u002Fplugin>\n```\n\nRun tests with coverage:\n```bash\nmvn clean test\nmvn jacoco:report\nmvn jacoco:check\n\n# Report at: target\u002Fsite\u002Fjacoco\u002Findex.html\n```\n\n## Test Dependencies\n\n```xml\n\u003Cdependencies>\n    \u003C!-- Quarkus Testing -->\n    \u003Cdependency>\n        \u003CgroupId>io.quarkus\u003C\u002FgroupId>\n        \u003CartifactId>quarkus-junit5\u003C\u002FartifactId>\n        \u003Cscope>test\u003C\u002Fscope>\n    \u003C\u002Fdependency>\n    \u003Cdependency>\n        \u003CgroupId>io.quarkus\u003C\u002FgroupId>\n        \u003CartifactId>quarkus-junit5-mockito\u003C\u002FartifactId>\n        \u003Cscope>test\u003C\u002Fscope>\n    \u003C\u002Fdependency>\n    \n    \u003C!-- Mockito -->\n    \u003Cdependency>\n        \u003CgroupId>org.mockito\u003C\u002FgroupId>\n        \u003CartifactId>mockito-core\u003C\u002FartifactId>\n        \u003Cscope>test\u003C\u002Fscope>\n    \u003C\u002Fdependency>\n    \n    \u003C!-- AssertJ (preferred over JUnit assertions) -->\n    \u003Cdependency>\n        \u003CgroupId>org.assertj\u003C\u002FgroupId>\n        \u003CartifactId>assertj-core\u003C\u002FartifactId>\n        \u003Cversion>3.24.2\u003C\u002Fversion>\n        \u003Cscope>test\u003C\u002Fscope>\n    \u003C\u002Fdependency>\n    \n    \u003C!-- REST Assured -->\n    \u003Cdependency>\n        \u003CgroupId>io.rest-assured\u003C\u002FgroupId>\n        \u003CartifactId>rest-assured\u003C\u002FartifactId>\n        \u003Cscope>test\u003C\u002Fscope>\n    \u003C\u002Fdependency>\n    \n    \u003C!-- Camel Testing -->\n    \u003Cdependency>\n        \u003CgroupId>org.apache.camel.quarkus\u003C\u002FgroupId>\n        \u003CartifactId>camel-quarkus-junit5\u003C\u002FartifactId>\n        \u003Cscope>test\u003C\u002Fscope>\n    \u003C\u002Fdependency>\n\u003C\u002Fdependencies>\n```\n\n## Best Practices\n\n### Test Organization\n- Use `@Nested` classes to group tests by method being tested\n- Use `@DisplayName` for readable test descriptions visible in reports\n- Follow `givenX_whenY_thenZ` naming convention for test methods\n- Use `@BeforeEach` for common test data setup to reduce duplication\n\n### Test Structure\n- Follow AAA pattern with explicit comments (`\u002F\u002F ARRANGE`, `\u002F\u002F ACT`, `\u002F\u002F ASSERT`)\n- Use `assertDoesNotThrow` for success scenarios\n- Use `assertThrows` for exception scenarios with message validation\n- Verify exception messages match expected values using AssertJ `contains()` or `isEqualTo()`\n\n### Test Coverage\n- Test happy paths for all public methods\n- Test null input handling\n- Test edge cases (empty collections, boundary values, negative IDs, blank strings)\n- Test exception scenarios comprehensively\n- Mock all external dependencies (repositories, services, Camel endpoints)\n- Aim for 80%+ line coverage, 70%+ branch coverage\n\n### Assertions\n- **Prefer AssertJ** (`assertThat`) over JUnit assertions for value checks\n- Use fluent AssertJ API for readability: `assertThat(list).hasSize(3).contains(item)`\n- For exceptions: use JUnit `assertThrows` to capture, then AssertJ to validate the message\n- For non-throwing success paths: use JUnit `assertDoesNotThrow`\n- For collections: `extracting()`, `filteredOn()`, `containsExactly()`\n\n### Testing Integration\n- Use `@QuarkusTest` for integration tests\n- Use `@InjectMock` to mock dependencies in Quarkus tests\n- Prefer REST Assured for API testing\n- Use `@TestProfile` for test-specific configuration\n\n### Event-Driven Testing\n- Test Camel routes with `AdviceWith` and `MockEndpoint`\n- Use `@CamelQuarkusTest` annotation (if using standalone Camel tests)\n- Verify message content, headers, and routing logic\n- Test error handling routes separately\n- Mock external systems (RabbitMQ, S3, databases) in unit tests\n\n### Camel Route Testing\n- Use `MockEndpoint` for asserting message flow\n- Use `AdviceWith` to modify routes for testing (replace endpoints with mocks)\n- Test message transformation and marshalling\n- Test exception handling and dead letter queues\n\n### Testing Async Operations\n- Test CompletableFuture success and failure scenarios\n- Use `.join()` in tests to wait for async completion\n- Test exception propagation from CompletableFuture\n- Verify LogContext propagation to async operations\n\n### Performance\n- Keep tests fast and isolated\n- Run tests in continuous mode: `mvn quarkus:test`\n- Use parameterized tests (`@ParameterizedTest`) for input variations\n- Build reusable test data builders or factory methods\n\n### Quarkus-Specific\n- Stay on latest LTS version (Quarkus 3.x)\n- Test native compilation compatibility periodically\n- Use Quarkus test profiles for different scenarios\n- Leverage Quarkus dev services for local testing\n- Use `@InjectMock` instead of `@MockBean` (Quarkus-specific)\n\n### Verification Best Practices\n- Always verify interactions on mocked dependencies\n- Use `verify(mock, never())` to ensure methods are NOT called in error scenarios\n- Use `argThat()` for complex argument matching\n- Verify the order of calls when it matters: `InOrder` from Mockito\n",{"name":5,"origin":24,"description":7},"ECC","master","d6ca01da0f24a3b0e26e4a8b7b66cbd25d429f5d","skills\u002Fquarkus-tdd",0,"https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills","https:\u002F\u002Fgithub.com\u002FSriramGandhiS","https:\u002F\u002Fsriram.website\u002F","Curious guy who keeps tinkering until something works","2026-05-20 16:21:34",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add SriramGandhiS\u002FSkills --skill quarkus-tdd",{"tool":40,"command":41},"bunx","bunx skills add SriramGandhiS\u002FSkills --skill quarkus-tdd",{"tool":43,"command":44},"pnpm","pnpm dlx skills add SriramGandhiS\u002FSkills --skill quarkus-tdd","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fskills\u002Fquarkus-tdd\u002FSKILL.md",true,[],[49,56,61,67,74,81],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M732609EPJWV13PVTX3GT4TM","webgpu-threejs-tsl","Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fwebgpu-threejs-tsl\u002Fskills\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[],{"skillNo":57,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M7325XM47AGWB6K6C4VXKE6B","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7325WP6DES69JKC840VMFEP","verification-loop","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7325TFQF1DZTQ6J3WGQQ1VR","tdd-workflow","Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Ftdd-workflow\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7325RGV9AY9PK92D2V8KKPW","strategic-compact","Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fstrategic-compact\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7325MZC28SE86E7NMCNEFS4","security-review","Use this skill when adding authentication, handling user input, working with secrets, creating API endpoints, or implementing payment\u002Fsensitive features. Provides comprehensive security checklist and patterns.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fsecurity-review\u002FSKILL.md",[],[]]