public AbstractNewCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration) {
structs = Lists.newArrayList();
for (Period period : timeMachineConfiguration.periods()) {
- structs.add(new PeriodStruct(period.getIndex(), period.getTargetDate()));
+ structs.add(new PeriodStruct(period.getIndex(), period.getDate()));
}
}
sameSecond = DateUtils.truncate(rightNow, Calendar.SECOND);
timeMachineConfiguration = mock(TimeMachineConfiguration.class);
- when(timeMachineConfiguration.periods()).thenReturn(newArrayList(new Period(1, fiveDaysAgo, afterFiveDaysAgo), new Period(2, tenDaysAgo, afterTenDaysAgo)));
+ when(timeMachineConfiguration.periods()).thenReturn(newArrayList(new Period(1, afterFiveDaysAgo), new Period(2, afterTenDaysAgo)));
project = mock(Project.class);
resource = mock(Resource.class);
fiveDaysAgo = org.apache.commons.lang.time.DateUtils.addDays(rightNow, -5);
fourDaysAgo = org.apache.commons.lang.time.DateUtils.addDays(rightNow, -4);
- when(timeMachineConfiguration.periods()).thenReturn(newArrayList(new Period(1, fiveDaysAgo, fiveDaysAgo), new Period(2, tenDaysAgo, tenDaysAgo)));
+ when(timeMachineConfiguration.periods()).thenReturn(newArrayList(new Period(1, fiveDaysAgo), new Period(2, tenDaysAgo)));
decorator = new NewTechnicalDebtDecorator(perspectives, timeMachineConfiguration, technicalDebtConverter);
}
@Test
public void save_on_one_issue_with_changelog_and_periods_have_no_dates() {
- when(timeMachineConfiguration.periods()).thenReturn(newArrayList(new Period(1, null, null), new Period(2, null, null)));
+ when(timeMachineConfiguration.periods()).thenReturn(newArrayList(new Period(1, null), new Period(2, null)));
Issue issue = new DefaultIssue().setKey("A").setCreationDate(tenDaysAgo).setTechnicalDebt(fiveDaysDebt).setChanges(
newArrayList(
@Test
public void save_on_one_issue_without_changelog_and_periods_have_no_dates() {
- when(timeMachineConfiguration.periods()).thenReturn(newArrayList(new Period(1, null, null), new Period(2, null, null)));
+ when(timeMachineConfiguration.periods()).thenReturn(newArrayList(new Period(1, null), new Period(2, null)));
when(issuable.issues()).thenReturn(newArrayList(
(Issue) new DefaultIssue().setKey("A").setCreationDate(nineDaysAgo).setTechnicalDebt(fiveDaysDebt))
return projectSnapshot != null ? projectSnapshot.getQualifier() : null;
}
- public Date getTargetDate() {
+ private Date getTargetDate() {
return targetDate;
}
+ public PastSnapshot clone(){
+ PastSnapshot clone = new PastSnapshot(mode, targetDate, projectSnapshot);
+ clone.setIndex(index);
+ clone.setModeParameter(modeParameter);
+ return clone;
+ }
+
@Override
public String toString() {
if (StringUtils.equals(mode, CoreProperties.TIMEMACHINE_MODE_VERSION)) {
public class Period {
private int index;
- private Date targetDate;
private Date date;
- public Period(int index, Date targetDate, @Nullable Date date) {
+ public Period(int index, @Nullable Date date) {
this.index = index;
- this.targetDate = targetDate;
this.date = date;
}
return index;
}
- public Date getTargetDate() {
- return targetDate;
- }
-
@CheckForNull
public Date getDate() {
return date;
for (PastSnapshot projectPastSnapshot : periodsDefinition.getRootProjectPastSnapshots()) {
Snapshot snapshot = findSnapshot(projectPastSnapshot.getProjectSnapshot());
- PastSnapshot pastSnapshot = new PastSnapshot(projectPastSnapshot.getMode(), projectPastSnapshot.getTargetDate(), projectPastSnapshot.getProjectSnapshot());
- pastSnapshot.setIndex(projectPastSnapshot.getIndex());
- pastSnapshot.setModeParameter(projectPastSnapshot.getModeParameter());
+ PastSnapshot pastSnapshot = projectPastSnapshot.clone();
modulePastSnapshots.add(pastSnapshot);
// When no snapshot is found, date of the period is null
- periods.add(new Period(pastSnapshot.getIndex(), pastSnapshot.getTargetDate(), snapshot != null ? snapshot.getCreatedAt() : null));
+ periods.add(new Period(pastSnapshot.getIndex(), snapshot != null ? snapshot.getCreatedAt() : null));
log(pastSnapshot);
}
}
PastSnapshot pastSnapshot = finder.findByPreviousAnalysis(projectSnapshot);
assertThat(pastSnapshot.isRelatedToSnapshot(), is(false));
assertThat(pastSnapshot.getProjectSnapshot(), nullValue());
- assertThat(pastSnapshot.getTargetDate(), nullValue());
+ assertThat(pastSnapshot.getDate(), nullValue());
}
}