Tabnine Logo
IssueFieldsSetter.setSeverity
Code IndexAdd Tabnine to your IDE (free)

How to use
setSeverity
method
in
org.sonar.server.issue.IssueFieldsSetter

Best Java code snippets using org.sonar.server.issue.IssueFieldsSetter.setSeverity (Showing top 13 results out of 315)

origin: SonarSource/sonarqube

public boolean setPastSeverity(DefaultIssue issue, @Nullable String previousSeverity, IssueChangeContext context) {
 String currentSeverity = issue.severity();
 issue.setSeverity(previousSeverity);
 return setSeverity(issue, currentSeverity, context);
}
origin: SonarSource/sonarqube

@Test
public void not_revert_manual_severity() {
 issue.setSeverity("MINOR").setManualSeverity(true);
 try {
  underTest.setSeverity(issue, "MAJOR", context);
 } catch (IllegalStateException e) {
  assertThat(e).hasMessage("Severity can't be changed");
 }
}
origin: SonarSource/sonarqube

@Test
public void not_change_severity() {
 issue.setSeverity("MINOR");
 boolean updated = underTest.setSeverity(issue, "MINOR", context);
 assertThat(updated).isFalse();
 assertThat(issue.mustSendNotifications()).isFalse();
 assertThat(issue.currentChange()).isNull();
}
origin: SonarSource/sonarqube

@Test
public void update_severity() {
 issue.setSeverity("BLOCKER");
 boolean updated = underTest.setSeverity(issue, "MINOR", context);
 assertThat(updated).isTrue();
 assertThat(issue.severity()).isEqualTo("MINOR");
 assertThat(issue.mustSendNotifications()).isFalse();
 FieldDiffs.Diff diff = issue.currentChange().get(SEVERITY);
 assertThat(diff.oldValue()).isEqualTo("BLOCKER");
 assertThat(diff.newValue()).isEqualTo("MINOR");
}
origin: SonarSource/sonarqube

@Test
public void set_severity() {
 boolean updated = underTest.setSeverity(issue, "BLOCKER", context);
 assertThat(updated).isTrue();
 assertThat(issue.severity()).isEqualTo("BLOCKER");
 assertThat(issue.manualSeverity()).isFalse();
 assertThat(issue.mustSendNotifications()).isFalse();
 FieldDiffs.Diff diff = issue.currentChange().get(SEVERITY);
 assertThat(diff.oldValue()).isNull();
 assertThat(diff.newValue()).isEqualTo("BLOCKER");
}
origin: SonarSource/sonarqube

@Test
public void update_issue() {
 DefaultIssue issue = db.issues().insertIssue(i -> i.setSeverity(MAJOR)).toDefaultIssue();
 IssueChangeContext context = IssueChangeContext.createUser(new Date(), "user_uuid");
 issueFieldsSetter.setSeverity(issue, BLOCKER, context);
 underTest.saveIssue(db.getSession(), issue, context, null);
 IssueDto issueReloaded = dbClient.issueDao().selectByKey(db.getSession(), issue.key()).get();
 assertThat(issueReloaded.getSeverity()).isEqualTo(BLOCKER);
}
origin: SonarSource/sonarqube

