#502 Adjusted tests for logger introduction
This commit is contained in:
		| @@ -22,17 +22,9 @@ | ||||
|  */ | ||||
| package com.iluwatar.doubledispatch; | ||||
|  | ||||
| import org.junit.After; | ||||
| import org.junit.Before; | ||||
|  | ||||
| import java.io.PrintStream; | ||||
| import java.util.Objects; | ||||
|  | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.mockito.Mockito.mock; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.verifyNoMoreInteractions; | ||||
|  | ||||
| /** | ||||
|  * Date: 12/10/15 - 8:37 PM | ||||
| @@ -41,43 +33,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; | ||||
|  */ | ||||
| public abstract class CollisionTest<O extends GameObject> { | ||||
|  | ||||
|   /** | ||||
|    * The mocked standard out {@link PrintStream}, required if some of the actions on the tested | ||||
|    * object don't have a direct influence on any other accessible objects, except for writing to | ||||
|    * std-out using {@link System#out} | ||||
|    */ | ||||
|   private final PrintStream stdOutMock = mock(PrintStream.class); | ||||
|  | ||||
|   /** | ||||
|    * Keep the original std-out so it can be restored after the test | ||||
|    */ | ||||
|   private final PrintStream stdOutOrig = System.out; | ||||
|  | ||||
|   /** | ||||
|    * Inject the mocked std-out {@link PrintStream} into the {@link System} class before each test | ||||
|    */ | ||||
|   @Before | ||||
|   public void setUp() { | ||||
|     System.setOut(this.stdOutMock); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Removed the mocked std-out {@link PrintStream} again from the {@link System} class | ||||
|    */ | ||||
|   @After | ||||
|   public void tearDown() { | ||||
|     System.setOut(this.stdOutOrig); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Get the mocked stdOut {@link PrintStream} | ||||
|    * | ||||
|    * @return The stdOut print stream mock, renewed before each test | ||||
|    */ | ||||
|   final PrintStream getStdOutMock() { | ||||
|     return this.stdOutMock; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Get the tested object | ||||
|    * | ||||
| @@ -106,9 +61,6 @@ public abstract class CollisionTest<O extends GameObject> { | ||||
|  | ||||
|     tested.collision(other); | ||||
|  | ||||
|     verify(getStdOutMock(), times(1)).println(description); | ||||
|     verifyNoMoreInteractions(getStdOutMock()); | ||||
|  | ||||
|     testOnFire(other, tested, otherOnFire); | ||||
|     testDamaged(other, tested, otherDamaged); | ||||
|  | ||||
| @@ -129,8 +81,8 @@ public abstract class CollisionTest<O extends GameObject> { | ||||
|     final String targetName = target.getClass().getSimpleName(); | ||||
|     final String otherName = other.getClass().getSimpleName(); | ||||
|  | ||||
|     final String errorMessage = expectTargetOnFire  | ||||
|         ? "Expected [" + targetName + "] to be on fire after colliding with [" + otherName + "] but it was not!"  | ||||
|     final String errorMessage = expectTargetOnFire | ||||
|         ? "Expected [" + targetName + "] to be on fire after colliding with [" + otherName + "] but it was not!" | ||||
|         : "Expected [" + targetName + "] not to be on fire after colliding with [" + otherName + "] but it was!"; | ||||
|  | ||||
|     assertEquals(errorMessage, expectTargetOnFire, target.isOnFire()); | ||||
| @@ -149,7 +101,7 @@ public abstract class CollisionTest<O extends GameObject> { | ||||
|     final String otherName = other.getClass().getSimpleName(); | ||||
|  | ||||
|     final String errorMessage = expectedDamage | ||||
|         ? "Expected [" + targetName + "] to be damaged after colliding with [" + otherName + "] but it was not!"  | ||||
|         ? "Expected [" + targetName + "] to be damaged after colliding with [" + otherName + "] but it was not!" | ||||
|         : "Expected [" + targetName + "] not to be damaged after colliding with [" + otherName + "] but it was!"; | ||||
|  | ||||
|     assertEquals(errorMessage, expectedDamage, target.isDamaged()); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user