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;
/**
Since Checkstyle 3.2
Validates Javadoc comments to help ensure they are well formed. The following checks are performed:
- Ensures the first sentence ends with proper punctuation (That is a period, question mark, or exclamation mark, by default). Javadoc automatically places the first sentence in the method summary table and index. Without proper punctuation the Javadoc may be malformed. All items eligible for the
{@inheritDoc}
tag are exempt from this requirement.- Check text for Javadoc statements that do not have any description. This includes both completely empty Javadoc, and Javadoc with only tags such as @param and @return.
- Check text for incomplete HTML tags. Verifies that HTML tags have corresponding end tags and issues an "Unclosed HTML tag found:" error if not. An "Extra HTML tag found:" error is issued if an end tag is found without a previous open tag.
- Check that a package Javadoc comment is well-formed (as described above) and NOT missing from any package-info.java files.
- Check for allowed HTML tags. The list of allowed HTML tags is "a", "abbr", "acronym", "address", "area", "b", "bdo", "big", "blockquote", "br", "caption", "cite", "code", "colgroup", "dd", "del", "div", "dfn", "dl", "dt", "em", "fieldset", "font", "h1" to "h6", "hr", "i", "img", "ins", "kbd", "li", "ol", "p", "pre", "q", "samp", "small", "span", "strong", "sub", "sup", "table", "tbody", "td", "tfoot", "th", "thread", "tr", "tt", "u", "ul".
These checks were patterned after the checks made by the DocCheck doclet available from Sun. Note: Original Sun's DocCheck tool does not exist anymore.
* 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(); 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; } }