@Test
public void verify_notification() {
 UserDto assignee = db.users().insertUser();
 RuleDto rule = db.rules().insertRule();
 ComponentDto project = db.components().insertPrivateProject();
 ComponentDto file = db.components().insertComponent(newFileDto(project));
 RuleType randomTypeExceptHotspot = RuleType.values()[nextInt(RuleType.values().length - 1)];
 DefaultIssue issue = db.issues().insertIssue(IssueTesting.newIssue(rule.getDefinition(), project, file)
  .setType(randomTypeExceptHotspot))
  .setSeverity(MAJOR)
  .setAssigneeUuid(assignee.getUuid())
  .toDefaultIssue();
 UserDto changeAuthor = db.users().insertUser();
 IssueChangeContext context = IssueChangeContext.createUser(new Date(), changeAuthor.getUuid());
 issueFieldsSetter.setSeverity(issue, BLOCKER, context);
 underTest.saveIssue(db.getSession(), issue, context, "increase severity");
 verify(notificationManager).scheduleForSending(notificationArgumentCaptor.capture());
 IssueChangeNotification issueChangeNotification = notificationArgumentCaptor.getValue();
 assertThat(issueChangeNotification.getFieldValue("key")).isEqualTo(issue.key());
 assertThat(issueChangeNotification.getFieldValue("old.severity")).isEqualTo(MAJOR);
 assertThat(issueChangeNotification.getFieldValue("new.severity")).isEqualTo(BLOCKER);
 assertThat(issueChangeNotification.getFieldValue("componentKey")).isEqualTo(file.getDbKey());
 assertThat(issueChangeNotification.getFieldValue("componentName")).isEqualTo(file.longName());
 assertThat(issueChangeNotification.getFieldValue("projectKey")).isEqualTo(project.getDbKey());
 assertThat(issueChangeNotification.getFieldValue("projectName")).isEqualTo(project.name());
 assertThat(issueChangeNotification.getFieldValue("ruleName")).isEqualTo(rule.getName());
 assertThat(issueChangeNotification.getFieldValue("changeAuthor")).isEqualTo(changeAuthor.getLogin());
 assertThat(issueChangeNotification.getFieldValue("comment")).isEqualTo("increase severity");
 assertThat(issueChangeNotification.getFieldValue("assignee")).isEqualTo(assignee.getLogin());
}
origin: SonarSource/sonarqube

@Test
public void verify_notification_on_branch() {
 RuleDto rule = db.rules().insertRule();
 ComponentDto project = db.components().insertMainBranch();
 ComponentDto branch = db.components().insertProjectBranch(project);
 ComponentDto file = db.components().insertComponent(newFileDto(branch));
 RuleType randomTypeExceptHotspot = RuleType.values()[nextInt(RuleType.values().length - 1)];
 DefaultIssue issue = db.issues().insertIssue(IssueTesting.newIssue(rule.getDefinition(), branch, file)
  .setType(randomTypeExceptHotspot)).setSeverity(MAJOR).toDefaultIssue();
 IssueChangeContext context = IssueChangeContext.createUser(new Date(), "user_uuid");
 issueFieldsSetter.setSeverity(issue, BLOCKER, context);
 underTest.saveIssue(db.getSession(), issue, context, "increase severity");
 verify(notificationManager).scheduleForSending(notificationArgumentCaptor.capture());
 IssueChangeNotification issueChangeNotification = notificationArgumentCaptor.getValue();
 assertThat(issueChangeNotification.getFieldValue("key")).isEqualTo(issue.key());
 assertThat(issueChangeNotification.getFieldValue("projectKey")).isEqualTo(project.getDbKey());
 assertThat(issueChangeNotification.getFieldValue("projectName")).isEqualTo(project.name());
 assertThat(issueChangeNotification.getFieldValue("branch")).isEqualTo(branch.getBranch());
}
origin: SonarSource/sonarqube

@Test
public void saveIssue_populates_specified_SearchResponseData_with_no_rule_but_with_project_and_component_if_rule_is_removed() {
 RuleDto rule = db.rules().insertRule(r -> r.setStatus(RuleStatus.REMOVED));
 ComponentDto project = db.components().insertPrivateProject();
 ComponentDto file = db.components().insertComponent(newFileDto(project));
 IssueDto issueDto = IssueTesting.newIssue(rule.getDefinition(), project, file);
 DefaultIssue issue = db.issues().insertIssue(issueDto).setSeverity(MAJOR).toDefaultIssue();
 IssueChangeContext context = IssueChangeContext.createUser(new Date(), "user_uuid");
 issueFieldsSetter.setSeverity(issue, BLOCKER, context);
 SearchResponseData preloadedSearchResponseData = underTest.saveIssueAndPreloadSearchResponseData(db.getSession(), issue, context, null, false);
 assertThat(preloadedSearchResponseData.getIssues())
  .hasSize(1);
 assertThat(preloadedSearchResponseData.getIssues().iterator().next())
  .isNotSameAs(issueDto);
 assertThat(preloadedSearchResponseData.getRules()).isNullOrEmpty();
 assertThat(preloadedSearchResponseData.getComponents())
  .extracting(ComponentDto::uuid)
  .containsOnly(project.uuid(), file.uuid());
}
origin: SonarSource/sonarqube

