package de.fred4jupiter.fredbet.domain;

import de.fred4jupiter.fredbet.common.UnitTest;
import org.junit.jupiter.api.Test;

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

@UnitTest
public class MatchUT {

    @Test
    public void isTeamOneWinner() {
        Match match = MatchBuilder.create()
                .withTeams("a", "b")
                .withGoals(2, 1)
                .withGroup(Group.GROUP_A)
                .build();
        assertThat(match).isNotNull();
        assertThat(match.isGroupMatch()).isTrue();
        assertThat(match.isTeamOneWinner()).isTrue();
        assertThat(match.isTeamTwoWinner()).isFalse();
    }

    @Test
    public void isTeamTwoWinner() {
        Match match = MatchBuilder.create()
                .withTeams("a", "b")
                .withGoals(1, 2)
                .withGroup(Group.GROUP_A)
                .build();
        assertThat(match).isNotNull();
        assertThat(match.isGroupMatch()).isTrue();
        assertThat(match.isTeamOneWinner()).isFalse();
        assertThat(match.isTeamTwoWinner()).isTrue();
    }

    @Test
    public void undecidedResult() {
        Match match = MatchBuilder.create()
                .withTeams("a", "b")
                .withGoals(1, 1)
                .withGroup(Group.GROUP_A)
                .build();
        assertThat(match).isNotNull();
        assertThat(match.isGroupMatch()).isTrue();
        assertThat(match.isTeamOneWinner()).isFalse();
        assertThat(match.isTeamTwoWinner()).isFalse();
    }

    @Test
    public void undecidedResultInKnockoutMatchAndPenaltyWinnerIsOne() {
        Match match = MatchBuilder.create()
                .withTeams("a", "b")
                .withGoals(1, 1)
                .withPenaltyWinnerOne(true)
                .withGroup(Group.FINAL)
                .build();
        assertThat(match).isNotNull();
        assertThat(match.isFinal()).isTrue();
        assertThat(match.isGroupMatch()).isFalse();
        assertThat(match.isTeamOneWinner()).isTrue();
        assertThat(match.isTeamTwoWinner()).isFalse();
        assertThat(match.isPenaltyWinnerOne()).isTrue();
    }

    @Test
    public void undecidedResultInKnockoutMatchAndPenaltyWinnerIsTwo() {
        Match match = MatchBuilder.create()
                .withTeams("a", "b")
                .withGoals(1, 1)
                .withPenaltyWinnerOne(false)
                .withGroup(Group.FINAL)
                .build();
        assertThat(match).isNotNull();
        assertThat(match.isFinal()).isTrue();
        assertThat(match.isGroupMatch()).isFalse();
        assertThat(match.isTeamOneWinner()).isFalse();
        assertThat(match.isTeamTwoWinner()).isTrue();
        assertThat(match.isPenaltyWinnerOne()).isFalse();
    }
}

@@ -1389,32 +1389,88 @@
 ch()).isTrue();%0A
+        assertThat(match.isUndecidedResult()).isTrue();%0A
         assertTh
@@ -2802,11 +2802,1489 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void winnerLooserWinnerOne() %7B%0A        Match match = MatchBuilder.create()%0A                .withTeams(Country.GERMANY, Country.ITALY)%0A                .withGoals(1, 1)%0A                .withPenaltyWinnerOne(true)%0A                .withGroup(Group.FINAL)%0A                .build();%0A        assertThat(match).isNotNull();%0A        assertThat(match.isFinal()).isTrue();%0A        assertThat(match.getWinner()).isEqualTo(Country.GERMANY);%0A        assertThat(match.getLooser()).isEqualTo(Country.ITALY);%0A        assertThat(match.isGroupMatch()).isFalse();%0A        assertThat(match.isTeamOneWinner()).isTrue();%0A        assertThat(match.isTeamTwoWinner()).isFalse();%0A        assertThat(match.isPenaltyWinnerOne()).isTrue();%0A    %7D%0A%0A    @Test%0A    public void winnerLooserWinnerTwo() %7B%0A        Match match = MatchBuilder.create()%0A                .withTeams(Country.GERMANY, Country.ITALY)%0A                .withGoals(1, 1)%0A                .withPenaltyWinnerOne(false)%0A                .withGroup(Group.FINAL)%0A                .build();%0A        assertThat(match).isNotNull();%0A        assertThat(match.isFinal()).isTrue();%0A        assertThat(match.getWinner()).isEqualTo(Country.ITALY);%0A        assertThat(match.getLooser()).isEqualTo(Country.GERMANY);%0A        assertThat(match.isGroupMatch()).isFalse();%0A        assertThat(match.isTeamOneWinner()).isFalse();%0A        assertThat(match.isTeamTwoWinner()).isTrue();%0A        assertThat(match.isPenaltyWinnerOne()).isFalse();%0A    %7D
 %0A%7D%0A

update tests