Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/main/java/com/mindee/parsing/v2/DataSchemaActiveOptions.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.mindee.parsing.v2;

import static com.mindee.parsing.SummaryHelper.formatForDisplay;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.StringJoiner;
import lombok.EqualsAndHashCode;

/**
Expand All @@ -11,13 +14,23 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class DataSchemaActiveOptions {

@JsonProperty("override")
private boolean override;
@JsonProperty("replace")
private boolean replace;

/**
* Whether a data schema override was provided for the inference.
* Whether the data schema was replaced for the inference.
*/
public boolean getOverride() {
return override;
public boolean getReplace() {
return replace;
}

@Override
public String toString() {
StringJoiner joiner = new StringJoiner("\n");
return joiner
.add("Data Schema")
.add("-----------")
.add(":Replace: " + formatForDisplay(replace, 5))
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import lombok.Getter;

/**
* Option response for V2 API inference.
* Options which were activated during the inference.
*/
@EqualsAndHashCode
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down Expand Up @@ -80,6 +80,9 @@ public String toString() {
.add(":Polygon: " + formatForDisplay(polygon, 5))
.add(":Confidence: " + formatForDisplay(confidence, 5))
.add(":RAG: " + formatForDisplay(rag, 5))
.add(":Text Context: " + formatForDisplay(textContext, 5))
.add("")
.add(dataSchema.toString())
.toString();
}
}
2 changes: 1 addition & 1 deletion src/test/java/com/mindee/input/LocalResponseV2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class LocalResponseV2Test {
/**
* Real signature using fake secret key.
*/
String signature = "b82a515c832fd2c4f4ce3a7e6f53c12e8d10e19223f6cf0e3a9809a7a3da26be";
String signature = "1df388c992d87897fe61dfc56c444c58fc3c7369c31e2b5fd20d867695e93e85";

/**
* File which the signature applies to.
Expand Down
31 changes: 25 additions & 6 deletions src/test/java/com/mindee/parsing/v2/InferenceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ void rawTexts_mustBeAccessible() throws IOException {
assertFalse(activeOptions.getPolygon());
assertFalse(activeOptions.getConfidence());
assertFalse(activeOptions.getTextContext());
assertFalse(activeOptions.getDataSchema().getOverride());
assertFalse(activeOptions.getDataSchema().getReplace());

assertNull(inference.getResult().getRag());

Expand Down Expand Up @@ -526,8 +526,8 @@ class RstDisplay {
void rstDisplay_mustBeAccessible() throws IOException {
InferenceResponse resp = loadInference("inference/standard_field_types.json");
String rstRef = readFileAsString("inference/standard_field_types.rst");
Inference inf = resp.getInference();
assertNotNull(inf);
Inference inference = resp.getInference();
assertNotNull(inference);
assertEquals(rstRef, resp.getInference().toString());
}
}
Expand All @@ -539,9 +539,28 @@ class TextContextTest {
@DisplayName("should be present and true when enabled")
void textContext_mustBePresentAndTrue() throws IOException {
InferenceResponse resp = loadInference("inference/text_context_enabled.json");
Inference inf = resp.getInference();
assertNotNull(inf);
assertTrue(inf.getActiveOptions().getTextContext());
Inference inference = resp.getInference();
assertNotNull(inference);
assertTrue(inference.getActiveOptions().getTextContext());
}
}

@Nested
@DisplayName("Data Schema Return")
class DataSchemaTest {
@Test
@DisplayName("should be present and true when enabled")
void textContext_mustBePresentAndTrue() throws IOException {
InferenceResponse resp = loadInference("inference/data_schema_replace.json");
Inference inference = resp.getInference();
assertNotNull(inference);
InferenceFields fields = inference.getResult().getFields();
assertEquals(
"a test value",
fields.get("test_replace").getSimpleField().getStringValue()
);

assertTrue(inference.getActiveOptions().getDataSchema().getReplace());
}
}
}
Loading