final org.sonar.api.resources.File dummyFile = new org.sonar.api.resources.File("dummy/test");
final SensorContext context = mock(SensorContext.class);
final ProjectFileSystem fileSystem = mock(ProjectFileSystem.class);
final List<File> sourceDirs = new ArrayList<File>();
final Map<String, CoverageMeasuresBuilder> measures = new HashMap<String, CoverageMeasuresBuilder>();
final CoverageMeasuresBuilder measureBuilder = CoverageMeasuresBuilder.create();
sourceDirs.add(new File("/dummy"));
measures.put("/dummy/test", measureBuilder);
measureBuilder.setHits(99, 99);
measureBuilder.setConditions(99, 99, 1);
when(fileSystem.getSourceDirs()).thenReturn(sourceDirs);
when(context.getResource(any(Resource.class))).thenReturn(dummyFile);
project.setFileSystem(fileSystem);
final CoverageMeasuresPersistor testedPersistor = new CoverageMeasuresPersistor(project, context);
testedPersistor.saveMeasures(measures);
for (final Measure measure : measureBuilder.createMeasures()) {
verify(context, times(1)).saveMeasure(eq(new org.sonar.api.resources.File("test")), eq(measure));
}
}