MoveBidding extends Move implements Comparable<MoveBidding> { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (!(obj instanceof MoveBidding)) { return false; } MoveBidding otherMove = (MoveBidding) obj; if (this.specialMove != null || otherMove.specialMove != null) { return this.specialMove == otherMove.specialMove; } return this.contract.equals(otherMove.contract); } private  MoveBidding(Contract contract, Special specialMove); static MoveBidding contractMove(Contract contract); static MoveBidding passMove(); static MoveBidding coincheMove(); static MoveBidding surcoincheMove(); @Override int compareTo(MoveBidding o); Contract getContract(); boolean isPass(); boolean isCoinche(); boolean isSurcoinche(); @Override boolean equals(Object obj); @Override String getShortName(); @Override String toString();  }
@Test public void equals() { class TestCase extends GameEngineTestHelper.ComparisonTestCase<MoveBidding> { TestCase(String name, MoveBidding m1, MoveBidding m2, boolean expected) { super(name, m1, m2, expected); } @Override protected void runAssertions() { assertThat(o1.equals(o2)).as("Check move equality").isEqualTo(expected); } } List<TestCase> testCases = new ArrayList<>( List.of( new TestCase("pass - pass", MoveBidding.passMove(), MoveBidding.passMove(), true), new TestCase( "coinche - coinche", MoveBidding.coincheMove(), MoveBidding.coincheMove(), true), new TestCase( "surcoinche - surcoinche", MoveBidding.surcoincheMove(), MoveBidding.surcoincheMove(), true), new TestCase( "pass - coinche", MoveBidding.passMove(), MoveBidding.coincheMove(), false), new TestCase( "surcoinche - coinche", MoveBidding.surcoincheMove(), MoveBidding.coincheMove(), false), new TestCase( "surcoinche - pass", MoveBidding.surcoincheMove(), MoveBidding.passMove(), false), new TestCase( "pass - capot heart", MoveBidding.passMove(), MoveBidding.contractMove(ContractFactory.createContract(250, Suit.HEARTS)), false), new TestCase( "pass - 130 spades", MoveBidding.passMove(), MoveBidding.contractMove(ContractFactory.createContract(130, Suit.SPADES)), false), new TestCase( "coinche - capot heart", MoveBidding.passMove(), MoveBidding.contractMove(ContractFactory.createContract(250, Suit.HEARTS)), false), new TestCase( "coinche - 130 spades", MoveBidding.passMove(), MoveBidding.contractMove(ContractFactory.createContract(130, Suit.SPADES)), false), new TestCase( "surcoinche - capot heart", MoveBidding.passMove(), MoveBidding.contractMove(ContractFactory.createContract(250, Suit.HEARTS)), false), new TestCase( "surcoinche - 130 spades", MoveBidding.passMove(), MoveBidding.contractMove(ContractFactory.createContract(130, Suit.SPADES)), false), new TestCase( "capot heart - capot heart", MoveBidding.contractMove(ContractFactory.createContract(250, Suit.HEARTS)), MoveBidding.contractMove(ContractFactory.createContract(250, Suit.HEARTS)), true), new TestCase( "generale clubs - generale clubs", MoveBidding.contractMove(ContractFactory.createContract(500, Suit.CLUBS)), MoveBidding.contractMove(ContractFactory.createContract(500, Suit.CLUBS)), true), new TestCase( "capot heart - capot spades", MoveBidding.contractMove(ContractFactory.createContract(250, Suit.HEARTS)), MoveBidding.contractMove(ContractFactory.createContract(250, Suit.SPADES)), false), new TestCase( "capot heart - generale heart", MoveBidding.contractMove(ContractFactory.createContract(250, Suit.HEARTS)), MoveBidding.contractMove(ContractFactory.createContract(500, Suit.HEARTS)), false), new TestCase( "generale heart - generale diamonds", MoveBidding.contractMove(ContractFactory.createContract(500, Suit.HEARTS)), MoveBidding.contractMove(ContractFactory.createContract(500, Suit.DIAMONDS)), false), new TestCase( "90 heart - 90 heart", MoveBidding.contractMove(ContractFactory.createContract(90, Suit.HEARTS)), MoveBidding.contractMove(ContractFactory.createContract(90, Suit.HEARTS)), true), new TestCase( "90 heart - 130 heart", MoveBidding.contractMove(ContractFactory.createContract(90, Suit.HEARTS)), MoveBidding.contractMove(ContractFactory.createContract(130, Suit.HEARTS)), false), new TestCase( "110 diamonds - 110 spades", MoveBidding.contractMove(ContractFactory.createContract(110, Suit.DIAMONDS)), MoveBidding.contractMove(ContractFactory.createContract(110, Suit.SPADES)), false), new TestCase( "capot heart - 100 heart", MoveBidding.contractMove(ContractFactory.createContract(250, Suit.HEARTS)), MoveBidding.contractMove(ContractFactory.createContract(100, Suit.HEARTS)), false), new TestCase( "generale heart - 140 heart", MoveBidding.contractMove(ContractFactory.createContract(500, Suit.HEARTS)), MoveBidding.contractMove(ContractFactory.createContract(140, Suit.HEARTS)), false))); testCases.forEach(TestCase::run); }