apupier commented on code in PR #8197:
URL: https://github.com/apache/camel-quarkus/pull/8197#discussion_r2721010311


##########
integration-tests/docling/src/test/java/org/apache/camel/quarkus/component/docling/it/DoclingTest.java:
##########
@@ -127,12 +133,62 @@ public void extractText() {
                 .post("/docling/extract/text")
                 .then()
                 .statusCode(200)
-                .body(not(emptyString()));
+                .body(containsString(testContent));
     }
 
     @Test
-    public void extractMetadata() {
-        String testContent = "# Test Document\nSome content for metadata 
extraction.";
+    void extractMetadataFromPdf() {
+        RestAssured.given()
+                .when()
+                .post("/docling/metadata/extract/pdf")
+                .then()
+                .statusCode(200)
+                .body(new BaseMatcher<String>() {
+
+                    private DocumentMetadata documentMetadata;
+
+                    @Override
+                    public boolean matches(Object actual) {
+                        ObjectMapper mapper = new ObjectMapper();
+                        try {
+                            documentMetadata = mapper.readValue((String) 
actual, DocumentMetadata.class);
+                            return 
documentMetadata.getFileName().startsWith("docling-test")
+                                    && 
documentMetadata.getFilePath().contains("docling-test");
+                            // TODO: improve test by checking other metadatas 
when https://issues.apache.org/jira/browse/CAMEL-22888 is fixed
+                        } catch (JsonProcessingException e) {
+                            e.printStackTrace();
+                            return false;
+                        }
+                    }
+
+                    @Override
+                    public void describeTo(Description description) {
+                        if (documentMetadata != null) {
+                            
description.appendText(documentMetadata.toString());
+                        } else {
+                            description.appendText("Wasn't able to parse the 
answer");
+                        }
+                    }
+                });

Review Comment:
   a lot easier effectively, we lost the type-safe side but a lot more concise. 
thanks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to