Package org.sonar.wsclient.services

Examples of org.sonar.wsclient.services.Server


public class ServerUnmarshallerTest extends UnmarshallerTestCase {

  @Test
  public void testToModel() {
    Server server = new ServerUnmarshaller().toModel(loadFile("/server/server.json"));
    assertThat(server.getId(), is("123456789"));
    assertThat(server.getVersion(), is("2.0-SNAPSHOT"));
    assertThat(server.getStatus(), is(Server.Status.UP));
    assertThat(server.getStatusMessage(), is("everything is under control"));
  }
View Full Code Here


    assertThat(server.getStatusMessage(), is("everything is under control"));
  }

  @Test
  public void shouldNotFailIfStatusIsMissing() {
    Server server = new ServerUnmarshaller().toModel(loadFile("/server/status_missing.json"));
    assertThat(server.getId(), is("123456789"));
    assertThat(server.getVersion(), is("2.0-SNAPSHOT"));
    assertThat(server.getStatus(), nullValue());
    assertThat(server.getStatusMessage(), nullValue());
  }
View Full Code Here

public class ServerUnmarshaller implements Unmarshaller<Server> {
  @Override
  public Server toModel(String json) {
    WSUtils utils = WSUtils.getINSTANCE();
    Object map = utils.parse(json);
    Server server = new Server()
        .setId(utils.getString(map, "id"))
        .setVersion(utils.getString(map, "version"))
        .setStatusMessage(utils.getString(map, "status_msg"));
    String status = utils.getString(map, "status");
    if (status != null) {
      server.setStatus(Server.Status.valueOf(status));
    }
    return server;
  }
View Full Code Here

    fakeSonar.findAll(MetricQuery.all());
  }

  @Test
  public void getVersion() {
    Server server = sonar.find(new ServerQuery());
    assertThat(server.getId(), Matchers.is("123456789"));
    assertThat(server.getVersion(), Matchers.is("2.0"));
  }
View Full Code Here

TOP

Related Classes of org.sonar.wsclient.services.Server

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.