예제 #1
0
 private void appendResourceBaseCondition(StringBuilder sb) {
   SnapshotDto baseSnapshot = context.getBaseSnapshot();
   if (baseSnapshot != null) {
     if (filter.isOnBaseResourceChildren()) {
       sb.append(" AND s.parent_snapshot_id=").append(baseSnapshot.getId());
     } else {
       Long rootSnapshotId =
           baseSnapshot.getRootId() != null ? baseSnapshot.getRootId() : baseSnapshot.getId();
       sb.append(" AND s.root_snapshot_id=").append(rootSnapshotId);
       sb.append(" AND s.path LIKE '")
           .append(StringUtils.defaultString(baseSnapshot.getPath()))
           .append(baseSnapshot.getId())
           .append(".%'");
     }
   }
 }
예제 #2
0
  @Test
  public void get_last_snapshot_by_component_uuid() {
    setupData("get_last_snapshot_by_component_uuid");

    SnapshotDto snapshotDto = dao.getLastSnapshotByResourceUuid("ABCD", session);
    assertThat(snapshotDto.getId()).isEqualTo(1);

    assertThat(snapshotDto.getPeriodMode(1)).isEqualTo("previous_analysis");
    assertThat(snapshotDto.getPeriodModeParameter(1)).isNull();
    assertThat(snapshotDto.getPeriodDate(1)).isNull();

    assertThat(snapshotDto.getPeriodMode(2)).isEqualTo("days");
    assertThat(snapshotDto.getPeriodModeParameter(2)).isEqualTo("30");
    assertThat(snapshotDto.getPeriodDate(2)).isEqualTo(DateUtils.parseDate("2011-09-24").getTime());

    assertThat(snapshotDto.getPeriodMode(3)).isEqualTo("days");
    assertThat(snapshotDto.getPeriodModeParameter(3)).isEqualTo("90");
    assertThat(snapshotDto.getPeriodDate(3)).isEqualTo(DateUtils.parseDate("2011-07-26").getTime());

    assertThat(snapshotDto.getPeriodMode(4)).isEqualTo("previous_analysis");
    assertThat(snapshotDto.getPeriodModeParameter(4)).isNull();
    assertThat(snapshotDto.getPeriodDate(4)).isNull();

    assertThat(snapshotDto.getPeriodMode(5)).isEqualTo("previous_version");
    assertThat(snapshotDto.getPeriodModeParameter(5)).isNull();
    assertThat(snapshotDto.getPeriodDate(5)).isNull();

    snapshotDto = dao.getLastSnapshotByResourceUuid("EFGH", session);
    assertThat(snapshotDto.getId()).isEqualTo(2L);

    snapshotDto = dao.getLastSnapshotByResourceUuid("GHIJ", session);
    assertThat(snapshotDto.getId()).isEqualTo(3L);

    assertThat(dao.getLastSnapshotByResourceUuid("UNKNOWN", session)).isNull();
  }