mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-18 13:26:03 +00:00
* fix checkstlye errors - visitor pattern * fix checkstlye errors - strategy pattern * fix checkstlye errors - singleton pattern
This commit is contained in:
committed by
Ilkka Seppälä
parent
1eb1961f1b
commit
3b1a28149b
@@ -26,9 +26,7 @@ package com.iluwatar.strategy;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
* Application test.
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
|
||||
@@ -23,21 +23,21 @@
|
||||
|
||||
package com.iluwatar.strategy;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Date: 12/29/15 - 10:50 PM
|
||||
* Date: 12/29/15 - 10:50 PM.
|
||||
*
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public class DragonSlayerTest {
|
||||
|
||||
/**
|
||||
* Verify if the dragon slayer uses the strategy during battle
|
||||
* Verify if the dragon slayer uses the strategy during battle.
|
||||
*/
|
||||
@Test
|
||||
public void testGoToBattle() {
|
||||
@@ -50,7 +50,7 @@ public class DragonSlayerTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the dragon slayer uses the new strategy during battle after a change of strategy
|
||||
* Verify if the dragon slayer uses the new strategy during battle after a change of strategy.
|
||||
*/
|
||||
@Test
|
||||
public void testChangeStrategy() {
|
||||
|
||||
@@ -23,45 +23,48 @@
|
||||
|
||||
package com.iluwatar.strategy;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.AppenderBase;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Date: 12/29/15 - 10:58 PM
|
||||
* Date: 12/29/15 - 10:58 PM.
|
||||
*
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public class DragonSlayingStrategyTest {
|
||||
|
||||
/**
|
||||
* Assembles test parameters.
|
||||
*
|
||||
* @return The test parameters for each cycle
|
||||
*/
|
||||
static Collection<Object[]> dataProvider() {
|
||||
return List.of(
|
||||
new Object[]{
|
||||
new MeleeStrategy(),
|
||||
"With your Excalibur you sever the dragon's head!"
|
||||
},
|
||||
new Object[]{
|
||||
new ProjectileStrategy(),
|
||||
"You shoot the dragon with the magical crossbow and it falls dead on the ground!"
|
||||
},
|
||||
new Object[]{
|
||||
new SpellStrategy(),
|
||||
"You cast the spell of disintegration and the dragon vaporizes in a pile of dust!"
|
||||
}
|
||||
return List.of(
|
||||
new Object[]{
|
||||
new MeleeStrategy(),
|
||||
"With your Excalibur you sever the dragon's head!"
|
||||
},
|
||||
new Object[]{
|
||||
new ProjectileStrategy(),
|
||||
"You shoot the dragon with the magical crossbow and it falls dead on the ground!"
|
||||
},
|
||||
new Object[]{
|
||||
new SpellStrategy(),
|
||||
"You cast the spell of disintegration and the dragon vaporizes in a pile of dust!"
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -79,7 +82,7 @@ public class DragonSlayingStrategyTest {
|
||||
|
||||
|
||||
/**
|
||||
* Test if executing the strategy gives the correct response
|
||||
* Test if executing the strategy gives the correct response.
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
|
||||
Reference in New Issue
Block a user