package powercards;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import powercards.cards.Copper;

import java.util.stream.IntStream;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;

@RunWith(MockitoJUnitRunner.class)
public class PileTest {
  @Test
  public void shouldPushAndPop() {
    Pile pile = new Pile(Copper.class, 8);

    assertThat(pile.isEmpty(), is(false));

    IntStream.rangeClosed(1, 5).forEach(n -> {
      pile.pop();
      assertThat(pile.size(), is(8 - n));
    });

    IntStream.rangeClosed(1, 3).forEach(n -> {
      pile.push(new Copper());
      assertThat(pile.size(), is(3 + n));
    });

    IntStream.rangeClosed(1, 6).forEach(n -> {
      pile.pop();
      assertThat(pile.size(), is(6 - n));
    });

    assertThat(pile.isEmpty(), is(true));

    IntStream.rangeClosed(1, 2).forEach(n -> {
      pile.push(new Copper());
      assertThat(pile.size(), is(n));
    });

    assertThat(pile.isEmpty(), is(false));
  }

  @Test(expected = IllegalStateException.class)
  public void shouldThrowIfPopEmptyPile() {
    Pile pile = new Pile(Copper.class, 1);
    pile.pop();
    assertThat(pile.isEmpty(), is(true));
    pile.pop();
  }
}

@@ -154,44 +154,8 @@
 r;%0A%0A
-import java.util.stream.IntStream;%0A%0A
 impo
@@ -441,48 +441,36 @@
     
-IntStream.rangeClosed(1, 5).forEach(n -%3E
+for (int i = 1; i %3C= 5; i++)
  %7B%0A 
@@ -523,17 +523,17 @@
  is(8 - 
-n
+i
 ));%0A    
@@ -537,56 +537,42 @@
    %7D
-);
 %0A%0A    
-IntStream.rangeClosed(1, 3).forEach(n -%3E
+for (int i = 1; i %3C= 3; i++)
  %7B%0A 
@@ -638,17 +638,17 @@
  is(3 + 
-n
+i
 ));%0A    
@@ -652,56 +652,42 @@
    %7D
-);
 %0A%0A    
-IntStream.rangeClosed(1, 6).forEach(n -%3E
+for (int i = 1; i %3C= 6; i++)
  %7B%0A 
@@ -740,17 +740,17 @@
  is(6 - 
-n
+i
 ));%0A    
@@ -742,34 +742,32 @@
 s(6 - i));%0A    %7D
-);
 %0A%0A    assertThat
@@ -803,48 +803,36 @@
     
-IntStream.rangeClosed(1, 2).forEach(n -%3E
+for (int i = 1; i %3C= 2; i++)
  %7B%0A 
@@ -894,17 +894,17 @@
 e(), is(
-n
+i
 ));%0A    
@@ -904,18 +904,16 @@
 );%0A    %7D
-);
 %0A%0A    as

change IntStream to for loop to avoid side effecting