### Question:
OpenNlpNerRecommender extends RecommendationEngine { @Override public void train(RecommenderContext aContext, List<CAS> aCasses) throws RecommendationException { List<NameSample> nameSamples = extractNameSamples(aCasses); if (nameSamples.size() < 2) { LOG.info("Not enough training data: [{}] items", nameSamples.size()); return; } int beamSize = Math.max(maxRecommendations, NameFinderME.DEFAULT_BEAM_SIZE); TrainingParameters params = traits.getParameters(); params.put(BeamSearch.BEAM_SIZE_PARAMETER, Integer.toString(beamSize)); TokenNameFinderModel model = train(nameSamples, params); aContext.put(KEY_MODEL, model); } OpenNlpNerRecommender(Recommender aRecommender, OpenNlpNerRecommenderTraits aTraits); @Override boolean isReadyForPrediction(RecommenderContext aContext); @Override void train(RecommenderContext aContext, List<CAS> aCasses); @Override RecommendationEngineCapability getTrainingCapability(); @Override void predict(RecommenderContext aContext, CAS aCas); @Override EvaluationResult evaluate(List<CAS> aCasses, DataSplitter aDataSplitter); static final Key<TokenNameFinderModel> KEY_MODEL; }### Answer:
@Test public void thatTrainingWorks() throws Exception { OpenNlpNerRecommender sut = new OpenNlpNerRecommender(recommender, traits); List<CAS> casList = loadDevelopmentData(); sut.train(context, casList); assertThat(context.get(OpenNlpNerRecommender.KEY_MODEL)) .as("Model has been set") .isPresent(); }