package nl.vpro.poel.domain;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class PredictionTest {

    @Test
    public void scoreForCorrectWinnerAndResult() {
        checkScore(new MatchResult(0, 0), new MatchResult(0, 0), 3);
    }

    @Test
    public void scoreForCorrectWinnerAndResultWithMultiplier() {
        checkScoreWithMultiplier(new MatchResult(1, 3), new MatchResult(1, 3), 6);
    }

    @Test
    public void scoreForCorrectWinnerWrongResult() {
        checkScore(new MatchResult(1, 0), new MatchResult(2, 0), 2);
    }

    @Test
    public void scoreForCorrectWinnerWrongResultWithMultiplier() {
        checkScoreWithMultiplier(new MatchResult(5, 0), new MatchResult(1, 0), 4);
    }

    @Test
    public void scoreForWrongWinner() {
        checkScore(new MatchResult(1, 0), new MatchResult(0, 1), 0);
    }

    @Test
    public void scoreForWrongWinnerWithMultiplier() {
        checkScoreWithMultiplier(new MatchResult(5, 4), new MatchResult(3, 3), 0);
    }

    @Test
    public void scoreForNoPredictedResult() {
        checkScore(null, new MatchResult(1, 0), 0);
    }

    @Test
    public void scoreForNoPredictedResultWithMultiplier() {
        checkScore(null, new MatchResult(1, 0), 0);
    }

    @Test
    public void scoreForNoActualResult() {
        checkScore(new MatchResult(1, 0), null, 0);
    }

    @Test
    public void scoreForNoActualResultWithMultiplier() {
        checkScoreWithMultiplier(new MatchResult(1, 0), null, 0);
    }

    @Test
    public void scoreForNoResultsAtAll() {
        checkScore(null, null, 0);
    }

    @Test
    public void scoreForNoResultsAtAllWithMultiplier() {
        checkScoreWithMultiplier(null, null, 0);
    }

    private void checkScoreWithMultiplier(MatchResult predictedResult, MatchResult actualResult, int expectedScore) {
        checkScore(predictedResult, actualResult, true, expectedScore);
    }

    private void checkScore(MatchResult predictedResult, MatchResult actualResult, int expectedScore) {
        checkScore(predictedResult, actualResult, false, expectedScore);
    }

    private void checkScore(MatchResult predictedResult, MatchResult actualResult, boolean multiplier, int expectedScore) {
        Prediction prediction = new Prediction(null, new Match("Home", "Away", null, actualResult), predictedResult, multiplier);
        int actualScore = prediction.getScore();
        assertThat(actualScore).isEqualTo(expectedScore);
    }
}
@@ -45,16 +45,75 @@
 it.Test;
+%0Aimport org.springframework.beans.factory.annotation.Value;
 %0A%0Aimport
@@ -196,16 +196,281 @@
 Test %7B%0A%0A
+    @Value(%22$%7Bpoel.pointsForCorrectWinner%7D%22)%0A    private int pointsForCorrectWinner;%0A%0A    @Value(%22$%7Bpoel.pointsForCorrectMatchResult%7D%22)%0A    private int pointsForCorrectMatchResult;%0A%0A    @Value(%22$%7Bpoel.scoreMultiplierFactor%22)%0A    private int scoreMultiplierFactor;%0A%0A
     @Tes
@@ -587,17 +587,68 @@
 (0, 0), 
-3
+pointsForCorrectWinner + pointsForCorrectMatchResult
 );%0A    %7D
@@ -807,9 +807,86 @@
 3), 
-6
+scoreMultiplierFactor * (pointsForCorrectWinner + pointsForCorrectMatchResult)
 );%0A 
@@ -1019,17 +1019,38 @@
 (2, 0), 
-2
+pointsForCorrectWinner
 );%0A    %7D
@@ -1207,17 +1207,62 @@
 (1, 0), 
-4
+scoreMultiplierFactor * pointsForCorrectWinner
 );%0A    %7D

Use the configured values, Luke!