From d9c1829dce33a0e129ac5efbedc43179921a05e4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Dec 2025 21:39:28 +0000 Subject: [PATCH 1/2] Initial plan From 5061f45d987b67f073d023d8392baccc1168952a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Dec 2025 21:47:19 +0000 Subject: [PATCH 2/2] Add pagination field to GetGroups200Response model Co-authored-by: Subterrane <5290140+Subterrane@users.noreply.github.com> --- .../client/model/GetGroups200Response.java | 35 +- .../model/GetGroups200ResponsePagination.java | 300 ++++++++++++++++++ .../GetGroups200ResponsePaginationTest.java | 72 +++++ .../model/GetGroups200ResponseTest.java | 9 + ...estGetGroups200ResponseWithPagination.java | 73 +++++ 5 files changed, 488 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/onelogin/client/model/GetGroups200ResponsePagination.java create mode 100644 src/test/java/com/onelogin/client/model/GetGroups200ResponsePaginationTest.java create mode 100644 src/test/java/com/onelogin/client/model/TestGetGroups200ResponseWithPagination.java diff --git a/src/main/java/com/onelogin/client/model/GetGroups200Response.java b/src/main/java/com/onelogin/client/model/GetGroups200Response.java index 8ff1bd8..47aee50 100644 --- a/src/main/java/com/onelogin/client/model/GetGroups200Response.java +++ b/src/main/java/com/onelogin/client/model/GetGroups200Response.java @@ -21,6 +21,7 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.onelogin.client.model.Error; +import com.onelogin.client.model.GetGroups200ResponsePagination; import com.onelogin.client.model.Group; import java.io.IOException; import java.util.ArrayList; @@ -60,6 +61,10 @@ public class GetGroups200Response { @SerializedName(SERIALIZED_NAME_STATUS) private Error status; + public static final String SERIALIZED_NAME_PAGINATION = "pagination"; + @SerializedName(SERIALIZED_NAME_PAGINATION) + private GetGroups200ResponsePagination pagination; + public static final String SERIALIZED_NAME_DATA = "data"; @SerializedName(SERIALIZED_NAME_DATA) private List data; @@ -88,6 +93,27 @@ public void setStatus(Error status) { } + public GetGroups200Response pagination(GetGroups200ResponsePagination pagination) { + + this.pagination = pagination; + return this; + } + + /** + * Get pagination + * @return pagination + **/ + @javax.annotation.Nullable + public GetGroups200ResponsePagination getPagination() { + return pagination; + } + + + public void setPagination(GetGroups200ResponsePagination pagination) { + this.pagination = pagination; + } + + public GetGroups200Response data(List data) { this.data = data; @@ -128,12 +154,13 @@ public boolean equals(Object o) { } GetGroups200Response getGroups200Response = (GetGroups200Response) o; return Objects.equals(this.status, getGroups200Response.status) && + Objects.equals(this.pagination, getGroups200Response.pagination) && Objects.equals(this.data, getGroups200Response.data); } @Override public int hashCode() { - return Objects.hash(status, data); + return Objects.hash(status, pagination, data); } @Override @@ -141,6 +168,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetGroups200Response {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" pagination: ").append(toIndentedString(pagination)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); sb.append("}"); return sb.toString(); @@ -165,6 +193,7 @@ private String toIndentedString(Object o) { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); openapiFields.add("status"); + openapiFields.add("pagination"); openapiFields.add("data"); // a set of required properties/fields (JSON key names) @@ -195,6 +224,10 @@ public static void validateJsonObject(JsonObject jsonObj) throws IOException { if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { Error.validateJsonObject(jsonObj.getAsJsonObject("status")); } + // validate the optional field `pagination` + if (jsonObj.get("pagination") != null && !jsonObj.get("pagination").isJsonNull()) { + GetGroups200ResponsePagination.validateJsonObject(jsonObj.getAsJsonObject("pagination")); + } if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); if (jsonArraydata != null) { diff --git a/src/main/java/com/onelogin/client/model/GetGroups200ResponsePagination.java b/src/main/java/com/onelogin/client/model/GetGroups200ResponsePagination.java new file mode 100644 index 0000000..d320af8 --- /dev/null +++ b/src/main/java/com/onelogin/client/model/GetGroups200ResponsePagination.java @@ -0,0 +1,300 @@ +/* + * OneLogin API + * OpenAPI Specification for OneLogin + * + * The version of the OpenAPI document: 3.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.onelogin.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.onelogin.client.JSON; + +/** + * GetGroups200ResponsePagination + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-07-18T11:53:48.226013-07:00[America/Los_Angeles]") +public class GetGroups200ResponsePagination { + public static final String SERIALIZED_NAME_BEFORE_CURSOR = "before_cursor"; + @SerializedName(SERIALIZED_NAME_BEFORE_CURSOR) + private String beforeCursor; + + public static final String SERIALIZED_NAME_AFTER_CURSOR = "after_cursor"; + @SerializedName(SERIALIZED_NAME_AFTER_CURSOR) + private String afterCursor; + + public static final String SERIALIZED_NAME_PREVIOUS_LINK = "previous_link"; + @SerializedName(SERIALIZED_NAME_PREVIOUS_LINK) + private String previousLink; + + public static final String SERIALIZED_NAME_NEXT_LINK = "next_link"; + @SerializedName(SERIALIZED_NAME_NEXT_LINK) + private String nextLink; + + public GetGroups200ResponsePagination() { + } + + public GetGroups200ResponsePagination beforeCursor(String beforeCursor) { + + this.beforeCursor = beforeCursor; + return this; + } + + /** + * Get beforeCursor + * @return beforeCursor + **/ + @javax.annotation.Nullable + public String getBeforeCursor() { + return beforeCursor; + } + + + public void setBeforeCursor(String beforeCursor) { + this.beforeCursor = beforeCursor; + } + + + public GetGroups200ResponsePagination afterCursor(String afterCursor) { + + this.afterCursor = afterCursor; + return this; + } + + /** + * Get afterCursor + * @return afterCursor + **/ + @javax.annotation.Nullable + public String getAfterCursor() { + return afterCursor; + } + + + public void setAfterCursor(String afterCursor) { + this.afterCursor = afterCursor; + } + + + public GetGroups200ResponsePagination previousLink(String previousLink) { + + this.previousLink = previousLink; + return this; + } + + /** + * Get previousLink + * @return previousLink + **/ + @javax.annotation.Nullable + public String getPreviousLink() { + return previousLink; + } + + + public void setPreviousLink(String previousLink) { + this.previousLink = previousLink; + } + + + public GetGroups200ResponsePagination nextLink(String nextLink) { + + this.nextLink = nextLink; + return this; + } + + /** + * Get nextLink + * @return nextLink + **/ + @javax.annotation.Nullable + public String getNextLink() { + return nextLink; + } + + + public void setNextLink(String nextLink) { + this.nextLink = nextLink; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetGroups200ResponsePagination getGroups200ResponsePagination = (GetGroups200ResponsePagination) o; + return Objects.equals(this.beforeCursor, getGroups200ResponsePagination.beforeCursor) && + Objects.equals(this.afterCursor, getGroups200ResponsePagination.afterCursor) && + Objects.equals(this.previousLink, getGroups200ResponsePagination.previousLink) && + Objects.equals(this.nextLink, getGroups200ResponsePagination.nextLink); + } + + @Override + public int hashCode() { + return Objects.hash(beforeCursor, afterCursor, previousLink, nextLink); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetGroups200ResponsePagination {\n"); + sb.append(" beforeCursor: ").append(toIndentedString(beforeCursor)).append("\n"); + sb.append(" afterCursor: ").append(toIndentedString(afterCursor)).append("\n"); + sb.append(" previousLink: ").append(toIndentedString(previousLink)).append("\n"); + sb.append(" nextLink: ").append(toIndentedString(nextLink)).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 "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("before_cursor"); + openapiFields.add("after_cursor"); + openapiFields.add("previous_link"); + openapiFields.add("next_link"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to GetGroups200ResponsePagination + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!GetGroups200ResponsePagination.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in GetGroups200ResponsePagination is not found in the empty JSON string", GetGroups200ResponsePagination.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!GetGroups200ResponsePagination.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetGroups200ResponsePagination` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("before_cursor") != null && !jsonObj.get("before_cursor").isJsonNull()) && !jsonObj.get("before_cursor").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `before_cursor` to be a primitive type in the JSON string but got `%s`", jsonObj.get("before_cursor").toString())); + } + if ((jsonObj.get("after_cursor") != null && !jsonObj.get("after_cursor").isJsonNull()) && !jsonObj.get("after_cursor").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `after_cursor` to be a primitive type in the JSON string but got `%s`", jsonObj.get("after_cursor").toString())); + } + if ((jsonObj.get("previous_link") != null && !jsonObj.get("previous_link").isJsonNull()) && !jsonObj.get("previous_link").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `previous_link` to be a primitive type in the JSON string but got `%s`", jsonObj.get("previous_link").toString())); + } + if ((jsonObj.get("next_link") != null && !jsonObj.get("next_link").isJsonNull()) && !jsonObj.get("next_link").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `next_link` to be a primitive type in the JSON string but got `%s`", jsonObj.get("next_link").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetGroups200ResponsePagination.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetGroups200ResponsePagination' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GetGroups200ResponsePagination.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GetGroups200ResponsePagination value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GetGroups200ResponsePagination read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GetGroups200ResponsePagination given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetGroups200ResponsePagination + * @throws IOException if the JSON string is invalid with respect to GetGroups200ResponsePagination + */ + public static GetGroups200ResponsePagination fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetGroups200ResponsePagination.class); + } + + /** + * Convert an instance of GetGroups200ResponsePagination to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/src/test/java/com/onelogin/client/model/GetGroups200ResponsePaginationTest.java b/src/test/java/com/onelogin/client/model/GetGroups200ResponsePaginationTest.java new file mode 100644 index 0000000..39ae2de --- /dev/null +++ b/src/test/java/com/onelogin/client/model/GetGroups200ResponsePaginationTest.java @@ -0,0 +1,72 @@ +/* + * OneLogin API + * OpenAPI Specification for OneLogin + * + * The version of the OpenAPI document: 3.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.onelogin.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for GetGroups200ResponsePagination + */ +public class GetGroups200ResponsePaginationTest { + private final GetGroups200ResponsePagination model = new GetGroups200ResponsePagination(); + + /** + * Model tests for GetGroups200ResponsePagination + */ + @Test + public void testGetGroups200ResponsePagination() { + // TODO: test GetGroups200ResponsePagination + } + + /** + * Test the property 'beforeCursor' + */ + @Test + public void beforeCursorTest() { + // TODO: test beforeCursor + } + + /** + * Test the property 'afterCursor' + */ + @Test + public void afterCursorTest() { + // TODO: test afterCursor + } + + /** + * Test the property 'previousLink' + */ + @Test + public void previousLinkTest() { + // TODO: test previousLink + } + + /** + * Test the property 'nextLink' + */ + @Test + public void nextLinkTest() { + // TODO: test nextLink + } + +} diff --git a/src/test/java/com/onelogin/client/model/GetGroups200ResponseTest.java b/src/test/java/com/onelogin/client/model/GetGroups200ResponseTest.java index 77157a8..2c1ac56 100644 --- a/src/test/java/com/onelogin/client/model/GetGroups200ResponseTest.java +++ b/src/test/java/com/onelogin/client/model/GetGroups200ResponseTest.java @@ -19,6 +19,7 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.onelogin.client.model.Error; +import com.onelogin.client.model.GetGroups200ResponsePagination; import com.onelogin.client.model.Group; import java.io.IOException; import java.util.ArrayList; @@ -49,6 +50,14 @@ public void statusTest() { // TODO: test status } + /** + * Test the property 'pagination' + */ + @Test + public void paginationTest() { + // TODO: test pagination + } + /** * Test the property 'data' */ diff --git a/src/test/java/com/onelogin/client/model/TestGetGroups200ResponseWithPagination.java b/src/test/java/com/onelogin/client/model/TestGetGroups200ResponseWithPagination.java new file mode 100644 index 0000000..b4ec826 --- /dev/null +++ b/src/test/java/com/onelogin/client/model/TestGetGroups200ResponseWithPagination.java @@ -0,0 +1,73 @@ +package com.onelogin.client.model; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.onelogin.client.JSON; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +import java.io.IOException; + +/** + * Integration test for GetGroups200Response with pagination field + */ +public class TestGetGroups200ResponseWithPagination { + + @BeforeAll + public static void setup() { + // Initialize the JSON helper with Gson configuration + GsonBuilder builder = JSON.createGson(); + builder.registerTypeAdapterFactory(new GetGroups200Response.CustomTypeAdapterFactory()); + builder.registerTypeAdapterFactory(new GetGroups200ResponsePagination.CustomTypeAdapterFactory()); + Gson gson = builder.create(); + JSON.setGson(gson); + } + + /** + * Test that the JSON from the issue can be deserialized successfully + */ + @Test + public void testDeserializeJsonWithPagination() throws IOException { + String jsonString = "{\"status\":{\"error\":false,\"code\":200,\"type\":\"success\",\"message\":\"Success\"},\"pagination\":{\"before_cursor\":null,\"after_cursor\":null,\"previous_link\":null,\"next_link\":null},\"data\":[{\"id\":502836,\"name\":\"test\",\"reference\":null}]}"; + + // This should not throw an exception anymore + GetGroups200Response response = GetGroups200Response.fromJson(jsonString); + + assertNotNull(response); + assertNotNull(response.getStatus()); + assertNotNull(response.getPagination()); + assertNotNull(response.getData()); + + assertEquals(1, response.getData().size()); + assertEquals("test", response.getData().get(0).getName()); + assertEquals(502836, response.getData().get(0).getId()); + + // Verify pagination object exists + GetGroups200ResponsePagination pagination = response.getPagination(); + assertNotNull(pagination); + assertNull(pagination.getBeforeCursor()); + assertNull(pagination.getAfterCursor()); + assertNull(pagination.getPreviousLink()); + assertNull(pagination.getNextLink()); + } + + /** + * Test that the pagination field can have values + */ + @Test + public void testDeserializeJsonWithPaginationValues() throws IOException { + String jsonString = "{\"status\":{\"error\":false,\"code\":200,\"type\":\"success\",\"message\":\"Success\"},\"pagination\":{\"before_cursor\":\"cursor1\",\"after_cursor\":\"cursor2\",\"previous_link\":\"http://prev\",\"next_link\":\"http://next\"},\"data\":[]}"; + + GetGroups200Response response = GetGroups200Response.fromJson(jsonString); + + assertNotNull(response); + assertNotNull(response.getPagination()); + + GetGroups200ResponsePagination pagination = response.getPagination(); + assertEquals("cursor1", pagination.getBeforeCursor()); + assertEquals("cursor2", pagination.getAfterCursor()); + assertEquals("http://prev", pagination.getPreviousLink()); + assertEquals("http://next", pagination.getNextLink()); + } +}