s.status as status,
s.purge_status as purgeStatus,
s.islast as last,
- s.version as version,
+ s.version as rawVersion,
s.period1_mode as periodMode,
s.period1_param as periodParam,
s.period1_date as periodDate
import java.util.Date;
import java.util.List;
import java.util.Optional;
+import org.apache.commons.lang.StringUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
}
@Test
- public void select_first_snapshots() throws Exception {
+ public void select_first_snapshots() {
ComponentDto project = newPrivateProjectDto(db.getDefaultOrganization());
db.getDbClient().componentDao().insert(dbSession, project);
assertThat(result.getComponentUuid()).isEqualTo("P1");
}
+ @Test
+ public void snashotDto_can_hold_version_larger_than_100_read_from_database() {
+ SnapshotDto analysis = insertAnalysis("P1", "A1", STATUS_PROCESSED, false);
+ db.commit();
+ String tooLongVersion = StringUtils.repeat("d", 200);
+ db.executeUpdateSql("update snapshots set version='" + tooLongVersion + "' where uuid='" + analysis.getUuid() + "'");
+ db.commit();
+
+ assertThat(underTest.selectByUuid(dbSession, analysis.getUuid())
+ .map(SnapshotDto::getVersion))
+ .contains(tooLongVersion);
+
+ }
+
private SnapshotDto insertAnalysis(String projectUuid, String uuid, String status, boolean isLastFlag) {
SnapshotDto snapshot = newAnalysis(newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid))
.setLast(isLastFlag)