Package org.sonar.api.database.model

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


  @Test
  public void shouldReturnPastSnapshotEvenWhenNoPreviousAnalysis() {
    setupData("shouldNotFindPreviousAnalysis");

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

    PastSnapshot pastSnapshot = finder.findByPreviousAnalysis(projectSnapshot);
    assertThat(pastSnapshot.isRelatedToSnapshot(), is(false));
    assertThat(pastSnapshot.getProjectSnapshot(), nullValue());
View Full Code Here


    storage = new ScanIssueStorage(getMyBatis(), new FakeRuleFinder(), snapshotCache, new ResourceDao(getMyBatis(), System2.INSTANCE), projectTree);
  }

  @Test
  public void should_load_component_id_from_cache() throws Exception {
    when(snapshotCache.get("struts:Action.java")).thenReturn(new Snapshot().setResourceId(123));

    long componentId = storage.componentId(new DefaultIssue().setComponentKey("struts:Action.java"));

    assertThat(componentId).isEqualTo(123);
  }
View Full Code Here

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

    Snapshot currentProjectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1010);
    PastSnapshotFinderByVersion finder = new PastSnapshotFinderByVersion(getSession());

    PastSnapshot foundSnapshot = finder.findByVersion(currentProjectSnapshot, "1.1");
    assertThat(foundSnapshot.getProjectSnapshotId()).isEqualTo(1009);
    assertThat(foundSnapshot.getMode()).isEqualTo(CoreProperties.TIMEMACHINE_MODE_VERSION);
View Full Code Here

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

    Snapshot currentProjectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1010);
    PastSnapshotFinderByVersion finder = new PastSnapshotFinderByVersion(getSession());

    PastSnapshot foundSnapshot = finder.findByVersion(currentProjectSnapshot, "2.1");
    assertThat(foundSnapshot.getMode()).isEqualTo(CoreProperties.TIMEMACHINE_MODE_VERSION);
    assertThat(foundSnapshot.getProjectSnapshot()).isNull();
View Full Code Here

    periodsDefinition = mock(PeriodsDefinition.class);
  }

  @Test
  public void get_project_past_snapshot() {
    Snapshot projectSnapshot = new Snapshot();
    projectSnapshot.setId(1010);
    PastSnapshot projectPastSnapshot = new PastSnapshot("mode", new Date(), projectSnapshot);

    when(periodsDefinition.getRootProjectPastSnapshots()).thenReturn(newArrayList(projectPastSnapshot));

    TimeMachineConfiguration timeMachineConfiguration = new TimeMachineConfiguration(getSession(), (Project) new Project("my:project").setId(1), periodsDefinition);
View Full Code Here

    assertThat(timeMachineConfiguration.getProjectPastSnapshots().get(0).getProjectSnapshot().getId()).isEqualTo(1010);
  }

  @Test
  public void get_module_past_snapshot() {
    Snapshot projectSnapshot = new Snapshot();
    projectSnapshot.setId(1010);
    PastSnapshot projectPastSnapshot = new PastSnapshot("mode", new Date(), projectSnapshot);

    when(periodsDefinition.getRootProjectPastSnapshots()).thenReturn(newArrayList(projectPastSnapshot));

    TimeMachineConfiguration timeMachineConfiguration = new TimeMachineConfiguration(getSession(), (Project) new Project("my:module").setId(2), periodsDefinition);
View Full Code Here

    assertThat(timeMachineConfiguration.getProjectPastSnapshots().get(0).getProjectSnapshot().getId()).isEqualTo(1010);
  }

  @Test
  public void complete_past_snapshot_from_project_past_snapshot() {
    Snapshot projectSnapshot = new Snapshot();
    projectSnapshot.setId(1010);

    PastSnapshot projectPastSnapshot = new PastSnapshot("mode", new Date(), projectSnapshot);
    projectPastSnapshot.setIndex(1);
    projectPastSnapshot.setMode("mode");
    projectPastSnapshot.setModeParameter("modeParam");
View Full Code Here

    assertThat(timeMachineConfiguration.getProjectPastSnapshots().get(0).getModeParameter()).isEqualTo("modeParam");
  }

  @Test
  public void get_no_date_on_new_project() {
    Snapshot projectSnapshot = new Snapshot();
    projectSnapshot.setId(1010);

    PastSnapshot projectPastSnapshot = new PastSnapshot("mode", new Date(), projectSnapshot);

    when(periodsDefinition.getRootProjectPastSnapshots()).thenReturn(newArrayList(projectPastSnapshot));
View Full Code Here

  @Test
  public void shouldFindByPreviousVersion() {
    setupData("with-previous-version");
    PastSnapshotFinderByPreviousVersion finder = new PastSnapshotFinderByPreviousVersion(getSession());

    Snapshot currentProjectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1003);
    PastSnapshot foundSnapshot = finder.findByPreviousVersion(currentProjectSnapshot);
    assertThat(foundSnapshot.getProjectSnapshotId()).isEqualTo(1001);
    assertThat(foundSnapshot.getMode()).isEqualTo(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_VERSION);
    assertThat(foundSnapshot.getModeParameter()).isEqualTo("1.1");
  }
View Full Code Here

  @Test
  public void shouldFindByPreviousVersionWhenPreviousVersionDeleted() {
    setupData("with-previous-version-deleted");
    PastSnapshotFinderByPreviousVersion finder = new PastSnapshotFinderByPreviousVersion(getSession());

    Snapshot currentProjectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1003);
    PastSnapshot foundSnapshot = finder.findByPreviousVersion(currentProjectSnapshot);
    assertThat(foundSnapshot.getProjectSnapshotId()).isEqualTo(1000);
    assertThat(foundSnapshot.getMode()).isEqualTo(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_VERSION);
    assertThat(foundSnapshot.getModeParameter()).isEqualTo("1.0");
  }
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.