Package match.aggregate

Examples of match.aggregate.MatchState


            MemoryEventStore memoryEventStore = new MemoryEventStore();
            MatchHandler matchHandler = new MatchHandler(soccerMatch.getMatch(), memoryEventStore);

            //Restore MatchA
            matchHandler.restoreState(resultA);
            MatchState state = matchHandler.getMatch().getState();
            assertThat("MatchA should be correctly restored.", state, equalTo(MatchState.ended));

            // Check if assigned cards are restored
            boolean frankHasCard = false, frankHasRedCard = false, pietHasCard = false, henkHasCard = false;
            for (PlayerModel playerModel : matchHandler.getMatch().getAssignedYellowCards()) {
                if (playerModel.getPlayerName().equals("frank")) {
                    frankHasCard = true;
                    break;
                }
            }
            for (PlayerModel playerModel : matchHandler.getMatch().getAssignedRedCards()) {
                if (playerModel.getPlayerName().equals("piet")) {
                    pietHasCard = true;
                }
                if (playerModel.getPlayerName().equals("henk")) {
                    henkHasCard = true;
                }
                if (playerModel.getPlayerName().equals("frank")) {
                    frankHasRedCard = true;
                }
            }

            assertThat("MatchA should have assigned a yellow card to frank.", frankHasCard, equalTo(true));
            assertThat("MatchA should have assigned a red card to piet.", pietHasCard, equalTo(true));
            assertThat("MatchA should have assigned a red card to henk.", henkHasCard, equalTo(true));
            assertThat("MatchA should not have assigned a red card to frank.", frankHasRedCard, equalTo(false));
        }
        {
            //Create new Match
            SoccerMatchModel soccerMatchB = SoccerMatchBuilder.build();
            MemoryEventStore memoryEventStoreB = new MemoryEventStore();
            MatchHandler matchHandlerB = new MatchHandler(soccerMatchB.getMatch(), memoryEventStoreB);

            //Restore MatchB
            matchHandlerB.restoreState(resultB);
            MatchState stateB = matchHandlerB.getMatch().getState();
            boolean equals = stateB.equals(MatchState.started);
            assertThat("MatchB should be correctly restored.", equals, equalTo(true));
        }
    }
View Full Code Here


        return this.matchId;
    }

    @Override
    public Event execute(Match match) {
        MatchState state = match.getState();
        if (state == MatchState.ended || state == MatchState.notStarted)
            throw new IllegalStateException(state.toString());
        return new DisqualifyPlayerEvent(this.getPlayerModel(), this.getMatchId());
    }
View Full Code Here

        return matchId;
    }

    @Override
    public Event execute(Match match) {
        MatchState state = match.getState();
        if (state != MatchState.notStarted)
            throw new IllegalStateException(state.toString());
        return new StartMatchEvent();
    }
View Full Code Here

    }

    @Override
    public Event execute(Match match) {

        MatchState state = match.getState();
        if (state != MatchState.started)
            throw new IllegalStateException(state.toString());
        return new EndMatchEvent();
    }
View Full Code Here

        return playerModel;
    }

    @Override
    public Event execute(Match match) {
        MatchState state = match.getState();
        if (state != MatchState.started)
            throw new IllegalStateException(state.toString());

        AssignYellowCardEvent assignYellowCardEvent = new AssignYellowCardEvent(this.getPlayerModel());

        if (hasYellowCard(match)) {
            Event redCardEvent = assignRedCard(match);
View Full Code Here

        return playerId;
    }

    @Override
    public Event execute(Match match) {
        MatchState state = match.getState();
        if (state != MatchState.started)
            throw new IllegalStateException(state.toString());
        return new AssignRedCardEvent(this.getPlayerId());
    }
View Full Code Here

TOP

Related Classes of match.aggregate.MatchState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.