@Test public void printsUsersChoice() { Prompt prompt = new CommandLinePrompt(defaultReader, writer); prompt.displayChosenMove(ROCK, "Bob"); assertThat(writer.toString(), is("Bob chose 1 - ROCK\n")); }
@Test public void readsInputFromPlayer() { Prompt prompt = new CommandLinePrompt(readerWithInput("1\n"), writer); Gesture gesture = prompt.readValidGestureFrom("player one"); assertThat(gesture, is(ROCK)); assertThat(writer.toString(), is("")); }
@Test public void readsReplayOption() { Prompt prompt = new CommandLinePrompt(readerWithInput("Y"), writer); ReplayOption replayOption = prompt.readValidReplayOption(); assertThat(replayOption, is(Y)); assertThat(writer.toString(), is("")); }
@Test public void repromptsUserWhenTheyEnterANumberOutsideOfGestureRange() { Prompt prompt = new CommandLinePrompt(readerWithInput("7\n2"), writer); Gesture gesture = prompt.readValidGestureFrom("Player one"); assertThat( writer.toString(), is("Player one - please enter:\n1 for ROCK\n2 for PAPER\n3 for SCISSORS\n")); assertThat(gesture, is(PAPER)); }
/** Displays the next user prompt and abandons the conversation if the next prompt is null. */ public void outputNextPrompt() { if (currentPrompt == null) { abandon(new ConversationAbandonedEvent(this)); } else { context .getForWhom() .sendRawMessage(prefix.getPrefix(context) + currentPrompt.getPromptText(context)); if (!currentPrompt.blocksForInput(context)) { currentPrompt = currentPrompt.acceptInput(context, null); outputNextPrompt(); } } }
public final void run() { label0: { x.a(e, null); com.nuance.nmdp.speechkit.x.b(e, null); x.c(e, null); x.d(e, null); if (a != null) { if (!a.a().b()) { x.a(e, a); } else { com.nuance.nmdp.speechkit.recognitionresult.b.b(this, "Recording start prompt is invalid"); } } if (b != null) { if (!b.a().b()) { com.nuance.nmdp.speechkit.x.b(e, b); } else { com.nuance.nmdp.speechkit.recognitionresult.b.b(this, "Recording stop prompt is invalid"); } } if (c != null) { if (!c.a().b()) { x.c(e, c); } else { com.nuance.nmdp.speechkit.recognitionresult.b.b(this, "Result prompt is invalid"); } } if (d != null) { if (d.a().b()) { break label0; } x.d(e, d); } return; } com.nuance.nmdp.speechkit.recognitionresult.b.b(this, "Error prompt is invalid"); }
@RequestMapping("/info") public String info(Model model, Principal principal) { String result = login(model, principal); List<Map<String, String>> list = new ArrayList<Map<String, String>>(); for (Prompt prompt : prompts) { Map<String, String> map = new LinkedHashMap<String, String>(); map.put("name", prompt.getName()); map.put("type", prompt.getDetails()[0]); map.put("text", prompt.getDetails()[1]); list.add(map); } model.addAttribute("prompts", list); return result; }
@Test public void promptPlayerForInput() { prompt.promptForGestureFrom("Player abc"); assertThat( writer.toString(), is("Player abc - please enter:\n1 for ROCK\n2 for PAPER\n3 for SCISSORS\n")); }
@RequestMapping(value = {"/", "/login"}) public String login(Model model, Principal principal) { Map<String, String[]> map = new LinkedHashMap<String, String[]>(); for (Prompt prompt : prompts) { map.put(prompt.getName(), prompt.getDetails()); } model.addAttribute("prompts", map); model.addAttribute("commit_id", gitProperties.getProperty("git.commit.id.abbrev", "UNKNOWN")); model.addAttribute( "timestamp", gitProperties.getProperty( "git.commit.time", new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()))); model.addAttribute("app", UaaStringUtils.getMapFromProperties(buildProperties, "build.")); if (principal == null) { return "login"; } return "home"; }
/** * Takes the user input and returns as a PegArray * * @return The inputter PegArray */ private PegArray getUserGuess() { // Setup the guess array and the char to read from user PegArray guess = new PegArray(); char read = '0'; // Cycle through the Array for (int ind = 0; ind < 4; ind++) { // Make sure to take only valid input if (read == '0') { read = Prompt.getString("\tEnter your guess for Peg number " + ind + " (A, B, C, D, E, F)") .charAt(0); // Set the peg with the new character guess.getPeg(ind).setLetter(read); } read = '0'; } return guess; }
/** * Passes player input into the current prompt. The next prompt (as determined by the current * prompt) is then displayed to the user. * * @param input The user's chat text. */ public void acceptInput(String input) { if (currentPrompt != null) { // Echo the user's input if (localEchoEnabled) { context.getForWhom().sendRawMessage(prefix.getPrefix(context) + input); } // Test for conversation abandonment based on input for (ConversationCanceller canceller : cancellers) { if (canceller.cancelBasedOnInput(context, input)) { abandon(new ConversationAbandonedEvent(this, canceller)); return; } } // Not abandoned, output the next prompt currentPrompt = currentPrompt.acceptInput(context, input); outputNextPrompt(); } }
@Test public void displaysDraw() { prompt.displayDraw(); assertThat(writer.toString(), is("Draw\n")); }
@Test public void displaysWin() { prompt.displayWinner("Winner name"); assertThat(writer.toString(), is("Winner name won\n")); }
@Test public void displaysStatus() { prompt.display("Winner"); assertThat(writer.toString(), is("Winner\n\n")); }
@Test(expected = WriteException.class) public void exceptionThrownWhenErrorWritingToPrompt() { Prompt prompt = new CommandLinePrompt(defaultReader, new StringWriterStub()); prompt.promptForGestureFrom("Player one"); }
public MenulistInput(JSONObject obj) { super(obj); mListitems = Prompt.getStringArray(obj, "values"); mSelected = obj.optInt("selected"); }
@Test public void promptsUserToReplay() { prompt.promptForReplay(); assertThat(writer.toString(), is("Enter Y to replay\n")); }
@Test(expected = ReadException.class) public void exceptionThrownWhenErrorReading() { Prompt prompt = new CommandLinePrompt(new StringReaderStub(), writer); prompt.readValidGestureFrom("Player one"); }