HandsComparator { public static int compareHands(List<Card> hand1, List<Card> hand2) { Possibilities v1 = evaluateHand(hand1); Possibilities v2 = evaluateHand(hand2); return (int) Math.signum(v2.ordinal() - v1.ordinal()); }  static Possibilities evaluateHand(List<Card> hand); static int compareHands(List<Card> hand1, List<Card> hand2);  }
@Test public void onePairWinsOverNothingP1P2() { int rez = HandsComparator.compareHands(makeHand("2P-2R-10P-8R-6I"), makeHand("2P-5R-10P-8R-6I")); assertEquals(-1, rez); }
@Test public void onePairWinsOverNothingP2P1() { int rez = HandsComparator.compareHands( makeHand("2P-5R-10P-8R-6I"), makeHand("2P-2R-10P-8R-6I")); assertEquals(1, rez); }
@Test public void onePairEqual() { int rez = HandsComparator.compareHands( makeHand("2P-2R-10P-8R-6I"), makeHand("2P-2R-10P-8R-6I")); assertEquals(0, rez); }
@Test public void nothingEqualsNothing() { int rez = HandsComparator.compareHands( makeHand("2P-3R-10P-8R-6I"), makeHand("2P-3R-10P-8R-6I")); assertEquals(0, rez); }
@Test public void twoPairsGre8ThenNothing() { int rez = HandsComparator.compareHands( makeHand("2P-2R-6P-6R-7I"), makeHand("2P-3R-10P-8R-6I")); assertEquals(-1, rez); }
@Test public void twoPairsGreaterThan1Pair() { int rez = HandsComparator.compareHands( makeHand("2P-2R-3T-3R-7I"), makeHand("2P-2R-10P-8R-6I")); assertEquals(-1, rez); }