@Test public void getUrl_allFieldsSet_correspondingUrlReturned() throws Exception { final String expectedUrl = "https: "normal&imageSource=auto&correctOrientation=true&correctSkew=true&readBarcodes=false&" + "exportFormat=pdfSearchable%2Cxml%2Ctxt&description=dummy&pdfPassword=dummy&xml%3AwriteFormatting=true&" + "xml%3AwriteRecognitionVariants=true&pdf%3AwriteTags=auto"; ProcessImageInput sut = (ProcessImageInput) new ProcessImageInput.Builder() .language("English") .textType(TextType.NORMAL.toString()) .imageSource(ImageSource.AUTO.toString()) .correctOrientation(String.valueOf(true)) .correctSkew(String.valueOf(true)) .exportFormat( StringUtils.join(new String[]{ExportFormat.PDF_SEARCHABLE.toString(), ExportFormat.XML.toString(), ExportFormat.TXT.toString()}, ',')) .description("dummy") .pdfPassword("dummy") .profile(Profile.TEXT_EXTRACTION.toString()) .writeTags(WriteTags.AUTO.toString()) .writeFormatting(String.valueOf(true)) .writeRecognitionVariants(String.valueOf(true)) .readBarcodes(String.valueOf(false)) .locationId(LocationId.EU.toString()) .build(); String url = sut.getUrl(); assertEquals(expectedUrl, url); }
@Override public @NotNull String getUrl() throws URISyntaxException { URIBuilder urlBuilder = new URIBuilder() .setScheme(this.getLocationId().getProtocol()) .setHost(String.format(Urls.HOST_TEMPLATE, this.getLocationId().toString(), Endpoints.PROCESS_IMAGE)); if (this.getLanguages() != null && !this.getLanguages().isEmpty()) { urlBuilder.addParameter(QueryParams.LANGUAGE, StringUtils.join(this.getLanguages(), ',')); } if (this.getProfile() != null) { urlBuilder.addParameter(QueryParams.PROFILE, this.getProfile().toString()); } if (this.getTextTypes() != null && !this.getTextTypes().isEmpty()) { urlBuilder.addParameter(QueryParams.TEXT_TYPE, StringUtils.join(this.getTextTypes(), ',')); } if (this.getImageSource() != null) { urlBuilder.addParameter(QueryParams.IMAGE_SOURCE, this.getImageSource().toString()); } urlBuilder.addParameter(QueryParams.CORRECT_ORIENTATION, String.valueOf(this.isCorrectOrientation())); urlBuilder.addParameter(QueryParams.CORRECT_SKEW, String.valueOf(this.isCorrectSkew())); if (this.isReadBarcodes() != null) { urlBuilder.addParameter(QueryParams.READ_BARCODES, String.valueOf(this.isReadBarcodes())); } if (this.getExportFormats() != null && !this.getExportFormats().isEmpty()) { urlBuilder.addParameter(QueryParams.EXPORT_FORMAT, StringUtils.join(this.getExportFormats(), ',')); } if (StringUtils.isNotEmpty(this.getDescription())) { urlBuilder.addParameter(QueryParams.DESCRIPTION, this.getDescription()); } if (StringUtils.isNotEmpty(this.getPdfPassword())) { urlBuilder.addParameter(QueryParams.PDF_PASSWORD, this.getPdfPassword()); } if (this.getExportFormats() != null && this.getExportFormats().contains(ExportFormat.XML)) { urlBuilder.addParameter(QueryParams.WRITE_FORMATTING, String.valueOf(this.isWriteFormatting())) .addParameter(QueryParams.WRITE_RECOGNITION_VARIANTS, String.valueOf(this.isWriteRecognitionVariants())); } if (this.getExportFormats() != null && this.getExportFormats().contains(ExportFormat.PDF_SEARCHABLE) && this.getWriteTags() != null) { urlBuilder.addParameter(QueryParams.WRITE_TAGS, this.getWriteTags().toString()); } return urlBuilder.build().toString(); }
ProcessImageInput extends AbbyyInput { @Override public @NotNull String getUrl() throws URISyntaxException { URIBuilder urlBuilder = new URIBuilder() .setScheme(this.getLocationId().getProtocol()) .setHost(String.format(Urls.HOST_TEMPLATE, this.getLocationId().toString(), Endpoints.PROCESS_IMAGE)); if (this.getLanguages() != null && !this.getLanguages().isEmpty()) { urlBuilder.addParameter(QueryParams.LANGUAGE, StringUtils.join(this.getLanguages(), ',')); } if (this.getProfile() != null) { urlBuilder.addParameter(QueryParams.PROFILE, this.getProfile().toString()); } if (this.getTextTypes() != null && !this.getTextTypes().isEmpty()) { urlBuilder.addParameter(QueryParams.TEXT_TYPE, StringUtils.join(this.getTextTypes(), ',')); } if (this.getImageSource() != null) { urlBuilder.addParameter(QueryParams.IMAGE_SOURCE, this.getImageSource().toString()); } urlBuilder.addParameter(QueryParams.CORRECT_ORIENTATION, String.valueOf(this.isCorrectOrientation())); urlBuilder.addParameter(QueryParams.CORRECT_SKEW, String.valueOf(this.isCorrectSkew())); if (this.isReadBarcodes() != null) { urlBuilder.addParameter(QueryParams.READ_BARCODES, String.valueOf(this.isReadBarcodes())); } if (this.getExportFormats() != null && !this.getExportFormats().isEmpty()) { urlBuilder.addParameter(QueryParams.EXPORT_FORMAT, StringUtils.join(this.getExportFormats(), ',')); } if (StringUtils.isNotEmpty(this.getDescription())) { urlBuilder.addParameter(QueryParams.DESCRIPTION, this.getDescription()); } if (StringUtils.isNotEmpty(this.getPdfPassword())) { urlBuilder.addParameter(QueryParams.PDF_PASSWORD, this.getPdfPassword()); } if (this.getExportFormats() != null && this.getExportFormats().contains(ExportFormat.XML)) { urlBuilder.addParameter(QueryParams.WRITE_FORMATTING, String.valueOf(this.isWriteFormatting())) .addParameter(QueryParams.WRITE_RECOGNITION_VARIANTS, String.valueOf(this.isWriteRecognitionVariants())); } if (this.getExportFormats() != null && this.getExportFormats().contains(ExportFormat.PDF_SEARCHABLE) && this.getWriteTags() != null) { urlBuilder.addParameter(QueryParams.WRITE_TAGS, this.getWriteTags().toString()); } return urlBuilder.build().toString(); } }
ProcessImageInput extends AbbyyInput { @Override public @NotNull String getUrl() throws URISyntaxException { URIBuilder urlBuilder = new URIBuilder() .setScheme(this.getLocationId().getProtocol()) .setHost(String.format(Urls.HOST_TEMPLATE, this.getLocationId().toString(), Endpoints.PROCESS_IMAGE)); if (this.getLanguages() != null && !this.getLanguages().isEmpty()) { urlBuilder.addParameter(QueryParams.LANGUAGE, StringUtils.join(this.getLanguages(), ',')); } if (this.getProfile() != null) { urlBuilder.addParameter(QueryParams.PROFILE, this.getProfile().toString()); } if (this.getTextTypes() != null && !this.getTextTypes().isEmpty()) { urlBuilder.addParameter(QueryParams.TEXT_TYPE, StringUtils.join(this.getTextTypes(), ',')); } if (this.getImageSource() != null) { urlBuilder.addParameter(QueryParams.IMAGE_SOURCE, this.getImageSource().toString()); } urlBuilder.addParameter(QueryParams.CORRECT_ORIENTATION, String.valueOf(this.isCorrectOrientation())); urlBuilder.addParameter(QueryParams.CORRECT_SKEW, String.valueOf(this.isCorrectSkew())); if (this.isReadBarcodes() != null) { urlBuilder.addParameter(QueryParams.READ_BARCODES, String.valueOf(this.isReadBarcodes())); } if (this.getExportFormats() != null && !this.getExportFormats().isEmpty()) { urlBuilder.addParameter(QueryParams.EXPORT_FORMAT, StringUtils.join(this.getExportFormats(), ',')); } if (StringUtils.isNotEmpty(this.getDescription())) { urlBuilder.addParameter(QueryParams.DESCRIPTION, this.getDescription()); } if (StringUtils.isNotEmpty(this.getPdfPassword())) { urlBuilder.addParameter(QueryParams.PDF_PASSWORD, this.getPdfPassword()); } if (this.getExportFormats() != null && this.getExportFormats().contains(ExportFormat.XML)) { urlBuilder.addParameter(QueryParams.WRITE_FORMATTING, String.valueOf(this.isWriteFormatting())) .addParameter(QueryParams.WRITE_RECOGNITION_VARIANTS, String.valueOf(this.isWriteRecognitionVariants())); } if (this.getExportFormats() != null && this.getExportFormats().contains(ExportFormat.PDF_SEARCHABLE) && this.getWriteTags() != null) { urlBuilder.addParameter(QueryParams.WRITE_TAGS, this.getWriteTags().toString()); } return urlBuilder.build().toString(); } private  ProcessImageInput(Builder builder); }
ProcessImageInput extends AbbyyInput { @Override public @NotNull String getUrl() throws URISyntaxException { URIBuilder urlBuilder = new URIBuilder() .setScheme(this.getLocationId().getProtocol()) .setHost(String.format(Urls.HOST_TEMPLATE, this.getLocationId().toString(), Endpoints.PROCESS_IMAGE)); if (this.getLanguages() != null && !this.getLanguages().isEmpty()) { urlBuilder.addParameter(QueryParams.LANGUAGE, StringUtils.join(this.getLanguages(), ',')); } if (this.getProfile() != null) { urlBuilder.addParameter(QueryParams.PROFILE, this.getProfile().toString()); } if (this.getTextTypes() != null && !this.getTextTypes().isEmpty()) { urlBuilder.addParameter(QueryParams.TEXT_TYPE, StringUtils.join(this.getTextTypes(), ',')); } if (this.getImageSource() != null) { urlBuilder.addParameter(QueryParams.IMAGE_SOURCE, this.getImageSource().toString()); } urlBuilder.addParameter(QueryParams.CORRECT_ORIENTATION, String.valueOf(this.isCorrectOrientation())); urlBuilder.addParameter(QueryParams.CORRECT_SKEW, String.valueOf(this.isCorrectSkew())); if (this.isReadBarcodes() != null) { urlBuilder.addParameter(QueryParams.READ_BARCODES, String.valueOf(this.isReadBarcodes())); } if (this.getExportFormats() != null && !this.getExportFormats().isEmpty()) { urlBuilder.addParameter(QueryParams.EXPORT_FORMAT, StringUtils.join(this.getExportFormats(), ',')); } if (StringUtils.isNotEmpty(this.getDescription())) { urlBuilder.addParameter(QueryParams.DESCRIPTION, this.getDescription()); } if (StringUtils.isNotEmpty(this.getPdfPassword())) { urlBuilder.addParameter(QueryParams.PDF_PASSWORD, this.getPdfPassword()); } if (this.getExportFormats() != null && this.getExportFormats().contains(ExportFormat.XML)) { urlBuilder.addParameter(QueryParams.WRITE_FORMATTING, String.valueOf(this.isWriteFormatting())) .addParameter(QueryParams.WRITE_RECOGNITION_VARIANTS, String.valueOf(this.isWriteRecognitionVariants())); } if (this.getExportFormats() != null && this.getExportFormats().contains(ExportFormat.PDF_SEARCHABLE) && this.getWriteTags() != null) { urlBuilder.addParameter(QueryParams.WRITE_TAGS, this.getWriteTags().toString()); } return urlBuilder.build().toString(); } private  ProcessImageInput(Builder builder); List<String> getLanguages(); Profile getProfile(); List<TextType> getTextTypes(); ImageSource getImageSource(); Boolean isCorrectOrientation(); Boolean isCorrectSkew(); Boolean isReadBarcodes(); List<ExportFormat> getExportFormats(); Boolean isWriteFormatting(); Boolean isWriteRecognitionVariants(); WriteTags getWriteTags(); String getDescription(); String getPdfPassword(); @Override @NotNull String getUrl(); }
ProcessImageInput extends AbbyyInput { @Override public @NotNull String getUrl() throws URISyntaxException { URIBuilder urlBuilder = new URIBuilder() .setScheme(this.getLocationId().getProtocol()) .setHost(String.format(Urls.HOST_TEMPLATE, this.getLocationId().toString(), Endpoints.PROCESS_IMAGE)); if (this.getLanguages() != null && !this.getLanguages().isEmpty()) { urlBuilder.addParameter(QueryParams.LANGUAGE, StringUtils.join(this.getLanguages(), ',')); } if (this.getProfile() != null) { urlBuilder.addParameter(QueryParams.PROFILE, this.getProfile().toString()); } if (this.getTextTypes() != null && !this.getTextTypes().isEmpty()) { urlBuilder.addParameter(QueryParams.TEXT_TYPE, StringUtils.join(this.getTextTypes(), ',')); } if (this.getImageSource() != null) { urlBuilder.addParameter(QueryParams.IMAGE_SOURCE, this.getImageSource().toString()); } urlBuilder.addParameter(QueryParams.CORRECT_ORIENTATION, String.valueOf(this.isCorrectOrientation())); urlBuilder.addParameter(QueryParams.CORRECT_SKEW, String.valueOf(this.isCorrectSkew())); if (this.isReadBarcodes() != null) { urlBuilder.addParameter(QueryParams.READ_BARCODES, String.valueOf(this.isReadBarcodes())); } if (this.getExportFormats() != null && !this.getExportFormats().isEmpty()) { urlBuilder.addParameter(QueryParams.EXPORT_FORMAT, StringUtils.join(this.getExportFormats(), ',')); } if (StringUtils.isNotEmpty(this.getDescription())) { urlBuilder.addParameter(QueryParams.DESCRIPTION, this.getDescription()); } if (StringUtils.isNotEmpty(this.getPdfPassword())) { urlBuilder.addParameter(QueryParams.PDF_PASSWORD, this.getPdfPassword()); } if (this.getExportFormats() != null && this.getExportFormats().contains(ExportFormat.XML)) { urlBuilder.addParameter(QueryParams.WRITE_FORMATTING, String.valueOf(this.isWriteFormatting())) .addParameter(QueryParams.WRITE_RECOGNITION_VARIANTS, String.valueOf(this.isWriteRecognitionVariants())); } if (this.getExportFormats() != null && this.getExportFormats().contains(ExportFormat.PDF_SEARCHABLE) && this.getWriteTags() != null) { urlBuilder.addParameter(QueryParams.WRITE_TAGS, this.getWriteTags().toString()); } return urlBuilder.build().toString(); } private  ProcessImageInput(Builder builder); List<String> getLanguages(); Profile getProfile(); List<TextType> getTextTypes(); ImageSource getImageSource(); Boolean isCorrectOrientation(); Boolean isCorrectSkew(); Boolean isReadBarcodes(); List<ExportFormat> getExportFormats(); Boolean isWriteFormatting(); Boolean isWriteRecognitionVariants(); WriteTags getWriteTags(); String getDescription(); String getPdfPassword(); @Override @NotNull String getUrl();  }