mapper.configure(rules, 1);
// test the mapper
DummyOutputCollector<LongWritable, CDFitness> collector = new DummyOutputCollector<LongWritable, CDFitness>();
for (int index1 = 0; index1 < mapper.rules.size(); index1++) {
CDFitness eval1 = CDMapper.evaluate(mapper.target, mapper.rules.get(index1).classify(dl), dl.getLabel());
collector.collect(new LongWritable(index1), eval1);
}
// check the evaluations
Set<LongWritable> keys = collector.getKeys();
assertEquals("Number of evaluations", rules.size(), keys.size());
CDFitness[] expected = {TP, FP, TN, FN};
for (LongWritable key : keys) {
int index = (int) key.get();
assertEquals("Values for key " + key, 1, collector.getValue(key).size());
CDFitness eval = collector.getValue(key).get(0);
assertEquals("Evaluation of the rule " + key, expected[index], eval);
}
EasyMock.verify(rule);