[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CSQTDSSVJ7D6R17B31SWWR":3,"skill-same:01M7CSQTDSSVJ7D6R17B31SWWR":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":26,"commitSha":27,"skillDirectory":28,"forksCount":14,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7CSQTDSSVJ7D6R17B31SWWR","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.","Henrique1601\u002FSkiilsToIAs","Henrique1601","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F92006691?v=4","01M7CRXVT0GVXVK80JT1GR687S","Henrique Bezerra Dos Santos","01M7CRXVTN5Y8TMWJ1MDSKCQ1T",0,"MIT","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Fbackend-database\u002Fquarkus-tdd\u002FSKILL.md",[],[],"2026-11-15 14:19:17",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.\nmetadata:\n  origin: 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,"metadata":24,"description":7},{"origin":25},"ECC","main","a73152352c0612252131e5cf84e91312a6cf17dc","backend-database\u002Fquarkus-tdd","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs","https:\u002F\u002Fgithub.com\u002FHenrique1601","https:\u002F\u002Fbezerraportifolio.netlify.app\u002F","Full Stack Developer | React, Next.js, TypeScript, Node.js & IA | Construindo produtos digitais e soluções SaaS","2026-11-15 02:56:04",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add Henrique1601\u002FSkiilsToIAs --skill quarkus-tdd",{"tool":40,"command":41},"bunx","bunx skills add Henrique1601\u002FSkiilsToIAs --skill quarkus-tdd",{"tool":43,"command":44},"pnpm","pnpm dlx skills add Henrique1601\u002FSkiilsToIAs --skill quarkus-tdd","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Fbackend-database\u002Fquarkus-tdd\u002FSKILL.md",true,[],[49,56,63,71,78,85],{"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},"01M7E2ANBW9V6AVX5JXNCEAWF8","rag-architect-agent","Agente Arquiteto de RAG, Embeddings & Busca Vetorial. Especialista em design e implementação de pipelines de Retrieval-Augmented Generation de alta fidelidade: chunking semântico, modelagem pgvector no PostgreSQL (Neon\u002FSupabase), busca híbrida (cosseno + BM25), reranking, validação via TypeSafe AI e filosofia Ponytail (anti-overengineering).","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Fcustom-agents\u002Frag-architect-agent\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7E29KKF8R02ZRGYE2MJM67G","rag-architecture-patterns","Padrões arquiteturais e implementação de pipelines RAG (Retrieval-Augmented Generation) de alta fidelidade para qualquer projeto ou sistema. Cobre chunking semântico, embeddings, busca híbrida (pgvector + BM25), reranking, validação via TypeSafe AI e filosofia Ponytail (anti-overengineering).","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Fai-agents\u002Frag-architecture-patterns\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7CWRA8E3BJ7CPY8N8EG28J1","skill-repair","Use this to fix and re-install agent skills that have failed installation.\nThis skill provides the necessary context and permissions to surgically update\nthe `manifest.json` after a fix has been applied.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Futilities\u002Fskill-repair\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7CWR66FZP8FA47WVZ4Z2EXC","security-scan","Scan your Claude Code configuration (.claude\u002F directory) for security vulnerabilities, misconfigurations, and injection risks using AgentShield. Checks CLAUDE.md, settings.json, MCP servers, hooks, and agent definitions.","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Futilities\u002Fsecurity-scan\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7CWR0QPY58QPTR1P759TFNG","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\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Futilities\u002Fsecurity-review\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M7CWQXCE40XWT4FZ3VWZFGDP","security-bounty-hunter","Hunt for exploitable, bounty-worthy security issues in repositories. Focuses on remotely reachable vulnerabilities that qualify for real reports instead of noisy local-only findings.","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Futilities\u002Fsecurity-bounty-hunter\u002FSKILL.md",[],[]]