CompareComply extends BaseService { public ServiceCall<ClassifyReturn> classifyElements( ClassifyElementsOptions classifyElementsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( classifyElementsOptions, "classifyElementsOptions cannot be null"); String[] pathSegments = {"v1/element_classification"}; RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); builder.query("version", versionDate); Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "classifyElements"); for (Entry<String, String> header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); if (classifyElementsOptions.model() != null) { builder.query("model", classifyElementsOptions.model()); } MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); okhttp3.RequestBody fileBody = RequestUtils.inputStreamBody( classifyElementsOptions.file(), classifyElementsOptions.fileContentType()); multipartBuilder.addFormDataPart("file", "filename", fileBody); builder.body(multipartBuilder.build()); ResponseConverter<ClassifyReturn> responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken<ClassifyReturn>() {}.getType()); return createServiceCall(builder.build(), responseConverter); } CompareComply(String versionDate);  CompareComply(String versionDate, Authenticator authenticator);  CompareComply(String versionDate, String serviceName);  CompareComply(String versionDate, String serviceName, Authenticator authenticator); ServiceCall<HTMLReturn> convertToHtml(ConvertToHtmlOptions convertToHtmlOptions); ServiceCall<ClassifyReturn> classifyElements(
      ClassifyElementsOptions classifyElementsOptions); ServiceCall<TableReturn> extractTables(ExtractTablesOptions extractTablesOptions); ServiceCall<CompareReturn> compareDocuments(
      CompareDocumentsOptions compareDocumentsOptions); ServiceCall<FeedbackReturn> addFeedback(AddFeedbackOptions addFeedbackOptions); ServiceCall<FeedbackList> listFeedback(ListFeedbackOptions listFeedbackOptions); ServiceCall<FeedbackList> listFeedback(); ServiceCall<GetFeedback> getFeedback(GetFeedbackOptions getFeedbackOptions); ServiceCall<FeedbackDeleted> deleteFeedback(DeleteFeedbackOptions deleteFeedbackOptions); ServiceCall<BatchStatus> createBatch(CreateBatchOptions createBatchOptions); ServiceCall<Batches> listBatches(ListBatchesOptions listBatchesOptions); ServiceCall<Batches> listBatches(); ServiceCall<BatchStatus> getBatch(GetBatchOptions getBatchOptions); ServiceCall<BatchStatus> updateBatch(UpdateBatchOptions updateBatchOptions);  }
