From 844d20c7f724dd230e54916fe0c3ecf1a3cbbfb0 Mon Sep 17 00:00:00 2001 From: Santhosh Gandhe <1909520+san81@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:46:11 -0700 Subject: [PATCH] removed unused model object Signed-off-by: Santhosh Gandhe <1909520+san81@users.noreply.github.com> --- .../plugins/source/jira/models/IssueBean.java | 12 -- .../source/jira/models/JsonTypeBean.java | 153 ----------------- .../source/jira/models/SearchResults.java | 121 +------------ .../source/jira/models/JsonTypeBeanTest.java | 159 ------------------ .../source/jira/models/SearchResultsTest.java | 10 -- 5 files changed, 2 insertions(+), 453 deletions(-) delete mode 100644 data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/models/JsonTypeBean.java delete mode 100644 data-prepper-plugins/saas-source-plugins/jira-source/src/test/java/org/opensearch/dataprepper/plugins/source/jira/models/JsonTypeBeanTest.java diff --git a/data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/models/IssueBean.java b/data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/models/IssueBean.java index 81f689e68b..dbcd65b1bb 100644 --- a/data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/models/IssueBean.java +++ b/data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/models/IssueBean.java @@ -12,37 +12,25 @@ public class IssueBean { /** - * -- GETTER -- * Expand options that include additional issue details in the response. - * - * @return expand expand */ @JsonProperty("expand") private String expand = null; /** - * -- GETTER -- * The ID of the issue. - * - * @return id id */ @JsonProperty("id") private String id = null; /** - * -- GETTER -- * The URL of the issue details. - * - * @return self self */ @JsonProperty("self") private String self = null; /** - * -- GETTER -- * The key of the issue. - * - * @return key key */ @JsonProperty("key") private String key = null; diff --git a/data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/models/JsonTypeBean.java b/data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/models/JsonTypeBean.java deleted file mode 100644 index 0c97e6b4ec..0000000000 --- a/data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/models/JsonTypeBean.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * The Jira Cloud platform REST API - * Jira Cloud platform REST API documentation - * - * OpenAPI spec version: 1001.0.0-SNAPSHOT - * Contact: ecosystem@atlassian.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -package org.opensearch.dataprepper.plugins.source.jira.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import org.opensearch.dataprepper.plugins.source.jira.utils.Constants; - -import java.util.Map; -import java.util.Objects; - -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.CLOSING_BRACKET; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.CUSTOM; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.CUSTOM_ID; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.ITEMS_WITH_SPACE; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.NEW_LINE; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.TYPE_WITH_SPACE; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants._CONFIG; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants._SYSTEM; - -/** - * The schema of a field. - */ -public class JsonTypeBean { - @JsonProperty("type") - private String type = null; - - @JsonProperty("items") - private String items = null; - - @JsonProperty("system") - private String system = null; - - @JsonProperty("custom") - private String custom = null; - - @JsonProperty("customId") - private Long customId = null; - - @JsonProperty("configuration") - private Map configuration = null; - - /** - * The data type of the field. - * - * @return type type - */ - public String getType() { - return type; - } - - /** - * When the data type is an array, the name of the field items within the array. - * - * @return items items - */ - public String getItems() { - return items; - } - - /** - * If the field is a system field, the name of the field. - * - * @return system system - */ - public String getSystem() { - return system; - } - - /** - * If the field is a custom field, the URI of the field. - * - * @return custom custom - */ - public String getCustom() { - return custom; - } - - /** - * If the field is a custom field, the custom ID of the field. - * - * @return customId custom id - */ - public Long getCustomId() { - return customId; - } - - /** - * If the field is a custom field, the configuration of the field. - * - * @return _configuration configuration - */ - public Map getConfiguration() { - return configuration; - } - - @Override - public boolean equals(Object o) { - if (this - == o) { - return true; - } - if (Objects.isNull(o) || getClass() != o.getClass()) { - return false; - } - JsonTypeBean jsonTypeBean = (JsonTypeBean) o; - return Objects.equals(this.type, jsonTypeBean.type) - && Objects.equals(this.items, jsonTypeBean.items) - && Objects.equals(this.system, jsonTypeBean.system) - && Objects.equals(this.custom, jsonTypeBean.custom) - && Objects.equals(this.customId, jsonTypeBean.customId) - && Objects.equals(this.configuration, jsonTypeBean.configuration); - } - - @Override - public int hashCode() { - return Objects.hash(type, items, system, custom, customId, configuration); - } - - @Override - public String toString() { - - String sb = Constants.JSON_TYPE_BEAN + - TYPE_WITH_SPACE + toIndentedString(type) + NEW_LINE + - ITEMS_WITH_SPACE + toIndentedString(items) + NEW_LINE + - _SYSTEM + toIndentedString(system) + NEW_LINE + - CUSTOM + toIndentedString(custom) + NEW_LINE + - CUSTOM_ID + toIndentedString(customId) + NEW_LINE + - _CONFIG + toIndentedString(configuration) + NEW_LINE + - CLOSING_BRACKET; - return sb; - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first - * line). - */ - private String toIndentedString(Object o) { - if (Objects.isNull(o)) { - return Constants.PRINT_NULL; - } - return o.toString().replace(NEW_LINE, Constants.NEW_LINE_WITH_SPACE); - } -} diff --git a/data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/models/SearchResults.java b/data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/models/SearchResults.java index 976dea640b..4a20ea762f 100644 --- a/data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/models/SearchResults.java +++ b/data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/models/SearchResults.java @@ -13,23 +13,14 @@ package org.opensearch.dataprepper.plugins.source.jira.models; import com.fasterxml.jackson.annotation.JsonProperty; -import org.opensearch.dataprepper.plugins.source.jira.utils.Constants; +import lombok.Getter; import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.CLOSING_BRACKET; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.ISSUE; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.NAME; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.NEW_LINE; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.NEW_LINE_WITH_SPACE; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.PRINT_NULL; -import static org.opensearch.dataprepper.plugins.source.jira.utils.Constants.SCHEMA; /** * The result of a JQL search. */ +@Getter public class SearchResults { @JsonProperty("expand") private String expand = null; @@ -46,112 +37,4 @@ public class SearchResults { @JsonProperty("issues") private List issues = null; - @JsonProperty("warningMessages") - private List warningMessages = null; - - @JsonProperty("names") - private Map names = null; - - @JsonProperty("schema") - private Map schema = null; - - /** - * Expand options that include additional search result details in the response. - * - * @return expand expand - */ - public String getExpand() { - return expand; - } - - /** - * The index of the first item returned on the page. - * - * @return startAt start at - */ - public Integer getStartAt() { - return startAt; - } - - /** - * The maximum number of results that could be on the page. - * - * @return maxResults max results - */ - public Integer getMaxResults() { - return maxResults; - } - - /** - * The number of results on the page. - * - * @return total total - */ - public Integer getTotal() { - return total; - } - - /** - * The list of issues found by the search. - * - * @return issues issues - */ - public List getIssues() { - return issues; - } - - /** - * Any warnings related to the JQL query. - * - * @return warningMessages warning messages - */ - public List getWarningMessages() { - return warningMessages; - } - - /** - * The ID and name of each field in the search results. - * - * @return names names - */ - public Map getNames() { - return names; - } - - /** - * The schema describing the field types in the search results. - * - * @return schema schema - */ - public Map getSchema() { - return schema; - } - - - @Override - public String toString() { - - String sb = Constants.SEARCH_RESULTS + - Constants.EXPAND_WITH_SPACE + toIndentedString(expand) + NEW_LINE + - Constants.HEAD_WITH_SPACE + toIndentedString(startAt) + NEW_LINE + - Constants.MAX_RESULTS_WITH_SPACE + toIndentedString(maxResults) + NEW_LINE + - Constants.TOTAL + toIndentedString(total) + NEW_LINE + - ISSUE + toIndentedString(issues) + NEW_LINE + - Constants.WARN_MSG + toIndentedString(warningMessages) + NEW_LINE + - NAME + toIndentedString(names) + NEW_LINE + - SCHEMA + toIndentedString(schema) + NEW_LINE + - CLOSING_BRACKET; - return sb; - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first - * line). - */ - private String toIndentedString(Object o) { - if (Objects.isNull(o)) { - return PRINT_NULL; - } - return o.toString().replace(NEW_LINE, NEW_LINE_WITH_SPACE); - } } diff --git a/data-prepper-plugins/saas-source-plugins/jira-source/src/test/java/org/opensearch/dataprepper/plugins/source/jira/models/JsonTypeBeanTest.java b/data-prepper-plugins/saas-source-plugins/jira-source/src/test/java/org/opensearch/dataprepper/plugins/source/jira/models/JsonTypeBeanTest.java deleted file mode 100644 index 2854538646..0000000000 --- a/data-prepper-plugins/saas-source-plugins/jira-source/src/test/java/org/opensearch/dataprepper/plugins/source/jira/models/JsonTypeBeanTest.java +++ /dev/null @@ -1,159 +0,0 @@ -package org.opensearch.dataprepper.plugins.source.jira.models; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -@ExtendWith(MockitoExtension.class) -public class JsonTypeBeanTest { - - private final ObjectMapper objectMapper = new ObjectMapper(); - - @Mock - private Map testConfiguration; - - private JsonTypeBean jsonTypeBean; - - @BeforeEach - public void setup() throws JsonProcessingException { - String state = "{}"; - jsonTypeBean = objectMapper.readValue(state, JsonTypeBean.class); - } - - @Test - public void testConstructor() { - assertNotNull(jsonTypeBean); - - assertNull(jsonTypeBean.getType()); - assertNull(jsonTypeBean.getItems()); - assertNull(jsonTypeBean.getSystem()); - assertNull(jsonTypeBean.getCustom()); - assertNull(jsonTypeBean.getCustomId()); - assertNull(jsonTypeBean.getConfiguration()); - } - - @Test - public void testGetters() throws JsonProcessingException { - String type = "typeTest"; - String items = "itemsTest"; - String system = "systemTest"; - String custom = "customTest"; - Long customId = 123L; - Map map = new HashMap<>(); - map.put("type", type); - map.put("items", items); - map.put("system", system); - map.put("custom", custom); - map.put("customId", customId); - map.put("configuration", testConfiguration); - - String jsonString = objectMapper.writeValueAsString(map); - - jsonTypeBean = objectMapper.readValue(jsonString, JsonTypeBean.class); - - assertEquals(jsonTypeBean.getType(), type); - assertEquals(jsonTypeBean.getItems(), items); - assertEquals(jsonTypeBean.getSystem(), system); - assertEquals(jsonTypeBean.getCustom(), custom); - assertEquals(jsonTypeBean.getCustomId(), customId); - assertEquals(jsonTypeBean.getConfiguration(), testConfiguration); - } - - @Test - public void testEquals() throws JsonProcessingException { - - assertNotEquals(null, jsonTypeBean); - assertNotEquals(jsonTypeBean, new Object()); - - JsonTypeBean sameEntryBean; - JsonTypeBean differentEntryBean; - - String type = "typeTest"; - String items = "itemsTest"; - String system = "systemTest"; - String custom = "customTest"; - Long customId = 123L; - - Map map = new HashMap<>(); - map.put("type", type); - map.put("items", items); - map.put("system", system); - map.put("custom", custom); - map.put("customId", customId); - map.put("configuration", testConfiguration); - - String jsonString = objectMapper.writeValueAsString(map); - - jsonTypeBean = objectMapper.readValue(jsonString, JsonTypeBean.class); - sameEntryBean = objectMapper.readValue(jsonString, JsonTypeBean.class); - - for (String key : map.keySet()) { - String oldString = ""; - if (key.equals("customId")) { - map.put(key, 456L); - } else if (key.equals("configuration")) { - Map differentTestConfiguration = new HashMap<>(); - differentTestConfiguration.put("differentKey", new JsonTypeBean()); - map.put("configuration", differentTestConfiguration); - } else { - oldString = map.get(key).toString(); - map.put(key, "different"); - } - differentEntryBean = objectMapper.readValue(objectMapper.writeValueAsString(map), JsonTypeBean.class); - assertEquals(jsonTypeBean, sameEntryBean); - assertNotEquals(jsonTypeBean, differentEntryBean); - if (key.equals("customId")) { - map.put(key, 123); - } else if (key.equals("configuration")) { - map.put("configuration", testConfiguration); - } else { - map.put(key, oldString); - } - } - } - - @Test - public void testHashCode() throws JsonProcessingException { - assertTrue(jsonTypeBean.hashCode() > 0); - String state = "{\"type\": \"same\"}"; - String state2 = "{\"type\": \"different\"}"; - - JsonTypeBean sameEntryBean; - JsonTypeBean differentEntryBean; - - jsonTypeBean = objectMapper.readValue(state, JsonTypeBean.class); - sameEntryBean = objectMapper.readValue(state, JsonTypeBean.class); - differentEntryBean = objectMapper.readValue(state2, JsonTypeBean.class); - - assertEquals(jsonTypeBean.hashCode(), sameEntryBean.hashCode()); - assertNotEquals(jsonTypeBean.hashCode(), differentEntryBean.hashCode()); - } - - @Test - public void testToString() throws JsonProcessingException { - String state = "{\"type\": \"same\"}"; - jsonTypeBean = objectMapper.readValue(state, JsonTypeBean.class); - String jsonString = jsonTypeBean.toString(); - assertTrue(jsonString.contains(JsonTypeBean.class.getSimpleName())); - assertTrue(jsonString.contains("type: same")); - assertTrue(jsonString.contains("items: null")); - assertTrue(jsonString.contains("system")); - assertTrue(jsonString.contains("custom")); - assertTrue(jsonString.contains("customId")); - assertTrue(jsonString.contains("configuration")); - - } -} diff --git a/data-prepper-plugins/saas-source-plugins/jira-source/src/test/java/org/opensearch/dataprepper/plugins/source/jira/models/SearchResultsTest.java b/data-prepper-plugins/saas-source-plugins/jira-source/src/test/java/org/opensearch/dataprepper/plugins/source/jira/models/SearchResultsTest.java index 5762bc277b..24d42eabe3 100644 --- a/data-prepper-plugins/saas-source-plugins/jira-source/src/test/java/org/opensearch/dataprepper/plugins/source/jira/models/SearchResultsTest.java +++ b/data-prepper-plugins/saas-source-plugins/jira-source/src/test/java/org/opensearch/dataprepper/plugins/source/jira/models/SearchResultsTest.java @@ -27,9 +27,6 @@ public class SearchResultsTest { @Mock private Map names; - @Mock - private Map schema; - private SearchResults searchResults; @BeforeEach @@ -47,9 +44,6 @@ public void testConstructor() { assertNull(searchResults.getMaxResults()); assertNull(searchResults.getTotal()); assertNull(searchResults.getIssues()); - assertNull(searchResults.getWarningMessages()); - assertNull(searchResults.getNames()); - assertNull(searchResults.getSchema()); } @Test @@ -75,7 +69,6 @@ public void testGetters() throws JsonProcessingException { map.put("issues", testIssues); map.put("warningMessages", testWarnings); map.put("names", names); - map.put("schema", schema); String jsonString = objectMapper.writeValueAsString(map); @@ -85,9 +78,6 @@ public void testGetters() throws JsonProcessingException { assertEquals(searchResults.getStartAt(), startAt); assertEquals(searchResults.getMaxResults(), maxResults); assertEquals(searchResults.getTotal(), total); - assertEquals(searchResults.getWarningMessages(), testWarnings); - assertEquals(searchResults.getNames(), names); - assertEquals(searchResults.getSchema(), schema); List returnedIssues = searchResults.getIssues();