Content of file SSPPlayerBuilderImplTest.java
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;
    /**
     * Setup
     */
    @BeforeEach
    void setUp() {
        playerBuilder = new SSPPlayerBuilderImpl();
    }
    /**
     * Test for method changeName.
     */
    @Test
    void changeName() throws GameException {
        SSPPlayer sspPlayer = playerBuilder.changeName("A").changePossibleOutcomes(createPossibleOutcomes()).build();
        assertEquals("A", sspPlayer.getName());
    }
    /**
     * Test for method changePossibleOutcomes.
     */
    @Test
    void changePossibleOutcomes() throws GameException {
        SSPPlayer player = playerBuilder.changeName("A").changePossibleOutcomes(createPossibleOutcomes()).build();
        assertEquals(createPossibleOutcomes(), player.getPossibleOutcomes());
    }
    /**
     * Test for method build.
     */
    @Test
    void build() throws GameException {
        SSPPlayer player = playerBuilder.changeName("A").changePossibleOutcomes(createPossibleOutcomes()).build();
A local variable assigned only once can be declared final.
        
    
        
public class Bar {
    public void foo () {
    String txtA = "a";          // if txtA will not be assigned again it is better to do this:
    final String txtB = "b";
    }
}
        
    
    See PMD documentation.
        assertEquals(player, playerBuilder.changeName("A").changePossibleOutcomes(createPossibleOutcomes()).build());
    }
    Map<String, Map<String, Double>> createPossibleOutcomes() {
        final Map<String, Map<String, Double>> possibleOutcomes = new LinkedHashMap<>();
        Map<String, Double> possibleOutcomesSchere = new LinkedHashMap<>();
        Map<String, Double> possibleOutcomesStein = new LinkedHashMap<>();
        Map<String, Double> possibleOutcomesPapier = new LinkedHashMap<>();
        possibleOutcomesSchere.put(SCHERE, 0.0);
        possibleOutcomesSchere.put(STEIN, 1.0);
        possibleOutcomesSchere.put(PAPIER, -1.0);
        possibleOutcomesStein.put(STEIN, 0.0);
        possibleOutcomesStein.put(SCHERE, -1.0);
        possibleOutcomesStein.put(PAPIER, 1.0);
        possibleOutcomesPapier.put(PAPIER, 0.0);
        possibleOutcomesPapier.put(SCHERE, 1.0);
        possibleOutcomesPapier.put(STEIN, -1.0);
        possibleOutcomes.put(SCHERE, possibleOutcomesSchere);
        possibleOutcomes.put(STEIN, possibleOutcomesStein);
        possibleOutcomes.put(PAPIER, possibleOutcomesPapier);
        return possibleOutcomes;
    }
}