Skip to content

Commit 3c1de72

Browse files
committed
test(Compare and Comply): Update unit tests
1 parent 12bedd3 commit 3c1de72

File tree

2 files changed

+146
-8
lines changed

2 files changed

+146
-8
lines changed

compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyTest.java

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.ibm.watson.compare_comply.v1.model.CompareDocumentsOptions;
2525
import com.ibm.watson.compare_comply.v1.model.CompareReturn;
2626
import com.ibm.watson.compare_comply.v1.model.ContractAmts;
27+
import com.ibm.watson.compare_comply.v1.model.ContractTerms;
2728
import com.ibm.watson.compare_comply.v1.model.ContractType;
2829
import com.ibm.watson.compare_comply.v1.model.ConvertToHtmlOptions;
2930
import com.ibm.watson.compare_comply.v1.model.CreateBatchOptions;
@@ -44,6 +45,7 @@
4445
import com.ibm.watson.compare_comply.v1.model.OriginalLabelsIn;
4546
import com.ibm.watson.compare_comply.v1.model.OriginalLabelsOut;
4647
import com.ibm.watson.compare_comply.v1.model.Parties;
48+
import com.ibm.watson.compare_comply.v1.model.PaymentTerms;
4749
import com.ibm.watson.compare_comply.v1.model.ShortDoc;
4850
import com.ibm.watson.compare_comply.v1.model.TableReturn;
4951
import com.ibm.watson.compare_comply.v1.model.TerminationDates;
@@ -133,6 +135,9 @@ public class CompareComplyTest extends WatsonServiceUnitTest {
133135
private static final String NAME = "name";
134136
private static final Long PAGE_LIMIT = 7L;
135137
private static final String CURSOR = "cursor";
138+
private static final String VALUE = "value";
139+
private static final String UNIT = "unit";
140+
private static final Double NUMERIC_VALUE = 21.0;
136141

137142
private static final String CONVERT_TO_HTML_PATH = String.format(
138143
"/v1/html_conversion?version=%s",
@@ -224,6 +229,8 @@ public void setUp() throws Exception {
224229
service.setEndPoint(getMockWebServerUrl());
225230
}
226231

232+
// --- MODELS ---
233+
227234
@Test
228235
public void testAddFeedbackOptions() {
229236
FeedbackDataInput feedbackDataInput = new FeedbackDataInput();
@@ -522,6 +529,8 @@ public void testUpdatedLabelsIn() {
522529
assertEquals(typeLabel, updatedLabelsIn.getTypes().get(0));
523530
}
524531

532+
// --- METHODS ---
533+
525534
@Test
526535
public void testConvertToHtml() throws FileNotFoundException, InterruptedException {
527536
server.enqueue(jsonResponse(convertToHtmlResponse));
@@ -631,6 +640,12 @@ public void testClassifyElements() throws FileNotFoundException, InterruptedExce
631640
assertEquals(BEGIN, response.getTables().get(0).getKeyValuePairs().get(0).getValue().getLocation().getBegin());
632641
assertEquals(END, response.getTables().get(0).getKeyValuePairs().get(0).getValue().getLocation().getEnd());
633642
assertEquals(TEXT, response.getTables().get(0).getKeyValuePairs().get(0).getValue().getText());
643+
assertEquals(TEXT, response.getTables().get(0).getTitle().getText());
644+
assertEquals(BEGIN, response.getTables().get(0).getTitle().getLocation().getBegin());
645+
assertEquals(END, response.getTables().get(0).getTitle().getLocation().getEnd());
646+
assertEquals(TEXT, response.getTables().get(0).getContexts().get(0).getText());
647+
assertEquals(BEGIN, response.getTables().get(0).getContexts().get(0).getLocation().getBegin());
648+
assertEquals(END, response.getTables().get(0).getContexts().get(0).getLocation().getEnd());
634649
assertEquals(TEXT, response.getDocumentStructure().getSectionTitles().get(0).getText());
635650
assertEquals(BEGIN, response.getDocumentStructure().getSectionTitles().get(0).getLocation().getBegin());
636651
assertEquals(END, response.getDocumentStructure().getSectionTitles().get(0).getLocation().getEnd());
@@ -646,6 +661,8 @@ public void testClassifyElements() throws FileNotFoundException, InterruptedExce
646661
response.getDocumentStructure().getLeadingSentences().get(0).getElementLocations().get(0).getBegin());
647662
assertEquals(END,
648663
response.getDocumentStructure().getLeadingSentences().get(0).getElementLocations().get(0).getEnd());
664+
assertEquals(BEGIN, response.getDocumentStructure().getParagraphs().get(0).getLocation().getBegin());
665+
assertEquals(END, response.getDocumentStructure().getParagraphs().get(0).getLocation().getEnd());
649666
assertEquals(PARTY, response.getParties().get(0).getParty());
650667
assertEquals(Parties.Importance.UNKNOWN, response.getParties().get(0).getImportance());
651668
assertEquals(ROLE, response.getParties().get(0).getRole());
@@ -654,22 +671,55 @@ public void testClassifyElements() throws FileNotFoundException, InterruptedExce
654671
assertEquals(END, response.getParties().get(0).getAddresses().get(0).getLocation().getEnd());
655672
assertEquals(NAME, response.getParties().get(0).getContacts().get(0).getName());
656673
assertEquals(ROLE, response.getParties().get(0).getContacts().get(0).getRole());
674+
assertEquals(TEXT, response.getParties().get(0).getMentions().get(0).getText());
675+
assertEquals(BEGIN, response.getParties().get(0).getMentions().get(0).getLocation().getBegin());
676+
assertEquals(END, response.getParties().get(0).getMentions().get(0).getLocation().getEnd());
657677
assertEquals(TEXT, response.getEffectiveDates().get(0).getText());
658678
assertEquals(BEGIN, response.getEffectiveDates().get(0).getLocation().getBegin());
659679
assertEquals(END, response.getEffectiveDates().get(0).getLocation().getEnd());
660680
assertEquals(EffectiveDates.ConfidenceLevel.HIGH, response.getEffectiveDates().get(0).getConfidenceLevel());
681+
assertEquals(TEXT_NORMALIZED, response.getEffectiveDates().get(0).getTextNormalized());
682+
assertEquals(PROVENANCE_ID, response.getEffectiveDates().get(0).getProvenanceIds().get(0));
661683
assertEquals(TEXT, response.getContractAmounts().get(0).getText());
662684
assertEquals(BEGIN, response.getContractAmounts().get(0).getLocation().getBegin());
663685
assertEquals(END, response.getContractAmounts().get(0).getLocation().getEnd());
664686
assertEquals(ContractAmts.ConfidenceLevel.HIGH, response.getContractAmounts().get(0).getConfidenceLevel());
687+
assertEquals(TEXT, response.getContractAmounts().get(0).getText());
688+
assertEquals(TEXT_NORMALIZED, response.getContractAmounts().get(0).getTextNormalized());
689+
assertEquals(VALUE, response.getContractAmounts().get(0).getInterpretation().getValue());
690+
assertEquals(NUMERIC_VALUE, response.getPaymentTerms().get(0).getInterpretation().getNumericValue());
691+
assertEquals(UNIT, response.getContractAmounts().get(0).getInterpretation().getUnit());
692+
assertEquals(PROVENANCE_ID, response.getContractAmounts().get(0).getProvenanceIds().get(0));
693+
assertEquals(BEGIN, response.getContractAmounts().get(0).getLocation().getBegin());
694+
assertEquals(END, response.getContractAmounts().get(0).getLocation().getEnd());
665695
assertEquals(TEXT, response.getTerminationDates().get(0).getText());
666696
assertEquals(BEGIN, response.getTerminationDates().get(0).getLocation().getBegin());
667697
assertEquals(END, response.getTerminationDates().get(0).getLocation().getEnd());
668698
assertEquals(TerminationDates.ConfidenceLevel.HIGH, response.getTerminationDates().get(0).getConfidenceLevel());
669-
assertEquals(TEXT, response.getContractType().get(0).getText());
670-
assertEquals(BEGIN, response.getContractType().get(0).getLocation().getBegin());
671-
assertEquals(END, response.getContractType().get(0).getLocation().getEnd());
672-
assertEquals(ContractType.ConfidenceLevel.HIGH, response.getContractType().get(0).getConfidenceLevel());
699+
assertEquals(TEXT_NORMALIZED, response.getTerminationDates().get(0).getTextNormalized());
700+
assertEquals(PROVENANCE_ID, response.getTerminationDates().get(0).getProvenanceIds().get(0));
701+
assertEquals(TEXT, response.getContractTypes().get(0).getText());
702+
assertEquals(BEGIN, response.getContractTypes().get(0).getLocation().getBegin());
703+
assertEquals(END, response.getContractTypes().get(0).getLocation().getEnd());
704+
assertEquals(ContractType.ConfidenceLevel.HIGH, response.getContractTypes().get(0).getConfidenceLevel());
705+
assertEquals(ContractTerms.ConfidenceLevel.HIGH, response.getContractTerms().get(0).getConfidenceLevel());
706+
assertEquals(TEXT, response.getContractTerms().get(0).getText());
707+
assertEquals(TEXT_NORMALIZED, response.getContractTerms().get(0).getTextNormalized());
708+
assertEquals(VALUE, response.getContractTerms().get(0).getInterpretation().getValue());
709+
assertEquals(NUMERIC_VALUE, response.getContractTerms().get(0).getInterpretation().getNumericValue());
710+
assertEquals(UNIT, response.getContractTerms().get(0).getInterpretation().getUnit());
711+
assertEquals(PROVENANCE_ID, response.getContractTerms().get(0).getProvenanceIds().get(0));
712+
assertEquals(BEGIN, response.getContractTerms().get(0).getLocation().getBegin());
713+
assertEquals(END, response.getContractTerms().get(0).getLocation().getEnd());
714+
assertEquals(PaymentTerms.ConfidenceLevel.HIGH, response.getPaymentTerms().get(0).getConfidenceLevel());
715+
assertEquals(TEXT, response.getPaymentTerms().get(0).getText());
716+
assertEquals(TEXT_NORMALIZED, response.getPaymentTerms().get(0).getTextNormalized());
717+
assertEquals(VALUE, response.getPaymentTerms().get(0).getInterpretation().getValue());
718+
assertEquals(NUMERIC_VALUE, response.getPaymentTerms().get(0).getInterpretation().getNumericValue());
719+
assertEquals(UNIT, response.getPaymentTerms().get(0).getInterpretation().getUnit());
720+
assertEquals(PROVENANCE_ID, response.getPaymentTerms().get(0).getProvenanceIds().get(0));
721+
assertEquals(BEGIN, response.getPaymentTerms().get(0).getLocation().getBegin());
722+
assertEquals(END, response.getPaymentTerms().get(0).getLocation().getEnd());
673723
}
674724

675725
@Test

compare-comply/src/test/resources/compare_comply/classify-return.json

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,22 @@
175175
"text": "text"
176176
}
177177
}
178+
],
179+
"title": {
180+
"text": "text",
181+
"location": {
182+
"begin": 0,
183+
"end": 1
184+
}
185+
},
186+
"contexts": [
187+
{
188+
"text": "text",
189+
"location": {
190+
"begin": 0,
191+
"end": 1
192+
}
193+
}
178194
]
179195
}
180196
],
@@ -209,6 +225,14 @@
209225
}
210226
]
211227
}
228+
],
229+
"paragraphs": [
230+
{
231+
"location": {
232+
"begin": 0,
233+
"end": 1
234+
}
235+
}
212236
]
213237
},
214238
"parties": [
@@ -230,6 +254,15 @@
230254
"name": "name",
231255
"role": "role"
232256
}
257+
],
258+
"mentions": [
259+
{
260+
"text": "text",
261+
"location": {
262+
"begin": 0,
263+
"end": 1
264+
}
265+
}
233266
]
234267
}
235268
],
@@ -240,7 +273,11 @@
240273
"begin": 0,
241274
"end": 1
242275
},
243-
"confidence_level": "High"
276+
"confidence_level": "High",
277+
"text_normalized": "text_normalized",
278+
"provenance_ids": [
279+
"provenance_id"
280+
]
244281
}
245282
],
246283
"contract_amounts": [
@@ -250,7 +287,16 @@
250287
"begin": 0,
251288
"end": 1
252289
},
253-
"confidence_level": "High"
290+
"confidence_level": "High",
291+
"text_normalized": "text_normalized",
292+
"interpretation": {
293+
"value": "value",
294+
"numeric_value": 21,
295+
"unit": "unit"
296+
},
297+
"provenance_ids": [
298+
"provenance_id"
299+
]
254300
}
255301
],
256302
"termination_dates": [
@@ -260,10 +306,14 @@
260306
"begin": 0,
261307
"end": 1
262308
},
263-
"confidence_level": "High"
309+
"confidence_level": "High",
310+
"text_normalized": "text_normalized",
311+
"provenance_ids": [
312+
"provenance_id"
313+
]
264314
}
265315
],
266-
"contract_type": [
316+
"contract_types": [
267317
{
268318
"text": "text",
269319
"location": {
@@ -272,5 +322,43 @@
272322
},
273323
"confidence_level": "High"
274324
}
325+
],
326+
"contract_terms": [
327+
{
328+
"confidence_level": "High",
329+
"text": "text",
330+
"text_normalized": "text_normalized",
331+
"interpretation": {
332+
"value": "value",
333+
"numeric_value": 21,
334+
"unit": "unit"
335+
},
336+
"provenance_ids": [
337+
"provenance_id"
338+
],
339+
"location": {
340+
"begin": 0,
341+
"end": 1
342+
}
343+
}
344+
],
345+
"payment_terms": [
346+
{
347+
"confidence_level": "High",
348+
"text": "text",
349+
"text_normalized": "text_normalized",
350+
"interpretation": {
351+
"value": "value",
352+
"numeric_value": 21,
353+
"unit": "unit"
354+
},
355+
"provenance_ids": [
356+
"provenance_id"
357+
],
358+
"location": {
359+
"begin": 0,
360+
"end": 1
361+
}
362+
}
275363
]
276364
}

0 commit comments

Comments
 (0)