Exemplo n.º 1
0
 private void resolveSeverity(IssueDto dbIssue, DefaultIssue issue) {
   if (dbIssue.isManualSeverity()) {
     issue.setManualSeverity(true);
     issue.setSeverity(dbIssue.getSeverity());
   }
   // else keep severity as declared in quality profile
 }
  @Test
  public void should_reload_issue_and_resolve_conflict() {
    DefaultIssue issue =
        new DefaultIssue()
            .setKey("ABCDE")
            .setType(RuleType.CODE_SMELL)
            .setRuleKey(RuleKey.of("squid", "AvoidCycles"))
            .setComponentKey("struts:org.apache.struts.Action")
            .setNew(false)
            .setStatus(Issue.STATUS_OPEN);

    // Issue as seen and changed by end-user
    IssueMapper mapper = mock(IssueMapper.class);
    when(mapper.selectByKey("ABCDE"))
        .thenReturn(
            new IssueDto()
                .setKee("ABCDE")
                .setType(RuleType.CODE_SMELL)
                .setRuleId(10)
                .setRuleKey("squid", "AvoidCycles")
                .setComponentKey("struts:org.apache.struts.Action")
                .setLine(10)
                .setStatus(Issue.STATUS_OPEN)

                // field changed by user
                .setAssignee("arthur"));

    new UpdateConflictResolver().resolve(issue, mapper);

    ArgumentCaptor<IssueDto> argument = ArgumentCaptor.forClass(IssueDto.class);
    verify(mapper).update(argument.capture());
    IssueDto updatedIssue = argument.getValue();
    assertThat(updatedIssue.getKee()).isEqualTo("ABCDE");
    assertThat(updatedIssue.getAssignee()).isEqualTo("arthur");
  }
Exemplo n.º 3
0
  public void resolve(DefaultIssue issue, IssueMapper mapper) {
    LOG.debug("Resolve conflict on issue {}", issue.key());

    IssueDto dbIssue = mapper.selectByKey(issue.key());
    if (dbIssue != null) {
      mergeFields(dbIssue, issue);
      mapper.update(IssueDto.toDtoForUpdate(issue, System.currentTimeMillis()));
    }
  }
Exemplo n.º 4
0
 private void resolveAssignee(IssueDto dbIssue, DefaultIssue issue) {
   issue.setAssignee(dbIssue.getAssignee());
 }
Exemplo n.º 5
0
 private void resolvePlan(IssueDto dbIssue, DefaultIssue issue) {
   issue.setActionPlanKey(dbIssue.getActionPlanKey());
 }
Exemplo n.º 6
0
 private void resolveEffortToFix(IssueDto dbIssue, DefaultIssue issue) {
   issue.setEffortToFix(dbIssue.getEffortToFix());
 }
Exemplo n.º 7
0
 private void resolveResolution(IssueDto dbIssue, DefaultIssue issue) {
   issue.setResolution(dbIssue.getResolution());
 }
Exemplo n.º 8
0
 private void resolveStatus(IssueDto dbIssue, DefaultIssue issue) {
   issue.setStatus(dbIssue.getStatus());
 }