@Test
public void verify_notification_when_issue_is_linked_on_removed_rule() {
 RuleDto rule = db.rules().insertRule(r -> r.setStatus(RuleStatus.REMOVED));
 ComponentDto project = db.components().insertPrivateProject();
 ComponentDto file = db.components().insertComponent(newFileDto(project));
 RuleType randomTypeExceptHotspot = RuleType.values()[nextInt(RuleType.values().length - 1)];
 DefaultIssue issue = db.issues().insertIssue(IssueTesting.newIssue(rule.getDefinition(), project, file)
 .setType(randomTypeExceptHotspot)).setSeverity(MAJOR).toDefaultIssue();
 IssueChangeContext context = IssueChangeContext.createUser(new Date(), "user_uuid");
 issueFieldsSetter.setSeverity(issue, BLOCKER, context);
 underTest.saveIssue(db.getSession(), issue, context, null);
 verify(notificationManager).scheduleForSending(notificationArgumentCaptor.capture());
 assertThat(notificationArgumentCaptor.getValue().getFieldValue("ruleName")).isNull();
}
origin: SonarSource/sonarqube

@Test
public void saveIssue_populates_specified_SearchResponseData_with_rule_project_and_component_retrieved_from_DB() {
 RuleDto rule = db.rules().insertRule();
 ComponentDto project = db.components().insertPrivateProject();
 ComponentDto file = db.components().insertComponent(newFileDto(project));
 IssueDto issueDto = IssueTesting.newIssue(rule.getDefinition(), project, file);
 DefaultIssue issue = db.issues().insertIssue(issueDto).setSeverity(MAJOR).toDefaultIssue();
 IssueChangeContext context = IssueChangeContext.createUser(new Date(), "user_uuid");
 issueFieldsSetter.setSeverity(issue, BLOCKER, context);
 SearchResponseData preloadedSearchResponseData = underTest.saveIssueAndPreloadSearchResponseData(db.getSession(), issue, context, null, true);
 assertThat(preloadedSearchResponseData.getIssues())
  .hasSize(1);
 assertThat(preloadedSearchResponseData.getIssues().iterator().next())
  .isNotSameAs(issueDto);
 assertThat(preloadedSearchResponseData.getRules())
  .extracting(RuleDefinitionDto::getKey)
  .containsOnly(rule.getKey());
 assertThat(preloadedSearchResponseData.getComponents())
  .extracting(ComponentDto::uuid)
  .containsOnly(project.uuid(), file.uuid());
 assertThat(issueChangePostProcessor.calledComponents()).containsExactlyInAnyOrder(file);
}
origin: SonarSource/sonarqube

@Test
public void verify_no_notification_on_hotspot() {
 UserDto assignee = db.users().insertUser();
 RuleDto rule = db.rules().insertRule();
 ComponentDto project = db.components().insertPrivateProject();
 ComponentDto file = db.components().insertComponent(newFileDto(project));
 DefaultIssue issue = db.issues().insertIssue(IssueTesting.newIssue(rule.getDefinition(), project, file)
  .setType(RuleType.SECURITY_HOTSPOT))
  .setSeverity(MAJOR)
  .setAssigneeUuid(assignee.getUuid())
  .toDefaultIssue();
 UserDto changeAuthor = db.users().insertUser();
 IssueChangeContext context = IssueChangeContext.createUser(new Date(), changeAuthor.getUuid());
 issueFieldsSetter.setSeverity(issue, BLOCKER, context);
 underTest.saveIssue(db.getSession(), issue, context, "increase severity");
 verify(notificationManager, never()).scheduleForSending(any());
}
origin: org.sonarsource.sonarqube/sonar-server

public boolean setPastSeverity(DefaultIssue issue, @Nullable String previousSeverity, IssueChangeContext context) {
 String currentSeverity = issue.severity();
 issue.setSeverity(previousSeverity);
 return setSeverity(issue, currentSeverity, context);
}
org.sonar.server.issueIssueFieldsSettersetSeverity

Popular methods of IssueFieldsSetter

  • assign
  • setResolution
  • setStatus
  • setType
  • setMessage
  • setPastEffort
  • setPastLine
  • setPastMessage
  • setPastSeverity
  • addComment
  • setCreationDate
  • setGap
  • setCreationDate,
  • setGap,
  • setIssueMoved,
  • setLocations,
  • setManualSeverity,
  • setNewAssignee,
  • setNewAuthor,
  • setPastGap,
  • setPastLocations

Popular in Java

  • Reading from database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • runOnUiThread (Activity)
  • getResourceAsStream (ClassLoader)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now