@Test(timeout = 2000) public void should_check_url() { when(conf.getThreadCount()).thenReturn(1); when(conf.getUrl()).thenReturn("scm:url"); scmActivitySensor.analyse(project, context); verify(urlChecker).check("scm:url"); }
@Test public void should_carry_on_after_error() { InputFile first = file("source.java"); InputFile second = file("UNKNOWN.java"); when(conf.getThreadCount()).thenReturn(1); fs.add(first); fs.add(second); when(context.getResource(any(org.sonar.api.resources.File.class))).thenReturn(file); when(blameVersionSelector.detect(file, first, context)).thenThrow(new RuntimeException("BUG")); when(blameVersionSelector.detect(file, second, context)).thenReturn(measureUpdate); scmActivitySensor.analyse(project, context); verify(measureUpdate).execute(timeMachine, context); }
@Test public void should_execute_measure_update_for_known_files() { InputFile source = file("source.java"); InputFile test = file("UNKNOWN.java"); when(conf.getThreadCount()).thenReturn(1); fs.add(source); fs.add(test); when(blameVersionSelector.detect( any(org.sonar.api.resources.File.class), eq(source), eq(context))) .thenReturn(measureUpdate); when(context.getResource(any(org.sonar.api.resources.File.class))) .thenReturn(file) .thenReturn(null); scmActivitySensor.analyse(project, context); verify(measureUpdate, only()).execute(timeMachine, context); }