### Question:
StringMatchingRecommender extends RecommendationEngine { @Override public void train(RecommenderContext aContext, List<CAS> aCasses) throws RecommendationException { if (gazeteerService != null) { for (Gazeteer gaz : gazeteerService.listGazeteers(recommender)) { try { pretrain(gazeteerService.readGazeteerFile(gaz), aContext); } catch (IOException e) { log.info("Unable to load gazeteer [{}] for recommender [{}]({}) in project [{}]({})", gaz.getName(), gaz.getRecommender().getName(), gaz.getRecommender().getId(), gaz.getRecommender().getProject().getName(), gaz.getRecommender().getProject().getId(), e); } } } Trie<DictEntry> dict = aContext.get(KEY_MODEL).orElseGet(this::createTrie); for (CAS cas : aCasses) { Type predictedType = getPredictedType(cas); Feature predictedFeature = getPredictedFeature(cas); for (AnnotationFS ann : select(cas, predictedType)) { learn(dict, ann.getCoveredText(), ann.getFeatureValueAsString(predictedFeature)); } } aContext.put(KEY_MODEL, dict); log.debug("Learned dictionary model with {} entries", dict.size()); } StringMatchingRecommender(Recommender aRecommender,
            StringMatchingRecommenderTraits aTraits);  StringMatchingRecommender(Recommender aRecommender,
            StringMatchingRecommenderTraits aTraits, GazeteerService aGazeteerService); @Override boolean isReadyForPrediction(RecommenderContext aContext); void pretrain(List<GazeteerEntry> aData, RecommenderContext aContext); @Override void train(RecommenderContext aContext, List<CAS> aCasses); @Override void predict(RecommenderContext aContext, CAS aCas); @Override EvaluationResult evaluate(List<CAS> aCasses, DataSplitter aDataSplitter); static final Key<Trie<DictEntry>> KEY_MODEL; }### Answer:
@Test public void thatTrainingWorks() throws Exception { StringMatchingRecommender sut = new StringMatchingRecommender(recommender, traits); List<CAS> casList = loadDevelopmentData(); sut.train(context, casList); assertThat(context.get(StringMatchingRecommender.KEY_MODEL)) .as("Model has been set") .isNotNull(); }