Package org.sonar.api.database.model

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


  @Test
  public void should_find() {
    Settings settings = new Settings().setProperty("sonar.timemachine.period5", "1.2");

    when(finderByVersion.findByVersion(null, "1.2")).thenReturn(new PastSnapshot("version", new Date(), new Snapshot()));

    PastSnapshot variationSnapshot = finder.find(null, null, settings, 5);

    verify(finderByVersion).findByVersion(null, "1.2");
    assertThat(variationSnapshot.getIndex(), is(5));
View Full Code Here


  @Test
  public void should_find_with_qualifier_suffix() {
    Settings settings = new Settings().setProperty("sonar.timemachine.period5.TRK", "1.2");

    when(finderByVersion.findByVersion(null, "1.2")).thenReturn(new PastSnapshot("version", new Date(), new Snapshot()));

    PastSnapshot variationSnapshot = finder.find(null, "TRK", settings, 5);

    verify(finderByVersion).findByVersion(null, "1.2");
    assertThat(variationSnapshot.getIndex(), is(5));
View Full Code Here

  @Test
  public void should_find_by_date() throws ParseException {
    final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    final Date date = format.parse("2010-05-18");
    when(finderByDate.findByDate((Snapshot) null, date)).thenReturn(new PastSnapshot("date", date, new Snapshot()));

    PastSnapshot variationSnapshot = finder.find(null, 2, "2010-05-18");

    verify(finderByDate).findByDate(any(Snapshot.class), argThat(new ArgumentMatcher<Date>() {
      @Override
View Full Code Here

  @Test
  public void should_find_by_previous_analysis() throws ParseException {
    final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    final Date date = format.parse("2010-05-18");
    Snapshot snapshot = new Snapshot();
    snapshot.setCreatedAt(date);
    when(finderByPreviousAnalysis.findByPreviousAnalysis(null)).thenReturn(new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, date, snapshot));

    PastSnapshot variationSnapshot = finder.find(null, 2, CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS);

    verify(finderByPreviousAnalysis).findByPreviousAnalysis(null);
View Full Code Here

  @Test
  public void should_find_by_previous_version() throws ParseException {
    final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    final Date date = format.parse("2010-05-18");
    Snapshot snapshot = new Snapshot();
    snapshot.setCreatedAt(date);
    when(finderByPreviousVersion.findByPreviousVersion(null)).thenReturn(new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_VERSION, date, snapshot));

    PastSnapshot variationSnapshot = finder.find(null, 2, CoreProperties.TIMEMACHINE_MODE_PREVIOUS_VERSION);

    verify(finderByPreviousVersion).findByPreviousVersion(null);
View Full Code Here

    assertThat(variationSnapshot.getProjectSnapshot(), not(nullValue()));
  }

  @Test
  public void should_find_by_version() {
    when(finderByVersion.findByVersion(null, "1.2")).thenReturn(new PastSnapshot("version", new Date(), new Snapshot()));

    PastSnapshot variationSnapshot = finder.find(null, 2, "1.2");

    verify(finderByVersion).findByVersion(null, "1.2");
    assertThat(variationSnapshot.getIndex(), is(2));
View Full Code Here

  }

  @Test
  public void should_not_fail_if_unknown_format() {
    // should not be called
    when(finderByPreviousAnalysis.findByPreviousAnalysis(null)).thenReturn(new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, new Date(), new Snapshot()));

    assertNull(finder.find(null, 2, "foooo"));
  }
View Full Code Here

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

    List<Metric> metrics = selectMetrics();
    Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", PROJECT_SNAPSHOT_ID);

    PastMeasuresLoader loader = new PastMeasuresLoader(getSession(), metrics);
    List<Object[]> measures = loader.getPastMeasures(FILE_KEY, projectSnapshot);
    assertThat(measures.size(), is(2));
View Full Code Here

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

    List<Metric> metrics = selectMetrics();
    Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", PROJECT_SNAPSHOT_ID);

    PastMeasuresLoader loader = new PastMeasuresLoader(getSession(), metrics);
    List<Object[]> measures = loader.getPastMeasures(PROJECT_KEY, projectSnapshot);
    assertThat(measures.size(), is(2));
View Full Code Here

public class PastSnapshotTest {

  @Test
  public void test_some_setters_and_getters() {
    Snapshot snapshot = new Snapshot().setQualifier(Qualifiers.FILE).setCreatedAt(new Date());
    snapshot.setId(10);
    PastSnapshot pastSnapshot = new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_VERSION, new Date(),
      snapshot)
      .setModeParameter("2.3")
      .setIndex(1);
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.