private void process(Component component, DefaultIssue issue, CacheAppender<DefaultIssue> cacheAppender) {
issueLifecycle.doAutomaticTransition(issue);
issueVisitors.onIssue(component, issue);
- if (issue.isNew() || issue.isChanged() || issue.isCopied() || issue.isNoLongerNewCodeReferenceIssue()) {
+ if (issue.isNew() || issue.isChanged() || issue.isCopied() ||
+ issue.isNoLongerNewCodeReferenceIssue() || issue.isToBeMigratedAsNewCodeReferenceIssue()) {
cacheAppender.append(issue);
}
}
return;
}
- issue.setIsOnReferencedBranch(newIssueClassifier.isOnBranchUsingReferenceBranch());
-
- if (issue.isOnReferencedBranch()) {
+ if (newIssueClassifier.isOnBranchUsingReferenceBranch()) {
issue.setIsOnChangedLine(newIssueClassifier.hasAtLeastOneLocationOnChangedLines(component, issue));
if (issue.isNewCodeReferenceIssue() && !issue.isOnChangedLine()) {
import org.sonar.ce.task.projectanalysis.issue.ProtoIssueCache;
import org.sonar.ce.task.projectanalysis.issue.RuleRepository;
import org.sonar.ce.task.projectanalysis.issue.UpdateConflictResolver;
+import org.sonar.ce.task.projectanalysis.period.PeriodHolder;
import org.sonar.ce.task.step.ComputationStep;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.core.util.CloseableIterator;
import org.sonar.db.issue.IssueDto;
import org.sonar.db.issue.IssueMapper;
import org.sonar.db.issue.NewCodeReferenceIssueDto;
+import org.sonar.db.newcodeperiod.NewCodePeriodType;
import org.sonar.server.issue.IssueStorage;
import static org.sonar.core.util.FileUtils.humanReadableByteCountSI;
private final System2 system2;
private final UpdateConflictResolver conflictResolver;
private final RuleRepository ruleRepository;
+ private final PeriodHolder periodHolder;
private final ProtoIssueCache protoIssueCache;
private final IssueStorage issueStorage;
private final UuidFactory uuidFactory;
public PersistIssuesStep(DbClient dbClient, System2 system2, UpdateConflictResolver conflictResolver,
- RuleRepository ruleRepository, ProtoIssueCache protoIssueCache, IssueStorage issueStorage, UuidFactory uuidFactory) {
+ RuleRepository ruleRepository, PeriodHolder periodHolder, ProtoIssueCache protoIssueCache, IssueStorage issueStorage,
+ UuidFactory uuidFactory) {
this.dbClient = dbClient;
this.system2 = system2;
this.conflictResolver = conflictResolver;
this.ruleRepository = ruleRepository;
+ this.periodHolder = periodHolder;
this.protoIssueCache = protoIssueCache;
this.issueStorage = issueStorage;
this.uuidFactory = uuidFactory;
List<DefaultIssue> addedIssues = new ArrayList<>(ISSUE_BATCHING_SIZE);
List<DefaultIssue> updatedIssues = new ArrayList<>(ISSUE_BATCHING_SIZE);
List<DefaultIssue> noLongerNewIssues = new ArrayList<>(ISSUE_BATCHING_SIZE);
+ List<DefaultIssue> newCodeIssuesToMigrate = new ArrayList<>(ISSUE_BATCHING_SIZE);
IssueMapper mapper = dbSession.getMapper(IssueMapper.class);
IssueChangeMapper changeMapper = dbSession.getMapper(IssueChangeMapper.class);
persistUpdatedIssues(statistics, updatedIssues, mapper, changeMapper);
updatedIssues.clear();
}
- } else if (issue.isNoLongerNewCodeReferenceIssue()) {
+ } else if (isOnBranchUsingReferenceBranch() && issue.isNoLongerNewCodeReferenceIssue()) {
noLongerNewIssues.add(issue);
if (noLongerNewIssues.size() >= ISSUE_BATCHING_SIZE) {
persistNoLongerNewIssues(statistics, noLongerNewIssues, mapper);
noLongerNewIssues.clear();
}
+ } else if (isOnBranchUsingReferenceBranch() && issue.isToBeMigratedAsNewCodeReferenceIssue()) {
+ newCodeIssuesToMigrate.add(issue);
+ if (newCodeIssuesToMigrate.size() >= ISSUE_BATCHING_SIZE) {
+ persistNewCodeIssuesToMigrate(statistics, newCodeIssuesToMigrate, mapper);
+ newCodeIssuesToMigrate.clear();
+ }
}
}
persistNewIssues(statistics, addedIssues, mapper, changeMapper);
persistUpdatedIssues(statistics, updatedIssues, mapper, changeMapper);
persistNoLongerNewIssues(statistics, noLongerNewIssues, mapper);
+ persistNewCodeIssuesToMigrate(statistics, newCodeIssuesToMigrate, mapper);
flushSession(dbSession);
} finally {
statistics.dumpTo(context);
String ruleUuid = ruleRepository.getByKey(i.ruleKey()).getUuid();
IssueDto dto = IssueDto.toDtoForComputationInsert(i, ruleUuid, now);
mapper.insert(dto);
- if (i.isOnReferencedBranch() && i.isOnChangedLine()) {
+ if (isOnBranchUsingReferenceBranch() && i.isOnChangedLine()) {
mapper.insertAsNewCodeOnReferenceBranch(NewCodeReferenceIssueDto.fromIssueDto(dto, now, uuidFactory));
}
statistics.inserts++;
}
+ private void persistNewCodeIssuesToMigrate(IssueStatistics statistics, List<DefaultIssue> newCodeIssuesToMigrate, IssueMapper mapper) {
+ if (newCodeIssuesToMigrate.isEmpty()) {
+ return;
+ }
+
+ long now = system2.now();
+ newCodeIssuesToMigrate.forEach(i -> {
+ mapper.insertAsNewCodeOnReferenceBranch(NewCodeReferenceIssueDto.fromIssueKey(i.key(), now, uuidFactory));
+ statistics.updates++;
+ });
+ }
+
private static void flushSession(DbSession dbSession) {
dbSession.flushStatements();
dbSession.commit();
}
+ private boolean isOnBranchUsingReferenceBranch() {
+ if (periodHolder.hasPeriod()) {
+ return periodHolder.getPeriod().getMode().equals(NewCodePeriodType.REFERENCE_BRANCH.name());
+ }
+ return false;
+ }
+
@Override
public String getDescription() {
return "Persist issues";
defaultIssue.setCloseDate(next.hasCloseDate() ? new Date(next.getCloseDate()) : null);
defaultIssue.setCurrentChangeWithoutAddChange(next.hasCurrentChanges() ? toDefaultIssueChanges(next.getCurrentChanges()) : null);
defaultIssue.setNew(next.getIsNew());
- defaultIssue.setIsOnReferencedBranch(next.getIsOnReferencedBranch());
defaultIssue.setIsOnChangedLine(next.getIsOnChangedLine());
+ defaultIssue.setIsNewCodeReferenceIssue(next.getIsNewCodeReferenceIssue());
defaultIssue.setCopied(next.getIsCopied());
defaultIssue.setBeingClosed(next.getBeingClosed());
defaultIssue.setOnDisabledRule(next.getOnDisabledRule());
ofNullable(defaultIssue.closeDate()).map(Date::getTime).ifPresent(builder::setCloseDate);
ofNullable(defaultIssue.currentChange()).ifPresent(c -> builder.setCurrentChanges(toProtoIssueChanges(c)));
builder.setIsNew(defaultIssue.isNew());
- builder.setIsOnReferencedBranch(defaultIssue.isOnReferencedBranch());
builder.setIsOnChangedLine(defaultIssue.isOnChangedLine());
+ builder.setIsNewCodeReferenceIssue(defaultIssue.isNewCodeReferenceIssue());
builder.setIsCopied(defaultIssue.isCopied());
builder.setBeingClosed(defaultIssue.isBeingClosed());
builder.setOnDisabledRule(defaultIssue.isOnDisabledRule());
optional bool isOnReferencedBranch = 40;
optional bool isOnChangedLine = 41;
- optional bool isNoLongerNewCodeReferenceIssue = 42;
+ optional bool isNewCodeReferenceIssue = 42;
+ optional bool isNoLongerNewCodeReferenceIssue = 43;
}
message Comment {
when(newIssueClassifier.isOnBranchUsingReferenceBranch()).thenReturn(false);
underTest.onIssue(component, issue);
- verify(issue).setIsOnReferencedBranch(false);
- verify(issue).isOnReferencedBranch();
verifyNoMoreInteractions(issue);
}
when(newIssueClassifier.isEnabled()).thenReturn(true);
when(newIssueClassifier.isOnBranchUsingReferenceBranch()).thenReturn(true);
when(newIssueClassifier.hasAtLeastOneLocationOnChangedLines(component, issue)).thenReturn(true);
- when(issue.isOnReferencedBranch()).thenReturn(true);
when(issue.isNewCodeReferenceIssue()).thenReturn(false);
underTest.onIssue(component, issue);
- verify(issue).setIsOnReferencedBranch(true);
- verify(issue).isOnReferencedBranch();
verify(issue).setIsOnChangedLine(true);
verify(issue).isNewCodeReferenceIssue();
verifyNoMoreInteractions(issue);
when(newIssueClassifier.isEnabled()).thenReturn(true);
when(newIssueClassifier.isOnBranchUsingReferenceBranch()).thenReturn(true);
when(newIssueClassifier.hasAtLeastOneLocationOnChangedLines(component, issue)).thenReturn(true);
- when(issue.isOnReferencedBranch()).thenReturn(true);
when(issue.isNewCodeReferenceIssue()).thenReturn(true);
when(issue.isOnChangedLine()).thenReturn(true);
underTest.onIssue(component, issue);
- verify(issue).setIsOnReferencedBranch(true);
- verify(issue).isOnReferencedBranch();
verify(issue).setIsOnChangedLine(true);
verify(issue).isNewCodeReferenceIssue();
verify(issue).isOnChangedLine();
when(newIssueClassifier.isEnabled()).thenReturn(true);
when(newIssueClassifier.isOnBranchUsingReferenceBranch()).thenReturn(true);
when(newIssueClassifier.hasAtLeastOneLocationOnChangedLines(component, issue)).thenReturn(false);
- when(issue.isOnReferencedBranch()).thenReturn(true);
when(issue.isNewCodeReferenceIssue()).thenReturn(true);
when(issue.isOnChangedLine()).thenReturn(false);
underTest.onIssue(component, issue);
- verify(issue).setIsOnReferencedBranch(true);
- verify(issue).isOnReferencedBranch();
verify(issue).setIsOnChangedLine(false);
verify(issue).isNewCodeReferenceIssue();
verify(issue).setIsNoLongerNewCodeReferenceIssue(true);
import org.sonar.ce.task.projectanalysis.issue.ProtoIssueCache;
import org.sonar.ce.task.projectanalysis.issue.RuleRepositoryImpl;
import org.sonar.ce.task.projectanalysis.issue.UpdateConflictResolver;
+import org.sonar.ce.task.projectanalysis.period.Period;
+import org.sonar.ce.task.projectanalysis.period.PeriodHolderRule;
import org.sonar.ce.task.projectanalysis.util.cache.DiskCache;
import org.sonar.ce.task.step.ComputationStep;
import org.sonar.ce.task.step.TestComputationStepContext;
import org.sonar.db.issue.IssueChangeDto;
import org.sonar.db.issue.IssueDto;
import org.sonar.db.issue.IssueMapper;
+import org.sonar.db.newcodeperiod.NewCodePeriodType;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.db.rule.RuleTesting;
import org.sonar.scanner.protocol.output.ScannerReport;
public DbTester db = DbTester.create(System2.INSTANCE);
@Rule
public BatchReportReaderRule reportReader = new BatchReportReaderRule();
+ @Rule
+ public PeriodHolderRule periodHolder = new PeriodHolderRule();
private System2 system2 = mock(System2.class);
private DbSession session = db.getSession();
@Before
public void setup() throws Exception {
+ periodHolder.setPeriod(new Period(NewCodePeriodType.NUMBER_OF_DAYS.name(), "10", 1000L));
+
protoIssueCache = new ProtoIssueCache(temp.newFile(), System2.INSTANCE);
reportReader.setMetadata(ScannerReport.Metadata.getDefaultInstance());
- underTest = new PersistIssuesStep(dbClient, system2, conflictResolver, new RuleRepositoryImpl(adHocRuleCreator, dbClient), protoIssueCache,
- new IssueStorage(), UuidFactoryImpl.INSTANCE);
+ underTest = new PersistIssuesStep(dbClient, system2, conflictResolver, new RuleRepositoryImpl(adHocRuleCreator, dbClient), periodHolder,
+ protoIssueCache, new IssueStorage(), UuidFactoryImpl.INSTANCE);
}
@After
@Test
public void insert_copied_issue_with_minimal_info() {
+ periodHolder.setPeriod(new Period(NewCodePeriodType.REFERENCE_BRANCH.name(), "master", null));
+
RuleDefinitionDto rule = RuleTesting.newRule(RuleKey.of("xoo", "S01"));
db.rules().insert(rule);
ComponentDto project = db.components().insertPrivateProject();
.setSeverity(BLOCKER)
.setStatus(STATUS_OPEN)
.setNew(false)
- .setIsOnReferencedBranch(true)
.setCopied(true)
.setType(RuleType.BUG)
.setCreationDate(new Date(NOW))
@Test
public void insert_merged_issue() {
+ periodHolder.setPeriod(new Period(NewCodePeriodType.REFERENCE_BRANCH.name(), "master", null));
RuleDefinitionDto rule = RuleTesting.newRule(RuleKey.of("xoo", "S01"));
db.rules().insert(rule);
ComponentDto project = db.components().insertPrivateProject();
.setSeverity(BLOCKER)
.setStatus(STATUS_OPEN)
.setNew(true)
- .setIsOnReferencedBranch(true)
.setIsOnChangedLine(true)
.setCopied(true)
.setType(RuleType.BUG)
@Test
public void insert_new_issue() {
+ periodHolder.setPeriod(new Period(NewCodePeriodType.REFERENCE_BRANCH.name(), "master", null));
RuleDefinitionDto rule = RuleTesting.newRule(RuleKey.of("xoo", "S01"));
db.rules().insert(rule);
ComponentDto project = db.components().insertPrivateProject();
.setStatus(STATUS_OPEN)
.setCreationDate(new Date(NOW))
.setNew(true)
- .setIsOnReferencedBranch(true)
.setIsOnChangedLine(true)
.setType(RuleType.BUG)).close();
@Test
public void handle_no_longer_new_issue() {
+ periodHolder.setPeriod(new Period(NewCodePeriodType.REFERENCE_BRANCH.name(), "master", null));
RuleDefinitionDto rule = RuleTesting.newRule(RuleKey.of("xoo", "S01"));
db.rules().insert(rule);
ComponentDto project = db.components().insertPrivateProject();
.setSeverity(BLOCKER)
.setStatus(STATUS_OPEN)
.setNew(true)
- .setIsOnReferencedBranch(true)
.setIsOnChangedLine(true)
.setIsNewCodeReferenceIssue(true)
.setIsNoLongerNewCodeReferenceIssue(false)
assertThat(result.isNewCodeReferenceIssue()).isTrue();
protoIssueCache.newAppender().append(defaultIssue.setNew(false)
- .setIsOnReferencedBranch(true)
.setIsOnChangedLine(false)
.setIsNewCodeReferenceIssue(false)
.setIsNoLongerNewCodeReferenceIssue(true))
assertThat(result.isNewCodeReferenceIssue()).isFalse();
}
+ @Test
+ public void handle_existing_new_code_issue_migration() {
+ periodHolder.setPeriod(new Period(NewCodePeriodType.REFERENCE_BRANCH.name(), "master", null));
+ RuleDefinitionDto rule = RuleTesting.newRule(RuleKey.of("xoo", "S01"));
+ db.rules().insert(rule);
+ ComponentDto project = db.components().insertPrivateProject();
+ ComponentDto file = db.components().insertComponent(newFileDto(project, null));
+ when(system2.now()).thenReturn(NOW);
+ String issueKey = "ISSUE-6";
+
+ DefaultIssue defaultIssue = new DefaultIssue()
+ .setKey(issueKey)
+ .setType(RuleType.CODE_SMELL)
+ .setRuleKey(rule.getKey())
+ .setComponentUuid(file.uuid())
+ .setComponentKey(file.getKey())
+ .setProjectUuid(project.uuid())
+ .setProjectKey(project.getKey())
+ .setSeverity(BLOCKER)
+ .setStatus(STATUS_OPEN)
+ .setNew(true)
+ .setCopied(false)
+ .setType(RuleType.BUG)
+ .setCreationDate(new Date(NOW))
+ .setSelectedAt(NOW);
+
+ IssueDto issueDto = IssueDto.toDtoForComputationInsert(defaultIssue, rule.getUuid(), NOW);
+ dbClient.issueDao().insert(session, issueDto);
+ session.commit();
+
+ IssueDto result = dbClient.issueDao().selectOrFailByKey(session, issueKey);
+ assertThat(result.isNewCodeReferenceIssue()).isFalse();
+
+ protoIssueCache.newAppender().append(defaultIssue.setNew(false)
+ .setIsOnChangedLine(true)
+ .setIsNewCodeReferenceIssue(false)
+ .setIsNoLongerNewCodeReferenceIssue(false))
+ .close();
+
+ TestComputationStepContext context = new TestComputationStepContext();
+ underTest.execute(context);
+
+ assertThat(context.getStatistics().getAll()).contains(
+ entry("inserts", "0"), entry("updates", "1"), entry("merged", "0"));
+
+ result = dbClient.issueDao().selectOrFailByKey(session, issueKey);
+ assertThat(result.isNewCodeReferenceIssue()).isTrue();
+ }
+
+ @Test
+ public void handle_existing_without_need_for_new_code_issue_migration() {
+ periodHolder.setPeriod(new Period(NewCodePeriodType.REFERENCE_BRANCH.name(), "master", null));
+ RuleDefinitionDto rule = RuleTesting.newRule(RuleKey.of("xoo", "S01"));
+ db.rules().insert(rule);
+ ComponentDto project = db.components().insertPrivateProject();
+ ComponentDto file = db.components().insertComponent(newFileDto(project, null));
+ when(system2.now()).thenReturn(NOW);
+ String issueKey = "ISSUE-7";
+
+ DefaultIssue defaultIssue = new DefaultIssue()
+ .setKey(issueKey)
+ .setType(RuleType.CODE_SMELL)
+ .setRuleKey(rule.getKey())
+ .setComponentUuid(file.uuid())
+ .setComponentKey(file.getKey())
+ .setProjectUuid(project.uuid())
+ .setProjectKey(project.getKey())
+ .setSeverity(BLOCKER)
+ .setStatus(STATUS_OPEN)
+ .setNew(true)
+ .setIsOnChangedLine(true)
+ .setIsNewCodeReferenceIssue(true)
+ .setIsNoLongerNewCodeReferenceIssue(false)
+ .setCopied(false)
+ .setType(RuleType.BUG)
+ .setCreationDate(new Date(NOW))
+ .setSelectedAt(NOW);
+
+ IssueDto issueDto = IssueDto.toDtoForComputationInsert(defaultIssue, rule.getUuid(), NOW);
+ dbClient.issueDao().insert(session, issueDto);
+ dbClient.issueDao().insertAsNewCodeOnReferenceBranch(session, newCodeReferenceIssue(issueDto));
+ session.commit();
+
+ IssueDto result = dbClient.issueDao().selectOrFailByKey(session, issueKey);
+ assertThat(result.isNewCodeReferenceIssue()).isTrue();
+
+ protoIssueCache.newAppender().append(defaultIssue.setNew(false)
+ .setIsOnChangedLine(false)
+ .setIsNewCodeReferenceIssue(true)
+ .setIsOnChangedLine(true)
+ .setIsNoLongerNewCodeReferenceIssue(false))
+ .close();
+
+ TestComputationStepContext context = new TestComputationStepContext();
+ underTest.execute(context);
+
+ assertThat(context.getStatistics().getAll()).contains(
+ entry("inserts", "0"), entry("updates", "0"), entry("merged", "0"));
+
+ result = dbClient.issueDao().selectOrFailByKey(session, issueKey);
+ assertThat(result.isNewCodeReferenceIssue()).isTrue();
+ }
+
@Test
public void add_comment() {
ComponentDto project = db.components().insertPrivateProject();
.setSelectedAt(NOW)
.setNew(false)
.setChanged(true)
+ .setIsOnChangedLine(false)
+ .setIsNewCodeReferenceIssue(false)
.setCurrentChange(new FieldDiffs()
.setIssueKey("ISSUE")
.setUserUuid("john_uuid")
.setIssueKey(issue.getKey())
.setCreatedAt(now);
}
+
+ public static NewCodeReferenceIssueDto fromIssueKey(String issueKey, long now, UuidFactory uuidFactory) {
+ return new NewCodeReferenceIssueDto()
+ .setUuid(uuidFactory.create())
+ .setIssueKey(issueKey)
+ .setCreatedAt(now);
+ }
}
assertThat(dto.getIssueKey()).isEqualTo(KEY);
assertThat(dto.getCreatedAt()).isNotNull();
}
+
+ @Test
+ public void create_from_issue_key() {
+ when(UUID_FACTORY.create()).thenReturn(UUID);
+ long now = System.currentTimeMillis();
+
+ NewCodeReferenceIssueDto dto = NewCodeReferenceIssueDto.fromIssueKey(KEY, now, UUID_FACTORY);
+
+ assertThat(dto.getUuid()).isEqualTo(UUID);
+ assertThat(dto.getIssueKey()).isEqualTo(KEY);
+ assertThat(dto.getCreatedAt()).isNotNull();
+ }
}
// true if the issue did not exist in the previous scan.
private boolean isNew = true;
- // true if the issue is on a branch using the reference branch new code strategy
- private boolean isOnReferencedBranch = false;
-
// true if the issue is on a changed line on a branch using the reference branch new code strategy
private boolean isOnChangedLine = false;
return isNew;
}
- public boolean isOnReferencedBranch() {
- return isOnReferencedBranch;
- }
-
public boolean isOnChangedLine() {
return isOnChangedLine;
}
return this;
}
- public DefaultIssue setIsOnReferencedBranch(boolean b) {
- isOnReferencedBranch = b;
- return this;
- }
-
public DefaultIssue setIsOnChangedLine(boolean b) {
isOnChangedLine = b;
return this;
return this;
}
+ // true if the issue is new on a reference branch,
+ // but it's not persisted as such due to being created before the SQ 9.3 migration
+ public boolean isToBeMigratedAsNewCodeReferenceIssue() {
+ return isOnChangedLine && !isNewCodeReferenceIssue && !isNoLongerNewCodeReferenceIssue;
+ }
+
@CheckForNull
public FieldDiffs currentChange() {
return currentChange;
*/
package org.sonar.core.issue;
-import com.google.common.collect.ImmutableMap;
import java.text.SimpleDateFormat;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.utils.Duration;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.entry;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
.setAuthorLogin("steph")
.setChecksum("c7b5db46591806455cf082bb348631e8")
.setNew(true)
- .setIsOnReferencedBranch(true)
.setIsOnChangedLine(true)
.setIsNewCodeReferenceIssue(true)
.setIsNoLongerNewCodeReferenceIssue(true)
assertThat(issue.authorLogin()).isEqualTo("steph");
assertThat(issue.checksum()).isEqualTo("c7b5db46591806455cf082bb348631e8");
assertThat(issue.isNew()).isTrue();
- assertThat(issue.isOnReferencedBranch()).isTrue();
assertThat(issue.isOnChangedLine()).isTrue();
assertThat(issue.isNewCodeReferenceIssue()).isTrue();
assertThat(issue.isNoLongerNewCodeReferenceIssue()).isTrue();
+ assertThat(issue.isToBeMigratedAsNewCodeReferenceIssue()).isFalse();
assertThat(issue.isCopied()).isTrue();
assertThat(issue.isBeingClosed()).isTrue();
assertThat(issue.isOnDisabledRule()).isTrue();
assertThat(issue.changes()).isEmpty();
}
+ @Test
+ public void test_isToBeMigratedAsNewCodeReferenceIssue_is_correctly_calculated() {
+ issue.setKey("ABCD")
+ .setIsOnChangedLine(true)
+ .setIsNewCodeReferenceIssue(false)
+ .setIsNoLongerNewCodeReferenceIssue(false);
+
+ assertThat(issue.isToBeMigratedAsNewCodeReferenceIssue()).isTrue();
+
+ issue.setKey("ABCD")
+ .setIsOnChangedLine(false)
+ .setIsNewCodeReferenceIssue(false)
+ .setIsNoLongerNewCodeReferenceIssue(false);
+
+ assertThat(issue.isToBeMigratedAsNewCodeReferenceIssue()).isFalse();
+
+ issue.setKey("ABCD")
+ .setIsOnChangedLine(true)
+ .setIsNewCodeReferenceIssue(true)
+ .setIsNoLongerNewCodeReferenceIssue(false);
+
+ assertThat(issue.isToBeMigratedAsNewCodeReferenceIssue()).isFalse();
+
+ issue.setKey("ABCD")
+ .setIsOnChangedLine(false)
+ .setIsNewCodeReferenceIssue(false)
+ .setIsNoLongerNewCodeReferenceIssue(true);
+
+ assertThat(issue.isToBeMigratedAsNewCodeReferenceIssue()).isFalse();
+
+ issue.setKey("ABCD")
+ .setIsOnChangedLine(true)
+ .setIsNewCodeReferenceIssue(true)
+ .setIsNoLongerNewCodeReferenceIssue(true);
+
+ assertThat(issue.isToBeMigratedAsNewCodeReferenceIssue()).isFalse();
+
+ issue.setKey("ABCD")
+ .setIsOnChangedLine(false)
+ .setIsNewCodeReferenceIssue(true)
+ .setIsNoLongerNewCodeReferenceIssue(true);
+
+ assertThat(issue.isToBeMigratedAsNewCodeReferenceIssue()).isFalse();
+
+ issue.setKey("ABCD")
+ .setIsOnChangedLine(true)
+ .setIsNewCodeReferenceIssue(false)
+ .setIsNoLongerNewCodeReferenceIssue(true);
+
+ assertThat(issue.isToBeMigratedAsNewCodeReferenceIssue()).isFalse();
+ }
+
@Test
public void isQuickFixAvailable_givenQuickFixAvailable_returnTrue() {
DefaultIssue defaultIssue = new DefaultIssue();