use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarqube by SonarSource.
the class IssuesActionTest method return_minimal_fields.
@Test
public void return_minimal_fields() throws Exception {
ComponentDto project = ComponentTesting.newProjectDto(db.getDefaultOrganization(), PROJECT_UUID).setKey(PROJECT_KEY);
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY);
ComponentDto file = ComponentTesting.newFileDto(module, null, FILE_UUID).setKey(FILE_KEY).setPath(null);
db.getDbClient().componentDao().insert(db.getSession(), project, module, file);
db.getSession().commit();
indexIssues(IssueDocTesting.newDoc("EFGH", file).setRuleKey("squid:AvoidCycle").setSeverity("BLOCKER").setStatus("RESOLVED").setResolution(null).setManualSeverity(false).setMessage(null).setLine(null).setChecksum(null).setAssignee(null));
addBrowsePermissionOnComponent(project);
WsTester.TestRequest request = tester.newGetRequest("batch", "issues").setParam("key", PROJECT_KEY);
ServerIssue serverIssue = ServerIssue.parseDelimitedFrom(new ByteArrayInputStream(request.execute().output()));
assertThat(serverIssue.getKey()).isEqualTo("EFGH");
assertThat(serverIssue.getModuleKey()).isEqualTo(MODULE_KEY);
assertThat(serverIssue.hasPath()).isFalse();
assertThat(serverIssue.getRuleRepository()).isEqualTo("squid");
assertThat(serverIssue.getRuleKey()).isEqualTo("AvoidCycle");
assertThat(serverIssue.hasLine()).isFalse();
assertThat(serverIssue.hasMsg()).isFalse();
assertThat(serverIssue.hasResolution()).isFalse();
assertThat(serverIssue.getStatus()).isEqualTo("RESOLVED");
assertThat(serverIssue.getSeverity()).isEqualTo(Severity.BLOCKER);
assertThat(serverIssue.getManualSeverity()).isFalse();
assertThat(serverIssue.hasChecksum()).isFalse();
assertThat(serverIssue.hasAssigneeLogin()).isFalse();
}
use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarqube by SonarSource.
the class IssuesActionTest method issues_attached_on_module.
@Test
public void issues_attached_on_module() throws Exception {
OrganizationDto organizationDto = db.organizations().insert();
ComponentDto project = ComponentTesting.newProjectDto(organizationDto, PROJECT_UUID).setKey(PROJECT_KEY);
ComponentDto module = ComponentTesting.newModuleDto(MODULE_UUID, project).setKey(MODULE_KEY);
db.getDbClient().componentDao().insert(db.getSession(), project, module);
db.getSession().commit();
indexIssues(IssueDocTesting.newDoc("EFGH", module).setRuleKey("squid:AvoidCycle").setSeverity("BLOCKER").setStatus("RESOLVED").setResolution("FALSE-POSITIVE").setManualSeverity(false).setMessage("Do not use this method").setLine(200).setChecksum("123456").setAssignee("john"));
addBrowsePermissionOnComponent(project);
WsTester.TestRequest request = tester.newGetRequest("batch", "issues").setParam("key", MODULE_KEY);
ServerIssue previousIssue = ServerIssue.parseDelimitedFrom(new ByteArrayInputStream(request.execute().output()));
assertThat(previousIssue.getKey()).isEqualTo("EFGH");
assertThat(previousIssue.getModuleKey()).isEqualTo(MODULE_KEY);
assertThat(previousIssue.hasPath()).isFalse();
assertThat(previousIssue.getRuleRepository()).isEqualTo("squid");
assertThat(previousIssue.getRuleKey()).isEqualTo("AvoidCycle");
assertThat(previousIssue.getLine()).isEqualTo(200);
assertThat(previousIssue.getMsg()).isEqualTo("Do not use this method");
assertThat(previousIssue.getResolution()).isEqualTo("FALSE-POSITIVE");
assertThat(previousIssue.getStatus()).isEqualTo("RESOLVED");
assertThat(previousIssue.getSeverity()).isEqualTo(Severity.BLOCKER);
assertThat(previousIssue.getManualSeverity()).isFalse();
assertThat(previousIssue.getChecksum()).isEqualTo("123456");
assertThat(previousIssue.getAssigneeLogin()).isEqualTo("john");
}
use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarqube by SonarSource.
the class DefaultServerIssuesLoader method parseIssues.
private static void parseIssues(InputStream is, Function<ServerIssue, Void> consumer) {
try {
ServerIssue previousIssue = ServerIssue.parseDelimitedFrom(is);
while (previousIssue != null) {
consumer.apply(previousIssue);
previousIssue = ServerIssue.parseDelimitedFrom(is);
}
} catch (IOException e) {
throw new IllegalStateException("Unable to get previous issues", e);
} finally {
IOUtils.closeQuietly(is);
}
}
use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarqube by SonarSource.
the class ServerIssueValueCoder method put.
@Override
public void put(Value value, Object object, CoderContext context) {
ServerIssue issue = (ServerIssue) object;
value.putByteArray(issue.toByteArray());
}
use of org.sonar.scanner.protocol.input.ScannerInput.ServerIssue in project sonarqube by SonarSource.
the class DefaultServerIssuesLoaderTest method loadFromWs.
@Test
public void loadFromWs() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ServerIssue.newBuilder().setKey("ab1").build().writeDelimitedTo(bos);
ServerIssue.newBuilder().setKey("ab2").build().writeDelimitedTo(bos);
InputStream is = new ByteArrayInputStream(bos.toByteArray());
WsTestUtil.mockStream(wsClient, "/batch/issues.protobuf?key=foo", is);
final List<ServerIssue> result = new ArrayList<>();
loader.load("foo", issue -> {
result.add(issue);
return null;
});
assertThat(result).extracting("key").containsExactly("ab1", "ab2");
}
Aggregations