diff --git a/README.md b/README.md
index 43bef61..30d121e 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
[](https://releases.aspose.cloud/java/repo/com/aspose/aspose-barcode-cloud/)
- API version: 4.0
-- SDK version: 26.6.0
+- SDK version: 26.7.0
## SDK and API Version Compatibility:
@@ -77,7 +77,7 @@ Add this dependency to your project's POM:
com.aspose
aspose-barcode-cloud
- 26.6.0
+ 26.7.0
compile
```
@@ -92,7 +92,7 @@ mvn clean package
Then manually install the following JARs:
-- `target/aspose-barcode-cloud-26.6.0.jar`
+- `target/aspose-barcode-cloud-26.7.0.jar`
- `target/lib/*.jar`
## Getting Started
diff --git a/pom.xml b/pom.xml
index 9078fea..8e7515d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
aspose-barcode-cloud
jar
aspose-barcode-cloud
- 26.6.0
+ 26.7.0
https://www.aspose.cloud
Aspose.BarCode Cloud SDK for Java
diff --git a/scripts/check-badges.bash b/scripts/check-badges.bash
index 578d958..a79bc39 100755
--- a/scripts/check-badges.bash
+++ b/scripts/check-badges.bash
@@ -16,7 +16,7 @@ pushd "${SCRIPT_DIR}/.." >/dev/null
fi
done
-(grep -oP '[^/]+\.yml/badge.svg(?!\?branch=main)' "${readme_file}" || echo ) | while read -r badge_without_branch; do
+(grep -oP '[^/]+\.yml/badge.svg(?!\?branch=(main|v4)\b)' "${readme_file}" || echo ) | while read -r badge_without_branch; do
if [ -z "${badge_without_branch}" ]; then continue; fi
>&2 echo "Badge without branch \"${badge_without_branch}\""
exit 1
diff --git a/skills/generate-and-scan-barcode-java/references/snippet-map.md b/skills/generate-and-scan-barcode-java/references/snippet-map.md
index c7d05d9..6c192c8 100644
--- a/skills/generate-and-scan-barcode-java/references/snippet-map.md
+++ b/skills/generate-and-scan-barcode-java/references/snippet-map.md
@@ -37,6 +37,11 @@ Use this reference when you want the closest existing pattern before writing new
- `src/test/java/com/aspose/barcode/cloud/test/ScanApiTest.java`: scan via base64 body, multipart, and URL.
- `src/test/java/com/aspose/barcode/cloud/test/ConfigurationTest.java`: configuration defaults and `buildApiClient()` behavior.
- `src/test/java/com/aspose/barcode/cloud/test/ExceptionTest.java`: expected failures and exception behavior.
-- `src/test/java/com/aspose/barcode/cloud/api/GenerateApiUnitTest.java`: request validation and generated request-path behavior.
-- `src/test/java/com/aspose/barcode/cloud/api/RecognizeApiUnitTest.java`: recognize request validation, request-path behavior, and async wiring.
+- `src/test/java/com/aspose/barcode/cloud/api/GenerateApiValidationUnitTest.java`: generate request validation.
+- `src/test/java/com/aspose/barcode/cloud/api/GenerateApiRequestUnitTest.java`: generated request-path, query-parameter, and header behavior.
+- `src/test/java/com/aspose/barcode/cloud/api/GenerateApiBodyUnitTest.java`: generate request content types and payload serialization.
+- `src/test/java/com/aspose/barcode/cloud/api/GenerateApiMethodCoverageUnitTest.java`: generate sync/async method wiring.
+- `src/test/java/com/aspose/barcode/cloud/api/RecognizeApiValidationUnitTest.java`: recognize request validation.
+- `src/test/java/com/aspose/barcode/cloud/api/RecognizeApiRequestUnitTest.java`: recognize request-path, query-parameter, and content-type behavior.
+- `src/test/java/com/aspose/barcode/cloud/api/RecognizeApiMethodCoverageUnitTest.java`: recognize sync/async method wiring.
- `src/test/java/com/aspose/barcode/cloud/api/ScanApiUnitTest.java`: scan request validation, request-path behavior, and async wiring.
diff --git a/snippets/dependency.xml b/snippets/dependency.xml
index 45c8796..635a540 100644
--- a/snippets/dependency.xml
+++ b/snippets/dependency.xml
@@ -11,7 +11,7 @@
com.aspose
aspose-barcode-cloud
- 26.6.0
+ 26.7.0
\ No newline at end of file
diff --git a/src/main/java/com/aspose/barcode/cloud/ApiClient.java b/src/main/java/com/aspose/barcode/cloud/ApiClient.java
index 9f4973d..86629d4 100644
--- a/src/main/java/com/aspose/barcode/cloud/ApiClient.java
+++ b/src/main/java/com/aspose/barcode/cloud/ApiClient.java
@@ -40,7 +40,7 @@
/** ApiClient. */
public class ApiClient {
public final String apiVersion = "v4.0";
- public final String clientVersion = "26.6.0";
+ public final String clientVersion = "26.7.0";
private String baseUrl = "https://api.aspose.cloud";
private String tokenUrl = "https://id.aspose.cloud/connect/token";
@@ -88,7 +88,7 @@ protected ApiClient(long readTimeoutMillis) {
json = new JSON();
// Set default User-Agent.
- setUserAgent("OpenApi-Generator/26.6.0/java");
+ setUserAgent("OpenApi-Generator/26.7.0/java");
addDefaultHeader("x-aspose-client", "java sdk");
addDefaultHeader("x-aspose-client-version", clientVersion);
diff --git a/src/main/java/com/aspose/barcode/cloud/ServerConfiguration.java b/src/main/java/com/aspose/barcode/cloud/ServerConfiguration.java
deleted file mode 100644
index 97727ba..0000000
--- a/src/main/java/com/aspose/barcode/cloud/ServerConfiguration.java
+++ /dev/null
@@ -1,91 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-//
-// Copyright (c) 2026 Aspose.BarCode for Cloud
-//
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-//
-// --------------------------------------------------------------------------------------------------------------------
-
-package com.aspose.barcode.cloud;
-
-import java.util.Map;
-
-/** Representing a Server configuration. */
-public class ServerConfiguration {
- public String url;
- public String description;
- public Map variables;
-
- /**
- * Constructor
- *
- * @param url A url to the target host.
- * @param description A description of the host designated by the url.
- * @param variables A map between a variable name and its value. The value is used for
- * substitution in the server's url template.
- */
- public ServerConfiguration(
- String url, String description, Map variables) {
- this.url = url;
- this.description = description;
- this.variables = variables;
- }
-
- /**
- * Format url template using given variables.
- *
- * @param variables A map between a variable name and its value.
- * @return Formatted url.
- */
- public String url(Map variables) {
- String url = this.url;
-
- // go through variables and replace placeholders
- for (Map.Entry variable : this.variables.entrySet()) {
- String name = variable.getKey();
- ServerVariable serverVariable = variable.getValue();
- String value = serverVariable.defaultValue;
-
- if (variables != null && variables.containsKey(name)) {
- value = variables.get(name);
- if (serverVariable.enumValues.size() > 0
- && !serverVariable.enumValues.contains(value)) {
- throw new IllegalArgumentException(
- "The variable "
- + name
- + " in the server url has invalid value "
- + value
- + ".");
- }
- }
- url = url.replace("{" + name + "}", value);
- }
- return url;
- }
-
- /**
- * Format url template using default server variables.
- *
- * @return Formatted url.
- */
- public String url() {
- return url(null);
- }
-}
diff --git a/src/main/java/com/aspose/barcode/cloud/ServerVariable.java b/src/main/java/com/aspose/barcode/cloud/ServerVariable.java
deleted file mode 100644
index 90949ed..0000000
--- a/src/main/java/com/aspose/barcode/cloud/ServerVariable.java
+++ /dev/null
@@ -1,49 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-//
-// Copyright (c) 2026 Aspose.BarCode for Cloud
-//
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-//
-// --------------------------------------------------------------------------------------------------------------------
-
-package com.aspose.barcode.cloud;
-
-import java.util.HashSet;
-
-/** Representing a Server Variable for server URL template substitution. */
-public class ServerVariable {
- public String description;
- public String defaultValue;
- public HashSet enumValues = null;
-
- /**
- * Constructor
- *
- * @param description A description for the server variable.
- * @param defaultValue The default value to use for substitution.
- * @param enumValues An enumeration of string values to be used if the substitution options are
- * from a limited set.
- */
- public ServerVariable(String description, String defaultValue, HashSet enumValues) {
- this.description = description;
- this.defaultValue = defaultValue;
- this.enumValues = enumValues;
- }
-}
diff --git a/src/main/java/com/aspose/barcode/cloud/model/AbstractOpenApiSchema.java b/src/main/java/com/aspose/barcode/cloud/model/AbstractOpenApiSchema.java
deleted file mode 100644
index eed95ae..0000000
--- a/src/main/java/com/aspose/barcode/cloud/model/AbstractOpenApiSchema.java
+++ /dev/null
@@ -1,156 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-//
-// Copyright (c) 2026 Aspose.BarCode for Cloud
-//
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-//
-// --------------------------------------------------------------------------------------------------------------------
-
-package com.aspose.barcode.cloud.model;
-
-import java.util.Map;
-import java.util.Objects;
-
-/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */
-public abstract class AbstractOpenApiSchema {
-
- // store the actual instance of the schema/object
- private Object instance;
-
- // is nullable
- private Boolean isNullable;
-
- // schema type (e.g. oneOf, anyOf)
- private final String schemaType;
-
- public AbstractOpenApiSchema(String schemaType, Boolean isNullable) {
- this.schemaType = schemaType;
- this.isNullable = isNullable;
- }
-
- /**
- * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object
- *
- * @return an instance of the actual schema/object
- */
- public abstract Map> getSchemas();
-
- /**
- * Get the actual instance
- *
- * @return an instance of the actual schema/object
- */
- // @JsonValue
- public Object getActualInstance() {
- return instance;
- }
-
- /**
- * Set the actual instance
- *
- * @param instance the actual instance of the schema/object
- */
- public void setActualInstance(Object instance) {
- this.instance = instance;
- }
-
- /**
- * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf
- * schema as well
- *
- * @return an instance of the actual schema/object
- */
- public Object getActualInstanceRecursively() {
- return getActualInstanceRecursively(this);
- }
-
- private Object getActualInstanceRecursively(AbstractOpenApiSchema object) {
- if (object.getActualInstance() == null) {
- return null;
- } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) {
- return getActualInstanceRecursively((AbstractOpenApiSchema) object.getActualInstance());
- } else {
- return object.getActualInstance();
- }
- }
-
- /**
- * Get the schema type (e.g. anyOf, oneOf)
- *
- * @return the schema type
- */
- public String getSchemaType() {
- return schemaType;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("class ").append(getClass()).append(" {\n");
- sb.append(" instance: ").append(toIndentedString(instance)).append("\n");
- sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n");
- sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n");
- sb.append("}");
- return sb.toString();
- }
-
- /**
- * Convert the given object to string with each line indented by 4 spaces (except the first
- * line).
- */
- private String toIndentedString(Object o) {
- if (o == null) {
- return "null";
- }
- return o.toString().replace("\n", "\n ");
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- AbstractOpenApiSchema a = (AbstractOpenApiSchema) o;
- return Objects.equals(this.instance, a.instance)
- && Objects.equals(this.isNullable, a.isNullable)
- && Objects.equals(this.schemaType, a.schemaType);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(instance, isNullable, schemaType);
- }
-
- /**
- * Is nullable
- *
- * @return true if it's nullable
- */
- public Boolean isNullable() {
- if (Boolean.TRUE.equals(isNullable)) {
- return Boolean.TRUE;
- } else {
- return Boolean.FALSE;
- }
- }
-}
diff --git a/src/test/java/com/aspose/barcode/cloud/ApiClientCoverageTest.java b/src/test/java/com/aspose/barcode/cloud/ApiClientCoverageTest.java
new file mode 100644
index 0000000..d22e119
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/ApiClientCoverageTest.java
@@ -0,0 +1,154 @@
+package com.aspose.barcode.cloud;
+
+import static org.junit.Assert.*;
+
+import com.aspose.barcode.cloud.model.ApiErrorResponse;
+
+import okhttp3.Headers;
+import okhttp3.MultipartBody;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+
+import org.junit.Test;
+
+import java.io.File;
+import java.time.LocalDate;
+import java.time.OffsetDateTime;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Coverage for {@link ApiClient}: parameter/URL/header formatting, multipart body building and
+ * response deserialization.
+ */
+public class ApiClientCoverageTest {
+
+ @Test
+ public void apiClientFormatsHeadersParametersUrlsAndMultipartBodies() {
+ ApiClient client = new ApiClient("fake-token");
+ client.setUserAgent("unit-test");
+ client.addDefaultHeader("X-Default", "default-value");
+ client.setTempFolderPath("target");
+ client.setReadTimeout(1234);
+
+ assertEquals("https://api.aspose.cloud/v4.0", client.getBasePath());
+ assertNotNull(client.getHttpClient());
+ assertFalse(client.isDebugging());
+ client.setDebugging(false);
+ assertFalse(client.isDebugging());
+ assertEquals("target", client.getTempFolderPath());
+ assertTrue(client.getConnectTimeout() >= 0);
+ assertEquals(1234, client.getReadTimeout());
+ assertTrue(client.getWriteTimeout() >= 0);
+
+ assertEquals("", client.parameterToString(null));
+ assertEquals("a,b", client.parameterToString(Arrays.asList("a", "b")));
+ assertEquals("2026-06-29", client.parameterToString(LocalDate.parse("2026-06-29")));
+ assertTrue(
+ client.parameterToString(OffsetDateTime.parse("2026-06-29T00:00:00Z"))
+ .startsWith("2026-06-29T00:00"));
+
+ assertTrue(client.parameterToPair(null, "value").isEmpty());
+ assertTrue(client.parameterToPair("empty", null).isEmpty());
+ assertEquals("value", client.parameterToPair("name", "value").get(0).getValue());
+ assertEquals(
+ "a%20b",
+ client.parameterToPairs("multi", "name", Arrays.asList("a b")).get(0).getValue());
+ assertEquals(
+ "a%20b,c",
+ client.parameterToPairs("csv", "name", Arrays.asList("a b", "c"))
+ .get(0)
+ .getValue());
+ assertEquals(
+ "a%20b%09c",
+ client.parameterToPairs("tsv", "name", Arrays.asList("a b", "c"))
+ .get(0)
+ .getValue());
+ assertEquals(
+ "a%20b%7Cc",
+ client.parameterToPairs("pipes", "name", Arrays.asList("a b", "c"))
+ .get(0)
+ .getValue());
+ assertTrue(client.parameterToPairs("csv", "", Arrays.asList("a")).isEmpty());
+
+ assertEquals("file.png", client.sanitizeFilename("../path/file.png"));
+ assertTrue(client.isJsonMime("application/vnd.test+json; charset=UTF-8"));
+ assertFalse(client.isJsonMime("text/plain"));
+ assertNull(client.selectHeaderAccept(new String[] {}));
+ assertEquals(
+ "application/json",
+ client.selectHeaderAccept(new String[] {"text/plain", "application/json"}));
+ assertEquals(
+ "text/plain,image/png",
+ client.selectHeaderAccept(new String[] {"text/plain", "image/png"}));
+ assertEquals("application/json", client.selectHeaderContentType(new String[] {}));
+ assertEquals("application/json", client.selectHeaderContentType(new String[] {"*/*"}));
+ assertEquals(
+ "application/json",
+ client.selectHeaderContentType(new String[] {"text/plain", "application/json"}));
+ assertEquals("text/plain", client.selectHeaderContentType(new String[] {"text/plain"}));
+ assertEquals("a%20b", client.escapeString("a b"));
+
+ Map headers = new HashMap<>();
+ Request.Builder requestBuilder = new Request.Builder().url("https://example.com");
+ client.processHeaderParams(headers, requestBuilder);
+ Request request = requestBuilder.get().build();
+ assertEquals("default-value", request.header("X-Default"));
+ assertEquals("unit-test", request.header("User-Agent"));
+
+ String url =
+ client.buildUrl(
+ "/resource?existing=1",
+ client.parameterToPair("q", "a b"),
+ client.parameterToPairs("multi", "kind", Arrays.asList("qr", "pdf")));
+ assertTrue(url.contains("existing=1&q=a%20b"));
+ assertTrue(url.contains("kind=qr"));
+ assertTrue(url.contains("kind=pdf"));
+
+ Map formParams = new HashMap<>();
+ formParams.put("name", "value");
+ formParams.put("many", Arrays.asList("one", "two"));
+ formParams.put("file", new File("test_data/pdf417Sample.png"));
+ RequestBody body = client.buildRequestBodyMultipart(formParams);
+ assertTrue(body instanceof MultipartBody);
+ MultipartBody multipartBody = (MultipartBody) body;
+ assertTrue(multipartBody.parts().size() >= 4);
+ assertEquals("image/png", client.guessContentTypeFromFile(new File("sample.png")));
+ assertEquals(
+ "application/octet-stream",
+ client.guessContentTypeFromFile(new File("sample.unknownext")));
+ }
+
+ @Test
+ public void apiClientDeserializesSimpleResponsesAndRejectsUnsupportedContent()
+ throws Exception {
+ ApiClient client = new ApiClient("fake-token");
+
+ Response stringResponse = response("plain text", "text/plain", 200, "OK");
+ assertEquals("plain text", client.deserialize(stringResponse, String.class));
+
+ Response emptyResponse = response("", "application/json", 204, "No Content");
+ assertNull(client.handleResponse(emptyResponse, null));
+
+ Response unsupported = response("payload", "text/plain", 200, "OK");
+ try {
+ client.deserialize(unsupported, ApiErrorResponse.class);
+ fail("Expected unsupported content type");
+ } catch (ApiException e) {
+ assertTrue(e.getDetails().contains("payload"));
+ }
+ }
+
+ private static Response response(String body, String contentType, int code, String message) {
+ return new Response.Builder()
+ .request(new Request.Builder().url("https://example.com").build())
+ .protocol(okhttp3.Protocol.HTTP_1_1)
+ .code(code)
+ .message(message)
+ .headers(Headers.of("Content-Type", contentType))
+ .body(okhttp3.ResponseBody.create(body, okhttp3.MediaType.parse(contentType)))
+ .build();
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/SdkCoreCoverageTest.java b/src/test/java/com/aspose/barcode/cloud/SdkCoreCoverageTest.java
index befc6f4..56fcf97 100644
--- a/src/test/java/com/aspose/barcode/cloud/SdkCoreCoverageTest.java
+++ b/src/test/java/com/aspose/barcode/cloud/SdkCoreCoverageTest.java
@@ -5,24 +5,17 @@
import com.aspose.barcode.cloud.model.ApiError;
import com.aspose.barcode.cloud.model.ApiErrorResponse;
-import okhttp3.Headers;
-import okhttp3.MultipartBody;
-import okhttp3.Request;
-import okhttp3.RequestBody;
-import okhttp3.Response;
-
import org.junit.Test;
-import java.io.File;
-import java.time.LocalDate;
-import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
+/**
+ * Coverage for the core SDK result and exception types: {@link ApiResponse} value exposure and
+ * {@link ApiException} detail/cause construction.
+ */
public class SdkCoreCoverageTest {
@Test
@@ -56,152 +49,4 @@ public void apiExceptionBuildsDetailsFromErrorResponseBodyOrEmptyFallback() {
new ApiException(new IllegalStateException("boom")).getCause()
instanceof IllegalStateException);
}
-
- @Test
- public void serverConfigurationExpandsDefaultsOverridesAndRejectsInvalidEnums() {
- HashSet enumValues = new HashSet<>(Arrays.asList("v4.0", "v5.0"));
- ServerVariable version = new ServerVariable("version", "v4.0", enumValues);
- Map variables = Collections.singletonMap("version", version);
- ServerConfiguration server =
- new ServerConfiguration("https://api.aspose.cloud/{version}", "Aspose", variables);
-
- assertEquals("https://api.aspose.cloud/v4.0", server.url());
- assertEquals(
- "https://api.aspose.cloud/v5.0",
- server.url(Collections.singletonMap("version", "v5.0")));
-
- try {
- server.url(Collections.singletonMap("version", "v6.0"));
- fail("Expected invalid enum value to be rejected");
- } catch (IllegalArgumentException e) {
- assertTrue(e.getMessage().contains("invalid value v6.0"));
- }
- }
-
- @Test
- public void apiClientFormatsHeadersParametersUrlsAndMultipartBodies() {
- ApiClient client = new ApiClient("fake-token");
- client.setUserAgent("unit-test");
- client.addDefaultHeader("X-Default", "default-value");
- client.setTempFolderPath("target");
- client.setReadTimeout(1234);
-
- assertEquals("https://api.aspose.cloud/v4.0", client.getBasePath());
- assertNotNull(client.getHttpClient());
- assertFalse(client.isDebugging());
- client.setDebugging(false);
- assertFalse(client.isDebugging());
- assertEquals("target", client.getTempFolderPath());
- assertTrue(client.getConnectTimeout() >= 0);
- assertEquals(1234, client.getReadTimeout());
- assertTrue(client.getWriteTimeout() >= 0);
-
- assertEquals("", client.parameterToString(null));
- assertEquals("a,b", client.parameterToString(Arrays.asList("a", "b")));
- assertEquals("2026-06-29", client.parameterToString(LocalDate.parse("2026-06-29")));
- assertTrue(
- client.parameterToString(OffsetDateTime.parse("2026-06-29T00:00:00Z"))
- .startsWith("2026-06-29T00:00"));
-
- assertTrue(client.parameterToPair(null, "value").isEmpty());
- assertTrue(client.parameterToPair("empty", null).isEmpty());
- assertEquals("value", client.parameterToPair("name", "value").get(0).getValue());
- assertEquals(
- "a%20b",
- client.parameterToPairs("multi", "name", Arrays.asList("a b")).get(0).getValue());
- assertEquals(
- "a%20b,c",
- client.parameterToPairs("csv", "name", Arrays.asList("a b", "c"))
- .get(0)
- .getValue());
- assertEquals(
- "a%20b%09c",
- client.parameterToPairs("tsv", "name", Arrays.asList("a b", "c"))
- .get(0)
- .getValue());
- assertEquals(
- "a%20b%7Cc",
- client.parameterToPairs("pipes", "name", Arrays.asList("a b", "c"))
- .get(0)
- .getValue());
- assertTrue(client.parameterToPairs("csv", "", Arrays.asList("a")).isEmpty());
-
- assertEquals("file.png", client.sanitizeFilename("../path/file.png"));
- assertTrue(client.isJsonMime("application/vnd.test+json; charset=UTF-8"));
- assertFalse(client.isJsonMime("text/plain"));
- assertNull(client.selectHeaderAccept(new String[] {}));
- assertEquals(
- "application/json",
- client.selectHeaderAccept(new String[] {"text/plain", "application/json"}));
- assertEquals(
- "text/plain,image/png",
- client.selectHeaderAccept(new String[] {"text/plain", "image/png"}));
- assertEquals("application/json", client.selectHeaderContentType(new String[] {}));
- assertEquals("application/json", client.selectHeaderContentType(new String[] {"*/*"}));
- assertEquals(
- "application/json",
- client.selectHeaderContentType(new String[] {"text/plain", "application/json"}));
- assertEquals("text/plain", client.selectHeaderContentType(new String[] {"text/plain"}));
- assertEquals("a%20b", client.escapeString("a b"));
-
- Map headers = new HashMap<>();
- Request.Builder requestBuilder = new Request.Builder().url("https://example.com");
- client.processHeaderParams(headers, requestBuilder);
- Request request = requestBuilder.get().build();
- assertEquals("default-value", request.header("X-Default"));
- assertEquals("unit-test", request.header("User-Agent"));
-
- String url =
- client.buildUrl(
- "/resource?existing=1",
- client.parameterToPair("q", "a b"),
- client.parameterToPairs("multi", "kind", Arrays.asList("qr", "pdf")));
- assertTrue(url.contains("existing=1&q=a%20b"));
- assertTrue(url.contains("kind=qr"));
- assertTrue(url.contains("kind=pdf"));
-
- Map formParams = new HashMap<>();
- formParams.put("name", "value");
- formParams.put("many", Arrays.asList("one", "two"));
- formParams.put("file", new File("test_data/pdf417Sample.png"));
- RequestBody body = client.buildRequestBodyMultipart(formParams);
- assertTrue(body instanceof MultipartBody);
- MultipartBody multipartBody = (MultipartBody) body;
- assertTrue(multipartBody.parts().size() >= 4);
- assertEquals("image/png", client.guessContentTypeFromFile(new File("sample.png")));
- assertEquals(
- "application/octet-stream",
- client.guessContentTypeFromFile(new File("sample.unknownext")));
- }
-
- @Test
- public void apiClientDeserializesSimpleResponsesAndRejectsUnsupportedContent()
- throws Exception {
- ApiClient client = new ApiClient("fake-token");
-
- Response stringResponse = response("plain text", "text/plain", 200, "OK");
- assertEquals("plain text", client.deserialize(stringResponse, String.class));
-
- Response emptyResponse = response("", "application/json", 204, "No Content");
- assertNull(client.handleResponse(emptyResponse, null));
-
- Response unsupported = response("payload", "text/plain", 200, "OK");
- try {
- client.deserialize(unsupported, ApiErrorResponse.class);
- fail("Expected unsupported content type");
- } catch (ApiException e) {
- assertTrue(e.getDetails().contains("payload"));
- }
- }
-
- private static Response response(String body, String contentType, int code, String message) {
- return new Response.Builder()
- .request(new Request.Builder().url("https://example.com").build())
- .protocol(okhttp3.Protocol.HTTP_1_1)
- .code(code)
- .message(message)
- .headers(Headers.of("Content-Type", contentType))
- .body(okhttp3.ResponseBody.create(body, okhttp3.MediaType.parse(contentType)))
- .build();
- }
}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/GenerateApiBodyUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/GenerateApiBodyUnitTest.java
new file mode 100644
index 0000000..0983e0b
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/GenerateApiBodyUnitTest.java
@@ -0,0 +1,123 @@
+package com.aspose.barcode.cloud.api;
+
+import static org.junit.Assert.*;
+
+import com.aspose.barcode.cloud.ApiException;
+import com.aspose.barcode.cloud.model.EncodeBarcodeType;
+import com.aspose.barcode.cloud.model.EncodeData;
+import com.aspose.barcode.cloud.model.GenerateParams;
+import com.aspose.barcode.cloud.requests.GenerateBodyRequestWrapper;
+import com.aspose.barcode.cloud.requests.GenerateMultipartRequestWrapper;
+
+import okhttp3.MultipartBody;
+import okhttp3.Request;
+
+import okio.Buffer;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.stream.Collectors;
+
+/** Offline unit tests for {@link GenerateApi} request content types and payload serialization. */
+public class GenerateApiBodyUnitTest {
+
+ private static GenerateApi api;
+
+ @BeforeClass
+ public static void setUp() {
+ api = GenerateApiTestFixtures.newApi();
+ }
+
+ @Test
+ public void testGenerateBodyCall_ContentTypeJson() throws ApiException {
+ EncodeData encodeData = new EncodeData("test");
+ GenerateParams params = new GenerateParams(EncodeBarcodeType.QR, encodeData);
+ GenerateBodyRequestWrapper request = new GenerateBodyRequestWrapper(params);
+ Request httpRequest = api.generateBodyCall(request, null, null).request();
+ String contentType = httpRequest.header("Content-Type");
+ assertTrue(contentType.contains("application/json"));
+ }
+
+ @Test
+ public void testGenerateBodyCall_HasBody() throws ApiException {
+ EncodeData encodeData = new EncodeData("test");
+ GenerateParams params = new GenerateParams(EncodeBarcodeType.QR, encodeData);
+ GenerateBodyRequestWrapper request = new GenerateBodyRequestWrapper(params);
+ Request httpRequest = api.generateBodyCall(request, null, null).request();
+ assertNotNull(httpRequest.body());
+ }
+
+ @Test
+ public void testGenerateBodyCall_WithGroupedGenerationParamsInJson() throws Exception {
+ EncodeData encodeData = new EncodeData("test");
+ GenerateParams params = new GenerateParams(EncodeBarcodeType.PDF417, encodeData);
+ params.setQrParams(GenerateApiTestFixtures.buildQrParams());
+ params.setCode128Params(GenerateApiTestFixtures.buildCode128Params());
+ params.setPdf417Params(GenerateApiTestFixtures.buildPdf417Params());
+
+ GenerateBodyRequestWrapper request = new GenerateBodyRequestWrapper(params);
+ Request httpRequest = api.generateBodyCall(request, null, null).request();
+
+ Buffer buffer = new Buffer();
+ httpRequest.body().writeTo(buffer);
+ String body = buffer.readUtf8();
+
+ assertTrue(body.contains("\"qrParams\""));
+ assertTrue(body.contains("\"qrEncodeMode\""));
+ assertTrue(body.contains("\"Auto\""));
+ assertTrue(body.contains("\"code128Params\""));
+ assertTrue(body.contains("\"code128EncodeMode\""));
+ assertTrue(body.contains("\"CodeB\""));
+ assertTrue(body.contains("\"pdf417Params\""));
+ assertTrue(body.contains("\"pdf417Columns\""));
+ assertTrue(body.contains("\"pdf417Rows\""));
+ assertTrue(body.contains("\"pdf417IsCode128Emulation\""));
+ }
+
+ @Test
+ public void testGenerateMultipartCall_ContentTypeMultipart() throws ApiException {
+ GenerateMultipartRequestWrapper request =
+ new GenerateMultipartRequestWrapper(EncodeBarcodeType.QR, "test");
+ Request httpRequest = api.generateMultipartCall(request, null, null).request();
+ String contentType = httpRequest.header("Content-Type");
+ assertTrue(contentType.contains("multipart/form-data"));
+ }
+
+ @Test
+ public void testGenerateMultipartCall_WithGroupedGenerationParams() throws ApiException {
+ GenerateMultipartRequestWrapper request =
+ new GenerateMultipartRequestWrapper(EncodeBarcodeType.PDF417, "test");
+ request.qrParams = GenerateApiTestFixtures.buildQrParams();
+ request.code128Params = GenerateApiTestFixtures.buildCode128Params();
+ request.pdf417Params = GenerateApiTestFixtures.buildPdf417Params();
+
+ Request httpRequest = api.generateMultipartCall(request, null, null).request();
+ assertTrue(httpRequest.body() instanceof MultipartBody);
+ MultipartBody body = (MultipartBody) httpRequest.body();
+ String partHeaders =
+ body.parts().stream()
+ .map(part -> part.headers().toString())
+ .collect(Collectors.joining("\n"));
+
+ assertTrue(partHeaders.contains("name=\"qrEncodeMode\""));
+ assertTrue(partHeaders.contains("name=\"qrErrorLevel\""));
+ assertTrue(partHeaders.contains("name=\"qrVersion\""));
+ assertTrue(partHeaders.contains("name=\"qrECIEncoding\""));
+ assertTrue(partHeaders.contains("name=\"qrAspectRatio\""));
+ assertTrue(partHeaders.contains("name=\"microQRVersion\""));
+ assertTrue(partHeaders.contains("name=\"rectMicroQrVersion\""));
+ assertTrue(partHeaders.contains("name=\"code128EncodeMode\""));
+ assertTrue(partHeaders.contains("name=\"pdf417EncodeMode\""));
+ assertTrue(partHeaders.contains("name=\"pdf417ErrorLevel\""));
+ assertTrue(partHeaders.contains("name=\"pdf417Truncate\""));
+ assertTrue(partHeaders.contains("name=\"pdf417Columns\""));
+ assertTrue(partHeaders.contains("name=\"pdf417Rows\""));
+ assertTrue(partHeaders.contains("name=\"pdf417AspectRatio\""));
+ assertTrue(partHeaders.contains("name=\"pdf417ECIEncoding\""));
+ assertTrue(partHeaders.contains("name=\"pdf417IsReaderInitialization\""));
+ assertTrue(partHeaders.contains("name=\"pdf417MacroCharacters\""));
+ assertTrue(partHeaders.contains("name=\"pdf417IsLinked\""));
+ assertTrue(partHeaders.contains("name=\"pdf417IsCode128Emulation\""));
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/GenerateApiMethodCoverageUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/GenerateApiMethodCoverageUnitTest.java
new file mode 100644
index 0000000..bcbf8fd
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/GenerateApiMethodCoverageUnitTest.java
@@ -0,0 +1,98 @@
+package com.aspose.barcode.cloud.api;
+
+import com.aspose.barcode.cloud.ApiCallback;
+import com.aspose.barcode.cloud.ApiException;
+import com.aspose.barcode.cloud.model.EncodeBarcodeType;
+import com.aspose.barcode.cloud.model.EncodeData;
+import com.aspose.barcode.cloud.model.GenerateParams;
+import com.aspose.barcode.cloud.requests.GenerateBodyRequestWrapper;
+import com.aspose.barcode.cloud.requests.GenerateMultipartRequestWrapper;
+import com.aspose.barcode.cloud.requests.GenerateRequestWrapper;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+/** Offline unit tests covering the public sync, http-info and async {@link GenerateApi} methods. */
+public class GenerateApiMethodCoverageUnitTest {
+
+ private static GenerateApi api;
+
+ @BeforeClass
+ public static void setUp() {
+ api = GenerateApiTestFixtures.newApi();
+ }
+
+ private static final ApiCallback NO_OP_CALLBACK =
+ new ApiCallback() {
+ @Override
+ public void onFailure(
+ ApiException e, int statusCode, Map> headers) {}
+
+ @Override
+ public void onSuccess(
+ File result, int statusCode, Map> headers) {}
+
+ @Override
+ public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {}
+
+ @Override
+ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {}
+ };
+
+ @Test(expected = ApiException.class)
+ public void testGenerate_CallsExecute() throws ApiException {
+ api.generate(new GenerateRequestWrapper(EncodeBarcodeType.QR, "test"));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testGenerateWithHttpInfo_CallsExecute() throws ApiException {
+ api.generateWithHttpInfo(new GenerateRequestWrapper(EncodeBarcodeType.QR, "test"));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGenerateAsync_CallsEnqueue() throws ApiException {
+ api.generateAsync(new GenerateRequestWrapper(EncodeBarcodeType.QR, "test"), NO_OP_CALLBACK);
+ }
+
+ @Test(expected = ApiException.class)
+ public void testGenerateBody_CallsExecute() throws ApiException {
+ EncodeData encodeData = new EncodeData("test");
+ GenerateParams params = new GenerateParams(EncodeBarcodeType.QR, encodeData);
+ api.generateBody(new GenerateBodyRequestWrapper(params));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testGenerateBodyWithHttpInfo_CallsExecute() throws ApiException {
+ EncodeData encodeData = new EncodeData("test");
+ GenerateParams params = new GenerateParams(EncodeBarcodeType.QR, encodeData);
+ api.generateBodyWithHttpInfo(new GenerateBodyRequestWrapper(params));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGenerateBodyAsync_CallsEnqueue() throws ApiException {
+ EncodeData encodeData = new EncodeData("test");
+ GenerateParams params = new GenerateParams(EncodeBarcodeType.QR, encodeData);
+ api.generateBodyAsync(new GenerateBodyRequestWrapper(params), NO_OP_CALLBACK);
+ }
+
+ @Test(expected = ApiException.class)
+ public void testGenerateMultipart_CallsExecute() throws ApiException {
+ api.generateMultipart(new GenerateMultipartRequestWrapper(EncodeBarcodeType.QR, "test"));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testGenerateMultipartWithHttpInfo_CallsExecute() throws ApiException {
+ api.generateMultipartWithHttpInfo(
+ new GenerateMultipartRequestWrapper(EncodeBarcodeType.QR, "test"));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGenerateMultipartAsync_CallsEnqueue() throws ApiException {
+ api.generateMultipartAsync(
+ new GenerateMultipartRequestWrapper(EncodeBarcodeType.QR, "test"), NO_OP_CALLBACK);
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/GenerateApiRequestUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/GenerateApiRequestUnitTest.java
new file mode 100644
index 0000000..3b000ff
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/GenerateApiRequestUnitTest.java
@@ -0,0 +1,221 @@
+package com.aspose.barcode.cloud.api;
+
+import static org.junit.Assert.*;
+
+import com.aspose.barcode.cloud.ApiException;
+import com.aspose.barcode.cloud.model.*;
+import com.aspose.barcode.cloud.requests.GenerateBodyRequestWrapper;
+import com.aspose.barcode.cloud.requests.GenerateMultipartRequestWrapper;
+import com.aspose.barcode.cloud.requests.GenerateRequestWrapper;
+
+import okhttp3.Request;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Offline unit tests for {@link GenerateApi} request building: paths, HTTP methods, query
+ * parameters, headers and edge cases.
+ */
+public class GenerateApiRequestUnitTest {
+
+ private static GenerateApi api;
+
+ @BeforeClass
+ public static void setUp() {
+ api = GenerateApiTestFixtures.newApi();
+ }
+
+ // --- Path construction tests ---
+
+ @Test
+ public void testGenerateCall_QR_Path() throws ApiException {
+ GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
+ Request httpRequest = api.generateCall(request, null, null).request();
+ assertTrue(httpRequest.url().toString().contains("/barcode/generate/QR"));
+ }
+
+ @Test
+ public void testGenerateCall_Code128_Path() throws ApiException {
+ GenerateRequestWrapper request =
+ new GenerateRequestWrapper(EncodeBarcodeType.CODE128, "test");
+ Request httpRequest = api.generateCall(request, null, null).request();
+ assertTrue(httpRequest.url().toString().contains("/barcode/generate/Code128"));
+ }
+
+ @Test
+ public void testGenerateCall_GS1Code128_Path() throws ApiException {
+ GenerateRequestWrapper request =
+ new GenerateRequestWrapper(EncodeBarcodeType.GS1_CODE128, "test");
+ Request httpRequest = api.generateCall(request, null, null).request();
+ assertTrue(httpRequest.url().toString().contains("/barcode/generate/GS1Code128"));
+ }
+
+ @Test
+ public void testGenerateCall_AllEnumTypes_Path() throws ApiException {
+ for (EncodeBarcodeType type : EncodeBarcodeType.values()) {
+ GenerateRequestWrapper request = new GenerateRequestWrapper(type, "test");
+ Request httpRequest = api.generateCall(request, null, null).request();
+ String url = httpRequest.url().toString();
+ assertTrue(
+ "URL should contain '" + type.toString() + "' for enum " + type.name(),
+ url.contains("/barcode/generate/" + type.toString()));
+ }
+ }
+
+ @Test
+ public void testGenerateCall_HttpMethodIsGet() throws ApiException {
+ GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
+ Request httpRequest = api.generateCall(request, null, null).request();
+ assertEquals("GET", httpRequest.method());
+ }
+
+ @Test
+ public void testGenerateBodyCall_PathAndMethod() throws ApiException {
+ EncodeData encodeData = new EncodeData("test");
+ GenerateParams params = new GenerateParams(EncodeBarcodeType.QR, encodeData);
+ GenerateBodyRequestWrapper request = new GenerateBodyRequestWrapper(params);
+ Request httpRequest = api.generateBodyCall(request, null, null).request();
+ assertTrue(httpRequest.url().toString().contains("/barcode/generate-body"));
+ assertEquals("POST", httpRequest.method());
+ }
+
+ @Test
+ public void testGenerateMultipartCall_PathAndMethod() throws ApiException {
+ GenerateMultipartRequestWrapper request =
+ new GenerateMultipartRequestWrapper(EncodeBarcodeType.QR, "test");
+ Request httpRequest = api.generateMultipartCall(request, null, null).request();
+ assertTrue(httpRequest.url().toString().contains("/barcode/generate-multipart"));
+ assertEquals("POST", httpRequest.method());
+ }
+
+ // --- Query parameter tests ---
+
+ @Test
+ public void testGenerateCall_RequiredParamsOnly_DefaultsPresent() throws ApiException {
+ GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "hello");
+ String url = api.generateCall(request, null, null).request().url().toString();
+
+ assertTrue(url.contains("data="));
+ assertFalse(url.contains("foregroundColor="));
+ assertFalse(url.contains("backgroundColor="));
+ assertFalse(url.contains("imageFormat="));
+ assertFalse(url.contains("textLocation="));
+ assertFalse(url.contains("units="));
+ assertFalse(url.contains("resolution="));
+ assertFalse(url.contains("imageHeight="));
+ assertFalse(url.contains("imageWidth="));
+ assertFalse(url.contains("rotationAngle="));
+ }
+
+ @Test
+ public void testGenerateCall_WithImageFormat() throws ApiException {
+ GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
+ request.barcodeImageParams = new BarcodeImageParams();
+ request.barcodeImageParams.setImageFormat(BarcodeImageFormat.PNG);
+ String url = api.generateCall(request, null, null).request().url().toString();
+ assertTrue(url.contains("imageFormat=Png"));
+ }
+
+ @Test
+ public void testGenerateCall_WithResolution() throws ApiException {
+ GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
+ request.barcodeImageParams = new BarcodeImageParams();
+ request.barcodeImageParams.setResolution(300.0f);
+ String url = api.generateCall(request, null, null).request().url().toString();
+ assertTrue(url.contains("resolution=300"));
+ }
+
+ @Test
+ public void testGenerateCall_WithDataType() throws ApiException {
+ GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
+ request.dataType = EncodeDataType.BASE64_BYTES;
+ String url = api.generateCall(request, null, null).request().url().toString();
+ assertTrue(url.contains("dataType=Base64Bytes"));
+ }
+
+ @Test
+ public void testGenerateCall_WithAllOptionalParams() throws ApiException {
+ GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
+ request.dataType = EncodeDataType.STRING_DATA;
+ request.barcodeImageParams = new BarcodeImageParams();
+ request.barcodeImageParams.setImageFormat(BarcodeImageFormat.JPEG);
+ request.barcodeImageParams.setTextLocation(CodeLocation.BELOW);
+ request.barcodeImageParams.setForegroundColor("Red");
+ request.barcodeImageParams.setBackgroundColor("Blue");
+ request.barcodeImageParams.setUnits(GraphicsUnit.PIXEL);
+ request.barcodeImageParams.setResolution(150.0f);
+ request.barcodeImageParams.setImageHeight(200.0f);
+ request.barcodeImageParams.setImageWidth(400.0f);
+ request.barcodeImageParams.setRotationAngle(90);
+
+ String url = api.generateCall(request, null, null).request().url().toString();
+ assertTrue(url.contains("dataType="));
+ assertTrue(url.contains("imageFormat="));
+ assertTrue(url.contains("textLocation="));
+ assertTrue(url.contains("foregroundColor="));
+ assertTrue(url.contains("backgroundColor="));
+ assertTrue(url.contains("units="));
+ assertTrue(url.contains("resolution="));
+ assertTrue(url.contains("imageHeight="));
+ assertTrue(url.contains("imageWidth="));
+ assertTrue(url.contains("rotationAngle="));
+ }
+
+ @Test
+ public void testGenerateCall_WithGroupedGenerationParams() throws ApiException {
+ GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
+ request.qrParams = GenerateApiTestFixtures.buildQrParams();
+ request.code128Params = GenerateApiTestFixtures.buildCode128Params();
+ request.pdf417Params = GenerateApiTestFixtures.buildPdf417Params();
+
+ String url = api.generateCall(request, null, null).request().url().toString();
+ assertTrue(url.contains("qrEncodeMode=Auto"));
+ assertTrue(url.contains("qrErrorLevel=LevelM"));
+ assertTrue(url.contains("qrVersion=Version01"));
+ assertTrue(url.contains("qrECIEncoding=UTF8"));
+ assertTrue(url.contains("qrAspectRatio=0.75"));
+ assertTrue(url.contains("microQRVersion=M2"));
+ assertTrue(url.contains("rectMicroQrVersion=R7x43"));
+ assertTrue(url.contains("code128EncodeMode=CodeB"));
+ assertTrue(url.contains("pdf417EncodeMode=Auto"));
+ assertTrue(url.contains("pdf417ErrorLevel=Level2"));
+ assertTrue(url.contains("pdf417Truncate=true"));
+ assertTrue(url.contains("pdf417Columns=3"));
+ assertTrue(url.contains("pdf417Rows=9"));
+ assertTrue(url.contains("pdf417AspectRatio=3.0"));
+ assertTrue(url.contains("pdf417ECIEncoding=UTF8"));
+ assertTrue(url.contains("pdf417IsReaderInitialization=false"));
+ assertTrue(url.contains("pdf417MacroCharacters=Macro05"));
+ assertTrue(url.contains("pdf417IsLinked=false"));
+ assertTrue(url.contains("pdf417IsCode128Emulation=false"));
+ }
+
+ // --- Header tests ---
+
+ @Test
+ public void testGenerateCall_AuthorizationHeader() throws ApiException {
+ GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
+ Request httpRequest = api.generateCall(request, null, null).request();
+ assertEquals(
+ "Bearer " + GenerateApiTestFixtures.FAKE_TOKEN,
+ httpRequest.header("Authorization"));
+ }
+
+ // --- Edge cases ---
+
+ @Test
+ public void testGenerateCall_SpecialCharactersInData() throws ApiException {
+ GenerateRequestWrapper request =
+ new GenerateRequestWrapper(EncodeBarcodeType.QR, "Hello World!@#$%");
+ Request httpRequest = api.generateCall(request, null, null).request();
+ assertNotNull(httpRequest.url());
+ }
+
+ @Test
+ public void testGenerateCall_EmptyStringData() throws ApiException {
+ GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "");
+ Request httpRequest = api.generateCall(request, null, null).request();
+ assertNotNull(httpRequest.url());
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/GenerateApiTestFixtures.java b/src/test/java/com/aspose/barcode/cloud/api/GenerateApiTestFixtures.java
new file mode 100644
index 0000000..2841c1b
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/GenerateApiTestFixtures.java
@@ -0,0 +1,50 @@
+package com.aspose.barcode.cloud.api;
+
+import com.aspose.barcode.cloud.ApiClient;
+import com.aspose.barcode.cloud.model.*;
+
+/** Shared fixtures for the offline {@link GenerateApi} unit tests. */
+final class GenerateApiTestFixtures {
+
+ static final String FAKE_TOKEN = "fake-test-token";
+
+ private GenerateApiTestFixtures() {}
+
+ static GenerateApi newApi() {
+ return new GenerateApi(new ApiClient(FAKE_TOKEN));
+ }
+
+ static QrParams buildQrParams() {
+ QrParams params = new QrParams();
+ params.setQrEncodeMode(QREncodeMode.AUTO);
+ params.setQrErrorLevel(QRErrorLevel.LEVEL_M);
+ params.setQrVersion(QRVersion.VERSION01);
+ params.setQrECIEncoding(ECIEncodings.UTF8);
+ params.setQrAspectRatio(0.75f);
+ params.setMicroQRVersion(MicroQRVersion.M2);
+ params.setRectMicroQrVersion(RectMicroQRVersion.R7X43);
+ return params;
+ }
+
+ static Code128Params buildCode128Params() {
+ Code128Params params = new Code128Params();
+ params.setCode128EncodeMode(Code128EncodeMode.CODE_B);
+ return params;
+ }
+
+ static Pdf417Params buildPdf417Params() {
+ Pdf417Params params = new Pdf417Params();
+ params.setPdf417EncodeMode(Pdf417EncodeMode.AUTO);
+ params.setPdf417ErrorLevel(Pdf417ErrorLevel.LEVEL2);
+ params.setPdf417Truncate(true);
+ params.setPdf417Columns(3);
+ params.setPdf417Rows(9);
+ params.setPdf417AspectRatio(3.0f);
+ params.setPdf417ECIEncoding(ECIEncodings.UTF8);
+ params.setPdf417IsReaderInitialization(false);
+ params.setPdf417MacroCharacters(MacroCharacter.MACRO05);
+ params.setPdf417IsLinked(false);
+ params.setPdf417IsCode128Emulation(false);
+ return params;
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/GenerateApiUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/GenerateApiUnitTest.java
deleted file mode 100644
index aedc3d5..0000000
--- a/src/test/java/com/aspose/barcode/cloud/api/GenerateApiUnitTest.java
+++ /dev/null
@@ -1,472 +0,0 @@
-package com.aspose.barcode.cloud.api;
-
-import static org.junit.Assert.*;
-
-import com.aspose.barcode.cloud.ApiCallback;
-import com.aspose.barcode.cloud.ApiClient;
-import com.aspose.barcode.cloud.ApiException;
-import com.aspose.barcode.cloud.model.*;
-import com.aspose.barcode.cloud.requests.GenerateBodyRequestWrapper;
-import com.aspose.barcode.cloud.requests.GenerateMultipartRequestWrapper;
-import com.aspose.barcode.cloud.requests.GenerateRequestWrapper;
-
-import okhttp3.MultipartBody;
-import okhttp3.Request;
-
-import okio.Buffer;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-public class GenerateApiUnitTest {
-
- private static final String FAKE_TOKEN = "fake-test-token";
- private static GenerateApi api;
-
- @BeforeClass
- public static void setUp() {
- ApiClient apiClient = new ApiClient(FAKE_TOKEN);
- api = new GenerateApi(apiClient);
- }
-
- // --- Group A: Validation tests ---
-
- @Test(expected = ApiException.class)
- public void testGenerate_NullBarcodeType_ThrowsApiException() throws ApiException {
- api.generate(new GenerateRequestWrapper(null, "data"));
- }
-
- @Test(expected = ApiException.class)
- public void testGenerate_NullData_ThrowsApiException() throws ApiException {
- api.generate(new GenerateRequestWrapper(EncodeBarcodeType.QR, null));
- }
-
- @Test
- public void testGenerate_NullBarcodeType_ErrorMessage() {
- try {
- api.generate(new GenerateRequestWrapper(null, "data"));
- fail("Expected ApiException");
- } catch (ApiException e) {
- assertTrue(e.getMessage().contains("request.barcodeType"));
- }
- }
-
- @Test
- public void testGenerate_NullData_ErrorMessage() {
- try {
- api.generate(new GenerateRequestWrapper(EncodeBarcodeType.QR, null));
- fail("Expected ApiException");
- } catch (ApiException e) {
- assertTrue(e.getMessage().contains("request.data"));
- }
- }
-
- @Test(expected = ApiException.class)
- public void testGenerateBody_NullParams_ThrowsApiException() throws ApiException {
- api.generateBody(new GenerateBodyRequestWrapper(null));
- }
-
- @Test(expected = ApiException.class)
- public void testGenerateMultipart_NullBarcodeType_ThrowsApiException() throws ApiException {
- api.generateMultipart(new GenerateMultipartRequestWrapper(null, "data"));
- }
-
- @Test(expected = ApiException.class)
- public void testGenerateMultipart_NullData_ThrowsApiException() throws ApiException {
- api.generateMultipart(new GenerateMultipartRequestWrapper(EncodeBarcodeType.QR, null));
- }
-
- // --- Group B: Path construction tests ---
-
- @Test
- public void testGenerateCall_QR_Path() throws ApiException {
- GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
- Request httpRequest = api.generateCall(request, null, null).request();
- assertTrue(httpRequest.url().toString().contains("/barcode/generate/QR"));
- }
-
- @Test
- public void testGenerateCall_Code128_Path() throws ApiException {
- GenerateRequestWrapper request =
- new GenerateRequestWrapper(EncodeBarcodeType.CODE128, "test");
- Request httpRequest = api.generateCall(request, null, null).request();
- assertTrue(httpRequest.url().toString().contains("/barcode/generate/Code128"));
- }
-
- @Test
- public void testGenerateCall_GS1Code128_Path() throws ApiException {
- GenerateRequestWrapper request =
- new GenerateRequestWrapper(EncodeBarcodeType.GS1_CODE128, "test");
- Request httpRequest = api.generateCall(request, null, null).request();
- assertTrue(httpRequest.url().toString().contains("/barcode/generate/GS1Code128"));
- }
-
- @Test
- public void testGenerateCall_AllEnumTypes_Path() throws ApiException {
- for (EncodeBarcodeType type : EncodeBarcodeType.values()) {
- GenerateRequestWrapper request = new GenerateRequestWrapper(type, "test");
- Request httpRequest = api.generateCall(request, null, null).request();
- String url = httpRequest.url().toString();
- assertTrue(
- "URL should contain '" + type.toString() + "' for enum " + type.name(),
- url.contains("/barcode/generate/" + type.toString()));
- }
- }
-
- @Test
- public void testGenerateCall_HttpMethodIsGet() throws ApiException {
- GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
- Request httpRequest = api.generateCall(request, null, null).request();
- assertEquals("GET", httpRequest.method());
- }
-
- @Test
- public void testGenerateBodyCall_PathAndMethod() throws ApiException {
- EncodeData encodeData = new EncodeData("test");
- GenerateParams params = new GenerateParams(EncodeBarcodeType.QR, encodeData);
- GenerateBodyRequestWrapper request = new GenerateBodyRequestWrapper(params);
- Request httpRequest = api.generateBodyCall(request, null, null).request();
- assertTrue(httpRequest.url().toString().contains("/barcode/generate-body"));
- assertEquals("POST", httpRequest.method());
- }
-
- @Test
- public void testGenerateMultipartCall_PathAndMethod() throws ApiException {
- GenerateMultipartRequestWrapper request =
- new GenerateMultipartRequestWrapper(EncodeBarcodeType.QR, "test");
- Request httpRequest = api.generateMultipartCall(request, null, null).request();
- assertTrue(httpRequest.url().toString().contains("/barcode/generate-multipart"));
- assertEquals("POST", httpRequest.method());
- }
-
- // --- Group C: Query parameter tests ---
-
- @Test
- public void testGenerateCall_RequiredParamsOnly_DefaultsPresent() throws ApiException {
- GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "hello");
- String url = api.generateCall(request, null, null).request().url().toString();
-
- assertTrue(url.contains("data="));
- assertFalse(url.contains("foregroundColor="));
- assertFalse(url.contains("backgroundColor="));
- assertFalse(url.contains("imageFormat="));
- assertFalse(url.contains("textLocation="));
- assertFalse(url.contains("units="));
- assertFalse(url.contains("resolution="));
- assertFalse(url.contains("imageHeight="));
- assertFalse(url.contains("imageWidth="));
- assertFalse(url.contains("rotationAngle="));
- }
-
- @Test
- public void testGenerateCall_WithImageFormat() throws ApiException {
- GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
- request.barcodeImageParams = new BarcodeImageParams();
- request.barcodeImageParams.setImageFormat(BarcodeImageFormat.PNG);
- String url = api.generateCall(request, null, null).request().url().toString();
- assertTrue(url.contains("imageFormat=Png"));
- }
-
- @Test
- public void testGenerateCall_WithResolution() throws ApiException {
- GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
- request.barcodeImageParams = new BarcodeImageParams();
- request.barcodeImageParams.setResolution(300.0f);
- String url = api.generateCall(request, null, null).request().url().toString();
- assertTrue(url.contains("resolution=300"));
- }
-
- @Test
- public void testGenerateCall_WithDataType() throws ApiException {
- GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
- request.dataType = EncodeDataType.BASE64_BYTES;
- String url = api.generateCall(request, null, null).request().url().toString();
- assertTrue(url.contains("dataType=Base64Bytes"));
- }
-
- @Test
- public void testGenerateCall_WithAllOptionalParams() throws ApiException {
- GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
- request.dataType = EncodeDataType.STRING_DATA;
- request.barcodeImageParams = new BarcodeImageParams();
- request.barcodeImageParams.setImageFormat(BarcodeImageFormat.JPEG);
- request.barcodeImageParams.setTextLocation(CodeLocation.BELOW);
- request.barcodeImageParams.setForegroundColor("Red");
- request.barcodeImageParams.setBackgroundColor("Blue");
- request.barcodeImageParams.setUnits(GraphicsUnit.PIXEL);
- request.barcodeImageParams.setResolution(150.0f);
- request.barcodeImageParams.setImageHeight(200.0f);
- request.barcodeImageParams.setImageWidth(400.0f);
- request.barcodeImageParams.setRotationAngle(90);
-
- String url = api.generateCall(request, null, null).request().url().toString();
- assertTrue(url.contains("dataType="));
- assertTrue(url.contains("imageFormat="));
- assertTrue(url.contains("textLocation="));
- assertTrue(url.contains("foregroundColor="));
- assertTrue(url.contains("backgroundColor="));
- assertTrue(url.contains("units="));
- assertTrue(url.contains("resolution="));
- assertTrue(url.contains("imageHeight="));
- assertTrue(url.contains("imageWidth="));
- assertTrue(url.contains("rotationAngle="));
- }
-
- @Test
- public void testGenerateCall_WithGroupedGenerationParams() throws ApiException {
- GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
- request.qrParams = buildQrParams();
- request.code128Params = buildCode128Params();
- request.pdf417Params = buildPdf417Params();
-
- String url = api.generateCall(request, null, null).request().url().toString();
- assertTrue(url.contains("qrEncodeMode=Auto"));
- assertTrue(url.contains("qrErrorLevel=LevelM"));
- assertTrue(url.contains("qrVersion=Version01"));
- assertTrue(url.contains("qrECIEncoding=UTF8"));
- assertTrue(url.contains("qrAspectRatio=0.75"));
- assertTrue(url.contains("microQRVersion=M2"));
- assertTrue(url.contains("rectMicroQrVersion=R7x43"));
- assertTrue(url.contains("code128EncodeMode=CodeB"));
- assertTrue(url.contains("pdf417EncodeMode=Auto"));
- assertTrue(url.contains("pdf417ErrorLevel=Level2"));
- assertTrue(url.contains("pdf417Truncate=true"));
- assertTrue(url.contains("pdf417Columns=3"));
- assertTrue(url.contains("pdf417Rows=9"));
- assertTrue(url.contains("pdf417AspectRatio=3.0"));
- assertTrue(url.contains("pdf417ECIEncoding=UTF8"));
- assertTrue(url.contains("pdf417IsReaderInitialization=false"));
- assertTrue(url.contains("pdf417MacroCharacters=Macro05"));
- assertTrue(url.contains("pdf417IsLinked=false"));
- assertTrue(url.contains("pdf417IsCode128Emulation=false"));
- }
-
- // --- Group D: Content-Type and body tests ---
-
- @Test
- public void testGenerateBodyCall_ContentTypeJson() throws ApiException {
- EncodeData encodeData = new EncodeData("test");
- GenerateParams params = new GenerateParams(EncodeBarcodeType.QR, encodeData);
- GenerateBodyRequestWrapper request = new GenerateBodyRequestWrapper(params);
- Request httpRequest = api.generateBodyCall(request, null, null).request();
- String contentType = httpRequest.header("Content-Type");
- assertTrue(contentType.contains("application/json"));
- }
-
- @Test
- public void testGenerateBodyCall_HasBody() throws ApiException {
- EncodeData encodeData = new EncodeData("test");
- GenerateParams params = new GenerateParams(EncodeBarcodeType.QR, encodeData);
- GenerateBodyRequestWrapper request = new GenerateBodyRequestWrapper(params);
- Request httpRequest = api.generateBodyCall(request, null, null).request();
- assertNotNull(httpRequest.body());
- }
-
- @Test
- public void testGenerateBodyCall_WithGroupedGenerationParamsInJson() throws Exception {
- EncodeData encodeData = new EncodeData("test");
- GenerateParams params = new GenerateParams(EncodeBarcodeType.PDF417, encodeData);
- params.setQrParams(buildQrParams());
- params.setCode128Params(buildCode128Params());
- params.setPdf417Params(buildPdf417Params());
-
- GenerateBodyRequestWrapper request = new GenerateBodyRequestWrapper(params);
- Request httpRequest = api.generateBodyCall(request, null, null).request();
-
- Buffer buffer = new Buffer();
- httpRequest.body().writeTo(buffer);
- String body = buffer.readUtf8();
-
- assertTrue(body.contains("\"qrParams\""));
- assertTrue(body.contains("\"qrEncodeMode\""));
- assertTrue(body.contains("\"Auto\""));
- assertTrue(body.contains("\"code128Params\""));
- assertTrue(body.contains("\"code128EncodeMode\""));
- assertTrue(body.contains("\"CodeB\""));
- assertTrue(body.contains("\"pdf417Params\""));
- assertTrue(body.contains("\"pdf417Columns\""));
- assertTrue(body.contains("\"pdf417Rows\""));
- assertTrue(body.contains("\"pdf417IsCode128Emulation\""));
- }
-
- @Test
- public void testGenerateMultipartCall_ContentTypeMultipart() throws ApiException {
- GenerateMultipartRequestWrapper request =
- new GenerateMultipartRequestWrapper(EncodeBarcodeType.QR, "test");
- Request httpRequest = api.generateMultipartCall(request, null, null).request();
- String contentType = httpRequest.header("Content-Type");
- assertTrue(contentType.contains("multipart/form-data"));
- }
-
- @Test
- public void testGenerateMultipartCall_WithGroupedGenerationParams() throws ApiException {
- GenerateMultipartRequestWrapper request =
- new GenerateMultipartRequestWrapper(EncodeBarcodeType.PDF417, "test");
- request.qrParams = buildQrParams();
- request.code128Params = buildCode128Params();
- request.pdf417Params = buildPdf417Params();
-
- Request httpRequest = api.generateMultipartCall(request, null, null).request();
- assertTrue(httpRequest.body() instanceof MultipartBody);
- MultipartBody body = (MultipartBody) httpRequest.body();
- String partHeaders =
- body.parts().stream()
- .map(part -> part.headers().toString())
- .collect(Collectors.joining("\n"));
-
- assertTrue(partHeaders.contains("name=\"qrEncodeMode\""));
- assertTrue(partHeaders.contains("name=\"qrErrorLevel\""));
- assertTrue(partHeaders.contains("name=\"qrVersion\""));
- assertTrue(partHeaders.contains("name=\"qrECIEncoding\""));
- assertTrue(partHeaders.contains("name=\"qrAspectRatio\""));
- assertTrue(partHeaders.contains("name=\"microQRVersion\""));
- assertTrue(partHeaders.contains("name=\"rectMicroQrVersion\""));
- assertTrue(partHeaders.contains("name=\"code128EncodeMode\""));
- assertTrue(partHeaders.contains("name=\"pdf417EncodeMode\""));
- assertTrue(partHeaders.contains("name=\"pdf417ErrorLevel\""));
- assertTrue(partHeaders.contains("name=\"pdf417Truncate\""));
- assertTrue(partHeaders.contains("name=\"pdf417Columns\""));
- assertTrue(partHeaders.contains("name=\"pdf417Rows\""));
- assertTrue(partHeaders.contains("name=\"pdf417AspectRatio\""));
- assertTrue(partHeaders.contains("name=\"pdf417ECIEncoding\""));
- assertTrue(partHeaders.contains("name=\"pdf417IsReaderInitialization\""));
- assertTrue(partHeaders.contains("name=\"pdf417MacroCharacters\""));
- assertTrue(partHeaders.contains("name=\"pdf417IsLinked\""));
- assertTrue(partHeaders.contains("name=\"pdf417IsCode128Emulation\""));
- }
-
- @Test
- public void testGenerateCall_AuthorizationHeader() throws ApiException {
- GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "test");
- Request httpRequest = api.generateCall(request, null, null).request();
- assertEquals("Bearer " + FAKE_TOKEN, httpRequest.header("Authorization"));
- }
-
- // --- Group E: Edge cases ---
-
- @Test
- public void testGenerateCall_SpecialCharactersInData() throws ApiException {
- GenerateRequestWrapper request =
- new GenerateRequestWrapper(EncodeBarcodeType.QR, "Hello World!@#$%");
- Request httpRequest = api.generateCall(request, null, null).request();
- assertNotNull(httpRequest.url());
- }
-
- @Test
- public void testGenerateCall_EmptyStringData() throws ApiException {
- GenerateRequestWrapper request = new GenerateRequestWrapper(EncodeBarcodeType.QR, "");
- Request httpRequest = api.generateCall(request, null, null).request();
- assertNotNull(httpRequest.url());
- }
-
- // --- Group F: Public method coverage ---
-
- private static final ApiCallback NO_OP_CALLBACK =
- new ApiCallback() {
- @Override
- public void onFailure(
- ApiException e, int statusCode, Map> headers) {}
-
- @Override
- public void onSuccess(
- File result, int statusCode, Map> headers) {}
-
- @Override
- public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {}
-
- @Override
- public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {}
- };
-
- @Test(expected = ApiException.class)
- public void testGenerate_CallsExecute() throws ApiException {
- api.generate(new GenerateRequestWrapper(EncodeBarcodeType.QR, "test"));
- }
-
- @Test(expected = ApiException.class)
- public void testGenerateWithHttpInfo_CallsExecute() throws ApiException {
- api.generateWithHttpInfo(new GenerateRequestWrapper(EncodeBarcodeType.QR, "test"));
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testGenerateAsync_CallsEnqueue() throws ApiException {
- api.generateAsync(new GenerateRequestWrapper(EncodeBarcodeType.QR, "test"), NO_OP_CALLBACK);
- }
-
- @Test(expected = ApiException.class)
- public void testGenerateBody_CallsExecute() throws ApiException {
- EncodeData encodeData = new EncodeData("test");
- GenerateParams params = new GenerateParams(EncodeBarcodeType.QR, encodeData);
- api.generateBody(new GenerateBodyRequestWrapper(params));
- }
-
- @Test(expected = ApiException.class)
- public void testGenerateBodyWithHttpInfo_CallsExecute() throws ApiException {
- EncodeData encodeData = new EncodeData("test");
- GenerateParams params = new GenerateParams(EncodeBarcodeType.QR, encodeData);
- api.generateBodyWithHttpInfo(new GenerateBodyRequestWrapper(params));
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testGenerateBodyAsync_CallsEnqueue() throws ApiException {
- EncodeData encodeData = new EncodeData("test");
- GenerateParams params = new GenerateParams(EncodeBarcodeType.QR, encodeData);
- api.generateBodyAsync(new GenerateBodyRequestWrapper(params), NO_OP_CALLBACK);
- }
-
- @Test(expected = ApiException.class)
- public void testGenerateMultipart_CallsExecute() throws ApiException {
- api.generateMultipart(new GenerateMultipartRequestWrapper(EncodeBarcodeType.QR, "test"));
- }
-
- @Test(expected = ApiException.class)
- public void testGenerateMultipartWithHttpInfo_CallsExecute() throws ApiException {
- api.generateMultipartWithHttpInfo(
- new GenerateMultipartRequestWrapper(EncodeBarcodeType.QR, "test"));
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testGenerateMultipartAsync_CallsEnqueue() throws ApiException {
- api.generateMultipartAsync(
- new GenerateMultipartRequestWrapper(EncodeBarcodeType.QR, "test"), NO_OP_CALLBACK);
- }
-
- private static QrParams buildQrParams() {
- QrParams params = new QrParams();
- params.setQrEncodeMode(QREncodeMode.AUTO);
- params.setQrErrorLevel(QRErrorLevel.LEVEL_M);
- params.setQrVersion(QRVersion.VERSION01);
- params.setQrECIEncoding(ECIEncodings.UTF8);
- params.setQrAspectRatio(0.75f);
- params.setMicroQRVersion(MicroQRVersion.M2);
- params.setRectMicroQrVersion(RectMicroQRVersion.R7X43);
- return params;
- }
-
- private static Code128Params buildCode128Params() {
- Code128Params params = new Code128Params();
- params.setCode128EncodeMode(Code128EncodeMode.CODE_B);
- return params;
- }
-
- private static Pdf417Params buildPdf417Params() {
- Pdf417Params params = new Pdf417Params();
- params.setPdf417EncodeMode(Pdf417EncodeMode.AUTO);
- params.setPdf417ErrorLevel(Pdf417ErrorLevel.LEVEL2);
- params.setPdf417Truncate(true);
- params.setPdf417Columns(3);
- params.setPdf417Rows(9);
- params.setPdf417AspectRatio(3.0f);
- params.setPdf417ECIEncoding(ECIEncodings.UTF8);
- params.setPdf417IsReaderInitialization(false);
- params.setPdf417MacroCharacters(MacroCharacter.MACRO05);
- params.setPdf417IsLinked(false);
- params.setPdf417IsCode128Emulation(false);
- return params;
- }
-}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/GenerateApiValidationUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/GenerateApiValidationUnitTest.java
new file mode 100644
index 0000000..d6d519d
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/GenerateApiValidationUnitTest.java
@@ -0,0 +1,68 @@
+package com.aspose.barcode.cloud.api;
+
+import static org.junit.Assert.*;
+
+import com.aspose.barcode.cloud.ApiException;
+import com.aspose.barcode.cloud.model.EncodeBarcodeType;
+import com.aspose.barcode.cloud.requests.GenerateBodyRequestWrapper;
+import com.aspose.barcode.cloud.requests.GenerateMultipartRequestWrapper;
+import com.aspose.barcode.cloud.requests.GenerateRequestWrapper;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Offline unit tests for {@link GenerateApi} required-parameter validation. */
+public class GenerateApiValidationUnitTest {
+
+ private static GenerateApi api;
+
+ @BeforeClass
+ public static void setUp() {
+ api = GenerateApiTestFixtures.newApi();
+ }
+
+ @Test(expected = ApiException.class)
+ public void testGenerate_NullBarcodeType_ThrowsApiException() throws ApiException {
+ api.generate(new GenerateRequestWrapper(null, "data"));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testGenerate_NullData_ThrowsApiException() throws ApiException {
+ api.generate(new GenerateRequestWrapper(EncodeBarcodeType.QR, null));
+ }
+
+ @Test
+ public void testGenerate_NullBarcodeType_ErrorMessage() {
+ try {
+ api.generate(new GenerateRequestWrapper(null, "data"));
+ fail("Expected ApiException");
+ } catch (ApiException e) {
+ assertTrue(e.getMessage().contains("request.barcodeType"));
+ }
+ }
+
+ @Test
+ public void testGenerate_NullData_ErrorMessage() {
+ try {
+ api.generate(new GenerateRequestWrapper(EncodeBarcodeType.QR, null));
+ fail("Expected ApiException");
+ } catch (ApiException e) {
+ assertTrue(e.getMessage().contains("request.data"));
+ }
+ }
+
+ @Test(expected = ApiException.class)
+ public void testGenerateBody_NullParams_ThrowsApiException() throws ApiException {
+ api.generateBody(new GenerateBodyRequestWrapper(null));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testGenerateMultipart_NullBarcodeType_ThrowsApiException() throws ApiException {
+ api.generateMultipart(new GenerateMultipartRequestWrapper(null, "data"));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testGenerateMultipart_NullData_ThrowsApiException() throws ApiException {
+ api.generateMultipart(new GenerateMultipartRequestWrapper(EncodeBarcodeType.QR, null));
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiMethodCoverageUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiMethodCoverageUnitTest.java
new file mode 100644
index 0000000..12d2fd8
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiMethodCoverageUnitTest.java
@@ -0,0 +1,113 @@
+package com.aspose.barcode.cloud.api;
+
+import com.aspose.barcode.cloud.ApiCallback;
+import com.aspose.barcode.cloud.ApiException;
+import com.aspose.barcode.cloud.model.BarcodeResponseList;
+import com.aspose.barcode.cloud.model.DecodeBarcodeType;
+import com.aspose.barcode.cloud.model.RecognizeBase64Request;
+import com.aspose.barcode.cloud.requests.RecognizeBase64RequestWrapper;
+import com.aspose.barcode.cloud.requests.RecognizeMultipartRequestWrapper;
+import com.aspose.barcode.cloud.requests.RecognizeRequestWrapper;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Offline unit tests covering the public sync, http-info and async {@link RecognizeApi} methods.
+ */
+public class RecognizeApiMethodCoverageUnitTest {
+
+ private static RecognizeApi api;
+
+ @BeforeClass
+ public static void setUp() {
+ api = RecognizeApiTestFixtures.newApi();
+ }
+
+ private static final ApiCallback NO_OP_CALLBACK =
+ new ApiCallback() {
+ @Override
+ public void onFailure(
+ ApiException e, int statusCode, Map> headers) {}
+
+ @Override
+ public void onSuccess(
+ BarcodeResponseList result,
+ int statusCode,
+ Map> headers) {}
+
+ @Override
+ public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {}
+
+ @Override
+ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {}
+ };
+
+ @Test(expected = ApiException.class)
+ public void testRecognize_CallsExecute() throws Exception {
+ api.recognize(
+ new RecognizeRequestWrapper(
+ DecodeBarcodeType.QR, new URI("https://example.com/img.png")));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testRecognizeWithHttpInfo_CallsExecute() throws Exception {
+ api.recognizeWithHttpInfo(
+ new RecognizeRequestWrapper(
+ DecodeBarcodeType.QR, new URI("https://example.com/img.png")));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testRecognizeAsync_CallsEnqueue() throws Exception {
+ api.recognizeAsync(
+ new RecognizeRequestWrapper(
+ DecodeBarcodeType.QR, new URI("https://example.com/img.png")),
+ NO_OP_CALLBACK);
+ }
+
+ @Test(expected = ApiException.class)
+ public void testRecognizeBase64_CallsExecute() throws ApiException {
+ RecognizeBase64Request body =
+ new RecognizeBase64Request(Arrays.asList(DecodeBarcodeType.QR), "dGVzdA==");
+ api.recognizeBase64(new RecognizeBase64RequestWrapper(body));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testRecognizeBase64WithHttpInfo_CallsExecute() throws ApiException {
+ RecognizeBase64Request body =
+ new RecognizeBase64Request(Arrays.asList(DecodeBarcodeType.QR), "dGVzdA==");
+ api.recognizeBase64WithHttpInfo(new RecognizeBase64RequestWrapper(body));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testRecognizeBase64Async_CallsEnqueue() throws ApiException {
+ RecognizeBase64Request body =
+ new RecognizeBase64Request(Arrays.asList(DecodeBarcodeType.QR), "dGVzdA==");
+ api.recognizeBase64Async(new RecognizeBase64RequestWrapper(body), NO_OP_CALLBACK);
+ }
+
+ @Test(expected = ApiException.class)
+ public void testRecognizeMultipart_CallsExecute() throws ApiException {
+ api.recognizeMultipart(
+ new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, new File("dummy.png")));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testRecognizeMultipartWithHttpInfo_CallsExecute() throws ApiException {
+ api.recognizeMultipartWithHttpInfo(
+ new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, new File("dummy.png")));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testRecognizeMultipartAsync_CallsEnqueue() throws ApiException {
+ api.recognizeMultipartAsync(
+ new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, new File("dummy.png")),
+ NO_OP_CALLBACK);
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiRequestUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiRequestUnitTest.java
new file mode 100644
index 0000000..e0440b3
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiRequestUnitTest.java
@@ -0,0 +1,157 @@
+package com.aspose.barcode.cloud.api;
+
+import static org.junit.Assert.*;
+
+import com.aspose.barcode.cloud.ApiException;
+import com.aspose.barcode.cloud.model.DecodeBarcodeType;
+import com.aspose.barcode.cloud.model.RecognitionImageKind;
+import com.aspose.barcode.cloud.model.RecognitionMode;
+import com.aspose.barcode.cloud.model.RecognizeBase64Request;
+import com.aspose.barcode.cloud.requests.RecognizeBase64RequestWrapper;
+import com.aspose.barcode.cloud.requests.RecognizeMultipartRequestWrapper;
+import com.aspose.barcode.cloud.requests.RecognizeRequestWrapper;
+
+import okhttp3.Request;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URI;
+import java.util.Arrays;
+
+/**
+ * Offline unit tests for {@link RecognizeApi} request building: paths, HTTP methods, query
+ * parameters, content types and headers.
+ */
+public class RecognizeApiRequestUnitTest {
+
+ private static RecognizeApi api;
+
+ @BeforeClass
+ public static void setUp() {
+ api = RecognizeApiTestFixtures.newApi();
+ }
+
+ // --- Path construction tests ---
+
+ @Test
+ public void testRecognizeCall_Path() throws Exception {
+ RecognizeRequestWrapper request =
+ new RecognizeRequestWrapper(
+ DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
+ Request httpRequest = api.recognizeCall(request, null, null).request();
+ assertTrue(httpRequest.url().toString().contains("/barcode/recognize"));
+ }
+
+ @Test
+ public void testRecognizeCall_HttpMethodIsGet() throws Exception {
+ RecognizeRequestWrapper request =
+ new RecognizeRequestWrapper(
+ DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
+ Request httpRequest = api.recognizeCall(request, null, null).request();
+ assertEquals("GET", httpRequest.method());
+ }
+
+ @Test
+ public void testRecognizeBase64Call_PathAndMethod() throws ApiException {
+ RecognizeBase64Request body =
+ new RecognizeBase64Request(Arrays.asList(DecodeBarcodeType.QR), "dGVzdA==");
+ RecognizeBase64RequestWrapper request = new RecognizeBase64RequestWrapper(body);
+ Request httpRequest = api.recognizeBase64Call(request, null, null).request();
+ assertTrue(httpRequest.url().toString().contains("/barcode/recognize-body"));
+ assertEquals("POST", httpRequest.method());
+ }
+
+ @Test
+ public void testRecognizeMultipartCall_PathAndMethod() throws ApiException {
+ RecognizeMultipartRequestWrapper request =
+ new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, new File("dummy.png"));
+ Request httpRequest = api.recognizeMultipartCall(request, null, null).request();
+ assertTrue(httpRequest.url().toString().contains("/barcode/recognize-multipart"));
+ assertEquals("POST", httpRequest.method());
+ }
+
+ // --- Query parameter tests ---
+
+ @Test
+ public void testRecognizeCall_QueryContainsBarcodeType() throws Exception {
+ RecognizeRequestWrapper request =
+ new RecognizeRequestWrapper(
+ DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
+ String url = api.recognizeCall(request, null, null).request().url().toString();
+ assertTrue(url.contains("barcodeType="));
+ }
+
+ @Test
+ public void testRecognizeCall_QueryContainsFileUrl() throws Exception {
+ RecognizeRequestWrapper request =
+ new RecognizeRequestWrapper(
+ DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
+ String url = api.recognizeCall(request, null, null).request().url().toString();
+ assertTrue(url.contains("fileUrl="));
+ }
+
+ @Test
+ public void testRecognizeCall_WithOptionalParams() throws Exception {
+ RecognizeRequestWrapper request =
+ new RecognizeRequestWrapper(
+ DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
+ request.recognitionMode = RecognitionMode.FAST;
+ request.recognitionImageKind = RecognitionImageKind.CLEAR_IMAGE;
+ String url = api.recognizeCall(request, null, null).request().url().toString();
+ assertTrue(url.contains("recognitionMode="));
+ assertTrue(url.contains("recognitionImageKind="));
+ }
+
+ @Test
+ public void testRecognizeCall_WithoutOptionalParams() throws Exception {
+ RecognizeRequestWrapper request =
+ new RecognizeRequestWrapper(
+ DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
+ String url = api.recognizeCall(request, null, null).request().url().toString();
+ assertFalse(url.contains("recognitionMode="));
+ assertFalse(url.contains("recognitionImageKind="));
+ }
+
+ // --- Content-Type tests ---
+
+ @Test
+ public void testRecognizeBase64Call_ContentTypeJson() throws ApiException {
+ RecognizeBase64Request body =
+ new RecognizeBase64Request(Arrays.asList(DecodeBarcodeType.QR), "dGVzdA==");
+ RecognizeBase64RequestWrapper request = new RecognizeBase64RequestWrapper(body);
+ Request httpRequest = api.recognizeBase64Call(request, null, null).request();
+ String contentType = httpRequest.header("Content-Type");
+ assertTrue(contentType.contains("application/json"));
+ }
+
+ @Test
+ public void testRecognizeBase64Call_HasBody() throws ApiException {
+ RecognizeBase64Request body =
+ new RecognizeBase64Request(Arrays.asList(DecodeBarcodeType.QR), "dGVzdA==");
+ RecognizeBase64RequestWrapper request = new RecognizeBase64RequestWrapper(body);
+ Request httpRequest = api.recognizeBase64Call(request, null, null).request();
+ assertNotNull(httpRequest.body());
+ }
+
+ @Test
+ public void testRecognizeMultipartCall_ContentTypeMultipart() throws ApiException {
+ RecognizeMultipartRequestWrapper request =
+ new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, new File("dummy.png"));
+ Request httpRequest = api.recognizeMultipartCall(request, null, null).request();
+ String contentType = httpRequest.header("Content-Type");
+ assertTrue(contentType.contains("multipart/form-data"));
+ }
+
+ @Test
+ public void testRecognizeCall_AuthorizationHeader() throws Exception {
+ RecognizeRequestWrapper request =
+ new RecognizeRequestWrapper(
+ DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
+ Request httpRequest = api.recognizeCall(request, null, null).request();
+ assertEquals(
+ "Bearer " + RecognizeApiTestFixtures.FAKE_TOKEN,
+ httpRequest.header("Authorization"));
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiTestFixtures.java b/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiTestFixtures.java
new file mode 100644
index 0000000..afc56c1
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiTestFixtures.java
@@ -0,0 +1,15 @@
+package com.aspose.barcode.cloud.api;
+
+import com.aspose.barcode.cloud.ApiClient;
+
+/** Shared fixtures for the offline {@link RecognizeApi} unit tests. */
+final class RecognizeApiTestFixtures {
+
+ static final String FAKE_TOKEN = "fake-test-token";
+
+ private RecognizeApiTestFixtures() {}
+
+ static RecognizeApi newApi() {
+ return new RecognizeApi(new ApiClient(FAKE_TOKEN));
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiUnitTest.java
deleted file mode 100644
index af203f5..0000000
--- a/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiUnitTest.java
+++ /dev/null
@@ -1,321 +0,0 @@
-package com.aspose.barcode.cloud.api;
-
-import static org.junit.Assert.*;
-
-import com.aspose.barcode.cloud.ApiCallback;
-import com.aspose.barcode.cloud.ApiClient;
-import com.aspose.barcode.cloud.ApiException;
-import com.aspose.barcode.cloud.model.BarcodeResponseList;
-import com.aspose.barcode.cloud.model.DecodeBarcodeType;
-import com.aspose.barcode.cloud.model.RecognitionImageKind;
-import com.aspose.barcode.cloud.model.RecognitionMode;
-import com.aspose.barcode.cloud.model.RecognizeBase64Request;
-import com.aspose.barcode.cloud.requests.RecognizeBase64RequestWrapper;
-import com.aspose.barcode.cloud.requests.RecognizeMultipartRequestWrapper;
-import com.aspose.barcode.cloud.requests.RecognizeRequestWrapper;
-
-import okhttp3.Request;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.File;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-public class RecognizeApiUnitTest {
-
- private static final String FAKE_TOKEN = "fake-test-token";
- private static RecognizeApi api;
-
- @BeforeClass
- public static void setUp() {
- ApiClient apiClient = new ApiClient(FAKE_TOKEN);
- api = new RecognizeApi(apiClient);
- }
-
- // --- Validation tests ---
-
- @Test(expected = ApiException.class)
- public void testRecognize_NullBarcodeType_ThrowsApiException() throws Exception {
- api.recognize(new RecognizeRequestWrapper(null, new URI("https://example.com/img.png")));
- }
-
- @Test(expected = ApiException.class)
- public void testRecognize_NullFileUrl_ThrowsApiException() throws Exception {
- api.recognize(new RecognizeRequestWrapper(DecodeBarcodeType.QR, null));
- }
-
- @Test
- public void testRecognize_NullBarcodeType_ErrorMessage() throws Exception {
- try {
- api.recognize(
- new RecognizeRequestWrapper(null, new URI("https://example.com/img.png")));
- fail("Expected ApiException");
- } catch (ApiException e) {
- assertTrue(e.getMessage().contains("request.barcodeType"));
- }
- }
-
- @Test
- public void testRecognize_NullFileUrl_ErrorMessage() throws Exception {
- try {
- api.recognize(new RecognizeRequestWrapper(DecodeBarcodeType.QR, null));
- fail("Expected ApiException");
- } catch (ApiException e) {
- assertTrue(e.getMessage().contains("request.fileUrl"));
- }
- }
-
- @Test(expected = ApiException.class)
- public void testRecognizeBase64_NullRequest_ThrowsApiException() throws ApiException {
- api.recognizeBase64(new RecognizeBase64RequestWrapper(null));
- }
-
- @Test
- public void testRecognizeBase64_NullRequest_ErrorMessage() {
- try {
- api.recognizeBase64(new RecognizeBase64RequestWrapper(null));
- fail("Expected ApiException");
- } catch (ApiException e) {
- assertTrue(e.getMessage().contains("request.recognizeBase64Request"));
- }
- }
-
- @Test(expected = ApiException.class)
- public void testRecognizeMultipart_NullBarcodeType_ThrowsApiException() throws ApiException {
- api.recognizeMultipart(new RecognizeMultipartRequestWrapper(null, new File("dummy.png")));
- }
-
- @Test(expected = ApiException.class)
- public void testRecognizeMultipart_NullFile_ThrowsApiException() throws ApiException {
- api.recognizeMultipart(new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, null));
- }
-
- @Test
- public void testRecognizeMultipart_NullBarcodeType_ErrorMessage() {
- try {
- api.recognizeMultipart(
- new RecognizeMultipartRequestWrapper(null, new File("dummy.png")));
- fail("Expected ApiException");
- } catch (ApiException e) {
- assertTrue(e.getMessage().contains("request.barcodeType"));
- }
- }
-
- @Test
- public void testRecognizeMultipart_NullFile_ErrorMessage() {
- try {
- api.recognizeMultipart(
- new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, null));
- fail("Expected ApiException");
- } catch (ApiException e) {
- assertTrue(e.getMessage().contains("request.file"));
- }
- }
-
- // --- Path construction tests ---
-
- @Test
- public void testRecognizeCall_Path() throws Exception {
- RecognizeRequestWrapper request =
- new RecognizeRequestWrapper(
- DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
- Request httpRequest = api.recognizeCall(request, null, null).request();
- assertTrue(httpRequest.url().toString().contains("/barcode/recognize"));
- }
-
- @Test
- public void testRecognizeCall_HttpMethodIsGet() throws Exception {
- RecognizeRequestWrapper request =
- new RecognizeRequestWrapper(
- DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
- Request httpRequest = api.recognizeCall(request, null, null).request();
- assertEquals("GET", httpRequest.method());
- }
-
- @Test
- public void testRecognizeBase64Call_PathAndMethod() throws ApiException {
- RecognizeBase64Request body =
- new RecognizeBase64Request(Arrays.asList(DecodeBarcodeType.QR), "dGVzdA==");
- RecognizeBase64RequestWrapper request = new RecognizeBase64RequestWrapper(body);
- Request httpRequest = api.recognizeBase64Call(request, null, null).request();
- assertTrue(httpRequest.url().toString().contains("/barcode/recognize-body"));
- assertEquals("POST", httpRequest.method());
- }
-
- @Test
- public void testRecognizeMultipartCall_PathAndMethod() throws ApiException {
- RecognizeMultipartRequestWrapper request =
- new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, new File("dummy.png"));
- Request httpRequest = api.recognizeMultipartCall(request, null, null).request();
- assertTrue(httpRequest.url().toString().contains("/barcode/recognize-multipart"));
- assertEquals("POST", httpRequest.method());
- }
-
- // --- Query parameter tests ---
-
- @Test
- public void testRecognizeCall_QueryContainsBarcodeType() throws Exception {
- RecognizeRequestWrapper request =
- new RecognizeRequestWrapper(
- DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
- String url = api.recognizeCall(request, null, null).request().url().toString();
- assertTrue(url.contains("barcodeType="));
- }
-
- @Test
- public void testRecognizeCall_QueryContainsFileUrl() throws Exception {
- RecognizeRequestWrapper request =
- new RecognizeRequestWrapper(
- DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
- String url = api.recognizeCall(request, null, null).request().url().toString();
- assertTrue(url.contains("fileUrl="));
- }
-
- @Test
- public void testRecognizeCall_WithOptionalParams() throws Exception {
- RecognizeRequestWrapper request =
- new RecognizeRequestWrapper(
- DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
- request.recognitionMode = RecognitionMode.FAST;
- request.recognitionImageKind = RecognitionImageKind.CLEAR_IMAGE;
- String url = api.recognizeCall(request, null, null).request().url().toString();
- assertTrue(url.contains("recognitionMode="));
- assertTrue(url.contains("recognitionImageKind="));
- }
-
- @Test
- public void testRecognizeCall_WithoutOptionalParams() throws Exception {
- RecognizeRequestWrapper request =
- new RecognizeRequestWrapper(
- DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
- String url = api.recognizeCall(request, null, null).request().url().toString();
- assertFalse(url.contains("recognitionMode="));
- assertFalse(url.contains("recognitionImageKind="));
- }
-
- // --- Content-Type tests ---
-
- @Test
- public void testRecognizeBase64Call_ContentTypeJson() throws ApiException {
- RecognizeBase64Request body =
- new RecognizeBase64Request(Arrays.asList(DecodeBarcodeType.QR), "dGVzdA==");
- RecognizeBase64RequestWrapper request = new RecognizeBase64RequestWrapper(body);
- Request httpRequest = api.recognizeBase64Call(request, null, null).request();
- String contentType = httpRequest.header("Content-Type");
- assertTrue(contentType.contains("application/json"));
- }
-
- @Test
- public void testRecognizeBase64Call_HasBody() throws ApiException {
- RecognizeBase64Request body =
- new RecognizeBase64Request(Arrays.asList(DecodeBarcodeType.QR), "dGVzdA==");
- RecognizeBase64RequestWrapper request = new RecognizeBase64RequestWrapper(body);
- Request httpRequest = api.recognizeBase64Call(request, null, null).request();
- assertNotNull(httpRequest.body());
- }
-
- @Test
- public void testRecognizeMultipartCall_ContentTypeMultipart() throws ApiException {
- RecognizeMultipartRequestWrapper request =
- new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, new File("dummy.png"));
- Request httpRequest = api.recognizeMultipartCall(request, null, null).request();
- String contentType = httpRequest.header("Content-Type");
- assertTrue(contentType.contains("multipart/form-data"));
- }
-
- @Test
- public void testRecognizeCall_AuthorizationHeader() throws Exception {
- RecognizeRequestWrapper request =
- new RecognizeRequestWrapper(
- DecodeBarcodeType.QR, new URI("https://example.com/img.png"));
- Request httpRequest = api.recognizeCall(request, null, null).request();
- assertEquals("Bearer " + FAKE_TOKEN, httpRequest.header("Authorization"));
- }
-
- // --- Public method coverage ---
-
- private static final ApiCallback NO_OP_CALLBACK =
- new ApiCallback() {
- @Override
- public void onFailure(
- ApiException e, int statusCode, Map> headers) {}
-
- @Override
- public void onSuccess(
- BarcodeResponseList result,
- int statusCode,
- Map> headers) {}
-
- @Override
- public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {}
-
- @Override
- public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {}
- };
-
- @Test(expected = ApiException.class)
- public void testRecognize_CallsExecute() throws Exception {
- api.recognize(
- new RecognizeRequestWrapper(
- DecodeBarcodeType.QR, new URI("https://example.com/img.png")));
- }
-
- @Test(expected = ApiException.class)
- public void testRecognizeWithHttpInfo_CallsExecute() throws Exception {
- api.recognizeWithHttpInfo(
- new RecognizeRequestWrapper(
- DecodeBarcodeType.QR, new URI("https://example.com/img.png")));
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testRecognizeAsync_CallsEnqueue() throws Exception {
- api.recognizeAsync(
- new RecognizeRequestWrapper(
- DecodeBarcodeType.QR, new URI("https://example.com/img.png")),
- NO_OP_CALLBACK);
- }
-
- @Test(expected = ApiException.class)
- public void testRecognizeBase64_CallsExecute() throws ApiException {
- RecognizeBase64Request body =
- new RecognizeBase64Request(Arrays.asList(DecodeBarcodeType.QR), "dGVzdA==");
- api.recognizeBase64(new RecognizeBase64RequestWrapper(body));
- }
-
- @Test(expected = ApiException.class)
- public void testRecognizeBase64WithHttpInfo_CallsExecute() throws ApiException {
- RecognizeBase64Request body =
- new RecognizeBase64Request(Arrays.asList(DecodeBarcodeType.QR), "dGVzdA==");
- api.recognizeBase64WithHttpInfo(new RecognizeBase64RequestWrapper(body));
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testRecognizeBase64Async_CallsEnqueue() throws ApiException {
- RecognizeBase64Request body =
- new RecognizeBase64Request(Arrays.asList(DecodeBarcodeType.QR), "dGVzdA==");
- api.recognizeBase64Async(new RecognizeBase64RequestWrapper(body), NO_OP_CALLBACK);
- }
-
- @Test(expected = ApiException.class)
- public void testRecognizeMultipart_CallsExecute() throws ApiException {
- api.recognizeMultipart(
- new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, new File("dummy.png")));
- }
-
- @Test(expected = ApiException.class)
- public void testRecognizeMultipartWithHttpInfo_CallsExecute() throws ApiException {
- api.recognizeMultipartWithHttpInfo(
- new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, new File("dummy.png")));
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testRecognizeMultipartAsync_CallsEnqueue() throws ApiException {
- api.recognizeMultipartAsync(
- new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, new File("dummy.png")),
- NO_OP_CALLBACK);
- }
-}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiValidationUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiValidationUnitTest.java
new file mode 100644
index 0000000..e7af2a9
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/RecognizeApiValidationUnitTest.java
@@ -0,0 +1,104 @@
+package com.aspose.barcode.cloud.api;
+
+import static org.junit.Assert.*;
+
+import com.aspose.barcode.cloud.ApiException;
+import com.aspose.barcode.cloud.model.DecodeBarcodeType;
+import com.aspose.barcode.cloud.requests.RecognizeBase64RequestWrapper;
+import com.aspose.barcode.cloud.requests.RecognizeMultipartRequestWrapper;
+import com.aspose.barcode.cloud.requests.RecognizeRequestWrapper;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URI;
+
+/** Offline unit tests for {@link RecognizeApi} required-parameter validation. */
+public class RecognizeApiValidationUnitTest {
+
+ private static RecognizeApi api;
+
+ @BeforeClass
+ public static void setUp() {
+ api = RecognizeApiTestFixtures.newApi();
+ }
+
+ @Test(expected = ApiException.class)
+ public void testRecognize_NullBarcodeType_ThrowsApiException() throws Exception {
+ api.recognize(new RecognizeRequestWrapper(null, new URI("https://example.com/img.png")));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testRecognize_NullFileUrl_ThrowsApiException() throws Exception {
+ api.recognize(new RecognizeRequestWrapper(DecodeBarcodeType.QR, null));
+ }
+
+ @Test
+ public void testRecognize_NullBarcodeType_ErrorMessage() throws Exception {
+ try {
+ api.recognize(
+ new RecognizeRequestWrapper(null, new URI("https://example.com/img.png")));
+ fail("Expected ApiException");
+ } catch (ApiException e) {
+ assertTrue(e.getMessage().contains("request.barcodeType"));
+ }
+ }
+
+ @Test
+ public void testRecognize_NullFileUrl_ErrorMessage() throws Exception {
+ try {
+ api.recognize(new RecognizeRequestWrapper(DecodeBarcodeType.QR, null));
+ fail("Expected ApiException");
+ } catch (ApiException e) {
+ assertTrue(e.getMessage().contains("request.fileUrl"));
+ }
+ }
+
+ @Test(expected = ApiException.class)
+ public void testRecognizeBase64_NullRequest_ThrowsApiException() throws ApiException {
+ api.recognizeBase64(new RecognizeBase64RequestWrapper(null));
+ }
+
+ @Test
+ public void testRecognizeBase64_NullRequest_ErrorMessage() {
+ try {
+ api.recognizeBase64(new RecognizeBase64RequestWrapper(null));
+ fail("Expected ApiException");
+ } catch (ApiException e) {
+ assertTrue(e.getMessage().contains("request.recognizeBase64Request"));
+ }
+ }
+
+ @Test(expected = ApiException.class)
+ public void testRecognizeMultipart_NullBarcodeType_ThrowsApiException() throws ApiException {
+ api.recognizeMultipart(new RecognizeMultipartRequestWrapper(null, new File("dummy.png")));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testRecognizeMultipart_NullFile_ThrowsApiException() throws ApiException {
+ api.recognizeMultipart(new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, null));
+ }
+
+ @Test
+ public void testRecognizeMultipart_NullBarcodeType_ErrorMessage() {
+ try {
+ api.recognizeMultipart(
+ new RecognizeMultipartRequestWrapper(null, new File("dummy.png")));
+ fail("Expected ApiException");
+ } catch (ApiException e) {
+ assertTrue(e.getMessage().contains("request.barcodeType"));
+ }
+ }
+
+ @Test
+ public void testRecognizeMultipart_NullFile_ErrorMessage() {
+ try {
+ api.recognizeMultipart(
+ new RecognizeMultipartRequestWrapper(DecodeBarcodeType.QR, null));
+ fail("Expected ApiException");
+ } catch (ApiException e) {
+ assertTrue(e.getMessage().contains("request.file"));
+ }
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/ScanApiBodyUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/ScanApiBodyUnitTest.java
new file mode 100644
index 0000000..4b9a4a4
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/ScanApiBodyUnitTest.java
@@ -0,0 +1,52 @@
+package com.aspose.barcode.cloud.api;
+
+import static org.junit.Assert.*;
+
+import com.aspose.barcode.cloud.ApiException;
+import com.aspose.barcode.cloud.model.ScanBase64Request;
+import com.aspose.barcode.cloud.requests.ScanBase64RequestWrapper;
+import com.aspose.barcode.cloud.requests.ScanMultipartRequestWrapper;
+
+import okhttp3.Request;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+
+/** Offline unit tests for {@link ScanApi} request content types and payload presence. */
+public class ScanApiBodyUnitTest {
+
+ private static ScanApi api;
+
+ @BeforeClass
+ public static void setUp() {
+ api = ScanApiTestFixtures.newApi();
+ }
+
+ @Test
+ public void testScanBase64Call_ContentTypeJson() throws ApiException {
+ ScanBase64Request body = new ScanBase64Request("dGVzdA==");
+ ScanBase64RequestWrapper request = new ScanBase64RequestWrapper(body);
+ Request httpRequest = api.scanBase64Call(request, null, null).request();
+ String contentType = httpRequest.header("Content-Type");
+ assertTrue(contentType.contains("application/json"));
+ }
+
+ @Test
+ public void testScanBase64Call_HasBody() throws ApiException {
+ ScanBase64Request body = new ScanBase64Request("dGVzdA==");
+ ScanBase64RequestWrapper request = new ScanBase64RequestWrapper(body);
+ Request httpRequest = api.scanBase64Call(request, null, null).request();
+ assertNotNull(httpRequest.body());
+ }
+
+ @Test
+ public void testScanMultipartCall_ContentTypeMultipart() throws ApiException {
+ ScanMultipartRequestWrapper request =
+ new ScanMultipartRequestWrapper(new File("dummy.png"));
+ Request httpRequest = api.scanMultipartCall(request, null, null).request();
+ String contentType = httpRequest.header("Content-Type");
+ assertTrue(contentType.contains("multipart/form-data"));
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/ScanApiMethodCoverageUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/ScanApiMethodCoverageUnitTest.java
new file mode 100644
index 0000000..8ddd1d9
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/ScanApiMethodCoverageUnitTest.java
@@ -0,0 +1,95 @@
+package com.aspose.barcode.cloud.api;
+
+import com.aspose.barcode.cloud.ApiCallback;
+import com.aspose.barcode.cloud.ApiException;
+import com.aspose.barcode.cloud.model.BarcodeResponseList;
+import com.aspose.barcode.cloud.model.ScanBase64Request;
+import com.aspose.barcode.cloud.requests.ScanBase64RequestWrapper;
+import com.aspose.barcode.cloud.requests.ScanMultipartRequestWrapper;
+import com.aspose.barcode.cloud.requests.ScanRequestWrapper;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+/** Offline unit tests covering the public sync, http-info and async {@link ScanApi} methods. */
+public class ScanApiMethodCoverageUnitTest {
+
+ private static ScanApi api;
+
+ @BeforeClass
+ public static void setUp() {
+ api = ScanApiTestFixtures.newApi();
+ }
+
+ private static final ApiCallback NO_OP_CALLBACK =
+ new ApiCallback() {
+ @Override
+ public void onFailure(
+ ApiException e, int statusCode, Map> headers) {}
+
+ @Override
+ public void onSuccess(
+ BarcodeResponseList result,
+ int statusCode,
+ Map> headers) {}
+
+ @Override
+ public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {}
+
+ @Override
+ public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {}
+ };
+
+ @Test(expected = ApiException.class)
+ public void testScan_CallsExecute() throws Exception {
+ api.scan(new ScanRequestWrapper(new URI("https://example.com/img.png")));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testScanWithHttpInfo_CallsExecute() throws Exception {
+ api.scanWithHttpInfo(new ScanRequestWrapper(new URI("https://example.com/img.png")));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testScanAsync_CallsEnqueue() throws Exception {
+ api.scanAsync(
+ new ScanRequestWrapper(new URI("https://example.com/img.png")), NO_OP_CALLBACK);
+ }
+
+ @Test(expected = ApiException.class)
+ public void testScanBase64_CallsExecute() throws ApiException {
+ api.scanBase64(new ScanBase64RequestWrapper(new ScanBase64Request("dGVzdA==")));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testScanBase64WithHttpInfo_CallsExecute() throws ApiException {
+ api.scanBase64WithHttpInfo(new ScanBase64RequestWrapper(new ScanBase64Request("dGVzdA==")));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testScanBase64Async_CallsEnqueue() throws ApiException {
+ api.scanBase64Async(
+ new ScanBase64RequestWrapper(new ScanBase64Request("dGVzdA==")), NO_OP_CALLBACK);
+ }
+
+ @Test(expected = ApiException.class)
+ public void testScanMultipart_CallsExecute() throws ApiException {
+ api.scanMultipart(new ScanMultipartRequestWrapper(new File("dummy.png")));
+ }
+
+ @Test(expected = ApiException.class)
+ public void testScanMultipartWithHttpInfo_CallsExecute() throws ApiException {
+ api.scanMultipartWithHttpInfo(new ScanMultipartRequestWrapper(new File("dummy.png")));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testScanMultipartAsync_CallsEnqueue() throws ApiException {
+ api.scanMultipartAsync(
+ new ScanMultipartRequestWrapper(new File("dummy.png")), NO_OP_CALLBACK);
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/ScanApiRequestUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/ScanApiRequestUnitTest.java
new file mode 100644
index 0000000..7c812f2
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/ScanApiRequestUnitTest.java
@@ -0,0 +1,84 @@
+package com.aspose.barcode.cloud.api;
+
+import static org.junit.Assert.*;
+
+import com.aspose.barcode.cloud.ApiException;
+import com.aspose.barcode.cloud.model.ScanBase64Request;
+import com.aspose.barcode.cloud.requests.ScanBase64RequestWrapper;
+import com.aspose.barcode.cloud.requests.ScanMultipartRequestWrapper;
+import com.aspose.barcode.cloud.requests.ScanRequestWrapper;
+
+import okhttp3.Request;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URI;
+
+/**
+ * Offline unit tests for {@link ScanApi} request building: paths, HTTP methods, query parameters
+ * and headers.
+ */
+public class ScanApiRequestUnitTest {
+
+ private static ScanApi api;
+
+ @BeforeClass
+ public static void setUp() {
+ api = ScanApiTestFixtures.newApi();
+ }
+
+ // --- Path construction tests ---
+
+ @Test
+ public void testScanCall_Path() throws Exception {
+ ScanRequestWrapper request = new ScanRequestWrapper(new URI("https://example.com/img.png"));
+ Request httpRequest = api.scanCall(request, null, null).request();
+ assertTrue(httpRequest.url().toString().contains("/barcode/scan"));
+ }
+
+ @Test
+ public void testScanCall_HttpMethodIsGet() throws Exception {
+ ScanRequestWrapper request = new ScanRequestWrapper(new URI("https://example.com/img.png"));
+ Request httpRequest = api.scanCall(request, null, null).request();
+ assertEquals("GET", httpRequest.method());
+ }
+
+ @Test
+ public void testScanBase64Call_PathAndMethod() throws ApiException {
+ ScanBase64Request body = new ScanBase64Request("dGVzdA==");
+ ScanBase64RequestWrapper request = new ScanBase64RequestWrapper(body);
+ Request httpRequest = api.scanBase64Call(request, null, null).request();
+ assertTrue(httpRequest.url().toString().contains("/barcode/scan-body"));
+ assertEquals("POST", httpRequest.method());
+ }
+
+ @Test
+ public void testScanMultipartCall_PathAndMethod() throws ApiException {
+ ScanMultipartRequestWrapper request =
+ new ScanMultipartRequestWrapper(new File("dummy.png"));
+ Request httpRequest = api.scanMultipartCall(request, null, null).request();
+ assertTrue(httpRequest.url().toString().contains("/barcode/scan-multipart"));
+ assertEquals("POST", httpRequest.method());
+ }
+
+ // --- Query parameter tests ---
+
+ @Test
+ public void testScanCall_QueryContainsFileUrl() throws Exception {
+ ScanRequestWrapper request = new ScanRequestWrapper(new URI("https://example.com/img.png"));
+ String url = api.scanCall(request, null, null).request().url().toString();
+ assertTrue(url.contains("fileUrl="));
+ }
+
+ // --- Header tests ---
+
+ @Test
+ public void testScanCall_AuthorizationHeader() throws Exception {
+ ScanRequestWrapper request = new ScanRequestWrapper(new URI("https://example.com/img.png"));
+ Request httpRequest = api.scanCall(request, null, null).request();
+ assertEquals(
+ "Bearer " + ScanApiTestFixtures.FAKE_TOKEN, httpRequest.header("Authorization"));
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/ScanApiTestFixtures.java b/src/test/java/com/aspose/barcode/cloud/api/ScanApiTestFixtures.java
new file mode 100644
index 0000000..42050a0
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/ScanApiTestFixtures.java
@@ -0,0 +1,15 @@
+package com.aspose.barcode.cloud.api;
+
+import com.aspose.barcode.cloud.ApiClient;
+
+/** Shared fixtures for the offline {@link ScanApi} unit tests. */
+final class ScanApiTestFixtures {
+
+ static final String FAKE_TOKEN = "fake-test-token";
+
+ private ScanApiTestFixtures() {}
+
+ static ScanApi newApi() {
+ return new ScanApi(new ApiClient(FAKE_TOKEN));
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/ScanApiUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/ScanApiUnitTest.java
deleted file mode 100644
index e67a6ba..0000000
--- a/src/test/java/com/aspose/barcode/cloud/api/ScanApiUnitTest.java
+++ /dev/null
@@ -1,228 +0,0 @@
-package com.aspose.barcode.cloud.api;
-
-import static org.junit.Assert.*;
-
-import com.aspose.barcode.cloud.ApiCallback;
-import com.aspose.barcode.cloud.ApiClient;
-import com.aspose.barcode.cloud.ApiException;
-import com.aspose.barcode.cloud.model.BarcodeResponseList;
-import com.aspose.barcode.cloud.model.ScanBase64Request;
-import com.aspose.barcode.cloud.requests.ScanBase64RequestWrapper;
-import com.aspose.barcode.cloud.requests.ScanMultipartRequestWrapper;
-import com.aspose.barcode.cloud.requests.ScanRequestWrapper;
-
-import okhttp3.Request;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.File;
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
-public class ScanApiUnitTest {
-
- private static final String FAKE_TOKEN = "fake-test-token";
- private static ScanApi api;
-
- @BeforeClass
- public static void setUp() {
- ApiClient apiClient = new ApiClient(FAKE_TOKEN);
- api = new ScanApi(apiClient);
- }
-
- // --- Validation tests ---
-
- @Test(expected = ApiException.class)
- public void testScan_NullFileUrl_ThrowsApiException() throws Exception {
- api.scan(new ScanRequestWrapper(null));
- }
-
- @Test
- public void testScan_NullFileUrl_ErrorMessage() throws Exception {
- try {
- api.scan(new ScanRequestWrapper(null));
- fail("Expected ApiException");
- } catch (ApiException e) {
- assertTrue(e.getMessage().contains("request.fileUrl"));
- }
- }
-
- @Test(expected = ApiException.class)
- public void testScanBase64_NullRequest_ThrowsApiException() throws ApiException {
- api.scanBase64(new ScanBase64RequestWrapper(null));
- }
-
- @Test
- public void testScanBase64_NullRequest_ErrorMessage() {
- try {
- api.scanBase64(new ScanBase64RequestWrapper(null));
- fail("Expected ApiException");
- } catch (ApiException e) {
- assertTrue(e.getMessage().contains("request.scanBase64Request"));
- }
- }
-
- @Test(expected = ApiException.class)
- public void testScanMultipart_NullFile_ThrowsApiException() throws ApiException {
- api.scanMultipart(new ScanMultipartRequestWrapper(null));
- }
-
- @Test
- public void testScanMultipart_NullFile_ErrorMessage() {
- try {
- api.scanMultipart(new ScanMultipartRequestWrapper(null));
- fail("Expected ApiException");
- } catch (ApiException e) {
- assertTrue(e.getMessage().contains("request.file"));
- }
- }
-
- // --- Path construction tests ---
-
- @Test
- public void testScanCall_Path() throws Exception {
- ScanRequestWrapper request = new ScanRequestWrapper(new URI("https://example.com/img.png"));
- Request httpRequest = api.scanCall(request, null, null).request();
- assertTrue(httpRequest.url().toString().contains("/barcode/scan"));
- }
-
- @Test
- public void testScanCall_HttpMethodIsGet() throws Exception {
- ScanRequestWrapper request = new ScanRequestWrapper(new URI("https://example.com/img.png"));
- Request httpRequest = api.scanCall(request, null, null).request();
- assertEquals("GET", httpRequest.method());
- }
-
- @Test
- public void testScanBase64Call_PathAndMethod() throws ApiException {
- ScanBase64Request body = new ScanBase64Request("dGVzdA==");
- ScanBase64RequestWrapper request = new ScanBase64RequestWrapper(body);
- Request httpRequest = api.scanBase64Call(request, null, null).request();
- assertTrue(httpRequest.url().toString().contains("/barcode/scan-body"));
- assertEquals("POST", httpRequest.method());
- }
-
- @Test
- public void testScanMultipartCall_PathAndMethod() throws ApiException {
- ScanMultipartRequestWrapper request =
- new ScanMultipartRequestWrapper(new File("dummy.png"));
- Request httpRequest = api.scanMultipartCall(request, null, null).request();
- assertTrue(httpRequest.url().toString().contains("/barcode/scan-multipart"));
- assertEquals("POST", httpRequest.method());
- }
-
- // --- Query parameter tests ---
-
- @Test
- public void testScanCall_QueryContainsFileUrl() throws Exception {
- ScanRequestWrapper request = new ScanRequestWrapper(new URI("https://example.com/img.png"));
- String url = api.scanCall(request, null, null).request().url().toString();
- assertTrue(url.contains("fileUrl="));
- }
-
- // --- Content-Type tests ---
-
- @Test
- public void testScanBase64Call_ContentTypeJson() throws ApiException {
- ScanBase64Request body = new ScanBase64Request("dGVzdA==");
- ScanBase64RequestWrapper request = new ScanBase64RequestWrapper(body);
- Request httpRequest = api.scanBase64Call(request, null, null).request();
- String contentType = httpRequest.header("Content-Type");
- assertTrue(contentType.contains("application/json"));
- }
-
- @Test
- public void testScanBase64Call_HasBody() throws ApiException {
- ScanBase64Request body = new ScanBase64Request("dGVzdA==");
- ScanBase64RequestWrapper request = new ScanBase64RequestWrapper(body);
- Request httpRequest = api.scanBase64Call(request, null, null).request();
- assertNotNull(httpRequest.body());
- }
-
- @Test
- public void testScanMultipartCall_ContentTypeMultipart() throws ApiException {
- ScanMultipartRequestWrapper request =
- new ScanMultipartRequestWrapper(new File("dummy.png"));
- Request httpRequest = api.scanMultipartCall(request, null, null).request();
- String contentType = httpRequest.header("Content-Type");
- assertTrue(contentType.contains("multipart/form-data"));
- }
-
- @Test
- public void testScanCall_AuthorizationHeader() throws Exception {
- ScanRequestWrapper request = new ScanRequestWrapper(new URI("https://example.com/img.png"));
- Request httpRequest = api.scanCall(request, null, null).request();
- assertEquals("Bearer " + FAKE_TOKEN, httpRequest.header("Authorization"));
- }
-
- // --- Public method coverage ---
-
- private static final ApiCallback NO_OP_CALLBACK =
- new ApiCallback() {
- @Override
- public void onFailure(
- ApiException e, int statusCode, Map> headers) {}
-
- @Override
- public void onSuccess(
- BarcodeResponseList result,
- int statusCode,
- Map> headers) {}
-
- @Override
- public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {}
-
- @Override
- public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {}
- };
-
- @Test(expected = ApiException.class)
- public void testScan_CallsExecute() throws Exception {
- api.scan(new ScanRequestWrapper(new URI("https://example.com/img.png")));
- }
-
- @Test(expected = ApiException.class)
- public void testScanWithHttpInfo_CallsExecute() throws Exception {
- api.scanWithHttpInfo(new ScanRequestWrapper(new URI("https://example.com/img.png")));
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testScanAsync_CallsEnqueue() throws Exception {
- api.scanAsync(
- new ScanRequestWrapper(new URI("https://example.com/img.png")), NO_OP_CALLBACK);
- }
-
- @Test(expected = ApiException.class)
- public void testScanBase64_CallsExecute() throws ApiException {
- api.scanBase64(new ScanBase64RequestWrapper(new ScanBase64Request("dGVzdA==")));
- }
-
- @Test(expected = ApiException.class)
- public void testScanBase64WithHttpInfo_CallsExecute() throws ApiException {
- api.scanBase64WithHttpInfo(new ScanBase64RequestWrapper(new ScanBase64Request("dGVzdA==")));
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testScanBase64Async_CallsEnqueue() throws ApiException {
- api.scanBase64Async(
- new ScanBase64RequestWrapper(new ScanBase64Request("dGVzdA==")), NO_OP_CALLBACK);
- }
-
- @Test(expected = ApiException.class)
- public void testScanMultipart_CallsExecute() throws ApiException {
- api.scanMultipart(new ScanMultipartRequestWrapper(new File("dummy.png")));
- }
-
- @Test(expected = ApiException.class)
- public void testScanMultipartWithHttpInfo_CallsExecute() throws ApiException {
- api.scanMultipartWithHttpInfo(new ScanMultipartRequestWrapper(new File("dummy.png")));
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testScanMultipartAsync_CallsEnqueue() throws ApiException {
- api.scanMultipartAsync(
- new ScanMultipartRequestWrapper(new File("dummy.png")), NO_OP_CALLBACK);
- }
-}
diff --git a/src/test/java/com/aspose/barcode/cloud/api/ScanApiValidationUnitTest.java b/src/test/java/com/aspose/barcode/cloud/api/ScanApiValidationUnitTest.java
new file mode 100644
index 0000000..849953b
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/api/ScanApiValidationUnitTest.java
@@ -0,0 +1,67 @@
+package com.aspose.barcode.cloud.api;
+
+import static org.junit.Assert.*;
+
+import com.aspose.barcode.cloud.ApiException;
+import com.aspose.barcode.cloud.requests.ScanBase64RequestWrapper;
+import com.aspose.barcode.cloud.requests.ScanMultipartRequestWrapper;
+import com.aspose.barcode.cloud.requests.ScanRequestWrapper;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Offline unit tests for {@link ScanApi} required-parameter validation. */
+public class ScanApiValidationUnitTest {
+
+ private static ScanApi api;
+
+ @BeforeClass
+ public static void setUp() {
+ api = ScanApiTestFixtures.newApi();
+ }
+
+ @Test(expected = ApiException.class)
+ public void testScan_NullFileUrl_ThrowsApiException() throws Exception {
+ api.scan(new ScanRequestWrapper(null));
+ }
+
+ @Test
+ public void testScan_NullFileUrl_ErrorMessage() throws Exception {
+ try {
+ api.scan(new ScanRequestWrapper(null));
+ fail("Expected ApiException");
+ } catch (ApiException e) {
+ assertTrue(e.getMessage().contains("request.fileUrl"));
+ }
+ }
+
+ @Test(expected = ApiException.class)
+ public void testScanBase64_NullRequest_ThrowsApiException() throws ApiException {
+ api.scanBase64(new ScanBase64RequestWrapper(null));
+ }
+
+ @Test
+ public void testScanBase64_NullRequest_ErrorMessage() {
+ try {
+ api.scanBase64(new ScanBase64RequestWrapper(null));
+ fail("Expected ApiException");
+ } catch (ApiException e) {
+ assertTrue(e.getMessage().contains("request.scanBase64Request"));
+ }
+ }
+
+ @Test(expected = ApiException.class)
+ public void testScanMultipart_NullFile_ThrowsApiException() throws ApiException {
+ api.scanMultipart(new ScanMultipartRequestWrapper(null));
+ }
+
+ @Test
+ public void testScanMultipart_NullFile_ErrorMessage() {
+ try {
+ api.scanMultipart(new ScanMultipartRequestWrapper(null));
+ fail("Expected ApiException");
+ } catch (ApiException e) {
+ assertTrue(e.getMessage().contains("request.file"));
+ }
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/model/GeneratedEnumCoverageTest.java b/src/test/java/com/aspose/barcode/cloud/model/GeneratedEnumCoverageTest.java
new file mode 100644
index 0000000..981ab32
--- /dev/null
+++ b/src/test/java/com/aspose/barcode/cloud/model/GeneratedEnumCoverageTest.java
@@ -0,0 +1,59 @@
+package com.aspose.barcode.cloud.model;
+
+import static org.junit.Assert.*;
+
+import com.google.gson.Gson;
+
+import org.junit.Test;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Coverage for the generated enum types: every constant must round-trip through the generated
+ * {@code getValue}/{@code fromValue} factories and through Gson serialization/deserialization.
+ */
+public class GeneratedEnumCoverageTest {
+ private static final Gson GSON = new Gson();
+
+ private static final List>> ENUM_TYPES =
+ Arrays.asList(
+ BarcodeImageFormat.class,
+ Code128EncodeMode.class,
+ CodeLocation.class,
+ DecodeBarcodeType.class,
+ ECIEncodings.class,
+ EncodeBarcodeType.class,
+ EncodeDataType.class,
+ GraphicsUnit.class,
+ MacroCharacter.class,
+ MicroQRVersion.class,
+ Pdf417EncodeMode.class,
+ Pdf417ErrorLevel.class,
+ QREncodeMode.class,
+ QRErrorLevel.class,
+ QRVersion.class,
+ RecognitionImageKind.class,
+ RecognitionMode.class,
+ RectMicroQRVersion.class);
+
+ @Test
+ public void enumValuesRoundTripThroughFactoriesAndJsonAdapters() throws Exception {
+ for (Class extends Enum>> enumType : ENUM_TYPES) {
+ Method getValue = enumType.getMethod("getValue");
+ Method fromValue = enumType.getMethod("fromValue", String.class);
+
+ for (Enum> enumValue : enumType.getEnumConstants()) {
+ String wireValue = (String) getValue.invoke(enumValue);
+
+ assertEquals(wireValue, enumValue.toString());
+ assertSame(enumValue, fromValue.invoke(null, wireValue));
+ assertEquals("\"" + wireValue + "\"", GSON.toJson(enumValue));
+ assertSame(enumValue, GSON.fromJson("\"" + wireValue + "\"", enumType));
+ }
+
+ assertNull(fromValue.invoke(null, "__missing_value__"));
+ }
+ }
+}
diff --git a/src/test/java/com/aspose/barcode/cloud/model/GeneratedModelCoverageTest.java b/src/test/java/com/aspose/barcode/cloud/model/GeneratedModelCoverageTest.java
index 65e8ec9..be17463 100644
--- a/src/test/java/com/aspose/barcode/cloud/model/GeneratedModelCoverageTest.java
+++ b/src/test/java/com/aspose/barcode/cloud/model/GeneratedModelCoverageTest.java
@@ -2,41 +2,19 @@
import static org.junit.Assert.*;
-import com.google.gson.Gson;
-
import org.junit.Test;
import java.lang.reflect.Method;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.Collections;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
+/**
+ * Coverage for the generated model classes: every model must behave as a value object
+ * (equals/hashCode/toString) and expose non-null accessors for populated fields.
+ */
public class GeneratedModelCoverageTest {
- private static final Gson GSON = new Gson();
-
- private static final List>> ENUM_TYPES =
- Arrays.asList(
- BarcodeImageFormat.class,
- Code128EncodeMode.class,
- CodeLocation.class,
- DecodeBarcodeType.class,
- ECIEncodings.class,
- EncodeBarcodeType.class,
- EncodeDataType.class,
- GraphicsUnit.class,
- MacroCharacter.class,
- MicroQRVersion.class,
- Pdf417EncodeMode.class,
- Pdf417ErrorLevel.class,
- QREncodeMode.class,
- QRErrorLevel.class,
- QRVersion.class,
- RecognitionImageKind.class,
- RecognitionMode.class,
- RectMicroQRVersion.class);
private static final List> MODEL_TYPES =
Arrays.asList(
@@ -54,25 +32,6 @@ public class GeneratedModelCoverageTest {
RegionPoint.class,
ScanBase64Request.class);
- @Test
- public void enumValuesRoundTripThroughFactoriesAndJsonAdapters() throws Exception {
- for (Class extends Enum>> enumType : ENUM_TYPES) {
- Method getValue = enumType.getMethod("getValue");
- Method fromValue = enumType.getMethod("fromValue", String.class);
-
- for (Enum> enumValue : enumType.getEnumConstants()) {
- String wireValue = (String) getValue.invoke(enumValue);
-
- assertEquals(wireValue, enumValue.toString());
- assertSame(enumValue, fromValue.invoke(null, wireValue));
- assertEquals("\"" + wireValue + "\"", GSON.toJson(enumValue));
- assertSame(enumValue, GSON.fromJson("\"" + wireValue + "\"", enumType));
- }
-
- assertNull(fromValue.invoke(null, "__missing_value__"));
- }
- }
-
@Test
public void generatedModelsExposeValueObjectBehavior() throws Exception {
for (Class> modelType : MODEL_TYPES) {
@@ -98,33 +57,6 @@ public void generatedModelsExposeValueObjectBehavior() throws Exception {
}
}
- @Test
- public void abstractOpenApiSchemaHandlesNestedInstances() {
- TestOpenApiSchema outer = new TestOpenApiSchema("oneOf", true);
- TestOpenApiSchema same = new TestOpenApiSchema("oneOf", true);
- TestOpenApiSchema inner = new TestOpenApiSchema("anyOf", false);
- inner.setActualInstance("leaf");
- outer.setActualInstance(inner);
- same.setActualInstance(inner);
-
- assertEquals(Collections.singletonMap("string", String.class), outer.getSchemas());
- assertSame(inner, outer.getActualInstance());
- assertEquals("leaf", outer.getActualInstanceRecursively());
- assertEquals("oneOf", outer.getSchemaType());
- assertTrue(outer.isNullable());
- assertFalse(inner.isNullable());
- assertEquals(outer, same);
- assertEquals(outer.hashCode(), same.hashCode());
- assertNotEquals(outer, inner);
- assertNotEquals(outer, null);
- assertNotEquals(outer, "not a schema");
- assertTrue(outer.toString().contains("oneOf"));
-
- TestOpenApiSchema empty = new TestOpenApiSchema("oneOf", null);
- assertNull(empty.getActualInstanceRecursively());
- assertFalse(empty.isNullable());
- }
-
private static boolean isValueAccessor(Method method) {
if (method.getParameterCount() != 0 || method.getDeclaringClass().equals(Object.class)) {
return false;
@@ -274,17 +206,4 @@ private static RegionPoint regionPoint(int variant) {
point.setY(20 + variant);
return point;
}
-
- private static class TestOpenApiSchema extends AbstractOpenApiSchema {
- TestOpenApiSchema(String schemaType, Boolean isNullable) {
- super(schemaType, isNullable);
- }
-
- @Override
- public Map> getSchemas() {
- Map> schemas = new LinkedHashMap<>();
- schemas.put("string", String.class);
- return schemas;
- }
- }
}