Package org.sonar.batch.bootstrap

Examples of org.sonar.batch.bootstrap.ServerClient


  @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


  }

  @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

  }

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

  }

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

  }

  @Test
  public void should_fail_to_download_source_from_ws() throws URISyntaxException {
    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);
View Full Code Here

  }

  @Test
  public void should_return_empty_source_if_preview_mode_and_no_last_snapshot() throws URISyntaxException {
    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());
View Full Code Here

  }

  @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

  @Test
  public void should_publish_results_for_regular_analysis() throws Exception {
    Settings settings = new Settings();
    Project project = new Project("struts");
    ServerClient serverClient = mock(ServerClient.class);
    UpdateStatusJob job = new UpdateStatusJob(settings, serverClient, project, mock(Snapshot.class), mode);

    job.uploadReport();
    verify(serverClient).request(contains("/batch/upload_report"), eq("POST"));
  }
View Full Code Here

  @Test
  public void should_not_publish_results_for_preview_analysis() throws Exception {
    Settings settings = new Settings();
    when(mode.isPreview()).thenReturn(true);
    Project project = new Project("struts");
    ServerClient serverClient = mock(ServerClient.class);
    UpdateStatusJob job = new UpdateStatusJob(settings, serverClient, project, mock(Snapshot.class), mode);

    job.uploadReport();
    verify(serverClient, never()).request(anyString());
  }
View Full Code Here

TOP

Related Classes of org.sonar.batch.bootstrap.ServerClient

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.