MovePlaying extends Move implements Comparable<MovePlaying> { @Override public int compareTo(MovePlaying o) { return this.card.compareTo(o.card); } private  MovePlaying(Card card); static MovePlaying cardMove(Card card); @Override int compareTo(MovePlaying o); @Override boolean equals(Object obj); @Override String getShortName(); @Override String toString();  }
@Test public void compareTo() { class TestCase extends GameEngineTestHelper.ComparisonTestCase<MovePlaying> { int expected; TestCase(String name, MovePlaying m1, MovePlaying m2, int expected) { super(name, m1, m2, true); this.expected = expected; } @Override protected void runAssertions() { if (expected > 0) { assertThat(o1).as("Check greater than").isGreaterThan(o2); return; } if (expected < 0) { assertThat(o1).as("Check less than").isLessThan(o2); return; } assertThat(o1).as("Check equals").isEqualByComparingTo(o2); } } List<TestCase> testCases = new ArrayList<>( List.of( new TestCase( "As - As", MovePlaying.cardMove(stringToCard("As")), MovePlaying.cardMove(stringToCard("As")), 0), new TestCase( "As - Js", MovePlaying.cardMove(stringToCard("As")), MovePlaying.cardMove(stringToCard("Js")), 1), new TestCase( "Ts - 9s", MovePlaying.cardMove(stringToCard("Ts")), MovePlaying.cardMove(stringToCard("9s")), 1), new TestCase( "As - Ah", MovePlaying.cardMove(stringToCard("As")), MovePlaying.cardMove(stringToCard("Ah")), -1), new TestCase( "7c - Tc", MovePlaying.cardMove(stringToCard("7c")), MovePlaying.cardMove(stringToCard("Tc")), -1), new TestCase( "7c - Ad", MovePlaying.cardMove(stringToCard("7c")), MovePlaying.cardMove(stringToCard("Ad")), -1), new TestCase( "Tc - Qc", MovePlaying.cardMove(stringToCard("Tc")), MovePlaying.cardMove(stringToCard("Qc")), -1), new TestCase( "Jh - Jd", MovePlaying.cardMove(stringToCard("Jh")), MovePlaying.cardMove(stringToCard("Jd")), -1), new TestCase( "8c - 8c", MovePlaying.cardMove(stringToCard("8c")), MovePlaying.cardMove(stringToCard("8c")), 0), new TestCase( "Jd - Qd", MovePlaying.cardMove(stringToCard("Jd")), MovePlaying.cardMove(stringToCard("Qd")), -1), new TestCase( "Td - Qd", MovePlaying.cardMove(stringToCard("Td")), MovePlaying.cardMove(stringToCard("Qd")), -1), new TestCase( "Ad - Qd", MovePlaying.cardMove(stringToCard("Ad")), MovePlaying.cardMove(stringToCard("Qd")), 1), new TestCase( "9s - 9c", MovePlaying.cardMove(stringToCard("9s")), MovePlaying.cardMove(stringToCard("9c")), -1))); testCases.forEach(TestCase::run); }