[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73FB3V9E2PSWWSYDHFWB7F2":3,"skill-same:01M73FB3V9E2PSWWSYDHFWB7F2":49},{"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":30,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M73FB3V9E2PSWWSYDHFWB7F2","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.","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\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","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa","core\u002Fskills\u002Fquarkus-tdd",2,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-12 23:12:27",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill quarkus-tdd",{"tool":41,"command":42},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill quarkus-tdd",{"tool":44,"command":45},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill quarkus-tdd","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fquarkus-tdd\u002FSKILL.md",true,[],[50,58,65,73,81,89],{"skillNo":51,"name":52,"nameZh":6,"description":53,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":54,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":69,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":77,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\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":85,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"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":92,"categories":93,"keywords":94,"publishedAt":19},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]