@Test public void testClassifyElements() throws FileNotFoundException, InterruptedException { server.enqueue(jsonResponse(classifyElementsResponse)); ClassifyElementsOptions classifyElementsOptions = new ClassifyElementsOptions.Builder().file(SAMPLE_PDF).build(); ClassifyReturn response = service.classifyElements(classifyElementsOptions).execute().getResult(); RecordedRequest request = server.takeRequest(); assertEquals(CLASSIFY_ELEMENTS_PATH, request.getPath()); assertEquals(TITLE, response.getDocument().getTitle()); assertEquals(HTML, response.getDocument().getHtml()); assertEquals(HASH, response.getDocument().getHash()); assertEquals(LABEL, response.getDocument().getLabel()); assertEquals(MODEL_ID, response.getModelId()); assertEquals(MODEL_VERSION, response.getModelVersion()); assertEquals(BEGIN, response.getElements().get(0).getLocation().begin()); assertEquals(END, response.getElements().get(0).getLocation().end()); assertEquals(TEXT, response.getElements().get(0).getText()); assertEquals(NATURE, response.getElements().get(0).getTypes().get(0).label().nature()); assertEquals(PARTY, response.getElements().get(0).getTypes().get(0).label().party()); assertEquals( PROVENANCE_ID, response.getElements().get(0).getTypes().get(0).provenanceIds().get(0)); assertEquals(LABEL, response.getElements().get(0).getCategories().get(0).label()); assertEquals( PROVENANCE_ID, response.getElements().get(0).getCategories().get(0).provenanceIds().get(0)); assertEquals(TYPE, response.getElements().get(0).getAttributes().get(0).getType()); assertEquals(TEXT, response.getElements().get(0).getAttributes().get(0).getText()); assertEquals(BEGIN, response.getElements().get(0).getAttributes().get(0).getLocation().begin()); assertEquals(END, response.getElements().get(0).getAttributes().get(0).getLocation().end()); assertEquals(BEGIN, response.getTables().get(0).getLocation().begin()); assertEquals(END, response.getTables().get(0).getLocation().end()); assertEquals(TEXT, response.getTables().get(0).getText()); assertEquals(BEGIN, response.getTables().get(0).getSectionTitle().getLocation().begin()); assertEquals(END, response.getTables().get(0).getSectionTitle().getLocation().end()); assertEquals(CELL_ID, response.getTables().get(0).getTableHeaders().get(0).getCellId()); assertEquals( BEGIN_DOUBLE, response.getTables().get(0).getTableHeaders().get(0).getLocation().get("begin")); assertEquals( END_DOUBLE, response.getTables().get(0).getTableHeaders().get(0).getLocation().get("end")); assertEquals(TEXT, response.getTables().get(0).getTableHeaders().get(0).getText()); assertEquals( ROW_INDEX_BEGIN, response.getTables().get(0).getTableHeaders().get(0).getRowIndexBegin()); assertEquals( ROW_INDEX_END, response.getTables().get(0).getTableHeaders().get(0).getRowIndexEnd()); assertEquals( COLUMN_INDEX_BEGIN, response.getTables().get(0).getTableHeaders().get(0).getColumnIndexBegin()); assertEquals( COLUMN_INDEX_END, response.getTables().get(0).getTableHeaders().get(0).getColumnIndexEnd()); assertEquals(CELL_ID, response.getTables().get(0).getColumnHeaders().get(0).getCellId()); assertEquals( BEGIN_DOUBLE, response.getTables().get(0).getColumnHeaders().get(0).getLocation().get("begin")); assertEquals( END_DOUBLE, response.getTables().get(0).getColumnHeaders().get(0).getLocation().get("end")); assertEquals(TEXT, response.getTables().get(0).getColumnHeaders().get(0).getText()); assertEquals( TEXT_NORMALIZED, response.getTables().get(0).getColumnHeaders().get(0).getTextNormalized()); assertEquals( ROW_INDEX_BEGIN, response.getTables().get(0).getColumnHeaders().get(0).getRowIndexBegin()); assertEquals( ROW_INDEX_END, response.getTables().get(0).getColumnHeaders().get(0).getRowIndexEnd()); assertEquals( COLUMN_INDEX_BEGIN, response.getTables().get(0).getColumnHeaders().get(0).getColumnIndexBegin()); assertEquals( COLUMN_INDEX_END, response.getTables().get(0).getColumnHeaders().get(0).getColumnIndexEnd()); assertEquals(CELL_ID, response.getTables().get(0).getRowHeaders().get(0).getCellId()); assertEquals(BEGIN, response.getTables().get(0).getRowHeaders().get(0).getLocation().begin()); assertEquals(END, response.getTables().get(0).getRowHeaders().get(0).getLocation().end()); assertEquals(TEXT, response.getTables().get(0).getRowHeaders().get(0).getText()); assertEquals( TEXT_NORMALIZED, response.getTables().get(0).getRowHeaders().get(0).getTextNormalized()); assertEquals( ROW_INDEX_BEGIN, response.getTables().get(0).getRowHeaders().get(0).getRowIndexBegin()); assertEquals( ROW_INDEX_END, response.getTables().get(0).getRowHeaders().get(0).getRowIndexEnd()); assertEquals( COLUMN_INDEX_BEGIN, response.getTables().get(0).getRowHeaders().get(0).getColumnIndexBegin()); assertEquals( COLUMN_INDEX_END, response.getTables().get(0).getRowHeaders().get(0).getColumnIndexEnd()); assertEquals(CELL_ID, response.getTables().get(0).getBodyCells().get(0).getCellId()); assertEquals(BEGIN, response.getTables().get(0).getBodyCells().get(0).getLocation().begin()); assertEquals(END, response.getTables().get(0).getBodyCells().get(0).getLocation().end()); assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getText()); assertEquals( ROW_INDEX_BEGIN, response.getTables().get(0).getBodyCells().get(0).getRowIndexBegin()); assertEquals(ROW_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getRowIndexEnd()); assertEquals( COLUMN_INDEX_BEGIN, response.getTables().get(0).getBodyCells().get(0).getColumnIndexBegin()); assertEquals( COLUMN_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getColumnIndexEnd()); assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0)); assertEquals( TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0)); assertEquals( TEXT_NORMALIZED, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0)); assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0)); assertEquals( TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0)); assertEquals( TEXT_NORMALIZED, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0)); assertEquals( TYPE, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getType()); assertEquals( TEXT, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getText()); assertEquals( BEGIN, response .getTables() .get(0) .getBodyCells() .get(0) .getAttributes() .get(0) .getLocation() .begin()); assertEquals( END, response .getTables() .get(0) .getBodyCells() .get(0) .getAttributes() .get(0) .getLocation() .end()); assertEquals( CELL_ID, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getCellId()); assertEquals( BEGIN, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getLocation().begin()); assertEquals( END, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getLocation().end()); assertEquals(TEXT, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getText()); assertEquals( CELL_ID, response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getCellId()); assertEquals( BEGIN, response .getTables() .get(0) .getKeyValuePairs() .get(0) .getValue() .get(0) .getLocation() .begin()); assertEquals( END, response .getTables() .get(0) .getKeyValuePairs() .get(0) .getValue() .get(0) .getLocation() .end()); assertEquals( TEXT, response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getText()); assertEquals(TEXT, response.getTables().get(0).getTitle().getText()); assertEquals(BEGIN, response.getTables().get(0).getTitle().getLocation().begin()); assertEquals(END, response.getTables().get(0).getTitle().getLocation().end()); assertEquals(TEXT, response.getTables().get(0).getContexts().get(0).getText()); assertEquals(BEGIN, response.getTables().get(0).getContexts().get(0).getLocation().begin()); assertEquals(END, response.getTables().get(0).getContexts().get(0).getLocation().end()); assertEquals(TEXT, response.getDocumentStructure().getSectionTitles().get(0).getText()); assertEquals( BEGIN, response.getDocumentStructure().getSectionTitles().get(0).getLocation().begin()); assertEquals( END, response.getDocumentStructure().getSectionTitles().get(0).getLocation().end()); assertEquals(LEVEL, response.getDocumentStructure().getSectionTitles().get(0).getLevel()); assertEquals( BEGIN, response .getDocumentStructure() .getSectionTitles() .get(0) .getElementLocations() .get(0) .getBegin()); assertEquals( END, response .getDocumentStructure() .getSectionTitles() .get(0) .getElementLocations() .get(0) .getEnd()); assertEquals(TEXT, response.getDocumentStructure().getLeadingSentences().get(0).getText()); assertEquals( BEGIN, response.getDocumentStructure().getLeadingSentences().get(0).getLocation().begin()); assertEquals( END, response.getDocumentStructure().getLeadingSentences().get(0).getLocation().end()); assertEquals( BEGIN, response .getDocumentStructure() .getLeadingSentences() .get(0) .getElementLocations() .get(0) .getBegin()); assertEquals( END, response .getDocumentStructure() .getLeadingSentences() .get(0) .getElementLocations() .get(0) .getEnd()); assertEquals( BEGIN, response.getDocumentStructure().getParagraphs().get(0).getLocation().begin()); assertEquals(END, response.getDocumentStructure().getParagraphs().get(0).getLocation().end()); assertEquals(PARTY, response.getParties().get(0).getParty()); assertEquals(Parties.Importance.UNKNOWN, response.getParties().get(0).getImportance()); assertEquals(ROLE, response.getParties().get(0).getRole()); assertEquals(TEXT, response.getParties().get(0).getAddresses().get(0).getText()); assertEquals(BEGIN, response.getParties().get(0).getAddresses().get(0).getLocation().begin()); assertEquals(END, response.getParties().get(0).getAddresses().get(0).getLocation().end()); assertEquals(NAME, response.getParties().get(0).getContacts().get(0).getName()); assertEquals(ROLE, response.getParties().get(0).getContacts().get(0).getRole()); assertEquals(TEXT, response.getParties().get(0).getMentions().get(0).getText()); assertEquals(BEGIN, response.getParties().get(0).getMentions().get(0).getLocation().begin()); assertEquals(END, response.getParties().get(0).getMentions().get(0).getLocation().end()); assertEquals(TEXT, response.getEffectiveDates().get(0).getText()); assertEquals(BEGIN, response.getEffectiveDates().get(0).getLocation().begin()); assertEquals(END, response.getEffectiveDates().get(0).getLocation().end()); assertEquals( EffectiveDates.ConfidenceLevel.HIGH, response.getEffectiveDates().get(0).getConfidenceLevel()); assertEquals(TEXT_NORMALIZED, response.getEffectiveDates().get(0).getTextNormalized()); assertEquals(PROVENANCE_ID, response.getEffectiveDates().get(0).getProvenanceIds().get(0)); assertEquals(TEXT, response.getContractAmounts().get(0).getText()); assertEquals(BEGIN, response.getContractAmounts().get(0).getLocation().begin()); assertEquals(END, response.getContractAmounts().get(0).getLocation().end()); assertEquals( ContractAmts.ConfidenceLevel.HIGH, response.getContractAmounts().get(0).getConfidenceLevel()); assertEquals(TEXT, response.getContractAmounts().get(0).getText()); assertEquals(TEXT_NORMALIZED, response.getContractAmounts().get(0).getTextNormalized()); assertEquals(VALUE, response.getContractAmounts().get(0).getInterpretation().getValue()); assertEquals( NUMERIC_VALUE, response.getPaymentTerms().get(0).getInterpretation().getNumericValue()); assertEquals(UNIT, response.getContractAmounts().get(0).getInterpretation().getUnit()); assertEquals(PROVENANCE_ID, response.getContractAmounts().get(0).getProvenanceIds().get(0)); assertEquals(BEGIN, response.getContractAmounts().get(0).getLocation().begin()); assertEquals(END, response.getContractAmounts().get(0).getLocation().end()); assertEquals(TEXT, response.getTerminationDates().get(0).getText()); assertEquals(BEGIN, response.getTerminationDates().get(0).getLocation().begin()); assertEquals(END, response.getTerminationDates().get(0).getLocation().end()); assertEquals( TerminationDates.ConfidenceLevel.HIGH, response.getTerminationDates().get(0).getConfidenceLevel()); assertEquals(TEXT_NORMALIZED, response.getTerminationDates().get(0).getTextNormalized()); assertEquals(PROVENANCE_ID, response.getTerminationDates().get(0).getProvenanceIds().get(0)); assertEquals(TEXT, response.getContractTypes().get(0).getText()); assertEquals(BEGIN, response.getContractTypes().get(0).getLocation().begin()); assertEquals(END, response.getContractTypes().get(0).getLocation().end()); assertEquals( ContractTypes.ConfidenceLevel.HIGH, response.getContractTypes().get(0).getConfidenceLevel()); assertEquals( ContractTerms.ConfidenceLevel.HIGH, response.getContractTerms().get(0).getConfidenceLevel()); assertEquals(TEXT, response.getContractTerms().get(0).getText()); assertEquals(TEXT_NORMALIZED, response.getContractTerms().get(0).getTextNormalized()); assertEquals(VALUE, response.getContractTerms().get(0).getInterpretation().getValue()); assertEquals( NUMERIC_VALUE, response.getContractTerms().get(0).getInterpretation().getNumericValue()); assertEquals(UNIT, response.getContractTerms().get(0).getInterpretation().getUnit()); assertEquals(PROVENANCE_ID, response.getContractTerms().get(0).getProvenanceIds().get(0)); assertEquals(BEGIN, response.getContractTerms().get(0).getLocation().begin()); assertEquals(END, response.getContractTerms().get(0).getLocation().end()); assertEquals( PaymentTerms.ConfidenceLevel.HIGH, response.getPaymentTerms().get(0).getConfidenceLevel()); assertEquals(TEXT, response.getPaymentTerms().get(0).getText()); assertEquals(TEXT_NORMALIZED, response.getPaymentTerms().get(0).getTextNormalized()); assertEquals(VALUE, response.getPaymentTerms().get(0).getInterpretation().getValue()); assertEquals( NUMERIC_VALUE, response.getPaymentTerms().get(0).getInterpretation().getNumericValue()); assertEquals(UNIT, response.getPaymentTerms().get(0).getInterpretation().getUnit()); assertEquals(PROVENANCE_ID, response.getPaymentTerms().get(0).getProvenanceIds().get(0)); assertEquals(BEGIN, response.getPaymentTerms().get(0).getLocation().begin()); assertEquals(END, response.getPaymentTerms().get(0).getLocation().end()); assertEquals( ContractCurrencies.ConfidenceLevel.HIGH, response.getContractCurrencies().get(0).getConfidenceLevel()); assertEquals(TEXT, response.getContractCurrencies().get(0).getText()); assertEquals(TEXT_NORMALIZED, response.getContractCurrencies().get(0).getTextNormalized()); assertEquals(PROVENANCE_ID, response.getContractCurrencies().get(0).getProvenanceIds().get(0)); assertEquals(BEGIN, response.getContractCurrencies().get(0).getLocation().begin()); assertEquals(END, response.getContractCurrencies().get(0).getLocation().end()); }