From 03beddff90d7ed33060f58aceee18d4f60dc47c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9=20s=C3=A9vi?= Date: Wed, 11 Mar 2026 15:12:57 +0100 Subject: [PATCH 1/2] :bug: decimal indicator should always be a period --- src/main/java/com/mindee/parsing/SummaryHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/mindee/parsing/SummaryHelper.java b/src/main/java/com/mindee/parsing/SummaryHelper.java index 007cd222c..eaf27baad 100644 --- a/src/main/java/com/mindee/parsing/SummaryHelper.java +++ b/src/main/java/com/mindee/parsing/SummaryHelper.java @@ -2,7 +2,9 @@ import com.mindee.parsing.standard.LineItemField; import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; import java.util.List; +import java.util.Locale; import java.util.stream.Collectors; /** @@ -21,7 +23,7 @@ public static String formatAmount(Double amountValue) { if (amountValue == null) { return ""; } - DecimalFormat df = new DecimalFormat("0.00###"); + DecimalFormat df = new DecimalFormat("0.00###", new DecimalFormatSymbols(Locale.US)); df.setMinimumFractionDigits(2); df.setMaximumFractionDigits(5); return df.format(amountValue); From 7316a13e8c94b5b900e3fb71f030c2889750e75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9=20s=C3=A9vi?= Date: Wed, 11 Mar 2026 15:45:47 +0100 Subject: [PATCH 2/2] :recycle: use base classes for v2 products --- .../java/com/mindee/InferenceParameters.java | 75 +++++++++++++------ src/main/java/com/mindee/MindeeClientV2.java | 17 +++-- .../java/com/mindee/http/MindeeApiV2.java | 14 ++-- .../java/com/mindee/http/MindeeHttpApiV2.java | 45 ++--------- .../java/com/mindee/parsing/v2/Inference.java | 44 +---------- .../mindee/parsing/v2/InferenceResponse.java | 2 +- .../mindee/parsing/v2/InferenceResult.java | 6 +- .../mindee/parsing/v2/field/SimpleField.java | 4 +- .../v2/clientOptions/BaseParameters.java | 37 +++++++++ .../com/mindee/v2/parsing/BaseInference.java | 58 ++++++++++++++ ...InferenceTest.java => ExtractionTest.java} | 40 +++++----- 11 files changed, 199 insertions(+), 143 deletions(-) create mode 100644 src/main/java/com/mindee/v2/clientOptions/BaseParameters.java create mode 100644 src/main/java/com/mindee/v2/parsing/BaseInference.java rename src/test/java/com/mindee/parsing/v2/{InferenceTest.java => ExtractionTest.java} (93%) diff --git a/src/main/java/com/mindee/InferenceParameters.java b/src/main/java/com/mindee/InferenceParameters.java index f27e84f40..c9b40ccee 100644 --- a/src/main/java/com/mindee/InferenceParameters.java +++ b/src/main/java/com/mindee/InferenceParameters.java @@ -1,19 +1,17 @@ package com.mindee; +import com.mindee.v2.clientOptions.BaseParameters; import java.util.Objects; -import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.Getter; +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; /** * Options to pass when calling methods using the API V2. */ @Getter -@Data -public final class InferenceParameters { - /** - * Model ID to use for the inference (required). - */ - private final String modelId; +@EqualsAndHashCode(callSuper = true) +public final class InferenceParameters extends BaseParameters { /** * Enhance extraction accuracy with Retrieval-Augmented Generation. */ @@ -31,19 +29,6 @@ public final class InferenceParameters { * Calculate confidence scores for all fields. */ private final Boolean confidence; - /** - * Optional alias for the file. - */ - private final String alias; - /** - * Webhook IDs to call after all processing is finished. - * If empty, no webhooks will be used. - */ - private final String[] webhookIds; - /** - * Polling options. Set only if having timeout issues. - */ - private final AsyncPollingOptions pollingOptions; /** * Additional text context used by the model during inference. * Not recommended, for specific use only. @@ -54,6 +39,50 @@ public final class InferenceParameters { */ private final String dataSchema; + private InferenceParameters( + String modelId, + String alias, + String[] webhookIds, + AsyncPollingOptions pollingOptions, + Boolean rag, + Boolean rawText, + Boolean polygon, + Boolean confidence, + String textContext, + String dataSchema + ) { + super(modelId, alias, webhookIds, pollingOptions); + this.rag = rag; + this.rawText = rawText; + this.polygon = polygon; + this.confidence = confidence; + this.textContext = textContext; + this.dataSchema = dataSchema; + } + + public MultipartEntityBuilder buildHttpBody(MultipartEntityBuilder builder) { + builder = super.buildHttpBody(builder); + if (this.getRag() != null) { + builder.addTextBody("rag", this.getRag().toString().toLowerCase()); + } + if (this.getRawText() != null) { + builder.addTextBody("raw_text", this.getRawText().toString().toLowerCase()); + } + if (this.getPolygon() != null) { + builder.addTextBody("polygon", this.getPolygon().toString().toLowerCase()); + } + if (this.getConfidence() != null) { + builder.addTextBody("confidence", this.getConfidence().toString().toLowerCase()); + } + if (this.getTextContext() != null) { + builder.addTextBody("text_context", this.getTextContext()); + } + if (this.getDataSchema() != null) { + builder.addTextBody("data_schema", this.getDataSchema()); + } + return builder; + } + /** * Create a new builder. * @@ -145,13 +174,13 @@ public Builder pollingOptions(AsyncPollingOptions pollingOptions) { public InferenceParameters build() { return new InferenceParameters( modelId, + alias, + webhookIds, + pollingOptions, rag, rawText, polygon, confidence, - alias, - webhookIds, - pollingOptions, textContext, dataSchema ); diff --git a/src/main/java/com/mindee/MindeeClientV2.java b/src/main/java/com/mindee/MindeeClientV2.java index 12097af80..1af7030c5 100644 --- a/src/main/java/com/mindee/MindeeClientV2.java +++ b/src/main/java/com/mindee/MindeeClientV2.java @@ -8,6 +8,7 @@ import com.mindee.parsing.v2.ErrorResponse; import com.mindee.parsing.v2.InferenceResponse; import com.mindee.parsing.v2.JobResponse; +import com.mindee.v2.clientOptions.BaseParameters; import java.io.IOException; /** @@ -36,7 +37,7 @@ public MindeeClientV2(MindeeApiV2 mindeeApi) { */ public JobResponse enqueueInference( LocalInputSource inputSource, - InferenceParameters params + BaseParameters params ) throws IOException { return mindeeApi.reqPostInferenceEnqueue(inputSource, params); } @@ -46,7 +47,7 @@ public JobResponse enqueueInference( */ public JobResponse enqueueInference( URLInputSource inputSource, - InferenceParameters params + BaseParameters params ) throws IOException { return mindeeApi.reqPostInferenceEnqueue(inputSource, params); } @@ -75,7 +76,7 @@ public InferenceResponse getInference(String inferenceId) { /** * Send a local file to an async queue, poll, and parse when complete. - * + * * @param inputSource The input source to send. * @param options The options to send along with the file. * @return an instance of {@link InferenceResponse}. @@ -84,7 +85,7 @@ public InferenceResponse getInference(String inferenceId) { */ public InferenceResponse enqueueAndGetInference( LocalInputSource inputSource, - InferenceParameters options + BaseParameters options ) throws IOException, InterruptedException { validatePollingOptions(options.getPollingOptions()); JobResponse job = enqueueInference(inputSource, options); @@ -93,7 +94,7 @@ public InferenceResponse enqueueAndGetInference( /** * Send a local file to an async queue, poll, and parse when complete. - * + * * @param inputSource The input source to send. * @param options The options to send along with the file. * @return an instance of {@link InferenceResponse}. @@ -102,7 +103,7 @@ public InferenceResponse enqueueAndGetInference( */ public InferenceResponse enqueueAndGetInference( URLInputSource inputSource, - InferenceParameters options + BaseParameters options ) throws IOException, InterruptedException { validatePollingOptions(options.getPollingOptions()); JobResponse job = enqueueInference(inputSource, options); @@ -111,14 +112,14 @@ public InferenceResponse enqueueAndGetInference( /** * Common logic for polling an asynchronous job for local & url files. - * + * * @param initialJob The initial job response. * @return an instance of {@link InferenceResponse}. * @throws InterruptedException Throws if interrupted. */ private InferenceResponse pollAndFetch( JobResponse initialJob, - InferenceParameters options + BaseParameters options ) throws InterruptedException { Thread.sleep((long) (options.getPollingOptions().getInitialDelaySec() * 1000)); diff --git a/src/main/java/com/mindee/http/MindeeApiV2.java b/src/main/java/com/mindee/http/MindeeApiV2.java index 3f327ce22..66ea62865 100644 --- a/src/main/java/com/mindee/http/MindeeApiV2.java +++ b/src/main/java/com/mindee/http/MindeeApiV2.java @@ -1,11 +1,11 @@ package com.mindee.http; -import com.mindee.InferenceParameters; import com.mindee.input.LocalInputSource; import com.mindee.input.URLInputSource; import com.mindee.parsing.v2.ErrorResponse; import com.mindee.parsing.v2.InferenceResponse; import com.mindee.parsing.v2.JobResponse; +import com.mindee.v2.clientOptions.BaseParameters; import java.io.IOException; /** @@ -14,36 +14,36 @@ public abstract class MindeeApiV2 extends MindeeApiCommon { /** * Send a file to the prediction queue with a local file. - * + * * @param inputSource Local input source from URL. * @param options parameters. */ public abstract JobResponse reqPostInferenceEnqueue( LocalInputSource inputSource, - InferenceParameters options + BaseParameters options ) throws IOException; /** * Send a file to the prediction queue with a remote file. - * + * * @param inputSource Remote input source from URL. * @param options parameters. */ public abstract JobResponse reqPostInferenceEnqueue( URLInputSource inputSource, - InferenceParameters options + BaseParameters options ) throws IOException; /** * Attempts to poll the queue. - * + * * @param jobId id of the job to get. */ public abstract JobResponse reqGetJob(String jobId); /** * Retrieves the inference from a 302 redirect. - * + * * @param inferenceId ID of the inference to poll. */ abstract public InferenceResponse reqGetInference(String inferenceId); diff --git a/src/main/java/com/mindee/http/MindeeHttpApiV2.java b/src/main/java/com/mindee/http/MindeeHttpApiV2.java index 1ced1e42f..6fcb61601 100644 --- a/src/main/java/com/mindee/http/MindeeHttpApiV2.java +++ b/src/main/java/com/mindee/http/MindeeHttpApiV2.java @@ -1,7 +1,6 @@ package com.mindee.http; import com.fasterxml.jackson.databind.ObjectMapper; -import com.mindee.InferenceParameters; import com.mindee.MindeeException; import com.mindee.MindeeSettingsV2; import com.mindee.input.LocalInputSource; @@ -10,6 +9,7 @@ import com.mindee.parsing.v2.ErrorResponse; import com.mindee.parsing.v2.InferenceResponse; import com.mindee.parsing.v2.JobResponse; +import com.mindee.v2.clientOptions.BaseParameters; import java.io.IOException; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; @@ -68,10 +68,7 @@ private MindeeHttpApiV2(MindeeSettingsV2 mindeeSettings, HttpClientBuilder httpC * @return A job response. */ @Override - public JobResponse reqPostInferenceEnqueue( - LocalInputSource inputSource, - InferenceParameters options - ) { + public JobResponse reqPostInferenceEnqueue(LocalInputSource inputSource, BaseParameters options) { String url = this.mindeeSettings.getBaseUrl() + "/products/extraction/enqueue"; HttpPost post = buildHttpPost(url); @@ -84,7 +81,7 @@ public JobResponse reqPostInferenceEnqueue( ContentType.DEFAULT_BINARY, inputSource.getFilename() ); - post.setEntity(buildHttpBody(builder, options)); + post.setEntity(options.buildHttpBody(builder).build()); return executeEnqueue(post); } @@ -96,17 +93,14 @@ public JobResponse reqPostInferenceEnqueue( * @return A job response. */ @Override - public JobResponse reqPostInferenceEnqueue( - URLInputSource inputSource, - InferenceParameters options - ) { + public JobResponse reqPostInferenceEnqueue(URLInputSource inputSource, BaseParameters options) { String url = this.mindeeSettings.getBaseUrl() + "/products/extraction/enqueue"; HttpPost post = buildHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.setMode(HttpMultipartMode.EXTENDED); builder.addTextBody("url", inputSource.getUrl()); - post.setEntity(buildHttpBody(builder, options)); + post.setEntity(options.buildHttpBody(builder).build()); return executeEnqueue(post); } @@ -224,35 +218,6 @@ private MindeeHttpExceptionV2 getHttpError(ClassicHttpResponse response) { } } - private HttpEntity buildHttpBody(MultipartEntityBuilder builder, InferenceParameters params) { - builder.addTextBody("model_id", params.getModelId()); - if (params.getRag() != null) { - builder.addTextBody("rag", params.getRag().toString().toLowerCase()); - } - if (params.getRawText() != null) { - builder.addTextBody("raw_text", params.getRawText().toString().toLowerCase()); - } - if (params.getPolygon() != null) { - builder.addTextBody("polygon", params.getPolygon().toString().toLowerCase()); - } - if (params.getConfidence() != null) { - builder.addTextBody("confidence", params.getConfidence().toString().toLowerCase()); - } - if (params.getAlias() != null) { - builder.addTextBody("alias", params.getAlias()); - } - if (params.getWebhookIds().length > 0) { - builder.addTextBody("webhook_ids", String.join(",", params.getWebhookIds())); - } - if (params.getTextContext() != null) { - builder.addTextBody("text_context", params.getTextContext()); - } - if (params.getDataSchema() != null) { - builder.addTextBody("data_schema", params.getDataSchema()); - } - return builder.build(); - } - private HttpPost buildHttpPost(String url) { HttpPost post; try { diff --git a/src/main/java/com/mindee/parsing/v2/Inference.java b/src/main/java/com/mindee/parsing/v2/Inference.java index 63aee3890..9f4517d10 100644 --- a/src/main/java/com/mindee/parsing/v2/Inference.java +++ b/src/main/java/com/mindee/parsing/v2/Inference.java @@ -2,9 +2,9 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; +import com.mindee.v2.parsing.BaseInference; import java.util.StringJoiner; import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -12,35 +12,10 @@ * Inference object for the V2 API. */ @Getter -@EqualsAndHashCode @JsonIgnoreProperties(ignoreUnknown = true) @AllArgsConstructor @NoArgsConstructor -public class Inference { - /** - * Inference ID. - */ - @JsonProperty("id") - private String id; - - /** - * Job the inference belongs to. - */ - @JsonProperty("job") - private InferenceJob job; - - /** - * Model info. - */ - @JsonProperty("model") - private InferenceModel model; - - /** - * File info. - */ - @JsonProperty("file") - private InferenceFile file; - +public class Inference extends BaseInference { /** * Active options for the inference. */ @@ -56,18 +31,7 @@ public class Inference { @Override public String toString() { StringJoiner joiner = new StringJoiner("\n"); - joiner - .add("Inference") - .add("#########") - .add(job.toString()) - .add("") - .add(model.toString()) - .add("") - .add(file.toString()) - .add("") - .add(activeOptions.toString()) - .add("") - .add(result != null ? result.toString() : ""); - return joiner.toString().trim() + "\n"; + joiner.add(activeOptions.toString()).add("").add(result != null ? result.toString() : ""); + return super.toString() + "\n" + joiner.toString().trim() + "\n"; } } diff --git a/src/main/java/com/mindee/parsing/v2/InferenceResponse.java b/src/main/java/com/mindee/parsing/v2/InferenceResponse.java index 7c5294c43..5280ae3ca 100644 --- a/src/main/java/com/mindee/parsing/v2/InferenceResponse.java +++ b/src/main/java/com/mindee/parsing/v2/InferenceResponse.java @@ -4,7 +4,7 @@ import lombok.Getter; /** - * Represents an asynchronous inference response (V2). + * Response for an extraction inference. */ @Getter public class InferenceResponse extends CommonResponse { diff --git a/src/main/java/com/mindee/parsing/v2/InferenceResult.java b/src/main/java/com/mindee/parsing/v2/InferenceResult.java index 7a328bf43..c47331cf8 100644 --- a/src/main/java/com/mindee/parsing/v2/InferenceResult.java +++ b/src/main/java/com/mindee/parsing/v2/InferenceResult.java @@ -10,7 +10,7 @@ import lombok.NoArgsConstructor; /** - * Generic result for any off-the-shelf Mindee V2 model. + * The inference result for an extraction request. */ @Getter @EqualsAndHashCode @@ -26,13 +26,13 @@ public final class InferenceResult { private InferenceFields fields; /** - * Raw text extracted from all pages in the document. + * If 'rawText' was activated, contains the extracted text of the document. */ @JsonProperty("raw_text") private RawText rawText; /** - * RAG metadata. + * If 'rag' was activated, contains metadata about the RAG operation. */ @JsonProperty("rag") private RagMetadata rag; diff --git a/src/main/java/com/mindee/parsing/v2/field/SimpleField.java b/src/main/java/com/mindee/parsing/v2/field/SimpleField.java index 2ea607f19..84c76c224 100644 --- a/src/main/java/com/mindee/parsing/v2/field/SimpleField.java +++ b/src/main/java/com/mindee/parsing/v2/field/SimpleField.java @@ -1,5 +1,7 @@ package com.mindee.parsing.v2.field; +import static com.mindee.parsing.SummaryHelper.formatForDisplay; + import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -76,7 +78,7 @@ public String toString() { if (value == null) return ""; if (value.getClass().equals(Boolean.class)) { - return ((Boolean) value) ? "True" : "False"; + return formatForDisplay((Boolean) value, 5); } return value.toString(); } diff --git a/src/main/java/com/mindee/v2/clientOptions/BaseParameters.java b/src/main/java/com/mindee/v2/clientOptions/BaseParameters.java new file mode 100644 index 000000000..c0b7ac9e3 --- /dev/null +++ b/src/main/java/com/mindee/v2/clientOptions/BaseParameters.java @@ -0,0 +1,37 @@ +package com.mindee.v2.clientOptions; + +import com.mindee.AsyncPollingOptions; +import lombok.Data; +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; + +@Data +public abstract class BaseParameters { + /** + * Model ID to use for the inference (required). + */ + protected final String modelId; + /** + * Optional alias for the file. + */ + protected final String alias; + /** + * Webhook IDs to call after all processing is finished. + * If empty, no webhooks will be used. + */ + protected final String[] webhookIds; + /** + * Polling options. Set only if having timeout issues. + */ + protected final AsyncPollingOptions pollingOptions; + + public MultipartEntityBuilder buildHttpBody(MultipartEntityBuilder builder) { + builder.addTextBody("model_id", this.getModelId()); + if (this.getAlias() != null) { + builder.addTextBody("alias", this.getAlias()); + } + if (this.getWebhookIds().length > 0) { + builder.addTextBody("webhook_ids", String.join(",", this.getWebhookIds())); + } + return builder; + } +} diff --git a/src/main/java/com/mindee/v2/parsing/BaseInference.java b/src/main/java/com/mindee/v2/parsing/BaseInference.java new file mode 100644 index 000000000..b1919acd8 --- /dev/null +++ b/src/main/java/com/mindee/v2/parsing/BaseInference.java @@ -0,0 +1,58 @@ +package com.mindee.v2.parsing; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.mindee.parsing.v2.*; +import java.util.StringJoiner; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * Inference object for the V2 API. + */ +@Getter +@EqualsAndHashCode +@JsonIgnoreProperties(ignoreUnknown = true) +@AllArgsConstructor +@NoArgsConstructor +public abstract class BaseInference { + /** + * Inference ID. + */ + @JsonProperty("id") + protected String id; + + /** + * Job the inference belongs to. + */ + @JsonProperty("job") + protected InferenceJob job; + + /** + * Model info. + */ + @JsonProperty("model") + protected InferenceModel model; + + /** + * File info. + */ + @JsonProperty("file") + protected InferenceFile file; + + @Override + public String toString() { + StringJoiner joiner = new StringJoiner("\n"); + joiner + .add("Inference") + .add("#########") + .add(job.toString()) + .add("") + .add(model.toString()) + .add("") + .add(file.toString()); + return joiner.toString().trim() + "\n"; + } +} diff --git a/src/test/java/com/mindee/parsing/v2/InferenceTest.java b/src/test/java/com/mindee/parsing/v2/ExtractionTest.java similarity index 93% rename from src/test/java/com/mindee/parsing/v2/InferenceTest.java rename to src/test/java/com/mindee/parsing/v2/ExtractionTest.java index 7a877591a..25700634e 100644 --- a/src/test/java/com/mindee/parsing/v2/InferenceTest.java +++ b/src/test/java/com/mindee/parsing/v2/ExtractionTest.java @@ -31,22 +31,22 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -@DisplayName("MindeeV2 - Inference Tests") -class InferenceTest { +@DisplayName("MindeeV2 - Extraction Model Tests") +class ExtractionTest { - private InferenceResponse loadInference(String filePath) throws IOException { + private InferenceResponse loadResponse(String filePath) throws IOException { LocalResponse localResponse = new LocalResponse(getV2ResourcePath(filePath)); return localResponse.deserializeResponse(InferenceResponse.class); } @Nested - @DisplayName("Inference on blank file") + @DisplayName("Extraction on blank file") class BlankPredictionTest { @Test @DisplayName("all properties must be valid") void asyncPredict_whenEmpty_mustHaveValidProperties() throws IOException { - InferenceResponse response = loadInference( + InferenceResponse response = loadResponse( "products/extraction/financial_document/blank.json" ); InferenceFields fields = response.getInference().getResult().getFields(); @@ -94,13 +94,13 @@ void asyncPredict_whenEmpty_mustHaveValidProperties() throws IOException { } @Nested - @DisplayName("Inference on filled file") + @DisplayName("Extraction on filled file") class CompletePredictionTest { @Test @DisplayName("every exposed property must be valid and consistent") void asyncPredict_whenComplete_mustExposeAllProperties() throws IOException { - InferenceResponse response = loadInference( + InferenceResponse response = loadResponse( "products/extraction/financial_document/complete.json" ); Inference inference = response.getInference(); @@ -175,7 +175,7 @@ class DeepNestedFieldsTest { @Test @DisplayName("all nested structures must be typed correctly") void deepNestedFields_mustExposeCorrectTypes() throws IOException { - InferenceResponse resp = loadInference("products/extraction/deep_nested_fields.json"); + InferenceResponse resp = loadResponse("products/extraction/deep_nested_fields.json"); Inference inf = resp.getInference(); assertNotNull(inf); @@ -241,7 +241,7 @@ private void testSimpleFieldString(SimpleField field) { @Test @DisplayName("simple fields must be recognised") void standardFieldTypes_mustExposeSimpleFieldValues() throws IOException { - InferenceResponse response = loadInference("products/extraction/standard_field_types.json"); + InferenceResponse response = loadResponse("products/extraction/standard_field_types.json"); Inference inference = response.getInference(); assertNotNull(inference); @@ -298,7 +298,7 @@ void standardFieldTypes_mustExposeSimpleFieldValues() throws IOException { @Test @DisplayName("simple list fields must be recognised") void standardFieldTypes_mustExposeSimpleListFieldValues() throws IOException { - InferenceResponse response = loadInference("products/extraction/standard_field_types.json"); + InferenceResponse response = loadResponse("products/extraction/standard_field_types.json"); Inference inference = response.getInference(); assertNotNull(inference); @@ -341,7 +341,7 @@ private void testObjectSubFieldSimpleString(String fieldName, SimpleField subFie @Test @DisplayName("object list fields must be recognised") void standardFieldTypes_mustExposeObjectListFieldValues() throws IOException { - InferenceResponse response = loadInference("products/extraction/standard_field_types.json"); + InferenceResponse response = loadResponse("products/extraction/standard_field_types.json"); Inference inference = response.getInference(); assertNotNull(inference); @@ -391,7 +391,7 @@ void standardFieldTypes_mustExposeObjectListFieldValues() throws IOException { @Test @DisplayName("simple / object / list variants must be recognised") void standardFieldTypes_mustExposeObjectFieldValues() throws IOException { - InferenceResponse response = loadInference("products/extraction/standard_field_types.json"); + InferenceResponse response = loadResponse("products/extraction/standard_field_types.json"); Inference inference = response.getInference(); assertNotNull(inference); @@ -426,7 +426,7 @@ void standardFieldTypes_mustExposeObjectFieldValues() throws IOException { @Test @DisplayName("allow getting fields using generics") void standardFieldTypes_getWithGenerics() throws IOException { - InferenceResponse response = loadInference("products/extraction/standard_field_types.json"); + InferenceResponse response = loadResponse("products/extraction/standard_field_types.json"); Inference inference = response.getInference(); assertNotNull(inference); InferenceFields fields = inference.getResult().getFields(); @@ -462,7 +462,7 @@ void standardFieldTypes_getWithGenerics() throws IOException { @Test @DisplayName("confidence and locations must be usable") void standardFieldTypes_confidenceAndLocations() throws IOException { - InferenceResponse response = loadInference("products/extraction/standard_field_types.json"); + InferenceResponse response = loadResponse("products/extraction/standard_field_types.json"); Inference inference = response.getInference(); assertNotNull(inference); @@ -502,7 +502,7 @@ class RawTextTest { @Test @DisplayName("raw texts option must be parsed and exposed") void rawTexts_mustBeAccessible() throws IOException { - InferenceResponse response = loadInference("products/extraction/raw_texts.json"); + InferenceResponse response = loadResponse("products/extraction/raw_texts.json"); Inference inference = response.getInference(); assertNotNull(inference); @@ -537,7 +537,7 @@ class RagMetadataTest { @Test @DisplayName("RAG metadata when matched") void rag_mustBeFilled_whenMatched() throws IOException { - InferenceResponse response = loadInference("products/extraction/rag_matched.json"); + InferenceResponse response = loadResponse("products/extraction/rag_matched.json"); Inference inference = response.getInference(); assertNotNull(inference); @@ -549,7 +549,7 @@ void rag_mustBeFilled_whenMatched() throws IOException { @Test @DisplayName("RAG metadata when not matched") void rag_mustBeNull_whenNotMatched() throws IOException { - InferenceResponse response = loadInference("products/extraction/rag_not_matched.json"); + InferenceResponse response = loadResponse("products/extraction/rag_not_matched.json"); Inference inference = response.getInference(); assertNotNull(inference); @@ -565,7 +565,7 @@ class RstDisplay { @Test @DisplayName("rst display must be parsed and exposed") void rstDisplay_mustBeAccessible() throws IOException { - InferenceResponse resp = loadInference("products/extraction/standard_field_types.json"); + InferenceResponse resp = loadResponse("products/extraction/standard_field_types.json"); String rstRef = readFileAsString( getV2ResourcePath("products/extraction/standard_field_types.rst") ); @@ -581,7 +581,7 @@ class TextContextTest { @Test @DisplayName("should be present and true when enabled") void textContext_mustBePresentAndTrue() throws IOException { - InferenceResponse resp = loadInference("products/extraction/text_context_enabled.json"); + InferenceResponse resp = loadResponse("products/extraction/text_context_enabled.json"); Inference inference = resp.getInference(); assertNotNull(inference); assertTrue(inference.getActiveOptions().getTextContext()); @@ -594,7 +594,7 @@ class DataSchemaTest { @Test @DisplayName("should be present and true when enabled") void textContext_mustBePresentAndTrue() throws IOException { - InferenceResponse resp = loadInference("products/extraction/data_schema_replace.json"); + InferenceResponse resp = loadResponse("products/extraction/data_schema_replace.json"); Inference inference = resp.getInference(); assertNotNull(inference); InferenceFields fields = inference.getResult().getFields();