package nl.tudelft.jpacman.board;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;

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

/**
 * Test suite to confirm the public API of {@link Square} works as desired.
 * 
 * @author Jeroen Roosen 
 */
public class SquareTest {

	/**
	 * The square under test.
	 */
	private Square square;

	/**
	 * Resets the square under test.
	 */
	@Before
	public void setUp() {
		square = new BasicSquare();
	}

	/**
	 * Assert that the square holds the occupant once it has occupied it.
	 */
	@Test
	public void testOccupy() {
		Unit occupant = mock(Unit.class);
		square.put(occupant);

		assertTrue(square.getOccupants().contains(occupant));
	}

	/**
	 * Assert that the square no longer holds the occupant after it has left the
	 * square.
	 */
	@Test
	public void testLeave() {
		Unit occupant = mock(Unit.class);
		square.put(occupant);
		square.remove(occupant);

		assertFalse(square.getOccupants().contains(occupant));
	}

	/**
	 * Assert that the order in which units entered the square is preserved.
	 */
	@Test
	public void testOrder() {
		Unit o1 = mock(Unit.class);
		Unit o2 = mock(Unit.class);
		square.put(o1);
		square.put(o2);

		Object[] occupantsAsArray = square.getOccupants().toArray();
		assertArrayEquals(new Object[] { o1, o2 }, occupantsAsArray);
	}
}

@@ -27,39 +27,32 @@
 .board;%0A%0Aimport 
-static 
 org.junit.Assert
@@ -49,32 +49,14 @@
 nit.
-Assert.assertArrayEquals
+Before
 ;%0Aim
@@ -52,39 +52,32 @@
 .Before;%0Aimport 
-static 
 org.junit.Assert
@@ -74,27 +74,14 @@
 nit.
-Assert.assertFalse;
+Test;%0A
 %0Aimp
@@ -99,28 +99,43 @@
 org.
-junit
+assertj.core.api
 .Assert
+ions
 .assertT
 rue;
@@ -130,19 +130,19 @@
 .assertT
-rue
+hat
 ;%0Aimport
@@ -180,57 +180,8 @@
 k;%0A%0A
-import org.junit.Before;%0Aimport org.junit.Test;%0A%0A
 /**%0A
@@ -679,11 +679,11 @@
 ertT
-rue
+hat
 (squ
@@ -692,32 +692,33 @@
 e.getOccupants()
+)
 .contains(occupa
@@ -712,33 +712,32 @@
 ntains(occupant)
-)
 ;%0A%09%7D%0A%0A%09/**%0A%09 * A
@@ -960,13 +960,12 @@
 sert
-False
+That
 (squ
@@ -982,25 +982,32 @@
 upants()
-.c
+).doesNotC
 ontain
-s
 (occupan
@@ -1008,17 +1008,16 @@
 ccupant)
-)
 ;%0A%09%7D%0A%0A%09/
@@ -1235,130 +1235,65 @@
 %0A%0A%09%09
-Object%5B%5D occupantsAsArray = square.getOccupants().toArray();%0A%09%09assertArrayEquals(new Object%5B%5D %7B o1, o2 %7D, occupantsAsArray
+assertThat(square.getOccupants()).containsSequence(o1, o2
 );%0A%09

Use AssertJ for assertions on list.