### Question:
IndexerForSearchSelector { protected boolean checkSearchSource(Indexer indexer) { boolean wrongSearchSource = !indexer.getConfig().getEnabledForSearchSource().meets(searchRequest); if (wrongSearchSource) { String message = String.format("Not using %s because the search source is %s but the indexer is only enabled for %s searches", indexer.getName(), searchRequest.getSource(), indexer.getConfig().getEnabledForSearchSource()); return handleIndexerNotSelected(indexer, message, "Not enabled for this search context"); } return true; }  IndexerForSearchSelection pickIndexers(SearchRequest searchRequest); static final Pattern SCHEDULER_PATTERN; }### Answer:
@Test public void shouldCheckContext() { when(searchModuleProviderMock.getIndexers()).thenReturn(Arrays.asList(indexer)); when(searchRequest.getSource()).thenReturn(SearchSource.INTERNAL); indexerConfigMock.setEnabledForSearchSource(SearchSourceRestriction.API); assertFalse(testee.checkSearchSource(indexer)); when(searchRequest.getSource()).thenReturn(SearchSource.API); assertTrue(testee.checkSearchSource(indexer)); }