SettingTableAttemptVisitor implements AttemptVisitor { @Override public RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion) { assert attempt.equals(attempt.toLowerCase()); RobotCompletionProposalSet ourProposalSet = new RobotCompletionProposalSet(); for (String key : settingKeys) { if (key.toLowerCase().startsWith(attempt)) { String proposal = key; Image image = null; String displayString = key; String additionalProposalInfo = null; String informationDisplayString = null; ourProposalSet.getProposals().add(new RobotCompletionProposal(proposal, null, replacementRegion, image, displayString, informationDisplayString, additionalProposalInfo)); } } return ourProposalSet; } SettingTableAttemptVisitor(); @Override RobotCompletionProposalSet visitAttempt(String attempt, IRegion replacementRegion);  }
@Test public void should_not_return_a_high_priority_proposalSet() { RobotCompletionProposalSet proposalSet = visitor.visitAttempt("", replacementRegion); assertThat(proposalSet.isPriorityProposal(), is(false)); }
@Test public void should_not_set_basedOnInput_property() { RobotCompletionProposalSet proposalSet = visitor.visitAttempt("", replacementRegion); try { proposalSet.isBasedOnInput(); fail("basedOnInput property was unexpectedly set"); } catch (IllegalStateException e) { } }
@Test public void should_return_all_for_empty_input() { String attempt = ""; RobotCompletionProposalSet proposalSet = visitor.visitAttempt(attempt, replacementRegion); verifyExpectedProposals(attempt, proposalSet, ALL_PROPOSALS); }
@Test public void should_return_Documentation_proposal_for_relevant_prefixes() { for (String attempt : new String[] { "do", "documentation" }) { RobotCompletionProposalSet proposalSet = visitor.visitAttempt(attempt, replacementRegion); verifyExpectedProposals(attempt, proposalSet, "Documentation"); } }
@Test public void should_return_Suite_Setup_proposal_for_relevant_prefixes() { for (String attempt : new String[] { "suite s", "suite setup" }) { RobotCompletionProposalSet proposalSet = visitor.visitAttempt(attempt, replacementRegion); verifyExpectedProposals(attempt, proposalSet, "Suite Setup"); } }
@Test public void should_return_T_proposals_for_relevant_prefixes() { for (String attempt : new String[] { "t", "test" }) { RobotCompletionProposalSet proposalSet = visitor.visitAttempt(attempt, replacementRegion); verifyExpectedProposals(attempt, proposalSet, "Test Setup", "Test Template", "Test Teardown", "Test Timeout"); } }
@Test public void should_not_return_any_proposals_for_irrelevant_prefixes() { for (char ch = 33; ch <= 126; ++ch) { if ("dflmprstv".indexOf(ch) != -1 || Character.isUpperCase(ch)) { continue; } String attempt = Character.toString(ch); RobotCompletionProposalSet proposalSet = visitor.visitAttempt(attempt, replacementRegion); verifyExpectedProposals(attempt, proposalSet); } }