use of org.sonar.java.SonarComponents in project sonar-java by SonarSource.
the class XmlCheckContextImplTest method createSonarComponentsMock.
private static SonarComponents createSonarComponentsMock() {
SonarComponents sonarComponents = mock(SonarComponents.class);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
reportedMessage = "onLine:" + invocation.getArguments()[3];
return null;
}
}).when(sonarComponents).addIssue(any(File.class), eq(CHECK), eq(LINE), anyString(), eq(null));
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
reportedMessage = "onFile:" + invocation.getArguments()[3];
return null;
}
}).when(sonarComponents).addIssue(any(File.class), eq(CHECK), eq(-1), anyString(), eq(null));
when(sonarComponents.fileLines(Mockito.any(File.class))).thenAnswer(invocation -> {
File arg = (File) invocation.getArguments()[0];
return Files.readLines(arg, StandardCharsets.UTF_8);
});
return sonarComponents;
}
Aggregations