@Test public void should_only_return_proposals_based_on_input_regardless_of_high_priority() throws Exception { RobotCompletionProposalSet setHighPriorityNotBasedOnInput = new RobotCompletionProposalSet(); setHighPriorityNotBasedOnInput.setBasedOnInput(false); setHighPriorityNotBasedOnInput.setPriorityProposal(); RobotCompletionProposalSet setNormalPriorityBasedOnInput = new RobotCompletionProposalSet(); setNormalPriorityBasedOnInput.setBasedOnInput(true); addProposalsTo(setHighPriorityNotBasedOnInput, 3, "setHighPriorityNotBasedOnInput"); ICompletionProposal[] expectedNormalPriorityBasedOnInput = addProposalsTo(setNormalPriorityBasedOnInput, 3, "setNormalPriorityBasedOnInput"); List<RobotCompletionProposalSet> sets = new ArrayList<RobotCompletionProposalSet>(); sets.add(setHighPriorityNotBasedOnInput); sets.add(setNormalPriorityBasedOnInput); ICompletionProposal[] actual = filter.extractMostRelevantProposals(sets); assertArrayEquals(expectedNormalPriorityBasedOnInput, actual); }
@Override public ICompletionProposal[] extractMostRelevantProposals(List<RobotCompletionProposalSet> proposalSets2) { PriorityDeque<RobotCompletionProposalSet> proposalSets = removeEmptyProposalSets(proposalSets2); int lowestPriority = proposalSets.peekLowestPriority(); boolean isEmpty = lowestPriority == -1; if (isEmpty) { return null; } if (lowestPriority < NOT_BASED_ON_INPUT_MASK) { proposalSets.clear(NOT_BASED_ON_INPUT_MASK, proposalSets.getNumberOfPriorityLevels() - 1); } List<RobotCompletionProposal> proposals = new ArrayList<RobotCompletionProposal>(); for (RobotCompletionProposalSet proposalSet : proposalSets) { proposals.addAll(proposalSet.getProposals()); } return proposals.toArray(new ICompletionProposal[proposals.size()]); }
RelevantProposalsFilter implements IRelevantProposalsFilter { @Override public ICompletionProposal[] extractMostRelevantProposals(List<RobotCompletionProposalSet> proposalSets2) { PriorityDeque<RobotCompletionProposalSet> proposalSets = removeEmptyProposalSets(proposalSets2); int lowestPriority = proposalSets.peekLowestPriority(); boolean isEmpty = lowestPriority == -1; if (isEmpty) { return null; } if (lowestPriority < NOT_BASED_ON_INPUT_MASK) { proposalSets.clear(NOT_BASED_ON_INPUT_MASK, proposalSets.getNumberOfPriorityLevels() - 1); } List<RobotCompletionProposal> proposals = new ArrayList<RobotCompletionProposal>(); for (RobotCompletionProposalSet proposalSet : proposalSets) { proposals.addAll(proposalSet.getProposals()); } return proposals.toArray(new ICompletionProposal[proposals.size()]); } }
RelevantProposalsFilter implements IRelevantProposalsFilter { @Override public ICompletionProposal[] extractMostRelevantProposals(List<RobotCompletionProposalSet> proposalSets2) { PriorityDeque<RobotCompletionProposalSet> proposalSets = removeEmptyProposalSets(proposalSets2); int lowestPriority = proposalSets.peekLowestPriority(); boolean isEmpty = lowestPriority == -1; if (isEmpty) { return null; } if (lowestPriority < NOT_BASED_ON_INPUT_MASK) { proposalSets.clear(NOT_BASED_ON_INPUT_MASK, proposalSets.getNumberOfPriorityLevels() - 1); } List<RobotCompletionProposal> proposals = new ArrayList<RobotCompletionProposal>(); for (RobotCompletionProposalSet proposalSet : proposalSets) { proposals.addAll(proposalSet.getProposals()); } return proposals.toArray(new ICompletionProposal[proposals.size()]); }  }
RelevantProposalsFilter implements IRelevantProposalsFilter { @Override public ICompletionProposal[] extractMostRelevantProposals(List<RobotCompletionProposalSet> proposalSets2) { PriorityDeque<RobotCompletionProposalSet> proposalSets = removeEmptyProposalSets(proposalSets2); int lowestPriority = proposalSets.peekLowestPriority(); boolean isEmpty = lowestPriority == -1; if (isEmpty) { return null; } if (lowestPriority < NOT_BASED_ON_INPUT_MASK) { proposalSets.clear(NOT_BASED_ON_INPUT_MASK, proposalSets.getNumberOfPriorityLevels() - 1); } List<RobotCompletionProposal> proposals = new ArrayList<RobotCompletionProposal>(); for (RobotCompletionProposalSet proposalSet : proposalSets) { proposals.addAll(proposalSet.getProposals()); } return proposals.toArray(new ICompletionProposal[proposals.size()]); }  @Override ICompletionProposal[] extractMostRelevantProposals(List<RobotCompletionProposalSet> proposalSets2); }
RelevantProposalsFilter implements IRelevantProposalsFilter { @Override public ICompletionProposal[] extractMostRelevantProposals(List<RobotCompletionProposalSet> proposalSets2) { PriorityDeque<RobotCompletionProposalSet> proposalSets = removeEmptyProposalSets(proposalSets2); int lowestPriority = proposalSets.peekLowestPriority(); boolean isEmpty = lowestPriority == -1; if (isEmpty) { return null; } if (lowestPriority < NOT_BASED_ON_INPUT_MASK) { proposalSets.clear(NOT_BASED_ON_INPUT_MASK, proposalSets.getNumberOfPriorityLevels() - 1); } List<RobotCompletionProposal> proposals = new ArrayList<RobotCompletionProposal>(); for (RobotCompletionProposalSet proposalSet : proposalSets) { proposals.addAll(proposalSet.getProposals()); } return proposals.toArray(new ICompletionProposal[proposals.size()]); }  @Override ICompletionProposal[] extractMostRelevantProposals(List<RobotCompletionProposalSet> proposalSets2);  }