int periodIndex = pastSnapshot.getIndex();
snapshot.setPeriodMode(periodIndex, pastSnapshot.getMode());
snapshot.setPeriodModeParameter(periodIndex, pastSnapshot.getModeParameter());
- snapshot.setPeriodDate(periodIndex, pastSnapshot.getTargetDate());
+ snapshot.setPeriodDate(periodIndex, pastSnapshot.getDate());
}
}
no_data=No data
no_lines_match_your_filter_criteria=No lines match your filter criteria.
no_results=No results
-over_x_days=over {0} days
+over_x_days=over {0} days ({1})
over_x_days.short={0} days
page_size=Page size
paging_first=First
since_version_detailed.short={0} ({1})
since_previous_version=since previous version
since_previous_version.short=\u0394 version
-since_previous_version_detailed=since previous version ({0})
+since_previous_version_detailed=since previous version ({0} - {1})
since_previous_version_detailed.short=\u0394 version ({0})
time_changes=Time changes
<dataset>
- <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]"
+ <snapshots purge_status="[null]"
+ period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+ period2_mode="[null]" period2_param="[null]" period2_date="[null]"
+ period3_mode="[null]" period3_param="[null]" period3_date="[null]"
+ period4_mode="[null]" period4_param="[null]" period4_date="[null]"
+ period5_mode="[null]" period5_param="[null]" period5_date="[null]"
id="100" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path=""
status="P" islast="false" depth="0" />
- <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]"
+ <snapshots purge_status="[null]"
+ period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+ period2_mode="[null]" period2_param="[null]" period2_date="[null]"
+ period3_mode="[null]" period3_param="[null]" period3_date="[null]"
+ period4_mode="[null]" period4_param="[null]" period4_date="[null]"
+ period5_mode="[null]" period5_param="[null]" period5_date="[null]"
id="200" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
scope="PRJ" qualifier="TRK" created_at="2008-12-15 13:58:00.00" build_date="2008-12-15 13:58:00.00" version="[null]" path=""
status="P" islast="false" depth="0" />
- <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]"
+ <!-- Snapshot of previous version -->
+ <snapshots purge_status="[null]"
+ period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+ period2_mode="[null]" period2_param="[null]" period2_date="[null]"
+ period3_mode="[null]" period3_param="[null]" period3_date="[null]"
+ period4_mode="[null]" period4_param="[null]" period4_date="[null]"
+ period5_mode="[null]" period5_param="[null]" period5_date="[null]"
+ id="300" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
+ scope="PRJ" qualifier="TRK" created_at="2008-12-13 13:58:00.00" build_date="2008-12-13 13:58:00.00" version="1.2.3" path=""
+ status="P" islast="false" depth="0" />
+
+ <snapshots purge_status="[null]"
+ period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+ period2_mode="[null]" period2_param="[null]" period2_date="[null]"
+ period3_mode="[null]" period3_param="[null]" period3_date="[null]"
+ period4_mode="[null]" period4_param="[null]" period4_date="[null]"
+ period5_mode="[null]" period5_param="[null]" period5_date="[null]"
id="1000" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
scope="PRJ" qualifier="TRK" created_at="2009-02-25 13:58:00.00" build_date="2009-02-25 13:58:00.00" version="[null]" path=""
status="P" islast="false" depth="0" />
-</dataset>
\ No newline at end of file
+</dataset>
<dataset>
- <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]"
+ <snapshots purge_status="[null]"
+ period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+ period2_mode="[null]" period2_param="[null]" period2_date="[null]"
+ period3_mode="[null]" period3_param="[null]" period3_date="[null]"
+ period4_mode="[null]" period4_param="[null]" period4_date="[null]"
+ period5_mode="[null]" period5_param="[null]" period5_date="[null]"
id="100" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path=""
status="P" islast="false" depth="0" />
- <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]"
+ <snapshots purge_status="[null]"
+ period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+ period2_mode="[null]" period2_param="[null]" period2_date="[null]"
+ period3_mode="[null]" period3_param="[null]" period3_date="[null]"
+ period4_mode="[null]" period4_param="[null]" period4_date="[null]"
+ period5_mode="[null]" period5_param="[null]" period5_date="[null]"
id="200" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
scope="PRJ" qualifier="TRK" created_at="2008-12-15 13:58:00.00" build_date="2008-12-15 13:58:00.00" version="[null]" path=""
status="P" islast="false" depth="0" />
- <snapshots purge_status="[null]" period1_mode="days" period1_param="30" period1_date="2009-01-25" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="version" period3_param="1.2.3" period3_date="2008-12-13" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]"
+ <!-- Snapshot of previous version -->
+ <snapshots purge_status="[null]"
+ period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+ period2_mode="[null]" period2_param="[null]" period2_date="[null]"
+ period3_mode="[null]" period3_param="[null]" period3_date="[null]"
+ period4_mode="[null]" period4_param="[null]" period4_date="[null]"
+ period5_mode="[null]" period5_param="[null]" period5_date="[null]"
+ id="300" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
+ scope="PRJ" qualifier="TRK" created_at="2008-12-13 13:58:00.00" build_date="2008-12-13 13:58:00.00" version="1.2.3" path=""
+ status="P" islast="false" depth="0" />
+
+ <snapshots purge_status="[null]"
+ period1_mode="days" period1_param="30" period1_date="2008-11-01 13:58:00.00"
+ period2_mode="[null]" period2_param="[null]" period2_date="[null]"
+ period3_mode="version" period3_param="1.2.3" period3_date="2008-12-13 13:58:00.0"
+ period4_mode="[null]" period4_param="[null]" period4_date="[null]"
+ period5_mode="[null]" period5_param="[null]" period5_date="[null]"
id="1000" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
scope="PRJ" qualifier="TRK" created_at="2009-02-25 13:58:00.00" build_date="2009-02-25 13:58:00.00" version="[null]" path=""
status="P" islast="false" depth="0" />
-</dataset>
\ No newline at end of file
+</dataset>
if (StringUtils.equals(mode, CoreProperties.TIMEMACHINE_MODE_VERSION)) {
String label = String.format("Compare to version %s", modeParameter);
if (getTargetDate() != null) {
- label += String.format(" (%s)", DateUtils.formatDate(getTargetDate()));
+ label += String.format(" (%s)", DateUtils.formatDate(getDate()));
}
return label;
}
@Test
public void testToStringForVersion() {
- PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_VERSION, new Date()).setModeParameter("2.3");
+ PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_VERSION, new Date(), new Snapshot().setCreatedAt(new Date())).setModeParameter("2.3");
assertThat(pastSnapshot.toString()).startsWith("Compare to version 2.3");
}
import org.apache.commons.lang.StringUtils;
import org.sonar.api.BatchExtension;
import org.sonar.api.CoreProperties;
+import org.sonar.api.ServerComponent;
import org.sonar.api.config.Settings;
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.i18n.I18n;
import java.util.Date;
import java.util.Locale;
-public class Periods implements BatchExtension {
+public class Periods implements BatchExtension, ServerComponent {
private final Settings settings;
private final I18n i18n;
private String label(String mode, String param, String date, boolean shortLabel) {
String label;
if (CoreProperties.TIMEMACHINE_MODE_DAYS.equals(mode)) {
- label = label("over_x_days", shortLabel, param);
+ label = label("over_x_days", shortLabel, param, date);
} else if (CoreProperties.TIMEMACHINE_MODE_VERSION.equals(mode)) {
label = label("since_version", shortLabel, param);
if (date != null) {
label = label("since_previous_version", shortLabel);
if (param != null) {
label = label("since_previous_version_detailed", shortLabel, param);
+ if (date != null) {
+ label = label("since_previous_version_detailed", shortLabel, param, date);
+ }
}
} else if (CoreProperties.TIMEMACHINE_MODE_DATE.equals(mode)) {
label = label("since_x", shortLabel, date);
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mockito;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
import org.sonar.api.database.model.Snapshot;
import java.util.Date;
import java.util.Locale;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Matchers.isNull;
+import static org.mockito.Mockito.*;
public class PeriodsTest {
@Test
public void label_of_duration_in_days() {
+ Date date = new Date();
when(snapshot.getPeriodMode(periodIndex)).thenReturn(CoreProperties.TIMEMACHINE_MODE_DAYS);
- when(snapshot.getPeriodDate(periodIndex)).thenReturn(new Date());
+ when(snapshot.getPeriodDate(periodIndex)).thenReturn(date);
when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
periods.label(snapshot, periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("over_x_days"), Mockito.isNull(String.class), Mockito.eq(param));
+ verify(i18n).message(any(Locale.class), eq("over_x_days"), isNull(String.class), eq(param), anyString());
}
@Test
when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
periods.abbreviation(snapshot, periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("over_x_days.short"), Mockito.isNull(String.class), Mockito.eq(param));
+ verify(i18n).message(any(Locale.class), eq("over_x_days.short"), isNull(String.class), eq(param), anyString());
}
@Test
when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
periods.label(snapshot, periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_version_detailed"), Mockito.isNull(String.class), Mockito.eq(param), Mockito.anyString());
+ verify(i18n).message(any(Locale.class), eq("since_version_detailed"), isNull(String.class), eq(param), anyString());
}
@Test
when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
periods.abbreviation(snapshot, periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_version_detailed.short"), Mockito.isNull(String.class), Mockito.eq(param), Mockito.anyString());
+ verify(i18n).message(any(Locale.class), eq("since_version_detailed.short"), isNull(String.class), eq(param), anyString());
}
@Test
when(snapshot.getPeriodDate(periodIndex)).thenReturn(new Date());
periods.label(snapshot, periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_analysis_detailed"), Mockito.isNull(String.class), Mockito.anyString());
+ verify(i18n).message(any(Locale.class), eq("since_previous_analysis_detailed"), isNull(String.class), anyString());
}
@Test
when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
periods.label(snapshot, periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_analysis"), Mockito.isNull(String.class));
+ verify(i18n).message(any(Locale.class), eq("since_previous_analysis"), isNull(String.class));
}
@Test
when(snapshot.getPeriodDate(periodIndex)).thenReturn(new Date());
periods.abbreviation(snapshot, periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_analysis_detailed.short"), Mockito.isNull(String.class), Mockito.anyString());
+ verify(i18n).message(any(Locale.class), eq("since_previous_analysis_detailed.short"), isNull(String.class), anyString());
}
@Test
when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
periods.abbreviation(snapshot, periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_analysis.short"), Mockito.isNull(String.class));
+ verify(i18n).message(any(Locale.class), eq("since_previous_analysis.short"), isNull(String.class));
}
@Test
when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
periods.label(snapshot, periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_version_detailed"), Mockito.isNull(String.class), Mockito.eq(param));
+ verify(i18n).message(any(Locale.class), eq("since_previous_version_detailed"), isNull(String.class), eq(param));
+ }
+
+ @Test
+ public void label_of_previous_version_with_param_and_date() {
+ when(snapshot.getPeriodMode(periodIndex)).thenReturn(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_VERSION);
+ when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(param);
+ when(snapshot.getPeriodDate(periodIndex)).thenReturn(new Date());
+
+ periods.label(snapshot, periodIndex);
+ verify(i18n).message(any(Locale.class), eq("since_previous_version_detailed"), isNull(String.class), eq(param), anyString());
}
@Test
when(snapshot.getPeriodModeParameter(periodIndex)).thenReturn(null);
periods.label(snapshot, periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_version"), Mockito.isNull(String.class));
+ verify(i18n).message(any(Locale.class), eq("since_previous_version"), isNull(String.class));
}
@Test
periods.label(snapshot, periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_x"), Mockito.isNull(String.class), Mockito.anyString());
+ verify(i18n).message(any(Locale.class), eq("since_x"), isNull(String.class), anyString());
}
@Test(expected = IllegalArgumentException.class)
settings.setProperty(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + periodIndex, days);
periods.label(periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("over_x_days"), Mockito.isNull(String.class), Mockito.eq(days));
+ verify(i18n).message(any(Locale.class), eq("over_x_days"), isNull(String.class), eq(days), anyString());
}
@Test
settings.setProperty(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + periodIndex, version);
periods.label(periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_version"), Mockito.isNull(String.class), Mockito.eq(version));
+ verify(i18n).message(any(Locale.class), eq("since_version"), isNull(String.class), eq(version));
}
@Test
settings.setProperty(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + periodIndex, CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS);
periods.label(periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_analysis"), Mockito.isNull(String.class));
+ verify(i18n).message(any(Locale.class), eq("since_previous_analysis"), isNull(String.class));
}
@Test
settings.setProperty(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + periodIndex, CoreProperties.TIMEMACHINE_MODE_PREVIOUS_VERSION);
periods.label(periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_version"), Mockito.isNull(String.class));
+ verify(i18n).message(any(Locale.class), eq("since_previous_version"), isNull(String.class));
}
@Test
settings.setProperty(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + periodIndex, CoreProperties.TIMEMACHINE_MODE_PREVIOUS_VERSION);
periods.abbreviation(periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_previous_version.short"), Mockito.isNull(String.class));
+ verify(i18n).message(any(Locale.class), eq("since_previous_version.short"), isNull(String.class));
}
@Test
periods.label(periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_x"), Mockito.isNull(String.class), Mockito.anyString());
+ verify(i18n).message(any(Locale.class), eq("since_x"), isNull(String.class), anyString());
}
@Test
periods.abbreviation(periodIndex);
- verify(i18n).message(Mockito.any(Locale.class), Mockito.eq("since_x.short"), Mockito.isNull(String.class), Mockito.anyString());
+ verify(i18n).message(any(Locale.class), eq("since_x.short"), isNull(String.class), anyString());
}
@Test(expected = IllegalArgumentException.class)
label = message('added_since_version', :params => mode_param.to_s)
elsif mode=='previous_analysis'
if !date.nil?
- label = message('added_since_previous_analysis_detailed', :params => date.strftime("%Y %b. %d").to_s)
+ label = message('added_since_previous_analysis_detailed', :params => date.strftime('%Y %b. %d').to_s)
else
label = message('added_since_previous_analysis')
end
label = message('added_since_previous_version')
end
elsif mode=='date'
- label = message('added_since', :params => date.strftime("%Y %b %d").to_s)
+ label = message('added_since', :params => date.strftime('%Y %b %d').to_s)
end
if label
selected=(params[:period]==index.to_s ? 'selected' : '')
<% if period_options %>
<form method="GET" action="<%= url_for :controller => :dashboard, :action => :index, :id => @resource.id -%>" style="display: inline" class="spacer-left">
<input type="hidden" name="did" value="<%= @dashboard.id -%>"/>
- <%= dropdown_tag "period", period_options, {:width => '230px'}, {:id => 'select-comparison', :onchange => 'submit()'} -%>
+ <%= dropdown_tag 'period', period_options, {:width => '250px'}, {:id => 'select-comparison', :onchange => 'submit()'} -%>
</form>
<% end %>
<% end %>
<% period_options = period_select_option_tags(@snapshot, 'small') %>
<% if period_options %>
<form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline" class="spacer-left">
- <%= dropdown_tag 'period', period_options, {:width => '230px'}, {:id => 'select-comparison', :onchange => 'submit()'} -%>
+ <%= dropdown_tag 'period', period_options, {:width => '250px'}, {:id => 'select-comparison', :onchange => 'submit()'} -%>
</form>
<% end %>
<% end %>