Skip to content

Commit abeea7b

Browse files
committed
♻️ update active options string output
1 parent c16c9e1 commit abeea7b

File tree

5 files changed

+49
-14
lines changed

5 files changed

+49
-14
lines changed
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package com.mindee.parsing.v2;
22

3+
import static com.mindee.parsing.SummaryHelper.formatForDisplay;
4+
35
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
46
import com.fasterxml.jackson.annotation.JsonProperty;
7+
import java.util.StringJoiner;
58
import lombok.EqualsAndHashCode;
69

710
/**
@@ -11,13 +14,23 @@
1114
@JsonIgnoreProperties(ignoreUnknown = true)
1215
public class DataSchemaActiveOptions {
1316

14-
@JsonProperty("override")
15-
private boolean override;
17+
@JsonProperty("replace")
18+
private boolean replace;
1619

1720
/**
18-
* Whether a data schema override was provided for the inference.
21+
* Whether the data schema was replaced for the inference.
1922
*/
20-
public boolean getOverride() {
21-
return override;
23+
public boolean getReplace() {
24+
return replace;
25+
}
26+
27+
@Override
28+
public String toString() {
29+
StringJoiner joiner = new StringJoiner("\n");
30+
return joiner
31+
.add("Data Schema")
32+
.add("-----------")
33+
.add(":Replace: " + formatForDisplay(replace, 5))
34+
.toString();
2235
}
2336
}

src/main/java/com/mindee/parsing/v2/InferenceActiveOptions.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import lombok.Getter;
1010

1111
/**
12-
* Option response for V2 API inference.
12+
* Options which were activated during the inference.
1313
*/
1414
@EqualsAndHashCode
1515
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -80,6 +80,9 @@ public String toString() {
8080
.add(":Polygon: " + formatForDisplay(polygon, 5))
8181
.add(":Confidence: " + formatForDisplay(confidence, 5))
8282
.add(":RAG: " + formatForDisplay(rag, 5))
83+
.add(":Text Context: " + formatForDisplay(textContext, 5))
84+
.add("")
85+
.add(dataSchema.toString())
8386
.toString();
8487
}
8588
}

src/test/java/com/mindee/input/LocalResponseV2Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class LocalResponseV2Test {
2121
/**
2222
* Real signature using fake secret key.
2323
*/
24-
String signature = "b82a515c832fd2c4f4ce3a7e6f53c12e8d10e19223f6cf0e3a9809a7a3da26be";
24+
String signature = "1df388c992d87897fe61dfc56c444c58fc3c7369c31e2b5fd20d867695e93e85";
2525

2626
/**
2727
* File which the signature applies to.

src/test/java/com/mindee/parsing/v2/InferenceTest.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ void rawTexts_mustBeAccessible() throws IOException {
472472
assertFalse(activeOptions.getPolygon());
473473
assertFalse(activeOptions.getConfidence());
474474
assertFalse(activeOptions.getTextContext());
475-
assertFalse(activeOptions.getDataSchema().getOverride());
475+
assertFalse(activeOptions.getDataSchema().getReplace());
476476

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

@@ -526,8 +526,8 @@ class RstDisplay {
526526
void rstDisplay_mustBeAccessible() throws IOException {
527527
InferenceResponse resp = loadInference("inference/standard_field_types.json");
528528
String rstRef = readFileAsString("inference/standard_field_types.rst");
529-
Inference inf = resp.getInference();
530-
assertNotNull(inf);
529+
Inference inference = resp.getInference();
530+
assertNotNull(inference);
531531
assertEquals(rstRef, resp.getInference().toString());
532532
}
533533
}
@@ -539,9 +539,28 @@ class TextContextTest {
539539
@DisplayName("should be present and true when enabled")
540540
void textContext_mustBePresentAndTrue() throws IOException {
541541
InferenceResponse resp = loadInference("inference/text_context_enabled.json");
542-
Inference inf = resp.getInference();
543-
assertNotNull(inf);
544-
assertTrue(inf.getActiveOptions().getTextContext());
542+
Inference inference = resp.getInference();
543+
assertNotNull(inference);
544+
assertTrue(inference.getActiveOptions().getTextContext());
545+
}
546+
}
547+
548+
@Nested
549+
@DisplayName("Data Schema Return")
550+
class DataSchemaTest {
551+
@Test
552+
@DisplayName("should be present and true when enabled")
553+
void textContext_mustBePresentAndTrue() throws IOException {
554+
InferenceResponse resp = loadInference("inference/data_schema_replace.json");
555+
Inference inference = resp.getInference();
556+
assertNotNull(inference);
557+
InferenceFields fields = inference.getResult().getFields();
558+
assertEquals(
559+
"a test value",
560+
fields.get("test_replace").getSimpleField().getStringValue()
561+
);
562+
563+
assertTrue(inference.getActiveOptions().getDataSchema().getReplace());
545564
}
546565
}
547566
}

0 commit comments

Comments
 (0)