package com.skraylabs.poker;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

import com.skraylabs.poker.model.BoardFormatException;
import com.skraylabs.poker.model.Card;
import com.skraylabs.poker.model.CardFormatException;
import com.skraylabs.poker.model.GameStateFormatException;
import com.skraylabs.poker.model.PocketFormatException;
import com.skraylabs.poker.model.Rank;
import com.skraylabs.poker.model.Suit;

import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Collection;

public class ThreeOfAKindTest {

  /**
   * Test board.
   *
   * <p>
   * Ah Kh Qh
   */
  Collection<Card> boardAceKingQueen;

  /**
   * Test pocket. No Three of a Kind with {@link #boardAceKingQueen}.
   *
   * <p>
   * 2d 7c
   */
  Collection<Card> pocketTwoSeven;

  /**
   * Test pocket. Makes triple queens with {@link #boardAceKingQueen}.
   *
   * <p>
   * Qd Qc
   */
  Collection<Card> pocketQueens;

  /**
   * Set up test board.
   */
  @Before
  public void setUpBoardAceKingQueen() {
    boardAceKingQueen = new ArrayList<Card>();
    boardAceKingQueen.add(new Card(Rank.Ace, Suit.Hearts));
    boardAceKingQueen.add(new Card(Rank.King, Suit.Hearts));
    boardAceKingQueen.add(new Card(Rank.Queen, Suit.Hearts));
  }

  /**
   * Set up test pocket.
   */
  @Before
  public void setUpPocketTwoSeven() {
    pocketTwoSeven = new ArrayList<Card>();
    pocketTwoSeven.add(new Card(Rank.Two, Suit.Diamonds));
    pocketTwoSeven.add(new Card(Rank.Seven, Suit.Clubs));
  }

  /**
   * Set up test pocket.
   */
  @Before
  public void setUpPocketQueens() {
    pocketQueens = new ArrayList<Card>();
    pocketQueens.add(new Card(Rank.Queen, Suit.Diamonds));
    pocketQueens.add(new Card(Rank.Queen, Suit.Clubs));
  }

  @Test
  public void handWithNoThreeOfAKindReturnsFalse() {
    Collection<Card> cards =
        ProbabilityCalculator.collectHandCards(boardAceKingQueen, pocketTwoSeven);

    boolean result = ProbabilityCalculator.hasThreeOfAKind(cards);

    assertThat(result, is(false));
  }

  @Test
  public void handWithThreeOfAKindReturnsTrue() throws CardFormatException, BoardFormatException,
      PocketFormatException, GameStateFormatException {
    Collection<Card> cards =
        ProbabilityCalculator.collectHandCards(boardAceKingQueen, pocketQueens);

    boolean result = ProbabilityCalculator.hasThreeOfAKind(cards);

    assertThat(result, is(true));
  }

}

@@ -653,16 +653,19 @@
 Ah Kh Qh
+ Jh
 %0A   */%0A 
@@ -699,16 +699,20 @@
 ingQueen
+Jack
 ;%0A%0A  /**
@@ -771,32 +771,36 @@
 oardAceKingQueen
+Jack
 %7D.%0A   *%0A   * %3Cp%3E
@@ -927,16 +927,20 @@
 ingQueen
+Jack
 %7D.%0A   *%0A
@@ -1081,16 +1081,20 @@
 ingQueen
+Jack
 () %7B%0A   
@@ -1111,16 +1111,20 @@
 ingQueen
+Jack
  = new A
@@ -1154,32 +1154,36 @@
 oardAceKingQueen
+Jack
 .add(new Card(Ra
@@ -1218,32 +1218,36 @@
 oardAceKingQueen
+Jack
 .add(new Card(Ra
@@ -1291,16 +1291,20 @@
 ingQueen
+Jack
 .add(new
@@ -1332,24 +1332,89 @@
 t.Hearts));%0A
+    boardAceKingQueenJack.add(new Card(Rank.Jack, Suit.Hearts));%0A
   %7D%0A%0A  /**%0A 
@@ -2048,32 +2048,36 @@
 oardAceKingQueen
+Jack
 , pocketTwoSeven
@@ -2443,16 +2443,20 @@
 ingQueen
+Jack
 , pocket

Refactor test fixture to include a Jack.