@Test public void should_propose_keyword_at_cursor_as_missing() throws Exception { Content origContents = new Content( "*Settings\nTest Teardown Existing keyword\nTest Teardown Missing keyword 1 argument1\n*Keywords\n<arg>Existing keyword<argend>"); IFile origFile = addFile("orig.txt", origContents.c()); visitor = new KeywordDefinitionAttemptVisitor( origFile, origContents.ps("arg-argend", 0, ArgumentType.NEW_KEYWORD)); RobotCompletionProposalSet proposalSet = visitor.visitAttempt("", new Region(0, 0)); List<RobotCompletionProposal> proposals = proposalSet.getProposals(); assertEquals(proposals.toString(), 2, proposals.size()); assertEquals("Existing keyword", proposals.get(0).getMatchArgument()); assertThat( htmlToText(proposals.get(0).getAdditionalProposalInfo()), is(PREAMBLE + "- SETTING Test Teardown")); assertEquals("Missing keyword 1", proposals.get(1).getMatchArgument()); assertThat( htmlToText(proposals.get(1).getAdditionalProposalInfo()), is(PREAMBLE + "- SETTING Test Teardown")); }
@Test public void should_filter_missing_keywords_by_attempted_prefix() throws Exception { Content origContents = new Content( "*Settings\nSuite Setup Existing keyword\nSuite Teardown Keyword missing 1 argument1\nTest Setup Keyword missing 2\nTest Teardown Keyword existing\nTest Template Non-existent but mismatching prefix\n*Keywords\nKeyword existing\n<arg>Keyword <cursor>missing 1<argend>"); IFile origFile = addFile("orig.txt", origContents.c()); visitor = new KeywordDefinitionAttemptVisitor( origFile, origContents.ps("arg-argend", 0, ArgumentType.NEW_KEYWORD)); RobotCompletionProposalSet proposalSet = visitor.visitAttempt(origContents.s("arg-cursor").toLowerCase(), new Region(0, 0)); List<RobotCompletionProposal> proposals = proposalSet.getProposals(); assertEquals(proposals.toString(), 2, proposals.size()); assertEquals("Keyword missing 1", proposals.get(0).getMatchArgument()); assertThat( htmlToText(proposals.get(0).getAdditionalProposalInfo()), is(PREAMBLE + "- SETTING Suite Teardown")); assertEquals("Keyword missing 2", proposals.get(1).getMatchArgument()); assertThat( htmlToText(proposals.get(1).getAdditionalProposalInfo()), is(PREAMBLE + "- SETTING Test Setup")); }