Examples of SnapshotSourceDao


Examples of org.sonar.core.source.db.SnapshotSourceDao

  @Before
  public void setUpDatasets() {
    setupData("shared");

    SnapshotSourceDao snapshotSourceDao = new SnapshotSourceDao(getMyBatis());
    SnapshotDataDao snapshotDataDao = new SnapshotDataDao(getMyBatis());
    sourceDecorator = new HtmlSourceDecorator(getMyBatis(), snapshotSourceDao, snapshotDataDao);
  }
View Full Code Here

Examples of org.sonar.core.source.db.SnapshotSourceDao

    );
  }

  @Test
  public void should_not_query_sources_if_no_snapshot_data() throws Exception {
    SnapshotSourceDao snapshotSourceDao = mock(SnapshotSourceDao.class);
    SnapshotDataDao snapshotDataDao = mock(SnapshotDataDao.class);

    HtmlSourceDecorator sourceDecorator = new HtmlSourceDecorator(mock(MyBatis.class), snapshotSourceDao, snapshotDataDao);

    sourceDecorator.getDecoratedSourceAsHtml(14L);
View Full Code Here

Examples of org.sonar.core.source.db.SnapshotSourceDao

    verify(snapshotSourceDao, times(0)).selectSnapshotSource(14L);
  }

  @Test
  public void should_not_query_sources_if_no_snapshot_data_from_component() throws Exception {
    SnapshotSourceDao snapshotSourceDao = mock(SnapshotSourceDao.class);
    SnapshotDataDao snapshotDataDao = mock(SnapshotDataDao.class);

    HtmlSourceDecorator sourceDecorator = new HtmlSourceDecorator(mock(MyBatis.class), snapshotSourceDao, snapshotDataDao);

    sourceDecorator.getDecoratedSourceAsHtml("org.apache.struts:struts:DebuggingInterceptor", null, null);
View Full Code Here

Examples of org.sonar.core.source.db.SnapshotSourceDao

  @Test
  public void should_get_source_of_last_snapshot() {
    db.prepareDbUnit(getClass(), "last_snapshot.xml");

    ServerClient server = mock(ServerClient.class);
    LastSnapshots lastSnapshots = new LastSnapshots(mode, new SnapshotSourceDao(db.myBatis()), server);

    assertThat(lastSnapshots.getSource(newFile())).isEqualTo("this is bar");
    verifyZeroInteractions(server);
  }
View Full Code Here

Examples of org.sonar.core.source.db.SnapshotSourceDao

  @Test
  public void should_return_empty_source_if_no_last_snapshot() {
    db.prepareDbUnit(getClass(), "no_last_snapshot.xml");
    ServerClient server = mock(ServerClient.class);

    LastSnapshots lastSnapshots = new LastSnapshots(mode, new SnapshotSourceDao(db.myBatis()), server);

    assertThat(lastSnapshots.getSource(newFile())).isEqualTo("");
    verifyZeroInteractions(server);
  }
View Full Code Here

Examples of org.sonar.core.source.db.SnapshotSourceDao

    db.prepareDbUnit(getClass(), "last_snapshot.xml");
    ServerClient server = mock(ServerClient.class);
    when(server.request(anyString(), eq("GET"), eq(false), eq(30 * 1000))).thenReturn("downloaded source of Bar.c");

    when(mode.isPreview()).thenReturn(true);
    LastSnapshots lastSnapshots = new LastSnapshots(mode, new SnapshotSourceDao(db.myBatis()), server);

    String source = lastSnapshots.getSource(newFile());
    assertThat(source).isEqualTo("downloaded source of Bar.c");
    verify(server).request("/api/sources/raw?key=myproject%3Aorg%2Ffoo%2FBar.c", "GET", false, 30 * 1000);
  }
View Full Code Here

Examples of org.sonar.core.source.db.SnapshotSourceDao

    db.prepareDbUnit(getClass(), "last_snapshot.xml");
    ServerClient server = mock(ServerClient.class);
    when(server.request(anyString(), eq("GET"), eq(false), eq(30 * 1000))).thenReturn("downloaded source of Foo Bar.c");

    when(mode.isPreview()).thenReturn(true);
    LastSnapshots lastSnapshots = new LastSnapshots(mode, new SnapshotSourceDao(db.myBatis()), server);

    String source = lastSnapshots.getSource(newFile());
    assertThat(source).isEqualTo("downloaded source of Foo Bar.c");
    verify(server).request("/api/sources/raw?key=myproject%3Aorg%2Ffoo%2FBar.c", "GET", false, 30 * 1000);
  }
View Full Code Here

Examples of org.sonar.core.source.db.SnapshotSourceDao

    db.prepareDbUnit(getClass(), "last_snapshot.xml");
    ServerClient server = mock(ServerClient.class);
    when(server.request(anyString(), eq("GET"), eq(false), eq(30 * 1000))).thenThrow(new HttpDownloader.HttpException(new URI(""), 500));

    when(mode.isPreview()).thenReturn(true);
    LastSnapshots lastSnapshots = new LastSnapshots(mode, new SnapshotSourceDao(db.myBatis()), server);

    thrown.expect(HttpDownloader.HttpException.class);
    lastSnapshots.getSource(newFile());
  }
View Full Code Here

Examples of org.sonar.core.source.db.SnapshotSourceDao

    db.prepareDbUnit(getClass(), "last_snapshot.xml");
    ServerClient server = mock(ServerClient.class);
    when(server.request(anyString(), eq("GET"), eq(false), eq(30 * 1000))).thenThrow(new HttpDownloader.HttpException(new URI(""), 404));

    when(mode.isPreview()).thenReturn(true);
    LastSnapshots lastSnapshots = new LastSnapshots(mode, new SnapshotSourceDao(db.myBatis()), server);

    String source = lastSnapshots.getSource(newFileWithSpace());
    assertThat(source).isEqualTo("");
    verify(server).request("/api/sources/raw?key=myproject%3Aorg%2Ffoo%2FFoo+Bar.c", "GET", false, 30 * 1000);
  }
View Full Code Here

Examples of org.sonar.core.source.db.SnapshotSourceDao

  @Test
  public void should_not_load_source_of_non_files() throws URISyntaxException {
    db.prepareDbUnit(getClass(), "last_snapshot.xml");
    ServerClient server = mock(ServerClient.class);

    LastSnapshots lastSnapshots = new LastSnapshots(mode, new SnapshotSourceDao(db.myBatis()), server);

    String source = lastSnapshots.getSource(new Project("my-project"));
    assertThat(source).isEqualTo("");
  }
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.