Fixed tests and fixed failed tests
This commit is contained in:
parent
01456bfc9f
commit
8825f4b3cc
|
|
@ -25,13 +25,13 @@ public class Lock implements Comparable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean equals(@Nullable Object o) {
|
public final boolean equals(@Nullable Object o) {
|
||||||
if (this == o) {
|
Lock other = (Lock) o;
|
||||||
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (other == null || getClass() != other.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Lock other = (Lock) o;
|
|
||||||
return data.equals(other.data) && serverHash == other.serverHash;
|
return data.equals(other.data) && serverHash == other.serverHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,6 +43,10 @@ public class Lock implements Comparable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(@NotNull Object o) {
|
public int compareTo(@NotNull Object o) {
|
||||||
return ((Lock) o).data.compareTo(data);
|
Lock lock = (Lock) o;
|
||||||
|
int data = lock.data.compareTo(this.data);
|
||||||
|
if (data != 0)
|
||||||
|
return data;
|
||||||
|
return Integer.compare(lock.getServerHash(), getServerHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,16 @@ class LockTest {
|
||||||
|
|
||||||
@org.junit.jupiter.api.Test
|
@org.junit.jupiter.api.Test
|
||||||
void testEquals() {
|
void testEquals() {
|
||||||
assertEquals(new Lock(123, "test"), new Lock(123, "test"));
|
assertTrue(new Lock(123, "test").equals(new Lock(123, "test")));
|
||||||
assertNotEquals(new Lock(123, "test1"), new Lock(123, "test2"));
|
assertFalse(new Lock(123, "test1").equals(new Lock(123, "test2")));
|
||||||
assertEquals(new Lock(123, "test"), new Lock(-123, "test"));
|
assertFalse(new Lock(123, "test").equals(new Lock(-123, "test")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@org.junit.jupiter.api.Test
|
@org.junit.jupiter.api.Test
|
||||||
void testHashCode() {
|
void testHashCode() {
|
||||||
assertEquals(new Lock(123, "test").hashCode(), new Lock(123, "test").hashCode());
|
assertEquals(new Lock(123, "test").hashCode(), new Lock(123, "test").hashCode());
|
||||||
assertNotEquals(new Lock(123, "test1").hashCode(), new Lock(123, "test2").hashCode());
|
assertNotEquals(new Lock(123, "test1").hashCode(), new Lock(123, "test2").hashCode());
|
||||||
assertEquals(new Lock(123, "test").hashCode(), new Lock(-123, "test").hashCode());
|
assertNotEquals(new Lock(123, "test").hashCode(), new Lock(-123, "test").hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@org.junit.jupiter.api.Test
|
@org.junit.jupiter.api.Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user