(Response response, ErrorBody errorBody) { }
diff --git a/src/main/java/api_assured/ServiceGenerator.java b/src/main/java/api_assured/ServiceGenerator.java
deleted file mode 100644
index f888c26..0000000
--- a/src/main/java/api_assured/ServiceGenerator.java
+++ /dev/null
@@ -1,512 +0,0 @@
-package api_assured;
-
-import context.ContextStore;
-import okhttp3.Headers;
-import okhttp3.OkHttpClient;
-import okhttp3.Request;
-import okhttp3.logging.HttpLoggingInterceptor;
-import okio.Buffer;
-import retrofit2.Retrofit;
-import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
-import retrofit2.converter.gson.GsonConverterFactory;
-import retrofit2.converter.jackson.JacksonConverterFactory;
-import retrofit2.converter.moshi.MoshiConverterFactory;
-import retrofit2.converter.protobuf.ProtoConverterFactory;
-import retrofit2.converter.scalars.ScalarsConverterFactory;
-import retrofit2.converter.simplexml.SimpleXmlConverterFactory;
-import retrofit2.converter.wire.WireConverterFactory;
-import utils.*;
-import utils.reflection.ReflectionUtilities;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-import java.util.Objects;
-import java.util.concurrent.TimeUnit;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static utils.mapping.MappingUtilities.Json.getJsonString;
-import static utils.mapping.MappingUtilities.Json.mapper;
-
-/**
- * The ServiceGenerator class is responsible for generating Retrofit Service based on the provided service class
- * and configurations. It also provides methods to set and get different configurations like headers, timeouts,
- * and base URL.
- *
- * @author Umut Ay Bora
- * @version 1.4.0 (Documented in 1.4.0, released in version 1.0.0)
- */
-@SuppressWarnings({"unused", "UnusedReturnValue"})
-@Deprecated(since = "1.7.4")
-public class ServiceGenerator {
-
- OkHttpClient client;
-
- /**
- * The header object containing the headers to be added to the requests.
- */
- Headers headers = new Headers.Builder().build();
-
- /**
- * A boolean indicating whether to log the headers in the requests.
- */
- boolean printHeaders = Boolean.parseBoolean(ContextStore.get("log-headers", "true"));
-
- /**
- * A boolean indicating whether to log detailed information in the requests.
- */
- boolean detailedLogging = Boolean.parseBoolean(ContextStore.get("detailed-logging", "false"));
-
- /**
- * A boolean indicating whether to verify the hostname in the requests.
- */
- boolean hostnameVerification = Boolean.parseBoolean(ContextStore.get("verify-hostname", "true"));
-
- /**
- * A boolean indicating whether to print request body in the outgoing requests.
- */
- boolean printRequestBody = Boolean.parseBoolean(ContextStore.get("print-request-body", "false"));
-
- /**
- * Connection timeout in seconds.
- */
- int connectionTimeout = Integer.parseInt(ContextStore.get("connection-timeout", "60"));
-
- /**
- * Read timeout in seconds.
- */
- int readTimeout = Integer.parseInt(ContextStore.get("connection-read-timeout", "30"));
-
- /**
- * Write timeout in seconds.
- */
- int writeTimeout = Integer.parseInt(ContextStore.get("connection-write-timeout", "30"));
-
- /**
- * Proxy host. (default: null)
- */
- String proxyHost = ContextStore.get("proxy-host", null);
-
- /**
- * Proxy port (default: 8888)
- */
- int proxyPort = Integer.parseInt(ContextStore.get("proxy-port", "8888"));
-
- /**
- * Follow redirects?
- */
- boolean followRedirects = Boolean.parseBoolean(ContextStore.get("request-follows-redirects", "false"));
-
- /**
- * Use proxy?
- */
- boolean useProxy = proxyHost != null;
-
- /**
- * The base URL for the service.
- */
- String BASE_URL = "";
-
- /**
- * The logger object for logging information.
- */
- private static final Printer log = new Printer(ServiceGenerator.class);
-
- /**
- * Constructor for the ServiceGenerator class with headers and base URL.
- *
- * @param headers The headers to be added to the requests.
- * @param BASE_URL The base URL for the service.
- */ // TODO: Constructor should reference each other
- public ServiceGenerator(Headers headers, String BASE_URL) {
- this(BASE_URL);
- setHeaders(headers);
- }
-
- /**
- * Constructor for the ServiceGenerator class with headers.
- *
- * @param headers The headers to be added to the requests.
- */
- public ServiceGenerator(Headers headers) {setHeaders(headers);}
-
- /**
- * Constructor for the ServiceGenerator class with base URL.
- *
- * @param BASE_URL The base URL for the service.
- */
- public ServiceGenerator(String BASE_URL) {this.BASE_URL = BASE_URL;}
-
- /**
- * Default constructor for the ServiceGenerator class.
- */
- public ServiceGenerator(){}
-
- /**
- * Creates Retrofit Service based on the provided service class and configurations.
- *
- * @param serviceClass The service class (api data store) to be used when creating Retrofit Service.
- * @return The created Retrofit Service.
- */
- public static S generate(
- Class serviceClass,
- String BASE_URL,
- boolean detailedLogging,
- int connectionTimeout,
- int readTimeout,
- int writeTimeout,
- Headers headers,
- boolean printRequestBody,
- boolean printHeaders,
- boolean hostnameVerification,
- String proxyHost
- ) {
- return new ServiceGenerator(headers, BASE_URL)
- .setRequestLogging(printRequestBody)
- .hostnameVerification(hostnameVerification)
- .detailedLogging(detailedLogging)
- .setPoxyHost(proxyHost)
- .printHeaders(printHeaders)
- .setReadTimeout(readTimeout)
- .setWriteTimeout(writeTimeout)
- .setConnectionTimeout(connectionTimeout)
- .generate(serviceClass);
- }
-
- /**
- * Creates Retrofit Service based on the provided service class and configurations.
- *
- * @param serviceClass The service class (api data store) to be used when creating Retrofit Service.
- * @return The created Retrofit Service.
- */
- public static S generate(Class serviceClass, String BASE_URL) {
- return new ServiceGenerator(BASE_URL).generate(serviceClass);
- }
-
- /**
- * Creates Retrofit Service based on the provided service class and configurations.
- *
- * @param serviceClass The service class (api data store) to be used when creating Retrofit Service.
- * @return The created Retrofit Service.
- */
- public S generate(Class serviceClass) {
-
- if (BASE_URL.isEmpty()) BASE_URL = (String) ReflectionUtilities.getFieldValue("BASE_URL", serviceClass);
-
- client = client == null ? getDefaultHttpClient() : client;
-
- assert BASE_URL != null;
- @SuppressWarnings("deprecation")
- Retrofit retrofit = new Retrofit.Builder()
- .baseUrl(BASE_URL)
- .addConverterFactory(JacksonConverterFactory.create(mapper))
- .addConverterFactory(GsonConverterFactory.create())
- .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
- .addConverterFactory(ScalarsConverterFactory.create())
- .addConverterFactory(SimpleXmlConverterFactory.create()) //Deprecated
- .addConverterFactory(MoshiConverterFactory.create())
- .addConverterFactory(WireConverterFactory.create())
- .addConverterFactory(ProtoConverterFactory.create())
- .client(client)
- .build();
- return retrofit.create(serviceClass);
- }
-
- /**
- * Sets the OkHttpClient instance to be used by the ServiceGenerator.
- *
- * @param client the OkHttpClient instance to be set
- * @return the current instance of ServiceGenerator for method chaining
- */
- public ServiceGenerator setHttpClient(OkHttpClient client){
- this.client = client;
- return this;
- }
-
- /**
- * Creates and returns a default OkHttpClient instance with predefined configurations.
- *
- * This client includes:
- *
- * - Logging interceptors for both body and headers.
- * - Connection, read, and write timeouts.
- * - Redirect handling.
- * - A network interceptor for modifying requests before execution.
- *
- * The interceptor ensures headers are set, logs the request body if enabled,
- * and prints headers when required.
- *
- * @return a configured OkHttpClient instance
- */
- public OkHttpClient getDefaultHttpClient(){
- OkHttpClient client = new OkHttpClient.Builder()
- .connectTimeout(connectionTimeout, TimeUnit.SECONDS)
- .readTimeout(readTimeout, TimeUnit.SECONDS)
- .writeTimeout(writeTimeout, TimeUnit.SECONDS)
- .followRedirects(followRedirects)
- .addNetworkInterceptor(chain -> {
- Request request = chain.request().newBuilder().build();
- request = request.newBuilder()
- .header("Host", request.url().host())
- .method(request.method(), request.body())
- .build();
- for (String header: headers.names()) {
- if (!request.headers().names().contains(header)){
- request = request.newBuilder()
- .addHeader(header, Objects.requireNonNull(headers.get(header)))
- .build();
- }
- }
- if (request.body() != null) {
- Boolean contentLength = Objects.requireNonNull(request.body()).contentLength()!=0;
- Boolean contentType = Objects.requireNonNull(request.body()).contentType() != null;
-
- if (contentLength && contentType)
- request = request.newBuilder()
- .header(
- "Content-Length",
- String.valueOf(Objects.requireNonNull(request.body()).contentLength()))
- .header(
- "Content-Type",
- String.valueOf(Objects.requireNonNull(request.body()).contentType()))
- .build();
-
- if (printRequestBody) {
- Request cloneRequest = request.newBuilder().build();
- if (cloneRequest.body()!= null){
- Buffer buffer = new Buffer();
- cloneRequest.body().writeTo(buffer);
- String bodyString = buffer.readString(UTF_8);
- try {
- Object jsonObject = mapper.readValue(bodyString, Object.class);
- String outgoingRequestLog = "The request body is: \n" + getJsonString(jsonObject);
- log.info(outgoingRequestLog);
- }
- catch (IOException ignored) {
- log.warning("Could not log request body!\nBody: " + bodyString);
- }
- }
- else log.warning("Request body is null!");
- }
- }
- if (printHeaders)
- log.info(("Headers(" + request.headers().size() + "): \n" + request.headers()).trim());
- return chain.proceed(request);
- }).build();
-
- if (detailedLogging)
- client = new OkHttpClient.Builder(client)
- .addInterceptor(getLogginInterceptor(HttpLoggingInterceptor.Level.BODY))
- .addInterceptor(getLogginInterceptor(HttpLoggingInterceptor.Level.HEADERS))
- .build();
-
- if (!hostnameVerification)
- client = new OkHttpClient.Builder(client).hostnameVerifier((hostname, session) -> true).build();
-
- if (useProxy)
- client = new OkHttpClient.Builder(client)
- .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)))
- .build();
-
- return client;
- }
-
- /**
- * Creates and returns an {@link HttpLoggingInterceptor} with the specified logging level.
- *
- * This interceptor is used to log HTTP request and response details,
- * such as headers, body, and metadata, depending on the provided level.
- *
- * @param level the logging level to set for the interceptor (e.g., BODY, HEADERS, BASIC, NONE)
- * @return an {@link HttpLoggingInterceptor} instance configured with the specified level
- */
- public HttpLoggingInterceptor getLogginInterceptor(HttpLoggingInterceptor.Level level){
- HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
- interceptor.setLevel(level);
- return interceptor;
- }
-
- /**
- * Sets whether to log the headers in the requests.
- *
- * @param printHeaders A boolean indicating whether to log the headers in the requests.
- * @return The updated ServiceGenerator object.
- */
- public ServiceGenerator printHeaders(boolean printHeaders) {
- this.printHeaders = printHeaders;
- return this;
- }
-
- /**
- * Sets whether to log detailed information in the requests.
- *
- * @param detailedLogging A boolean indicating whether to log detailed information in the requests.
- * @return The updated ServiceGenerator object.
- */
- public ServiceGenerator detailedLogging(boolean detailedLogging) {
- this.detailedLogging = detailedLogging;
- return this;
- }
-
- /**
- * Sets whether to verify the hostname in the requests.
- *
- * @param hostnameVerification A boolean indicating whether to verify the hostname in the requests.
- * @return The updated ServiceGenerator object.
- */
- public ServiceGenerator hostnameVerification(boolean hostnameVerification) {
- this.hostnameVerification = hostnameVerification;
- return this;
- }
-
- /**
- * Sets whether to print request bodies in the outgoing requests.
- *
- * @param logRequestBody A boolean indicating whether to print request bodies in the outgoing requests.
- * @return The updated ServiceGenerator object.
- */
- public ServiceGenerator setRequestLogging(boolean logRequestBody) {
- this.printRequestBody = logRequestBody;
- return this;
- }
-
- /**
- * Sets the headers to be added to the requests.
- *
- * @param headers The headers to be added to the requests.
- * @return The updated ServiceGenerator object.
- */
- public ServiceGenerator setHeaders(Headers headers){
- this.headers = headers;
- return this;
- }
-
- /**
- * Gets the headers to be added to the requests.
- *
- * @return The headers to be added to the requests.
- */
- public Headers getHeaders() {
- return headers;
- }
-
- /**
- * Gets whether to log the headers in the requests.
- *
- * @return A boolean indicating whether to log the headers in the requests.
- */
- public boolean printHeaders() {
- return printHeaders;
- }
-
- /**
- * Gets whether to log detailed information in the requests.
- *
- * @return A boolean indicating whether to log detailed information in the requests.
- */
- public boolean detailedLogs() {
- return detailedLogging;
- }
-
- /**
- * Gets whether to verify the hostname in the requests.
- *
- * @return A boolean indicating whether to verify the hostname in the requests.
- */
- public boolean isHostnameVerification() {
- return hostnameVerification;
- }
-
- /**
- * Sets the connection timeout in seconds.
- *
- * @param connectionTimeout The connection timeout in seconds.
- * @return The updated ServiceGenerator object.
- */
- public ServiceGenerator setConnectionTimeout(int connectionTimeout) {
- this.connectionTimeout = connectionTimeout;
- return this;
- }
-
- /**
- * Sets the read timeout in seconds.
- *
- * @param readTimeout The read timeout in seconds.
- * @return The updated ServiceGenerator object.
- */
- public ServiceGenerator setReadTimeout(int readTimeout) {
- this.readTimeout = readTimeout;
- return this;
- }
-
- /**
- * Sets write timeout in seconds.
- *
- * @param writeTimeout write timeout in seconds.
- * @return The updated ServiceGenerator object.
- */
- public ServiceGenerator setWriteTimeout(int writeTimeout) {
- this.writeTimeout = writeTimeout;
- return this;
- }
-
- /**
- * Sets write timeout in seconds.
- *
- * @param proxyHost proxy host.
- * @return The updated ServiceGenerator object.
- */
- public ServiceGenerator setPoxyHost(String proxyHost) {
- this.proxyHost = proxyHost;
- return this;
- }
-
- /**
- * Sets write timeout in seconds.
- *
- * @param proxyPort proxy host.
- * @return The updated ServiceGenerator object.
- */
- public ServiceGenerator setPoxyPort(int proxyPort) {
- this.proxyPort = proxyPort;
- return this;
- }
-
- /**
- * Sets the base URL for the service.
- *
- * @param BASE_URL The base URL for the service.
- * @return The updated ServiceGenerator object.
- */
- public ServiceGenerator setBASE_URL(String BASE_URL) {
- this.BASE_URL = BASE_URL;
- return this;
- }
-
- /**
- * Gets connection timeout in seconds.
- *
- * @return connection timeout in seconds.
- */
- public int getConnectionTimeout() {
- return connectionTimeout;
- }
-
- /**
- * Gets read timeout in seconds.
- *
- * @return read timeout in seconds.
- */
- public int getReadTimeout() {
- return readTimeout;
- }
-
- /**
- * Gets write timeout in seconds.
- *
- * @return write timeout in seconds.
- */
- public int getWriteTimeout() {
- return writeTimeout;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/api_assured/exceptions/FailedCallException.java b/src/main/java/api_assured/exceptions/FailedCallException.java
deleted file mode 100644
index 507c63c..0000000
--- a/src/main/java/api_assured/exceptions/FailedCallException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package api_assured.exceptions;
-
-/**
- * This class represents an exception that is thrown when a call fails.
- */
-@Deprecated(since = "1.7.4")
-public class FailedCallException extends RuntimeException {
-
- /**
- * Constructs a FailedCallException with the specified runtime exception.
- * @param errorMessage The runtime exception to be associated with this exception.
- */
- public FailedCallException(String errorMessage) {super(errorMessage);}
-
- public FailedCallException(RuntimeException errorMessage) {super(errorMessage);}
-}
diff --git a/src/main/java/api_assured/exceptions/JavaUtilitiesException.java b/src/main/java/exceptions/JavaUtilitiesException.java
similarity index 89%
rename from src/main/java/api_assured/exceptions/JavaUtilitiesException.java
rename to src/main/java/exceptions/JavaUtilitiesException.java
index 3d1b94d..db9e65f 100644
--- a/src/main/java/api_assured/exceptions/JavaUtilitiesException.java
+++ b/src/main/java/exceptions/JavaUtilitiesException.java
@@ -1,9 +1,8 @@
-package api_assured.exceptions;
+package exceptions;
/**
* This class represents an exception that is thrown when an error occurs in JavaUtilities.
*/
-@Deprecated(since = "1.7.4")
public class JavaUtilitiesException extends RuntimeException {
/**
diff --git a/src/main/java/utils/FileUtilities.java b/src/main/java/utils/FileUtilities.java
index c502bf9..405afbe 100644
--- a/src/main/java/utils/FileUtilities.java
+++ b/src/main/java/utils/FileUtilities.java
@@ -1,6 +1,6 @@
package utils;
-import api_assured.exceptions.JavaUtilitiesException;
+import exceptions.JavaUtilitiesException;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
diff --git a/src/main/java/utils/StringUtilities.java b/src/main/java/utils/StringUtilities.java
index 507267d..6301c05 100644
--- a/src/main/java/utils/StringUtilities.java
+++ b/src/main/java/utils/StringUtilities.java
@@ -3,7 +3,6 @@
import com.google.gson.JsonObject;
import context.ContextStore;
import org.apache.commons.lang3.RandomStringUtils;
-import org.jetbrains.annotations.NotNull;
import properties.PropertyUtilities;
import java.text.Normalizer;
import java.util.*;
@@ -223,7 +222,7 @@ else if (keyValue[0] == null)
* @param input string that is to be context checked
* @return value depending on the context (could be from ContextStore, Properties, Random etc)
*/
- public static String contextCheck(@NotNull String input){
+ public static String contextCheck(String input){
if (input.contains("CONTEXT-"))
input = ContextStore.get(TextParser.parse("CONTEXT-", null, input));
else if (input.contains("PROPERTY-")){
diff --git a/src/test/java/AppTest.java b/src/test/java/AppTest.java
index ca73ec5..3f19fd7 100644
--- a/src/test/java/AppTest.java
+++ b/src/test/java/AppTest.java
@@ -1,14 +1,10 @@
import collections.Pair;
-import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.gson.JsonObject;
import context.ContextStore;
import enums.ZoneIds;
import org.junit.Assert;
import org.junit.Before;
-import petstore.PetStore;
-import petstore.PetStoreServices;
-import petstore.models.Pet;
import org.junit.Test;
import utils.*;
import utils.arrays.ArrayUtilities;
@@ -17,14 +13,12 @@
import utils.reflection.ReflectionUtilities;
import java.io.IOException;
import java.net.URL;
-import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import static utils.arrays.ArrayUtilities.*;
import static utils.email.EmailUtilities.Inbox.EmailField.CONTENT;
import static utils.email.EmailUtilities.Inbox.EmailField.SUBJECT;
-import static utils.mapping.MappingUtilities.Json.*;
import static utils.StringUtilities.contextCheck;
public class AppTest {
@@ -49,82 +43,6 @@ public void dataGeneratorPetTest() {
printer.info("Test!");
}
- @Test
- public void stringToObjectTest() throws JsonProcessingException {
- Pet pet = fromJsonString("{\"id\" : null, \"category\" : {\"id\" : null, \"name\" : \"Cats\"},\"name\" : \"Whiskers\", \"photoUrls\" : [ \"https://example.com/cat.jpg\" ],\"tags\" : [ {\"id\" : 123456789, \"name\" : \"Furry\"}, {\"id\" : 987654321, \"name\" : \"Playful\"} ],\"status\" : \"Available\"}", Pet.class);
- printer.success("The stringToObjectTest() test passed!");
- }
-
- @Test
- public void petStatusTest() {
- PetStore petStore = new PetStore();
- petStore.getPetsByStatus(PetStoreServices.PetStatus.pending);
- printer.success("The petStatusTest() test passed!");
- }
-
- @Test
- public void petPostTest() {
- PetStore petStore = new PetStore();
- Pet pet = new Pet();
- pet.setName("doggie");
- List photoUrls = List.of("string");
- pet.setPhotoUrls(photoUrls);
- pet.setStatus("available");
- petStore.postPet(pet);
- printer.success("The petPostTest() test passed!");
- }
-
- @Test
- public void petCompareJsonTest() {
- PetStore petStore = new PetStore();
- List photoUrls = List.of("string1", "string2");
- List tags = new ArrayList<>();
- Pet.DataModel dataModel = new Pet.DataModel(111222L, "dataModel1");
- tags.add(dataModel);
- Pet.DataModel category = new Pet.DataModel(3333L, "category");
- Pet pet = new Pet(category, "Puppy", photoUrls, tags, "available");
- Pet createdPet = petStore.postPet(pet);
- Pet actualPet = petStore.getPetById(createdPet.getId());
- createdPet.setId(actualPet.getId());
- ReflectionUtilities.objectsMatch(createdPet, actualPet);
- printer.success("The petCompareJsonTest() test passed!");
- }
-
- @Test
- public void compareJsonPetWithEmptyArrayNegativeTest() {
- PetStore petStore = new PetStore();
- List photoUrls = List.of("string1", "string2");
- List tags = new ArrayList<>();
- Pet.DataModel dataModel = new Pet.DataModel(111222L, "dataModel1");
- tags.add(dataModel);
- Pet.DataModel category = new Pet.DataModel(3333L, "category");
- Pet pet = new Pet(category, "Puppy", photoUrls, tags, "available");
- Pet createdPet = petStore.postPet(pet);
- Pet actualPet = petStore.getPetById(createdPet.getId());
- createdPet.setId(actualPet.getId());
- createdPet.setPhotoUrls(new ArrayList<>());
- Assert.assertFalse("The compareJsonPetWithEmptyArrayNegativeTest() negative test fails!", ReflectionUtilities.objectsMatch(createdPet, actualPet));
- printer.success("The compareJsonPetWithEmptyArrayNegativeTest() negative test passes!");
- }
-
- @Test
- public void compareJsonPetWithNullFieldValueInObjectNegativeTest() {
- PetStore petStore = new PetStore();
- List photoUrls = List.of("string1", "string2");
- List tags = new ArrayList<>();
- Pet.DataModel dataModel = new Pet.DataModel(111222L, "dataModel1");
- tags.add(dataModel);
- Pet.DataModel category = new Pet.DataModel(3333L, "category");
- Pet pet = new Pet(category, "Puppy", photoUrls, tags, "available");
- Pet createdPet = petStore.postPet(pet);
- Pet actualPet = petStore.getPetById(createdPet.getId());
- createdPet.setId(actualPet.getId());
- Pet.DataModel expectedCategory = new Pet.DataModel(3333L, null);
- createdPet.setCategory(expectedCategory);
- Assert.assertFalse("The compareJsonPetWithNullFieldValueInObjectNegativeTest() negative test fails!", ReflectionUtilities.objectsMatch(createdPet, actualPet));
- printer.success("The compareJsonPetWithNullFieldValueInObjectNegativeTest() negative test passes!");
- }
-
@Test
public void localisationCapabilityTest() {
JsonObject localisationJson = FileUtilities.Json.parseJsonFile("src/test/resources/localisation.json");
@@ -277,20 +195,6 @@ public void filterEmailTest() {
printer.success("Sending and receiving emails tests are successful!");
}
- @Test
- public void setFieldTest() {
- Pet pet = new Pet();
- String expectedFieldName = "name";
- String expectedFieldValue = "Bella";
- ReflectionUtilities.setField(pet, expectedFieldName, expectedFieldValue);
- Assert.assertEquals(
- "Value of field " + expectedFieldName + " does not match!",
- expectedFieldValue,
- pet.getName()
- );
- printer.success("The setFieldTest() test pass!");
- }
-
@Test
public void lastItemOfTest() {
List integers = List.of(1, 2, 3, 4, 5);
@@ -328,17 +232,6 @@ public void partitionCountTest() {
printer.success("The partitionCountTest() test pass!");
}
- @Test
- public void jsonSchemaTest() {
- JsonNode petSchema = MappingUtilities.Json.Schema.getJsonNodeFor(Pet.class);
- Assert.assertEquals(
- "Generated json schema did not match the expected one!",
- "{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"category\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"}}},\"name\":{\"type\":\"string\"},\"photoUrls\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"tags\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"}}}},\"status\":{\"type\":\"string\"}}}",
- petSchema.toString()
- );
- printer.success("The jsonSchemaTest() test pass!");
- }
-
@Test
public void dateFormatTest() {
String date = "2025-6-20";
diff --git a/src/test/java/petstore/PetStore.java b/src/test/java/petstore/PetStore.java
deleted file mode 100644
index 0e8c496..0000000
--- a/src/test/java/petstore/PetStore.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package petstore;
-
-import api_assured.ApiUtilities;
-import api_assured.ServiceGenerator;
-import petstore.models.Pet;
-import retrofit2.Call;
-import utils.StringUtilities;
-import java.util.List;
-
-import static utils.StringUtilities.*;
-
-public class PetStore extends ApiUtilities {
-
- PetStoreServices petStoreServices = new ServiceGenerator()
- .setRequestLogging(true)
- .printHeaders(true)
- .generate(PetStoreServices.class);
-
- public List getPetsByStatus(PetStoreServices.PetStatus status){
- log.info("Getting pets by status: " + highlighted(StringUtilities.Color.BLUE, status.name()));
- Call> petByStatusCall = petStoreServices.getPet(status);
- return getResponseForCode(30, 200, petByStatusCall, true).body();
- }
-
- public Pet postPet(Pet pet){
- log.info("Post pet");
- Call postPetCall = petStoreServices.postPet(pet);
- return monitorFieldValueFromResponse(30, "available", postPetCall, "status", true).body();
- }
-
- public Pet getPetById(Long petId){
- log.info("Getting pet by petId: " + highlighted(StringUtilities.Color.BLUE, String.valueOf(petId)));
- Call petByIdCall = petStoreServices.getPetById(petId);
- return getResponseForCode(30, 200, petByIdCall, true).body();
- }
-}
diff --git a/src/test/java/petstore/PetStoreServices.java b/src/test/java/petstore/PetStoreServices.java
deleted file mode 100644
index 6c7989c..0000000
--- a/src/test/java/petstore/PetStoreServices.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package petstore;
-
-import petstore.models.Pet;
-import retrofit2.Call;
-import retrofit2.http.*;
-
-import java.util.List;
-
-public interface PetStoreServices {
-
- enum PetStatus {
- available,
- pending,
- sold
- }
-
- String BASE_URL = "https://petstore.swagger.io/v2/";
-
- @GET("pet/findByStatus")
- Call> getPet(@Query("status") PetStatus status);
-
- @GET("pet/{petId}")
- Call getPetById(@Path("petId") Long petId);
-
- @POST("pet")
- Call postPet(@Body Pet pet);
-}
diff --git a/src/test/java/petstore/models/Pet.java b/src/test/java/petstore/models/Pet.java
deleted file mode 100644
index fb9b034..0000000
--- a/src/test/java/petstore/models/Pet.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package petstore.models;
-
-import java.util.List;
-
-public class Pet {
- Long id;
- DataModel category;
- String name;
- List photoUrls;
- List tags;
- String status;
-
- public Pet(DataModel category, String name, List photoUrls, List tags, String status) {
- this.category = category;
- this.name = name;
- this.photoUrls = photoUrls;
- this.tags = tags;
- this.status = status;
- }
-
- public Pet() {
- }
-
- public Pet(Long id, DataModel category, String name, List photoUrls, List tags, String status) {
- this.id = id;
- this.category = category;
- this.name = name;
- this.photoUrls = photoUrls;
- this.tags = tags;
- this.status = status;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public DataModel getCategory() {
- return category;
- }
-
- public void setCategory(DataModel category) {
- this.category = category;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List getPhotoUrls() {
- return photoUrls;
- }
-
- public void setPhotoUrls(List photoUrls) {
- this.photoUrls = photoUrls;
- }
-
- public List getTags() {
- return tags;
- }
-
- public void setTags(List tags) {
- this.tags = tags;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public static class DataModel {
- Long id;
- String name;
-
- public DataModel(Long id, String name) {
- this.id = id;
- this.name = name;
- }
-
- public DataModel() {
- }
- }
-}
-