From b5308044a14428563526faf69050abf8bd2cb56d Mon Sep 17 00:00:00 2001 From: Tyshchenko Leonid <32874828+Lcarrot@users.noreply.github.com> Date: Mon, 25 Mar 2024 08:33:35 +0300 Subject: [PATCH] SetParams should implement equals and hashcode issue #2687 (#3728) --- .../clients/jedis/args/RawableFactory.java | 12 +++++ .../clients/jedis/params/BitPosParams.java | 15 ++++++ .../jedis/params/ClientKillParams.java | 14 +++++ .../params/CommandListFilterByParams.java | 15 ++++++ .../clients/jedis/params/FailoverParams.java | 15 ++++++ .../clients/jedis/params/GeoAddParams.java | 14 +++++ .../clients/jedis/params/GetExParams.java | 15 ++++++ .../redis/clients/jedis/params/LCSParams.java | 15 ++++++ .../clients/jedis/params/LPosParams.java | 14 +++++ .../clients/jedis/params/LolwutParams.java | 18 +++++++ .../clients/jedis/params/MigrateParams.java | 15 ++++++ .../jedis/params/ModuleLoadExParams.java | 14 +++++ .../clients/jedis/params/RestoreParams.java | 15 ++++++ .../clients/jedis/params/ScanParams.java | 14 +++++ .../redis/clients/jedis/params/SetParams.java | 16 ++++++ .../clients/jedis/params/ShutdownParams.java | 15 ++++++ .../clients/jedis/params/SortingParams.java | 18 +++++-- .../clients/jedis/params/XAddParams.java | 15 ++++++ .../jedis/params/XAutoClaimParams.java | 14 +++++ .../clients/jedis/params/XClaimParams.java | 15 ++++++ .../clients/jedis/params/XPendingParams.java | 15 ++++++ .../jedis/params/XReadGroupParams.java | 15 ++++++ .../clients/jedis/params/XReadParams.java | 15 ++++++ .../clients/jedis/params/XTrimParams.java | 15 ++++++ .../clients/jedis/params/ZAddParams.java | 14 +++++ .../clients/jedis/params/ZIncrByParams.java | 14 +++++ .../redis/clients/jedis/params/ZParams.java | 14 +++++ .../clients/jedis/params/ZRangeParams.java | 15 ++++++ .../jedis/params/BitPosParamsTest.java | 49 +++++++++++++++++ .../jedis/params/ClientKillParamsTest.java | 52 +++++++++++++++++++ .../params/CommandListFilterByParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/FailoverParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/GeoAddParamsTest.java | 51 ++++++++++++++++++ .../clients/jedis/params/GetExParamsTest.java | 51 ++++++++++++++++++ .../clients/jedis/params/LCSParamsTest.java | 51 ++++++++++++++++++ .../clients/jedis/params/LPosParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/LolwutParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/MigrateParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/ModuleLoadExParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/RestoreParamsTest.java | 51 ++++++++++++++++++ .../clients/jedis/params/ScanParamsTest.java | 51 ++++++++++++++++++ .../clients/jedis/params/SetParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/ShutdownParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/SortingParamsTest.java | 51 ++++++++++++++++++ .../clients/jedis/params/XAddParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/XAutoClaimParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/XClaimParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/XPendingParamsTest.java | 52 +++++++++++++++++++ .../jedis/params/XReadGroupParamsTest.java | 51 ++++++++++++++++++ .../clients/jedis/params/XReadParamsTest.java | 51 ++++++++++++++++++ .../clients/jedis/params/XTrimParamsTest.java | 51 ++++++++++++++++++ .../clients/jedis/params/ZAddParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/ZIncrByParamsTest.java | 51 ++++++++++++++++++ .../clients/jedis/params/ZParamsTest.java | 51 ++++++++++++++++++ .../jedis/params/ZRangeParamsTest.java | 51 ++++++++++++++++++ 55 files changed, 1788 insertions(+), 4 deletions(-) create mode 100644 src/test/java/redis/clients/jedis/params/BitPosParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/ClientKillParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/CommandListFilterByParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/FailoverParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/GeoAddParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/GetExParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/LCSParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/LPosParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/LolwutParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/MigrateParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/ModuleLoadExParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/RestoreParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/ScanParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/SetParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/ShutdownParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/SortingParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/XAddParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/XAutoClaimParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/XClaimParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/XPendingParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/XReadGroupParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/XReadParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/XTrimParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/ZAddParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/ZIncrByParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/ZParamsTest.java create mode 100644 src/test/java/redis/clients/jedis/params/ZRangeParamsTest.java diff --git a/src/main/java/redis/clients/jedis/args/RawableFactory.java b/src/main/java/redis/clients/jedis/args/RawableFactory.java index 90bcc3c297..8bce7f0e78 100644 --- a/src/main/java/redis/clients/jedis/args/RawableFactory.java +++ b/src/main/java/redis/clients/jedis/args/RawableFactory.java @@ -61,6 +61,18 @@ public Raw(byte[] raw) { public byte[] getRaw() { return raw; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + return Arrays.equals(raw, ((Raw) o).raw); + } + + @Override + public int hashCode() { + return Arrays.hashCode(raw); + } } /** diff --git a/src/main/java/redis/clients/jedis/params/BitPosParams.java b/src/main/java/redis/clients/jedis/params/BitPosParams.java index dc9d3ceea1..c9d3ce32dd 100644 --- a/src/main/java/redis/clients/jedis/params/BitPosParams.java +++ b/src/main/java/redis/clients/jedis/params/BitPosParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.args.BitCountOption; +import java.util.Objects; + public class BitPosParams implements IParams { private Long start; @@ -62,4 +64,17 @@ public void addParams(CommandArguments args) { } } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + BitPosParams that = (BitPosParams) o; + return Objects.equals(start, that.start) && Objects.equals(end, that.end) && Objects.equals(modifier, that.modifier); + } + + @Override + public int hashCode() { + return Objects.hash(start, end, modifier); + } } diff --git a/src/main/java/redis/clients/jedis/params/ClientKillParams.java b/src/main/java/redis/clients/jedis/params/ClientKillParams.java index 0082ef3340..997d084bdf 100644 --- a/src/main/java/redis/clients/jedis/params/ClientKillParams.java +++ b/src/main/java/redis/clients/jedis/params/ClientKillParams.java @@ -1,6 +1,7 @@ package redis.clients.jedis.params; import java.util.ArrayList; +import java.util.Objects; import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; @@ -81,4 +82,17 @@ public ClientKillParams maxAge(long maxAge) { public void addParams(CommandArguments args) { params.forEach(kv -> args.add(kv.getKey()).add(kv.getValue())); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ClientKillParams that = (ClientKillParams) o; + return Objects.equals(params, that.params); + } + + @Override + public int hashCode() { + return Objects.hash(params); + } } diff --git a/src/main/java/redis/clients/jedis/params/CommandListFilterByParams.java b/src/main/java/redis/clients/jedis/params/CommandListFilterByParams.java index cce880fada..9127670b3e 100644 --- a/src/main/java/redis/clients/jedis/params/CommandListFilterByParams.java +++ b/src/main/java/redis/clients/jedis/params/CommandListFilterByParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class CommandListFilterByParams implements IParams { private String moduleName; @@ -46,4 +48,17 @@ public void addParams(CommandArguments args) { + getClass().getSimpleName()); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CommandListFilterByParams that = (CommandListFilterByParams) o; + return Objects.equals(moduleName, that.moduleName) && Objects.equals(category, that.category) && Objects.equals(pattern, that.pattern); + } + + @Override + public int hashCode() { + return Objects.hash(moduleName, category, pattern); + } } diff --git a/src/main/java/redis/clients/jedis/params/FailoverParams.java b/src/main/java/redis/clients/jedis/params/FailoverParams.java index d1afbe368c..4219a9ff22 100644 --- a/src/main/java/redis/clients/jedis/params/FailoverParams.java +++ b/src/main/java/redis/clients/jedis/params/FailoverParams.java @@ -4,6 +4,8 @@ import redis.clients.jedis.HostAndPort; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class FailoverParams implements IParams { private HostAndPort to; @@ -59,4 +61,17 @@ public void addParams(CommandArguments args) { } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + FailoverParams that = (FailoverParams) o; + return force == that.force && Objects.equals(to, that.to) && Objects.equals(timeout, that.timeout); + } + + @Override + public int hashCode() { + return Objects.hash(to, force, timeout); + } } diff --git a/src/main/java/redis/clients/jedis/params/GeoAddParams.java b/src/main/java/redis/clients/jedis/params/GeoAddParams.java index 6dbcf99b94..633923f9b8 100644 --- a/src/main/java/redis/clients/jedis/params/GeoAddParams.java +++ b/src/main/java/redis/clients/jedis/params/GeoAddParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class GeoAddParams implements IParams { private boolean nx = false; @@ -57,4 +59,16 @@ public void addParams(CommandArguments args) { } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GeoAddParams that = (GeoAddParams) o; + return nx == that.nx && xx == that.xx && ch == that.ch; + } + + @Override + public int hashCode() { + return Objects.hash(nx, xx, ch); + } } diff --git a/src/main/java/redis/clients/jedis/params/GetExParams.java b/src/main/java/redis/clients/jedis/params/GetExParams.java index 27c875e83a..521d4c5092 100644 --- a/src/main/java/redis/clients/jedis/params/GetExParams.java +++ b/src/main/java/redis/clients/jedis/params/GetExParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class GetExParams implements IParams { private Keyword expiration; @@ -74,4 +76,17 @@ public void addParams(CommandArguments args) { } } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GetExParams that = (GetExParams) o; + return persist == that.persist && expiration == that.expiration && Objects.equals(expirationValue, that.expirationValue); + } + + @Override + public int hashCode() { + return Objects.hash(expiration, expirationValue, persist); + } } diff --git a/src/main/java/redis/clients/jedis/params/LCSParams.java b/src/main/java/redis/clients/jedis/params/LCSParams.java index be3152aefc..a1cc0a208f 100644 --- a/src/main/java/redis/clients/jedis/params/LCSParams.java +++ b/src/main/java/redis/clients/jedis/params/LCSParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class LCSParams implements IParams { private boolean len = false; @@ -65,4 +67,17 @@ public void addParams(CommandArguments args) { args.add(Keyword.WITHMATCHLEN); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + LCSParams lcsParams = (LCSParams) o; + return len == lcsParams.len && idx == lcsParams.idx && withMatchLen == lcsParams.withMatchLen && Objects.equals(minMatchLen, lcsParams.minMatchLen); + } + + @Override + public int hashCode() { + return Objects.hash(len, idx, minMatchLen, withMatchLen); + } } diff --git a/src/main/java/redis/clients/jedis/params/LPosParams.java b/src/main/java/redis/clients/jedis/params/LPosParams.java index 257e97d1ba..b13ba4f81a 100644 --- a/src/main/java/redis/clients/jedis/params/LPosParams.java +++ b/src/main/java/redis/clients/jedis/params/LPosParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class LPosParams implements IParams { private Integer rank; @@ -33,4 +35,16 @@ public void addParams(CommandArguments args) { } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + LPosParams that = (LPosParams) o; + return Objects.equals(rank, that.rank) && Objects.equals(maxlen, that.maxlen); + } + + @Override + public int hashCode() { + return Objects.hash(rank, maxlen); + } } diff --git a/src/main/java/redis/clients/jedis/params/LolwutParams.java b/src/main/java/redis/clients/jedis/params/LolwutParams.java index 9b8c996793..70fcca405c 100644 --- a/src/main/java/redis/clients/jedis/params/LolwutParams.java +++ b/src/main/java/redis/clients/jedis/params/LolwutParams.java @@ -3,6 +3,9 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Arrays; +import java.util.Objects; + public class LolwutParams implements IParams { private Integer version; @@ -33,4 +36,19 @@ public void addParams(CommandArguments args) { } } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + LolwutParams that = (LolwutParams) o; + return Objects.equals(version, that.version) && Arrays.equals(opargs, that.opargs); + } + + @Override + public int hashCode() { + int result = Objects.hash(version); + result = 31 * result + Arrays.hashCode(opargs); + return result; + } } diff --git a/src/main/java/redis/clients/jedis/params/MigrateParams.java b/src/main/java/redis/clients/jedis/params/MigrateParams.java index a75251e0e4..08a2f401c2 100644 --- a/src/main/java/redis/clients/jedis/params/MigrateParams.java +++ b/src/main/java/redis/clients/jedis/params/MigrateParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class MigrateParams implements IParams { private boolean copy = false; @@ -52,4 +54,17 @@ public void addParams(CommandArguments args) { args.add(Keyword.AUTH).add(password); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MigrateParams that = (MigrateParams) o; + return copy == that.copy && replace == that.replace && Objects.equals(username, that.username) && Objects.equals(password, that.password); + } + + @Override + public int hashCode() { + return Objects.hash(copy, replace, username, password); + } } diff --git a/src/main/java/redis/clients/jedis/params/ModuleLoadExParams.java b/src/main/java/redis/clients/jedis/params/ModuleLoadExParams.java index 9866d8f4dc..21a4f5ad83 100644 --- a/src/main/java/redis/clients/jedis/params/ModuleLoadExParams.java +++ b/src/main/java/redis/clients/jedis/params/ModuleLoadExParams.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; @@ -38,4 +39,17 @@ public void addParams(CommandArguments args) { args.add(Keyword.ARGS).addObjects(this.args); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ModuleLoadExParams that = (ModuleLoadExParams) o; + return Objects.equals(configs, that.configs) && Objects.equals(args, that.args); + } + + @Override + public int hashCode() { + return Objects.hash(configs, args); + } } diff --git a/src/main/java/redis/clients/jedis/params/RestoreParams.java b/src/main/java/redis/clients/jedis/params/RestoreParams.java index 499bad7302..5a2af6316e 100644 --- a/src/main/java/redis/clients/jedis/params/RestoreParams.java +++ b/src/main/java/redis/clients/jedis/params/RestoreParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class RestoreParams implements IParams { private boolean replace; @@ -55,4 +57,17 @@ public void addParams(CommandArguments args) { args.add(Keyword.FREQ).add(frequency); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RestoreParams that = (RestoreParams) o; + return replace == that.replace && absTtl == that.absTtl && Objects.equals(idleTime, that.idleTime) && Objects.equals(frequency, that.frequency); + } + + @Override + public int hashCode() { + return Objects.hash(replace, absTtl, idleTime, frequency); + } } diff --git a/src/main/java/redis/clients/jedis/params/ScanParams.java b/src/main/java/redis/clients/jedis/params/ScanParams.java index ad22a5778c..6fc162cf20 100644 --- a/src/main/java/redis/clients/jedis/params/ScanParams.java +++ b/src/main/java/redis/clients/jedis/params/ScanParams.java @@ -5,6 +5,7 @@ import java.nio.ByteBuffer; import java.util.EnumMap; import java.util.Map; +import java.util.Objects; import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; @@ -63,4 +64,17 @@ public String match() { return null; } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ScanParams that = (ScanParams) o; + return Objects.equals(params, that.params); + } + + @Override + public int hashCode() { + return Objects.hash(params); + } } diff --git a/src/main/java/redis/clients/jedis/params/SetParams.java b/src/main/java/redis/clients/jedis/params/SetParams.java index b0e4310327..11f368f3de 100644 --- a/src/main/java/redis/clients/jedis/params/SetParams.java +++ b/src/main/java/redis/clients/jedis/params/SetParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class SetParams implements IParams { private Keyword existance; @@ -106,4 +108,18 @@ public void addParams(CommandArguments args) { } } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SetParams setParams = (SetParams) o; + return Objects.equals(existance, setParams.existance) && Objects.equals(expiration, setParams.expiration) + && Objects.equals(expirationValue, setParams.expirationValue); + } + + @Override + public int hashCode() { + return Objects.hash(existance, expiration, expirationValue); + } } diff --git a/src/main/java/redis/clients/jedis/params/ShutdownParams.java b/src/main/java/redis/clients/jedis/params/ShutdownParams.java index 0c35943abe..d07fd26f10 100644 --- a/src/main/java/redis/clients/jedis/params/ShutdownParams.java +++ b/src/main/java/redis/clients/jedis/params/ShutdownParams.java @@ -4,6 +4,8 @@ import redis.clients.jedis.Protocol.Keyword; import redis.clients.jedis.args.SaveMode; +import java.util.Objects; + public class ShutdownParams implements IParams { private SaveMode saveMode; @@ -49,4 +51,17 @@ public void addParams(CommandArguments args) { args.add(Keyword.FORCE); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ShutdownParams that = (ShutdownParams) o; + return now == that.now && force == that.force && saveMode == that.saveMode; + } + + @Override + public int hashCode() { + return Objects.hash(saveMode, now, force); + } } diff --git a/src/main/java/redis/clients/jedis/params/SortingParams.java b/src/main/java/redis/clients/jedis/params/SortingParams.java index 6762acf301..ad9b596bc0 100644 --- a/src/main/java/redis/clients/jedis/params/SortingParams.java +++ b/src/main/java/redis/clients/jedis/params/SortingParams.java @@ -1,9 +1,6 @@ package redis.clients.jedis.params; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; +import java.util.*; import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol; @@ -163,4 +160,17 @@ public SortingParams get(byte[]... patterns) { public void addParams(CommandArguments args) { args.addObjects(params); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SortingParams that = (SortingParams) o; + return Objects.equals(params, that.params); + } + + @Override + public int hashCode() { + return Objects.hash(params); + } } diff --git a/src/main/java/redis/clients/jedis/params/XAddParams.java b/src/main/java/redis/clients/jedis/params/XAddParams.java index 8c8d09141d..3575c6e5d2 100644 --- a/src/main/java/redis/clients/jedis/params/XAddParams.java +++ b/src/main/java/redis/clients/jedis/params/XAddParams.java @@ -7,6 +7,8 @@ import redis.clients.jedis.args.Rawable; import redis.clients.jedis.args.RawableFactory; +import java.util.Objects; + public class XAddParams implements IParams { private Rawable id; @@ -114,4 +116,17 @@ public void addParams(CommandArguments args) { args.add(id != null ? id : StreamEntryID.NEW_ENTRY); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + XAddParams that = (XAddParams) o; + return approximateTrimming == that.approximateTrimming && exactTrimming == that.exactTrimming && nomkstream == that.nomkstream && Objects.equals(id, that.id) && Objects.equals(maxLen, that.maxLen) && Objects.equals(minId, that.minId) && Objects.equals(limit, that.limit); + } + + @Override + public int hashCode() { + return Objects.hash(id, maxLen, approximateTrimming, exactTrimming, nomkstream, minId, limit); + } } diff --git a/src/main/java/redis/clients/jedis/params/XAutoClaimParams.java b/src/main/java/redis/clients/jedis/params/XAutoClaimParams.java index ce20d8652d..3834dd3804 100644 --- a/src/main/java/redis/clients/jedis/params/XAutoClaimParams.java +++ b/src/main/java/redis/clients/jedis/params/XAutoClaimParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class XAutoClaimParams implements IParams { private Integer count; @@ -31,4 +33,16 @@ public void addParams(CommandArguments args) { } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + XAutoClaimParams that = (XAutoClaimParams) o; + return Objects.equals(count, that.count); + } + + @Override + public int hashCode() { + return Objects.hash(count); + } } diff --git a/src/main/java/redis/clients/jedis/params/XClaimParams.java b/src/main/java/redis/clients/jedis/params/XClaimParams.java index 977e825ff2..944e57087d 100644 --- a/src/main/java/redis/clients/jedis/params/XClaimParams.java +++ b/src/main/java/redis/clients/jedis/params/XClaimParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class XClaimParams implements IParams { private Long idleTime; @@ -72,4 +74,17 @@ public void addParams(CommandArguments args) { args.add(Keyword.FORCE); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + XClaimParams that = (XClaimParams) o; + return force == that.force && Objects.equals(idleTime, that.idleTime) && Objects.equals(idleUnixTime, that.idleUnixTime) && Objects.equals(retryCount, that.retryCount); + } + + @Override + public int hashCode() { + return Objects.hash(idleTime, idleUnixTime, retryCount, force); + } } diff --git a/src/main/java/redis/clients/jedis/params/XPendingParams.java b/src/main/java/redis/clients/jedis/params/XPendingParams.java index 5985ed3f7e..647aa1e952 100644 --- a/src/main/java/redis/clients/jedis/params/XPendingParams.java +++ b/src/main/java/redis/clients/jedis/params/XPendingParams.java @@ -7,6 +7,8 @@ import redis.clients.jedis.StreamEntryID; import redis.clients.jedis.args.Rawable; +import java.util.Objects; + public class XPendingParams implements IParams { private Long idle; @@ -103,4 +105,17 @@ public void addParams(CommandArguments args) { args.add(consumer); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + XPendingParams that = (XPendingParams) o; + return Objects.equals(idle, that.idle) && Objects.equals(start, that.start) && Objects.equals(end, that.end) && Objects.equals(count, that.count) && Objects.equals(consumer, that.consumer); + } + + @Override + public int hashCode() { + return Objects.hash(idle, start, end, count, consumer); + } } diff --git a/src/main/java/redis/clients/jedis/params/XReadGroupParams.java b/src/main/java/redis/clients/jedis/params/XReadGroupParams.java index 07f878fb99..a761f166b2 100644 --- a/src/main/java/redis/clients/jedis/params/XReadGroupParams.java +++ b/src/main/java/redis/clients/jedis/params/XReadGroupParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class XReadGroupParams implements IParams { private Integer count = null; @@ -40,4 +42,17 @@ public void addParams(CommandArguments args) { args.add(Keyword.NOACK); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + XReadGroupParams that = (XReadGroupParams) o; + return noack == that.noack && Objects.equals(count, that.count) && Objects.equals(block, that.block); + } + + @Override + public int hashCode() { + return Objects.hash(count, block, noack); + } } diff --git a/src/main/java/redis/clients/jedis/params/XReadParams.java b/src/main/java/redis/clients/jedis/params/XReadParams.java index a64d3c1afa..3c19446e78 100644 --- a/src/main/java/redis/clients/jedis/params/XReadParams.java +++ b/src/main/java/redis/clients/jedis/params/XReadParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class XReadParams implements IParams { private Integer count = null; @@ -31,4 +33,17 @@ public void addParams(CommandArguments args) { args.add(Keyword.BLOCK).add(block).blocking(); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + XReadParams that = (XReadParams) o; + return Objects.equals(count, that.count) && Objects.equals(block, that.block); + } + + @Override + public int hashCode() { + return Objects.hash(count, block); + } } diff --git a/src/main/java/redis/clients/jedis/params/XTrimParams.java b/src/main/java/redis/clients/jedis/params/XTrimParams.java index a7c7a05562..af77ba81b3 100644 --- a/src/main/java/redis/clients/jedis/params/XTrimParams.java +++ b/src/main/java/redis/clients/jedis/params/XTrimParams.java @@ -4,6 +4,8 @@ import redis.clients.jedis.Protocol; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class XTrimParams implements IParams { private Long maxLen; @@ -74,4 +76,17 @@ public void addParams(CommandArguments args) { args.add(Keyword.LIMIT).add(limit); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + XTrimParams that = (XTrimParams) o; + return approximateTrimming == that.approximateTrimming && exactTrimming == that.exactTrimming && Objects.equals(maxLen, that.maxLen) && Objects.equals(minId, that.minId) && Objects.equals(limit, that.limit); + } + + @Override + public int hashCode() { + return Objects.hash(maxLen, approximateTrimming, exactTrimming, minId, limit); + } } diff --git a/src/main/java/redis/clients/jedis/params/ZAddParams.java b/src/main/java/redis/clients/jedis/params/ZAddParams.java index 8194c041a6..8781e3e87b 100644 --- a/src/main/java/redis/clients/jedis/params/ZAddParams.java +++ b/src/main/java/redis/clients/jedis/params/ZAddParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + public class ZAddParams implements IParams { private Keyword existence; @@ -75,4 +77,16 @@ public void addParams(CommandArguments args) { } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ZAddParams that = (ZAddParams) o; + return change == that.change && existence == that.existence && comparison == that.comparison; + } + + @Override + public int hashCode() { + return Objects.hash(existence, comparison, change); + } } diff --git a/src/main/java/redis/clients/jedis/params/ZIncrByParams.java b/src/main/java/redis/clients/jedis/params/ZIncrByParams.java index 6d5b5a411d..cc0ebb6d3f 100644 --- a/src/main/java/redis/clients/jedis/params/ZIncrByParams.java +++ b/src/main/java/redis/clients/jedis/params/ZIncrByParams.java @@ -3,6 +3,8 @@ import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; +import java.util.Objects; + /** * Parameters for ZINCRBY commands. In fact, Redis doesn't have parameters for ZINCRBY. Instead * Redis has INCR parameter for ZADD. @@ -51,4 +53,16 @@ public void addParams(CommandArguments args) { args.add(Keyword.INCR); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ZIncrByParams that = (ZIncrByParams) o; + return existance == that.existance; + } + + @Override + public int hashCode() { + return Objects.hash(existance); + } } diff --git a/src/main/java/redis/clients/jedis/params/ZParams.java b/src/main/java/redis/clients/jedis/params/ZParams.java index ea45cc9327..15f2b35ea2 100644 --- a/src/main/java/redis/clients/jedis/params/ZParams.java +++ b/src/main/java/redis/clients/jedis/params/ZParams.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import redis.clients.jedis.CommandArguments; import redis.clients.jedis.Protocol.Keyword; @@ -46,4 +47,17 @@ public ZParams aggregate(final Aggregate aggregate) { public void addParams(CommandArguments args) { args.addObjects(params); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ZParams zParams = (ZParams) o; + return Objects.equals(params, zParams.params); + } + + @Override + public int hashCode() { + return Objects.hash(params); + } } diff --git a/src/main/java/redis/clients/jedis/params/ZRangeParams.java b/src/main/java/redis/clients/jedis/params/ZRangeParams.java index 7d990c6198..fc73c9141e 100644 --- a/src/main/java/redis/clients/jedis/params/ZRangeParams.java +++ b/src/main/java/redis/clients/jedis/params/ZRangeParams.java @@ -8,6 +8,8 @@ import redis.clients.jedis.Protocol.Keyword; import redis.clients.jedis.args.Rawable; +import java.util.Objects; + public class ZRangeParams implements IParams { private final Keyword by; @@ -98,4 +100,17 @@ public void addParams(CommandArguments args) { args.add(Keyword.LIMIT).add(offset).add(count); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ZRangeParams that = (ZRangeParams) o; + return rev == that.rev && limit == that.limit && offset == that.offset && count == that.count && by == that.by && Objects.equals(min, that.min) && Objects.equals(max, that.max); + } + + @Override + public int hashCode() { + return Objects.hash(by, min, max, rev, limit, offset, count); + } } diff --git a/src/test/java/redis/clients/jedis/params/BitPosParamsTest.java b/src/test/java/redis/clients/jedis/params/BitPosParamsTest.java new file mode 100644 index 0000000000..4a38018c36 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/BitPosParamsTest.java @@ -0,0 +1,49 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class BitPosParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + BitPosParams firstParam = getDefaultValue(); + BitPosParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + BitPosParams firstParam = getDefaultValue(); + BitPosParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + BitPosParams firstParam = getDefaultValue(); + BitPosParams secondParam = getDefaultValue(); + secondParam.end(15); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + BitPosParams firstParam = getDefaultValue(); + BitPosParams secondParam = getDefaultValue(); + secondParam.start(15); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + BitPosParams firstParam = getDefaultValue(); + BitPosParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private BitPosParams getDefaultValue() { + return new BitPosParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/ClientKillParamsTest.java b/src/test/java/redis/clients/jedis/params/ClientKillParamsTest.java new file mode 100644 index 0000000000..6a9a75c8d8 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/ClientKillParamsTest.java @@ -0,0 +1,52 @@ +package redis.clients.jedis.params; + +import org.junit.Test; +import redis.clients.jedis.args.ClientType; + +import static org.junit.Assert.*; + +public class ClientKillParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + ClientKillParams firstParam = getDefaultValue(); + ClientKillParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + ClientKillParams firstParam = getDefaultValue(); + ClientKillParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + ClientKillParams firstParam = getDefaultValue(); + firstParam.type(ClientType.NORMAL); + ClientKillParams secondParam = getDefaultValue(); + secondParam.skipMe(ClientKillParams.SkipMe.NO); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + ClientKillParams firstParam = getDefaultValue(); + firstParam.type(ClientType.NORMAL); + ClientKillParams secondParam = getDefaultValue(); + secondParam.skipMe(ClientKillParams.SkipMe.NO); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + ClientKillParams firstParam = getDefaultValue(); + ClientKillParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private ClientKillParams getDefaultValue() { + return new ClientKillParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/CommandListFilterByParamsTest.java b/src/test/java/redis/clients/jedis/params/CommandListFilterByParamsTest.java new file mode 100644 index 0000000000..dff749febc --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/CommandListFilterByParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class CommandListFilterByParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + CommandListFilterByParams firstParam = getDefaultValue(); + CommandListFilterByParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + CommandListFilterByParams firstParam = getDefaultValue(); + CommandListFilterByParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + CommandListFilterByParams firstParam = getDefaultValue(); + firstParam.filterByAclCat("admin"); + CommandListFilterByParams secondParam = getDefaultValue(); + secondParam.filterByModule("JSON"); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + CommandListFilterByParams firstParam = getDefaultValue(); + firstParam.filterByAclCat("admin"); + CommandListFilterByParams secondParam = getDefaultValue(); + secondParam.filterByModule("JSON"); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + CommandListFilterByParams firstParam = getDefaultValue(); + CommandListFilterByParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private CommandListFilterByParams getDefaultValue() { + return new CommandListFilterByParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/FailoverParamsTest.java b/src/test/java/redis/clients/jedis/params/FailoverParamsTest.java new file mode 100644 index 0000000000..80d9bb1137 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/FailoverParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class FailoverParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + FailoverParams firstParam = getDefaultValue(); + FailoverParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + FailoverParams firstParam = getDefaultValue(); + FailoverParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + FailoverParams firstParam = getDefaultValue(); + firstParam.timeout(15); + FailoverParams secondParam = getDefaultValue(); + secondParam.timeout(20); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + FailoverParams firstParam = getDefaultValue(); + firstParam.timeout(15); + FailoverParams secondParam = getDefaultValue(); + secondParam.timeout(20); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + FailoverParams firstParam = getDefaultValue(); + FailoverParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private FailoverParams getDefaultValue() { + return new FailoverParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/GeoAddParamsTest.java b/src/test/java/redis/clients/jedis/params/GeoAddParamsTest.java new file mode 100644 index 0000000000..cf3b5a3305 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/GeoAddParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class GeoAddParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + GeoAddParams firstParam = getDefaultValue(); + GeoAddParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + GeoAddParams firstParam = getDefaultValue(); + GeoAddParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + GeoAddParams firstParam = getDefaultValue(); + firstParam.nx(); + GeoAddParams secondParam = getDefaultValue(); + secondParam.xx(); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + GeoAddParams firstParam = getDefaultValue(); + firstParam.nx(); + GeoAddParams secondParam = getDefaultValue(); + secondParam.xx(); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + GeoAddParams firstParam = getDefaultValue(); + GeoAddParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private GeoAddParams getDefaultValue() { + return new GeoAddParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/GetExParamsTest.java b/src/test/java/redis/clients/jedis/params/GetExParamsTest.java new file mode 100644 index 0000000000..0774bfde54 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/GetExParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class GetExParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + GetExParams firstParam = getDefaultValue(); + GetExParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + GetExParams firstParam = getDefaultValue(); + GetExParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + GetExParams firstParam = getDefaultValue(); + firstParam.ex(15); + GetExParams secondParam = getDefaultValue(); + secondParam.px(20); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + GetExParams firstParam = getDefaultValue(); + firstParam.ex(15); + GetExParams secondParam = getDefaultValue(); + secondParam.px(20); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + GetExParams firstParam = getDefaultValue(); + GetExParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private GetExParams getDefaultValue() { + return new GetExParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/LCSParamsTest.java b/src/test/java/redis/clients/jedis/params/LCSParamsTest.java new file mode 100644 index 0000000000..a3f759304c --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/LCSParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class LCSParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + LCSParams firstParam = getDefaultValue(); + LCSParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + LCSParams firstParam = getDefaultValue(); + LCSParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + LCSParams firstParam = getDefaultValue(); + firstParam.idx(); + LCSParams secondParam = getDefaultValue(); + secondParam.len(); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + LCSParams firstParam = getDefaultValue(); + firstParam.idx(); + LCSParams secondParam = getDefaultValue(); + secondParam.len(); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + LCSParams firstParam = getDefaultValue(); + LCSParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private LCSParams getDefaultValue() { + return new LCSParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/LPosParamsTest.java b/src/test/java/redis/clients/jedis/params/LPosParamsTest.java new file mode 100644 index 0000000000..73e23b7798 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/LPosParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class LPosParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + LPosParams firstParam = getDefaultValue(); + LPosParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + LPosParams firstParam = getDefaultValue(); + LPosParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + LPosParams firstParam = getDefaultValue(); + firstParam.rank(1); + LPosParams secondParam = getDefaultValue(); + secondParam.rank(2); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + LPosParams firstParam = getDefaultValue(); + firstParam.rank(1); + LPosParams secondParam = getDefaultValue(); + secondParam.rank(2); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + LPosParams firstParam = getDefaultValue(); + LPosParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private LPosParams getDefaultValue() { + return new LPosParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/LolwutParamsTest.java b/src/test/java/redis/clients/jedis/params/LolwutParamsTest.java new file mode 100644 index 0000000000..0e49f8686c --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/LolwutParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class LolwutParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + LolwutParams firstParam = getDefaultValue(); + LolwutParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + LolwutParams firstParam = getDefaultValue(); + LolwutParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + LolwutParams firstParam = getDefaultValue(); + firstParam.version(1); + LolwutParams secondParam = getDefaultValue(); + secondParam.version(2); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + LolwutParams firstParam = getDefaultValue(); + firstParam.version(1); + LolwutParams secondParam = getDefaultValue(); + secondParam.version(2); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + LolwutParams firstParam = getDefaultValue(); + LolwutParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private LolwutParams getDefaultValue() { + return new LolwutParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/MigrateParamsTest.java b/src/test/java/redis/clients/jedis/params/MigrateParamsTest.java new file mode 100644 index 0000000000..eab24f6f71 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/MigrateParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class MigrateParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + MigrateParams firstParam = getDefaultValue(); + MigrateParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + MigrateParams firstParam = getDefaultValue(); + MigrateParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + MigrateParams firstParam = getDefaultValue(); + firstParam.auth("123"); + MigrateParams secondParam = getDefaultValue(); + secondParam.auth("234"); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + MigrateParams firstParam = getDefaultValue(); + firstParam.auth("123"); + MigrateParams secondParam = getDefaultValue(); + secondParam.auth("234"); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + MigrateParams firstParam = getDefaultValue(); + MigrateParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private MigrateParams getDefaultValue() { + return new MigrateParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/ModuleLoadExParamsTest.java b/src/test/java/redis/clients/jedis/params/ModuleLoadExParamsTest.java new file mode 100644 index 0000000000..08f8034bd2 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/ModuleLoadExParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ModuleLoadExParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + ModuleLoadExParams firstParam = getDefaultValue(); + ModuleLoadExParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + ModuleLoadExParams firstParam = getDefaultValue(); + ModuleLoadExParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + ModuleLoadExParams firstParam = getDefaultValue(); + firstParam.arg("123"); + ModuleLoadExParams secondParam = getDefaultValue(); + secondParam.arg("234"); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + ModuleLoadExParams firstParam = getDefaultValue(); + firstParam.arg("123"); + ModuleLoadExParams secondParam = getDefaultValue(); + secondParam.arg("234"); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + ModuleLoadExParams firstParam = getDefaultValue(); + ModuleLoadExParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private ModuleLoadExParams getDefaultValue() { + return new ModuleLoadExParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/RestoreParamsTest.java b/src/test/java/redis/clients/jedis/params/RestoreParamsTest.java new file mode 100644 index 0000000000..05f328bc41 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/RestoreParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class RestoreParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + RestoreParams firstParam = getDefaultValue(); + RestoreParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + RestoreParams firstParam = getDefaultValue(); + RestoreParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + RestoreParams firstParam = getDefaultValue(); + firstParam.idleTime(14); + RestoreParams secondParam = getDefaultValue(); + secondParam.idleTime(15); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + RestoreParams firstParam = getDefaultValue(); + firstParam.idleTime(14); + RestoreParams secondParam = getDefaultValue(); + secondParam.idleTime(15); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + RestoreParams firstParam = getDefaultValue(); + RestoreParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private RestoreParams getDefaultValue() { + return new RestoreParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/ScanParamsTest.java b/src/test/java/redis/clients/jedis/params/ScanParamsTest.java new file mode 100644 index 0000000000..111f953b2f --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/ScanParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ScanParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + ScanParams firstParam = getDefaultValue(); + ScanParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + ScanParams firstParam = getDefaultValue(); + ScanParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + ScanParams firstParam = getDefaultValue(); + firstParam.count(15); + ScanParams secondParam = getDefaultValue(); + secondParam.count(16); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + ScanParams firstParam = getDefaultValue(); + firstParam.count(15); + ScanParams secondParam = getDefaultValue(); + secondParam.count(16); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + ScanParams firstParam = getDefaultValue(); + ScanParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private ScanParams getDefaultValue() { + return new ScanParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/SetParamsTest.java b/src/test/java/redis/clients/jedis/params/SetParamsTest.java new file mode 100644 index 0000000000..14b81deeb4 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/SetParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class SetParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + SetParams firstParam = getDefaultValue(); + SetParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + SetParams firstParam = getDefaultValue(); + SetParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + SetParams firstParam = getDefaultValue(); + firstParam.nx(); + SetParams secondParam = getDefaultValue(); + secondParam.xx(); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + SetParams firstParam = getDefaultValue(); + firstParam.nx(); + SetParams secondParam = getDefaultValue(); + secondParam.xx(); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + SetParams firstParam = getDefaultValue(); + SetParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private SetParams getDefaultValue() { + return new SetParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/ShutdownParamsTest.java b/src/test/java/redis/clients/jedis/params/ShutdownParamsTest.java new file mode 100644 index 0000000000..625e98b295 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/ShutdownParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ShutdownParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + ShutdownParams firstParam = getDefaultValue(); + ShutdownParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + ShutdownParams firstParam = getDefaultValue(); + ShutdownParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + ShutdownParams firstParam = getDefaultValue(); + firstParam.force(); + ShutdownParams secondParam = getDefaultValue(); + secondParam.nosave(); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + ShutdownParams firstParam = getDefaultValue(); + firstParam.force(); + ShutdownParams secondParam = getDefaultValue(); + secondParam.nosave(); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + ShutdownParams firstParam = getDefaultValue(); + ShutdownParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private ShutdownParams getDefaultValue() { + return new ShutdownParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/SortingParamsTest.java b/src/test/java/redis/clients/jedis/params/SortingParamsTest.java new file mode 100644 index 0000000000..a66669584f --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/SortingParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class SortingParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + SortingParams firstParam = getDefaultValue(); + SortingParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + SortingParams firstParam = getDefaultValue(); + SortingParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + SortingParams firstParam = getDefaultValue(); + firstParam.limit(15, 20); + SortingParams secondParam = getDefaultValue(); + secondParam.limit(10, 15); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + SortingParams firstParam = getDefaultValue(); + firstParam.limit(15, 20); + SortingParams secondParam = getDefaultValue(); + secondParam.limit(10, 15); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + SortingParams firstParam = getDefaultValue(); + SortingParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private SortingParams getDefaultValue() { + return new SortingParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/XAddParamsTest.java b/src/test/java/redis/clients/jedis/params/XAddParamsTest.java new file mode 100644 index 0000000000..db3cac5e56 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/XAddParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class XAddParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + XAddParams firstParam = getDefaultValue(); + XAddParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + XAddParams firstParam = getDefaultValue(); + XAddParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + XAddParams firstParam = getDefaultValue(); + firstParam.id(15); + XAddParams secondParam = getDefaultValue(); + secondParam.id(20); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + XAddParams firstParam = getDefaultValue(); + firstParam.id(15); + XAddParams secondParam = getDefaultValue(); + secondParam.id(20); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + XAddParams firstParam = getDefaultValue(); + XAddParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private XAddParams getDefaultValue() { + return new XAddParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/XAutoClaimParamsTest.java b/src/test/java/redis/clients/jedis/params/XAutoClaimParamsTest.java new file mode 100644 index 0000000000..eeb9aeb38a --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/XAutoClaimParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class XAutoClaimParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + XAutoClaimParams firstParam = getDefaultValue(); + XAutoClaimParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + XAutoClaimParams firstParam = getDefaultValue(); + XAutoClaimParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + XAutoClaimParams firstParam = getDefaultValue(); + firstParam.count(15); + XAutoClaimParams secondParam = getDefaultValue(); + secondParam.count(20); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + XAutoClaimParams firstParam = getDefaultValue(); + firstParam.count(15); + XAutoClaimParams secondParam = getDefaultValue(); + secondParam.count(20); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + XAutoClaimParams firstParam = getDefaultValue(); + XAutoClaimParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private XAutoClaimParams getDefaultValue() { + return new XAutoClaimParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/XClaimParamsTest.java b/src/test/java/redis/clients/jedis/params/XClaimParamsTest.java new file mode 100644 index 0000000000..1cef5b8dbe --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/XClaimParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class XClaimParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + XClaimParams firstParam = getDefaultValue(); + XClaimParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + XClaimParams firstParam = getDefaultValue(); + XClaimParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + XClaimParams firstParam = getDefaultValue(); + firstParam.time(20); + XClaimParams secondParam = getDefaultValue(); + secondParam.time(21); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + XClaimParams firstParam = getDefaultValue(); + firstParam.time(20); + XClaimParams secondParam = getDefaultValue(); + secondParam.time(21); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + XClaimParams firstParam = getDefaultValue(); + XClaimParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private XClaimParams getDefaultValue() { + return new XClaimParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/XPendingParamsTest.java b/src/test/java/redis/clients/jedis/params/XPendingParamsTest.java new file mode 100644 index 0000000000..b6698d875f --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/XPendingParamsTest.java @@ -0,0 +1,52 @@ +package redis.clients.jedis.params; + +import org.junit.Test; +import redis.clients.jedis.StreamEntryID; + +import static org.junit.Assert.*; + +public class XPendingParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + XPendingParams firstParam = getDefaultValue(); + XPendingParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + XPendingParams firstParam = getDefaultValue(); + XPendingParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + XPendingParams firstParam = getDefaultValue(); + firstParam.start(StreamEntryID.LAST_ENTRY); + XPendingParams secondParam = getDefaultValue(); + secondParam.start(StreamEntryID.NEW_ENTRY); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + XPendingParams firstParam = getDefaultValue(); + firstParam.start(StreamEntryID.LAST_ENTRY); + XPendingParams secondParam = getDefaultValue(); + secondParam.start(StreamEntryID.NEW_ENTRY); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + XPendingParams firstParam = getDefaultValue(); + XPendingParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private XPendingParams getDefaultValue() { + return new XPendingParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/XReadGroupParamsTest.java b/src/test/java/redis/clients/jedis/params/XReadGroupParamsTest.java new file mode 100644 index 0000000000..a489d50648 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/XReadGroupParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class XReadGroupParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + XReadGroupParams firstParam = getDefaultValue(); + XReadGroupParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + XReadGroupParams firstParam = getDefaultValue(); + XReadGroupParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + XReadGroupParams firstParam = getDefaultValue(); + firstParam.block(14); + XReadGroupParams secondParam = getDefaultValue(); + secondParam.block(15); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + XReadGroupParams firstParam = getDefaultValue(); + firstParam.block(14); + XReadGroupParams secondParam = getDefaultValue(); + secondParam.block(15); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + XReadGroupParams firstParam = getDefaultValue(); + XReadGroupParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private XReadGroupParams getDefaultValue() { + return new XReadGroupParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/XReadParamsTest.java b/src/test/java/redis/clients/jedis/params/XReadParamsTest.java new file mode 100644 index 0000000000..d3277cd70f --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/XReadParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class XReadParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + XReadParams firstParam = getDefaultValue(); + XReadParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + XReadParams firstParam = getDefaultValue(); + XReadParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + XReadParams firstParam = getDefaultValue(); + firstParam.block(14); + XReadParams secondParam = getDefaultValue(); + secondParam.block(15); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + XReadParams firstParam = getDefaultValue(); + firstParam.block(14); + XReadParams secondParam = getDefaultValue(); + secondParam.block(15); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + XReadParams firstParam = getDefaultValue(); + XReadParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private XReadParams getDefaultValue() { + return new XReadParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/XTrimParamsTest.java b/src/test/java/redis/clients/jedis/params/XTrimParamsTest.java new file mode 100644 index 0000000000..dcd344816d --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/XTrimParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class XTrimParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + XTrimParams firstParam = getDefaultValue(); + XTrimParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + XTrimParams firstParam = getDefaultValue(); + XTrimParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + XTrimParams firstParam = getDefaultValue(); + firstParam.maxLen(15); + XTrimParams secondParam = getDefaultValue(); + secondParam.maxLen(16); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + XTrimParams firstParam = getDefaultValue(); + firstParam.maxLen(15); + XTrimParams secondParam = getDefaultValue(); + secondParam.maxLen(16); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + XTrimParams firstParam = getDefaultValue(); + XTrimParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private XTrimParams getDefaultValue() { + return new XTrimParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/ZAddParamsTest.java b/src/test/java/redis/clients/jedis/params/ZAddParamsTest.java new file mode 100644 index 0000000000..5d3148e415 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/ZAddParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ZAddParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + ZAddParams firstParam = getDefaultValue(); + ZAddParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + ZAddParams firstParam = getDefaultValue(); + ZAddParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + ZAddParams firstParam = getDefaultValue(); + firstParam.nx(); + ZAddParams secondParam = getDefaultValue(); + secondParam.xx(); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + ZAddParams firstParam = getDefaultValue(); + firstParam.nx(); + ZAddParams secondParam = getDefaultValue(); + secondParam.xx(); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + ZAddParams firstParam = getDefaultValue(); + ZAddParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private ZAddParams getDefaultValue() { + return new ZAddParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/ZIncrByParamsTest.java b/src/test/java/redis/clients/jedis/params/ZIncrByParamsTest.java new file mode 100644 index 0000000000..7e68e93cbe --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/ZIncrByParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ZIncrByParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + ZIncrByParams firstParam = getDefaultValue(); + ZIncrByParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + ZIncrByParams firstParam = getDefaultValue(); + ZIncrByParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + ZIncrByParams firstParam = getDefaultValue(); + firstParam.nx(); + ZIncrByParams secondParam = getDefaultValue(); + secondParam.xx(); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + ZIncrByParams firstParam = getDefaultValue(); + firstParam.nx(); + ZIncrByParams secondParam = getDefaultValue(); + secondParam.xx(); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + ZIncrByParams firstParam = getDefaultValue(); + ZIncrByParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private ZIncrByParams getDefaultValue() { + return new ZIncrByParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/ZParamsTest.java b/src/test/java/redis/clients/jedis/params/ZParamsTest.java new file mode 100644 index 0000000000..902748a054 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/ZParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ZParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + ZParams firstParam = getDefaultValue(); + ZParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + ZParams firstParam = getDefaultValue(); + ZParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + ZParams firstParam = getDefaultValue(); + firstParam.aggregate(ZParams.Aggregate.MIN); + ZParams secondParam = getDefaultValue(); + secondParam.aggregate(ZParams.Aggregate.MAX); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + ZParams firstParam = getDefaultValue(); + firstParam.aggregate(ZParams.Aggregate.MIN); + ZParams secondParam = getDefaultValue(); + secondParam.aggregate(ZParams.Aggregate.MAX); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + ZParams firstParam = getDefaultValue(); + ZParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private ZParams getDefaultValue() { + return new ZParams(); + } +} diff --git a/src/test/java/redis/clients/jedis/params/ZRangeParamsTest.java b/src/test/java/redis/clients/jedis/params/ZRangeParamsTest.java new file mode 100644 index 0000000000..a2f5e02105 --- /dev/null +++ b/src/test/java/redis/clients/jedis/params/ZRangeParamsTest.java @@ -0,0 +1,51 @@ +package redis.clients.jedis.params; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ZRangeParamsTest { + + @Test + public void checkEqualsIdenticalParams() { + ZRangeParams firstParam = getDefaultValue(); + ZRangeParams secondParam = getDefaultValue(); + assertTrue(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeIdenticalParams() { + ZRangeParams firstParam = getDefaultValue(); + ZRangeParams secondParam = getDefaultValue(); + assertEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsVariousParams() { + ZRangeParams firstParam = getDefaultValue(); + firstParam.limit(15, 20); + ZRangeParams secondParam = getDefaultValue(); + secondParam.limit(16, 21); + assertFalse(firstParam.equals(secondParam)); + } + + @Test + public void checkHashCodeVariousParams() { + ZRangeParams firstParam = getDefaultValue(); + firstParam.limit(15, 20); + ZRangeParams secondParam = getDefaultValue(); + secondParam.limit(16, 21); + assertNotEquals(firstParam.hashCode(), secondParam.hashCode()); + } + + @Test + public void checkEqualsWithNull() { + ZRangeParams firstParam = getDefaultValue(); + ZRangeParams secondParam = null; + assertFalse(firstParam.equals(secondParam)); + } + + private ZRangeParams getDefaultValue() { + return new ZRangeParams(0, 0); + } +}