Examples of SnapshotDto


Examples of org.sonar.core.component.SnapshotDto

  @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"));

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

    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();
  }
View Full Code Here

Examples of org.sonar.core.component.SnapshotDto

    MockUserSession.set().addComponentPermission(UserRole.USER, SUB_PROJECT_KEY, COMPONENT_KEY);

    ComponentDto file = addComponent();

    when(resourceDao.getLastSnapshotByResourceUuid(file.projectUuid(), session)).thenReturn(
      new SnapshotDto().setPeriodMode(1, "previous_analysis").setPeriodDate(1, DateUtils.parseDate("2014-05-08"))
      );
    when(periods.label(anyString(), anyString(), any(Date.class))).thenReturn("since previous analysis (May 08 2014)");

    WsTester.TestRequest request = tester.newGetRequest("api/components", "app").setParam("key", COMPONENT_KEY);
    request.execute().assertJson(getClass(), "app_with_periods.json");
View Full Code Here

Examples of org.sonar.core.component.SnapshotDto

    addComponent();

    Date periodDate = DateUtils.parseDate("2014-05-08");
    when(resourceDao.getLastSnapshotByResourceUuid(project.uuid(), session)).thenReturn(
      new SnapshotDto().setPeriodMode(1, "previous_analysis").setPeriodDate(1, periodDate)
      );
    when(periods.label(anyString(), anyString(), any(Date.class))).thenReturn("since previous analysis (May 08 2014)");

    when(issueService.findRulesByComponent(COMPONENT_KEY, periodDate, session)).thenReturn(
      new RulesAggregation().add(new RuleDto().setRuleKey("AvoidCycle").setRepositoryKey("squid").setName("Avoid Cycle"))
View Full Code Here

Examples of org.sonar.core.component.SnapshotDto

  }

  private void addPeriod() {
    Date periodDate = DateUtils.parseDate("2014-05-08");
    when(resourceDao.getLastSnapshotByResourceUuid(project.uuid(), session)).thenReturn(
      new SnapshotDto().setPeriodMode(1, "previous_analysis").setPeriodDate(1, periodDate)
      );
    when(periods.label(anyString(), anyString(), any(Date.class))).thenReturn("since previous analysis (May 08 2014)");
  }
View Full Code Here

Examples of org.sonar.core.component.SnapshotDto

    file = ComponentTesting.newFileDto(project).setUuid("BCDE")
      .setKey("MyComponent")
      .setSubProjectId(project.getId());
    db.componentDao().insert(session, file);
    SnapshotDto snapshot = db.snapshotDao().insert(session, SnapshotTesting.createForComponent(file, project));
    SnapshotSourceDto snapshotSource = new SnapshotSourceDto().setSnapshotId(snapshot.getId()).setData("First Line\n"
      + "Second Line\n"
      + "Third Line\n"
      + "Fourth Line\n"
      + "Fifth Line\n");
    tester.get(SnapshotSourceDao.class).insert(snapshotSource);
View Full Code Here

Examples of org.sonar.core.component.SnapshotDto

    }
  }

  private List<Period> periods(String projectUuid, DbSession session) {
    List<Period> periodList = newArrayList();
    SnapshotDto snapshotDto = dbClient.resourceDao().getLastSnapshotByResourceUuid(projectUuid, session);
    if (snapshotDto != null) {
      for (int i = 1; i <= 5; i++) {
        String mode = snapshotDto.getPeriodMode(i);
        if (mode != null) {
          Date periodDate = snapshotDto.getPeriodDate(i);
          String label = periods.label(mode, snapshotDto.getPeriodModeParameter(i), periodDate);
          if (label != null) {
            periodList.add(new Period(i, label, periodDate));
          }
        }
      }
View Full Code Here

Examples of org.sonar.core.component.SnapshotDto

  public String getDescription() {
    return "Switch last snapshot flag";
  }

  private void disablePreviousSnapshot(DbSession session, AnalysisReportDto report) {
    SnapshotDto referenceSnapshot;

    try {
      referenceSnapshot = dao.getByKey(session, report.getSnapshotId());
    } catch (Exception exception) {
      throw new IllegalStateException(String.format("Unexpected error while trying to retrieve snapshot of analysis %s", report), exception);
    }

    List<SnapshotDto> snapshots = dao.findSnapshotAndChildrenOfProjectScope(session, referenceSnapshot);
    for (SnapshotDto snapshot : snapshots) {
      SnapshotDto previousLastSnapshot = dao.getLastSnapshot(session, snapshot);
      if (previousLastSnapshot != null) {
        dao.updateSnapshotAndChildrenLastFlag(session, previousLastSnapshot, false);
        session.commit();
      }
    }
View Full Code Here

Examples of org.sonar.core.component.SnapshotDto

      }
    }
  }

  private void enableCurrentSnapshot(DbSession session, AnalysisReportDto report) {
    SnapshotDto snapshot = dao.getByKey(session, report.getSnapshotId());
    SnapshotDto previousLastSnapshot = dao.getLastSnapshot(session, snapshot);

    boolean isLast = dao.isLast(snapshot, previousLastSnapshot);
    dao.updateSnapshotAndChildrenLastFlagAndStatus(session, snapshot, isLast, SnapshotDto.STATUS_PROCESSED);
    session.commit();
  }
View Full Code Here

Examples of org.sonar.core.component.SnapshotDto

      sb.append(" ");
    }
  }

  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(".%'");
      }
    }
  }
View Full Code Here

Examples of org.sonar.core.component.SnapshotDto

  /**
   * When project is null, that means that the component is a project
   */
  public static SnapshotDto createForComponent(ComponentDto component, ComponentDto project) {
    return new SnapshotDto()
      .setResourceId(component.getId())
      .setRootProjectId(project.getId())
      .setLast(true);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.