Package org.sonar.api.database.model

Examples of org.sonar.api.database.model.Snapshot


    assertThat(pastSnapshot.getProjectSnapshotId()).isNull();
  }

  @Test
  public void testToStringForVersion() {
    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");
  }
View Full Code Here


    assertThat(pastSnapshot.toString()).startsWith("Compare over 30 days (");
  }

  @Test
  public void testToStringForNumberOfDaysWithSnapshot() {
    PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_DAYS, new Date(), new Snapshot().setCreatedAt(new Date())).setModeParameter("30");
    assertThat(pastSnapshot.toString()).startsWith("Compare over 30 days (");
  }
View Full Code Here

    assertThat(pastSnapshot.toString()).startsWith("Compare to date ");
  }

  @Test
  public void testToStringForDateWithSnapshot() {
    PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_DATE, new Date(), new Snapshot().setCreatedAt(new Date()));
    assertThat(pastSnapshot.toString()).startsWith("Compare to date ");
  }
View Full Code Here

    assertThat(pastSnapshot.toString()).startsWith("Compare to date ");
  }

  @Test
  public void testToStringForPreviousAnalysis() {
    PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, new Date(), new Snapshot().setCreatedAt(new Date()));
    assertThat(pastSnapshot.toString()).startsWith("Compare to previous analysis ");
  }
View Full Code Here

  @Before
  public void before() {
    setupData("shared");
    ResourcePersister resourcePersister = mock(ResourcePersister.class);
    Snapshot snapshot = new Snapshot();
    snapshot.setId(1000);
    when(resourcePersister.getSnapshotOrFail(any(Resource.class))).thenReturn(snapshot);
    sourcePersister = new SourcePersister(resourcePersister, new SnapshotSourceDao(getMyBatis()));
  }
View Full Code Here

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

    Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1009); // 2008-11-16
    PastSnapshotFinderByDays finder = new PastSnapshotFinderByDays(getSession());

    assertThat(finder.findFromDays(projectSnapshot, 50).getProjectSnapshotId(), is(1000));
  }
View Full Code Here

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

    Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1009); // 2008-11-16
    PastSnapshotFinderByDays finder = new PastSnapshotFinderByDays(getSession());

    assertThat(finder.findFromDays(projectSnapshot, 7).getProjectSnapshotId(), is(1006));
  }
View Full Code Here

  @Test
  public void shouldNotFindSelf() {
    setupData("shouldNotFindSelf");

    Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1009); // 2008-11-16
    PastSnapshotFinderByDays finder = new PastSnapshotFinderByDays(getSession());

    assertThat(finder.findFromDays(projectSnapshot, 1).getProjectSnapshot(), nullValue());
  }
View Full Code Here

    List<Snapshot> snapshots = Collections.emptyList();
    assertThat(PastSnapshotFinderByDays.getNearestToTarget(snapshots, current, 15), IsNull.nullValue());
  }

  private Snapshot newSnapshot(int id, String date) throws ParseException {
    Snapshot snapshot = new Snapshot();
    snapshot.setId(id);
    snapshot.setCreatedAt(dateFormat.parse(date));
    return snapshot;
  }
View Full Code Here

  @Test
  public void shouldFindPreviousAnalysis() {
    setupData("shouldFindPreviousAnalysis");

    Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1010);
    PastSnapshotFinderByPreviousAnalysis finder = new PastSnapshotFinderByPreviousAnalysis(getSession());

    PastSnapshot pastSnapshot = finder.findByPreviousAnalysis(projectSnapshot);
    assertThat(pastSnapshot.getProjectSnapshotId(), is(1009));
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.database.model.Snapshot

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.