### Question:
SimpleSelector extends AbstractSelector { @SuppressWarnings("unchecked") public void registerCandidates(Class<?> candidateType, Set candidates) { Collection existed = this.candidatesByType.get(candidateType); if (existed == null) { this.candidatesByType.put(candidateType, candidates); } else { existed.addAll(candidates); } } SimpleSelector();  SimpleSelector(Class<? extends SelectPolicy> defaultSelectPolicyClass); @SuppressWarnings("unchecked") void registerCandidates(Class<?> candidateType, Set candidates); void registerCandidate(Class<?> candidateType, Object candidate);  }### Answer:
@Test public void no_winner_when_no_matcher_annotation() { SimpleSelector simpleSelector = new SimpleSelector(); Set<Handler> handlers = new HashSet<>(); handlers.add(new NoAnno1Handler()); handlers.add(new NoAnno2Handler()); simpleSelector.registerCandidates(Handler.class, handlers); Handler winner = simpleSelector.select(new Object(), Handler.class); assertThat(winner).isNull(); }
@Test public void no_winner_when_all_reject() { SimpleSelector simpleSelector = new SimpleSelector(); Set<Handler> handlers = new HashSet<>(); handlers.add(new StarkHandler()); simpleSelector.registerCandidates(Handler.class, handlers); Map<String, String> req = new HashMap<>(); req.put("username", "thor"); req.put("version", "1.0.0"); Handler winner = simpleSelector.select(req, Handler.class); assertThat(winner).isNull(); }
@Test public void test_first_match_policy() { SimpleSelector simpleSelector = new SimpleSelector(); Set<Handler> handlers = new HashSet<>(); handlers.add(new StarkHandler()); simpleSelector.registerCandidates(Handler.class, handlers); Map<String, String> req = new HashMap<>(); req.put("username", "stark"); req.put("version", "1.0.0"); Handler winner = simpleSelector.select(req, Handler.class, new FirstMatchSelectPolicy<>()); assertThat(winner).isInstanceOf(StarkHandler.class); }