package de.schereSteinPapier.domain.impl;
import static de.schereSteinPapier.SSPConstants.AuswahlConstants.PAPIER;
import static de.schereSteinPapier.SSPConstants.AuswahlConstants.SCHERE;
import static de.schereSteinPapier.SSPConstants.AuswahlConstants.STEIN;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import de.fhdw.gaming.core.domain.GameException;
import de.schereSteinPapier.domain.SSPPlayer;
import de.schereSteinPapier.domain.SSPPlayerBuilder;
/**
* Tests {@link class SSPPlayerBuilderImpl}.
*/
class SSPPlayerBuilderImplTest {
/**
* Tries to create a SSP player.
*/
@Test
void testCreatePlayerWithDefaults() throws GameException {
final SSPPlayerBuilder builder = new SSPPlayerBuilderImpl();
final SSPPlayerBuilder builder2 = new SSPPlayerBuilderImpl();
final Map<String, Map<String, Double>> possibleOutcomes = new LinkedHashMap<>();
final Map<String, Double> possibleOutcomesPapier = new LinkedHashMap<>();
final Map<String, Double> possibleOutcomesStein = new LinkedHashMap<>();
final Map<String, Double> possibleOutcomesSchere = new LinkedHashMap<>();
possibleOutcomesSchere.put(SCHERE, 0.0);
possibleOutcomesSchere.put(STEIN, -1.0);
possibleOutcomesSchere.put(PAPIER, 1.0);
possibleOutcomesStein.put(SCHERE, 1.0);
possibleOutcomesStein.put(STEIN, 0.0);
possibleOutcomesStein.put(PAPIER, -1.0);
possibleOutcomesPapier.put(SCHERE, -1.0);
possibleOutcomesPapier.put(STEIN, 1.0);
possibleOutcomesPapier.put(PAPIER, 0.0);
possibleOutcomes.put(SCHERE, possibleOutcomesSchere);
possibleOutcomes.put(STEIN, possibleOutcomesStein);
possibleOutcomes.put(PAPIER, possibleOutcomesPapier);
final Map<String, Map<String, Double>> possibleOutcomesSecond = new LinkedHashMap<>();
final Map<String, Double> possibleOutcomesPapierSecond = new LinkedHashMap<>();
final Map<String, Double> possibleOutcomesSteinSecond = new LinkedHashMap<>();
final Map<String, Double> possibleOutcomesSchereSecond = new LinkedHashMap<>();
possibleOutcomesSchereSecond.put(SCHERE, 0.0);
possibleOutcomesSchereSecond.put(STEIN, 1.0);
possibleOutcomesSchereSecond.put(PAPIER, -1.0);
possibleOutcomesSteinSecond.put(SCHERE, -1.0);
possibleOutcomesSteinSecond.put(STEIN, 0.0);
possibleOutcomesSteinSecond.put(PAPIER, 1.0);
possibleOutcomesPapierSecond.put(SCHERE, 1.0);
possibleOutcomesPapierSecond.put(STEIN, -1.0);
possibleOutcomesPapierSecond.put(PAPIER, 0.0);
possibleOutcomesSecond.put(SCHERE, possibleOutcomesSchereSecond);
possibleOutcomesSecond.put(STEIN, possibleOutcomesSteinSecond);
possibleOutcomesSecond.put(PAPIER, possibleOutcomesPapierSecond);
builder.changeName("A").changePossibleOutcomes(possibleOutcomes);
builder2.changeName("B").changePossibleOutcomes(possibleOutcomesSecond);
final SSPPlayer player = builder.build();
final SSPPlayer player2 = builder2.build();
assertThat(player.getName(), is(equalTo("A")));
assertThat(player2.getName(), is(equalTo("B")));
}
SSPPlayerBuilder playerBuilder;
Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
public class HelloWorldBean {
// Field declared before methods / inner classes - OK
private String _thing;
public String getMessage() {
return "Hello World!";
}
// Field declared after methods / inner classes - avoid this
private String _fieldInWrongLocation;
}