Examples of MatchState


Examples of fiftyone.mobile.detection.Match.MatchState

     * @return
     * @throws IOException
     * @throws Exception
     */
    public Match match(String targetUserAgent, Match match) throws IOException {
        MatchState state;

        if (userAgentCache != null && targetUserAgent != null) {
            state = userAgentCache.tryGetValue(targetUserAgent);
            if (state == null) {
                // The user agent has not been checked previously. Therefore perform
                // the match and store the results in the cache.
                match = matchNoCache(targetUserAgent, match);

                // Record the match state in the cache for next time.
                state = match.new MatchState(match);
                userAgentCache.setActive(targetUserAgent, state);
            } else {
                // The state of a previous match exists so the match should
                // be configured based on the results of the previous state.
                match.setState(state);
View Full Code Here

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

Examples of match.aggregate.MatchState

        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

Examples of match.aggregate.MatchState

        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

Examples of match.aggregate.MatchState

    }

    @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

Examples of match.aggregate.MatchState

        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

Examples of match.aggregate.MatchState

        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

Examples of org.languagetool.rules.patterns.MatchState

  public void testSpeller() throws Exception {
    //tests with synthesizer
    Match match = getMatch("POS1", "POS2", true);
    final Polish polish = new Polish();
    MatchState matchState = new MatchState(match, polish.getSynthesizer());
    matchState.setToken(getAnalyzedTokenReadings("inflectedform11", "POS1", "Lemma1"));
    //getting empty strings, which is what we want
    assertEquals("[]", Arrays.toString(matchState.toFinalString(polish)));

    // contrast with a speller = false!
    match = getMatch("POS1", "POS2", false);
    matchState = new MatchState(match, polish.getSynthesizer());
    matchState.setToken(getAnalyzedTokenReadings("inflectedform11", "POS1", "Lemma1"));
    assertEquals("[(inflectedform11)]", Arrays.toString(matchState.toFinalString(polish)));

    //and now a real word - we should get something
    match = getMatch("subst:sg:acc.nom:m3", "subst:sg:gen:m3", true);
    matchState = new MatchState(match, polish.getSynthesizer());
    matchState.setToken(getAnalyzedTokenReadings("AON", "subst:sg:acc.nom:m3", "AON"));
    assertEquals("[AON-u]", Arrays.toString(matchState.toFinalString(polish)));

    //and now pure text changes       
    match = getTextMatch("^(.*)$", "$0-u", true);
    match.setSynthesizer(polish.getSynthesizer());
    match.setLemmaString("AON");
    matchState = new MatchState(match, polish.getSynthesizer());
    assertEquals("[AON-u]", Arrays.toString(matchState.toFinalString(polish)));
    match.setLemmaString("batalion");
    //should be empty
    matchState = new MatchState(match, polish.getSynthesizer());
    assertEquals("[]", Arrays.toString(matchState.toFinalString(polish)));
    match.setLemmaString("ASEAN");
    //and this one not
    matchState = new MatchState(match, polish.getSynthesizer());
    assertEquals("[ASEAN-u]", Arrays.toString(matchState.toFinalString(polish)));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.