Search in sources :

Example 6 with BLOCKER

use of org.sonar.api.rule.Severity.BLOCKER in project sonarqube by SonarSource.

the class IssueUpdaterTest method update_issue.

@Test
public void update_issue() {
    DefaultIssue issue = db.issues().insertIssue(i -> i.setSeverity(MAJOR)).toDefaultIssue();
    UserDto user = db.users().insertUser();
    IssueChangeContext context = IssueChangeContext.createUser(new Date(), user.getUuid());
    issueFieldsSetter.setSeverity(issue, BLOCKER, context);
    underTest.saveIssueAndPreloadSearchResponseData(db.getSession(), issue, context, false);
    IssueDto issueReloaded = dbClient.issueDao().selectByKey(db.getSession(), issue.key()).get();
    assertThat(issueReloaded.getSeverity()).isEqualTo(BLOCKER);
}
Also used : MAJOR(org.sonar.api.rule.Severity.MAJOR) IssueDto(org.sonar.db.issue.IssueDto) RuleDefinitionDto(org.sonar.db.rule.RuleDefinitionDto) UserDto(org.sonar.db.user.UserDto) Date(java.util.Date) EsTester(org.sonar.server.es.EsTester) ComponentTesting.newFileDto(org.sonar.db.component.ComponentTesting.newFileDto) RuleStatus(org.sonar.api.rule.RuleStatus) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Mockito.verifyZeroInteractions(org.mockito.Mockito.verifyZeroInteractions) IssueFieldsSetter(org.sonar.server.issue.IssueFieldsSetter) WebIssueStorage(org.sonar.server.issue.WebIssueStorage) ArgumentCaptor(org.mockito.ArgumentCaptor) IssueIteratorFactory(org.sonar.server.issue.index.IssueIteratorFactory) BLOCKER(org.sonar.api.rule.Severity.BLOCKER) IssueChangeContext(org.sonar.core.issue.IssueChangeContext) ChangedIssue(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue) NotificationManager(org.sonar.server.notification.NotificationManager) RESOLUTION_FIXED(org.sonar.api.issue.Issue.RESOLUTION_FIXED) DbTester(org.sonar.db.DbTester) BranchType(org.sonar.db.component.BranchType) TestIssueChangePostProcessor(org.sonar.server.issue.TestIssueChangePostProcessor) DefaultIssue(org.sonar.core.issue.DefaultIssue) System2(org.sonar.api.utils.System2) DefaultRuleFinder(org.sonar.server.rule.DefaultRuleFinder) IssuesChangesNotificationBuilderTesting.ruleOf(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.ruleOf) IssuesChangesNotificationBuilderTesting.userOf(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.userOf) Test(org.junit.Test) IssuesChangesNotification(org.sonar.server.issue.notification.IssuesChangesNotification) BRANCH(org.sonar.db.component.BranchType.BRANCH) UserChange(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange) IssuesChangesNotificationBuilderTesting.projectOf(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.projectOf) SequenceUuidFactory(org.sonar.core.util.SequenceUuidFactory) Mockito.verify(org.mockito.Mockito.verify) DbClient(org.sonar.db.DbClient) ComponentDto(org.sonar.db.component.ComponentDto) Rule(org.junit.Rule) IssuesChangesNotificationBuilderTesting.projectBranchOf(org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.projectBranchOf) IssueIndexer(org.sonar.server.issue.index.IssueIndexer) IssuesChangesNotificationSerializer(org.sonar.server.issue.notification.IssuesChangesNotificationSerializer) IssuesChangesNotificationBuilder(org.sonar.server.issue.notification.IssuesChangesNotificationBuilder) Mockito.mock(org.mockito.Mockito.mock) IssueChangeContext(org.sonar.core.issue.IssueChangeContext) UserDto(org.sonar.db.user.UserDto) IssueDto(org.sonar.db.issue.IssueDto) DefaultIssue(org.sonar.core.issue.DefaultIssue) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6 Test (org.junit.Test)6 Mockito.mock (org.mockito.Mockito.mock)6 RuleStatus (org.sonar.api.rule.RuleStatus)6 BLOCKER (org.sonar.api.rule.Severity.BLOCKER)6 System2 (org.sonar.api.utils.System2)6 DbTester (org.sonar.db.DbTester)6 RuleDefinitionDto (org.sonar.db.rule.RuleDefinitionDto)6 UserDto (org.sonar.db.user.UserDto)6 EsTester (org.sonar.server.es.EsTester)6 Date (java.util.Date)5 Rule (org.junit.Rule)5 ArgumentCaptor (org.mockito.ArgumentCaptor)5 Mockito.verify (org.mockito.Mockito.verify)5 Mockito.verifyZeroInteractions (org.mockito.Mockito.verifyZeroInteractions)5 RESOLUTION_FIXED (org.sonar.api.issue.Issue.RESOLUTION_FIXED)5 MAJOR (org.sonar.api.rule.Severity.MAJOR)5 DefaultIssue (org.sonar.core.issue.DefaultIssue)5 IssueChangeContext (org.sonar.core.issue.IssueChangeContext)5 SequenceUuidFactory (org.sonar.core.util.SequenceUuidFactory)5