Package org.sonar.batch.components

Examples of org.sonar.batch.components.PastSnapshot


  @Test
  public void shouldCompareAndSaveVariation() {
    Resource dir = new Directory("org/foo");

    PastMeasuresLoader pastMeasuresLoader = mock(PastMeasuresLoader.class);
    PastSnapshot pastSnapshot1 = new PastSnapshot("days", new Date()).setIndex(1);
    PastSnapshot pastSnapshot3 = new PastSnapshot("days", new Date()).setIndex(3);

    // first past analysis
    when(pastMeasuresLoader.getPastMeasures(dir, pastSnapshot1)).thenReturn(Arrays.asList(
      new Object[] {NCLOC_ID, null, null, null, 180.0},
      new Object[] {COVERAGE_ID, null, null, null, 75.0}));
View Full Code Here


    when(ruleFinder.findByKey(rule2.ruleKey())).thenReturn(rule2);

    Resource dir = new Directory("org/foo");

    PastMeasuresLoader pastMeasuresLoader = mock(PastMeasuresLoader.class);
    PastSnapshot pastSnapshot1 = new PastSnapshot("days", new Date()).setIndex(1);

    // first past analysis
    when(pastMeasuresLoader.getPastMeasures(dir, pastSnapshot1)).thenReturn(Arrays.asList(
      new Object[] {VIOLATIONS_ID, null, null, null, 180.0},// total
      new Object[] {VIOLATIONS_ID, null, null, rule1.getId(), 100.0},// rule 1
View Full Code Here

  @Test
  public void shouldSaveConfigurationInSnapshotsTable() {
    setupData("shared");

    TimeMachineConfiguration timeMachineConfiguration = mock(TimeMachineConfiguration.class);
    PastSnapshot vs1 = new PastSnapshot("days", DateUtils.parseDate("2009-01-25"), getSession().getSingleResult(Snapshot.class, "id", 100))
      .setModeParameter("30").setIndex(1);
    PastSnapshot vs3 = new PastSnapshot("version", DateUtils.parseDate("2008-12-13"), getSession().getSingleResult(Snapshot.class, "id", 300))
      .setModeParameter("1.2.3").setIndex(3);
    when(timeMachineConfiguration.getProjectPastSnapshots()).thenReturn(Arrays.asList(vs1, vs3));
    Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1000);

    TimeMachineConfigurationPersister persister = new TimeMachineConfigurationPersister(timeMachineConfiguration, projectSnapshot, getSession());
View Full Code Here

  SnapshotDataDao snapshotDataDao = mock(SnapshotDataDao.class);
  PreviousFileHashLoader loader = new PreviousFileHashLoader(snapshot, snapshotDataDao, pastSnapshotFinder);

  @Test
  public void should_return_null_if_no_previous_snapshot() throws Exception {
    when(pastSnapshotFinder.findPreviousAnalysis(snapshot)).thenReturn(new PastSnapshot("foo"));

    Map<String, String> hashByRelativePath = loader.hashByRelativePath();
    assertThat(hashByRelativePath.get("src/main/java/foo/Bar.java")).isNull();
  }
View Full Code Here

  }

  @Test
  public void should_return_null_if_no_remote_hashes() throws Exception {
    Snapshot previousSnapshot = mock(Snapshot.class);
    PastSnapshot pastSnapshot = new PastSnapshot("foo", new Date(), previousSnapshot);
    when(pastSnapshotFinder.findPreviousAnalysis(snapshot)).thenReturn(pastSnapshot);

    Map<String, String> hashByRelativePath = loader.hashByRelativePath();
    assertThat(hashByRelativePath.get("src/main/java/foo/Bar.java")).isNull();
  }
View Full Code Here

  @Test
  public void should_return_remote_hash() throws Exception {
    Snapshot previousSnapshot = mock(Snapshot.class);
    when(previousSnapshot.getId()).thenReturn(123);
    PastSnapshot pastSnapshot = new PastSnapshot("foo", new Date(), previousSnapshot);
    when(pastSnapshotFinder.findPreviousAnalysis(snapshot)).thenReturn(pastSnapshot);

    SnapshotDataDto snapshotDataDto = new SnapshotDataDto();
    snapshotDataDto.setData("src/main/java/foo/Bar.java=abcd1234");
    when(snapshotDataDao.selectSnapshotData(123, Arrays.asList(SnapshotDataTypes.FILE_HASHES)))
View Full Code Here

  /**
   * Extract hash of the files parsed during the previous analysis
   */
  public Map<String, String> hashByRelativePath() {
    Map<String, String> map = Maps.newHashMap();
    PastSnapshot pastSnapshot = pastSnapshotFinder.findPreviousAnalysis(snapshot);
    if (pastSnapshot.isRelatedToSnapshot()) {
      Collection<SnapshotDataDto> selectSnapshotData = dao.selectSnapshotData(
        pastSnapshot.getProjectSnapshot().getId().longValue(),
        Arrays.asList(SnapshotDataTypes.FILE_HASHES)
        );
      if (!selectSnapshotData.isEmpty()) {
        SnapshotDataDto snapshotDataDto = selectSnapshotData.iterator().next();
        String data = snapshotDataDto.getData();
View Full Code Here

TOP

Related Classes of org.sonar.batch.components.PastSnapshot

Copyright © 2018 www.massapicom. 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.