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

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

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

origin: SonarSource/sonarqube

 @Override
 public void onIssue(Component component, DefaultIssue issue) {
  if (component.getType() != Component.Type.FILE || component.getUuid().equals(issue.componentUuid())) {
   return;
  }
  Optional<OriginalFile> originalFileOptional = movedFilesRepository.getOriginalFile(component);
  checkState(originalFileOptional.isPresent(),
   "Issue %s for component %s has a different component key but no original file exist in MovedFilesRepository",
   issue, component);
  OriginalFile originalFile = originalFileOptional.get();
  checkState(originalFile.getUuid().equals(issue.componentUuid()),
   "Issue %s doesn't belong to file %s registered as original file of current file %s",
   issue, originalFile.getUuid(), component);

  // changes the issue's component uuid, add a change and set issue as changed to enforce it is persisted to DB
  issueUpdater.setIssueMoved(issue, component.getUuid(), IssueChangeContext.createUser(new Date(analysisMetadataHolder.getAnalysisDate()), null));
  // other fields (such as module, modulePath, componentKey) are read-only and set/reset for consistency only
  issue.setComponentKey(component.getKey());
  issue.setModuleUuid(null);
  issue.setModuleUuidPath(null);
 }
}
origin: SonarSource/sonarqube

 private Collection<? extends DefaultIssue> migrateIssuesToTheRoot(List<DefaultIssue> issuesOnModule, String modulePath) {
  for (DefaultIssue i : issuesOnModule) {
   // changes the issue's component uuid, add a change and set issue as changed to enforce it is persisted to DB
   IssueChangeContext context = IssueChangeContext.createUser(new Date(analysisMetadataHolder.getAnalysisDate()), null);
   if (StringUtils.isNotBlank(modulePath)) {
    issueUpdater.setMessage(i, "[" + modulePath + "] " + i.getMessage(), context);
   }
   issueUpdater.setIssueMoved(i, component.getUuid(), context);
   // other fields (such as module, modulePath, componentKey) are read-only and set/reset for consistency only
   i.setComponentKey(component.getKey());
   i.setModuleUuid(null);
   i.setModuleUuidPath(null);
  }
  return issuesOnModule;
 }
}
origin: SonarSource/sonarqube

@Test
public void setIssueMoved_has_no_effect_if_component_uuid_is_not_changed() {
 String componentUuid = "a";
 issue.setComponentUuid(componentUuid);
 underTest.setIssueMoved(issue, componentUuid, context);
 assertThat(issue.changes()).isEmpty();
 assertThat(issue.componentUuid()).isEqualTo(componentUuid);
 assertThat(issue.isChanged()).isFalse();
 assertThat(issue.updateDate()).isNull();
 assertThat(issue.mustSendNotifications()).isFalse();
}
origin: SonarSource/sonarqube

 @Test
 public void setIssueMoved_changes_componentUuid_adds_a_change() {
  String oldComponentUuid = "a";
  String newComponentUuid = "b";
  issue.setComponentUuid(oldComponentUuid);

  underTest.setIssueMoved(issue, newComponentUuid, context);

  assertThat(issue.changes()).hasSize(1);
  FieldDiffs fieldDiffs = issue.changes().get(0);
  assertThat(fieldDiffs.creationDate()).isEqualTo(context.date());
  assertThat(fieldDiffs.diffs()).hasSize(1);
  Map.Entry<String, FieldDiffs.Diff> entry = fieldDiffs.diffs().entrySet().iterator().next();
  assertThat(entry.getKey()).isEqualTo("file");
  assertThat(entry.getValue().oldValue()).isEqualTo(oldComponentUuid);
  assertThat(entry.getValue().newValue()).isEqualTo(newComponentUuid);
  assertThat(issue.componentUuid()).isEqualTo(newComponentUuid);
  assertThat(issue.isChanged()).isTrue();
  assertThat(issue.updateDate()).isEqualTo(DateUtils.truncate(context.date(), Calendar.SECOND));
 }
}
origin: org.sonarsource.sonarqube/sonar-server

 @Override
 public void onIssue(Component component, DefaultIssue issue) {
  if (component.getType() != Component.Type.FILE || component.getUuid().equals(issue.componentUuid())) {
   return;
  }
  Optional<OriginalFile> originalFileOptional = movedFilesRepository.getOriginalFile(component);
  checkState(originalFileOptional.isPresent(),
   "Issue %s for component %s has a different component key but no original file exist in MovedFilesRepository",
   issue, component);
  OriginalFile originalFile = originalFileOptional.get();
  checkState(originalFile.getUuid().equals(issue.componentUuid()),
   "Issue %s doesn't belong to file %s registered as original file of current file %s",
   issue, originalFile.getUuid(), component);

  // changes the issue's component uuid, add a change and set issue as changed to enforce it is persisted to DB
  issueUpdater.setIssueMoved(issue, component.getUuid(), IssueChangeContext.createUser(new Date(analysisMetadataHolder.getAnalysisDate()), null));
  // other fields (such as module, modulePath, componentKey) are read-only and set/reset for consistency only
  issue.setComponentKey(component.getPublicKey());
  issue.setModuleUuid(null);
  issue.setModuleUuidPath(null);
 }
}
org.sonar.server.issueIssueFieldsSettersetIssueMoved

Popular methods of IssueFieldsSetter

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

Popular in Java

  • Running tasks concurrently on multiple threads
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getApplicationContext (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Kernel (java.awt.image)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • IsNull (org.hamcrest.core)
    Is the value null?
  • 21 Best IntelliJ Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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