Skip to content

Commit

Permalink
Simplify assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Feb 1, 2021
1 parent c704713 commit 85ee212
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -174,8 +175,8 @@ void sameEnginesAreEqual() {
var id1 = UniqueId.root("engine", "junit-jupiter");
var id2 = UniqueId.root("engine", "junit-jupiter");

assertTrue(id1.equals(id2));
assertTrue(id2.equals(id1));
assertEquals(id2, id1);
assertEquals(id1, id2);
assertEquals(id1.hashCode(), id2.hashCode());
}

Expand All @@ -184,17 +185,17 @@ void differentEnginesAreNotEqual() {
var id1 = UniqueId.root("engine", "junit-vintage");
var id2 = UniqueId.root("engine", "junit-jupiter");

assertFalse(id1.equals(id2));
assertFalse(id2.equals(id1));
assertNotEquals(id2, id1);
assertNotEquals(id1, id2);
}

@Test
void uniqueIdWithSameSegmentsAreEqual() {
var id1 = UniqueId.root("engine", "junit-jupiter").append("t1", "v1").append("t2", "v2");
var id2 = UniqueId.root("engine", "junit-jupiter").append("t1", "v1").append("t2", "v2");

assertTrue(id1.equals(id2));
assertTrue(id2.equals(id1));
assertEquals(id2, id1);
assertEquals(id1, id2);
assertEquals(id1.hashCode(), id2.hashCode());
}

Expand All @@ -203,17 +204,17 @@ void differentOrderOfSegmentsAreNotEqual() {
var id1 = UniqueId.root("engine", "junit-jupiter").append("t2", "v2").append("t1", "v1");
var id2 = UniqueId.root("engine", "junit-jupiter").append("t1", "v1").append("t2", "v2");

assertFalse(id1.equals(id2));
assertFalse(id2.equals(id1));
assertNotEquals(id2, id1);
assertNotEquals(id1, id2);
}

@Test
void additionalSegmentMakesItNotEqual() {
var id1 = UniqueId.root("engine", "junit-jupiter").append("t1", "v1");
var id2 = id1.append("t2", "v2");

assertFalse(id1.equals(id2));
assertFalse(id2.equals(id1));
assertNotEquals(id2, id1);
assertNotEquals(id1, id2);
}
}

Expand Down

0 comments on commit 85ee212

Please sign in to comment.