Search in sources :

Example 1 with CurrentGoCDVersion

use of com.thoughtworks.go.CurrentGoCDVersion in project gocd by gocd.

the class MessageHandlerForServerInfoRequestProcessor2_0Test method shouldSerializeServerConfigToJSON.

@Test
public void shouldSerializeServerConfigToJSON() {
    ServerConfig serverConfig = new ServerConfig();
    serverConfig.ensureServerIdExists();
    serverConfig.setSecureSiteUrl("https://example.com:8154/go");
    serverConfig.setSiteUrl("http://example.com:8153/go");
    CurrentGoCDVersion goCDVersion = CurrentGoCDVersion.getInstance();
    MessageHandlerForServerInfoRequestProcessor2_0 processor = new MessageHandlerForServerInfoRequestProcessor2_0();
    String expectedJsonStr = format("{\"server_id\":\"%s\"," + "\"site_url\":\"%s\"," + "\"secure_site_url\":\"%s\"," + "\"go_version\":\"%s\"," + "\"dist_version\":\"%s\"," + "\"git_revision\":\"%s\"" + "}", serverConfig.getServerId(), serverConfig.getSiteUrl().getUrl(), serverConfig.getSecureSiteUrl().getUrl(), goCDVersion.goVersion(), goCDVersion.distVersion(), goCDVersion.gitRevision());
    assertThatJson(expectedJsonStr).isEqualTo(processor.serverInfoToJSON(serverConfig));
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) CurrentGoCDVersion(com.thoughtworks.go.CurrentGoCDVersion) Test(org.junit.jupiter.api.Test)

Example 2 with CurrentGoCDVersion

use of com.thoughtworks.go.CurrentGoCDVersion in project gocd by gocd.

the class MessageHandlerForServerInfoRequestProcessor2_0 method serverInfoToJSON.

@Override
public String serverInfoToJSON(ServerConfig serverConfig) {
    JsonObject object = new JsonObject();
    CurrentGoCDVersion currentGoCDVersion = CurrentGoCDVersion.getInstance();
    object.addProperty("server_id", serverConfig.getServerId());
    object.addProperty("site_url", serverConfig.getSiteUrl().getUrl());
    object.addProperty("secure_site_url", serverConfig.getSecureSiteUrl().getUrl());
    object.addProperty("go_version", currentGoCDVersion.goVersion());
    object.addProperty("dist_version", currentGoCDVersion.distVersion());
    object.addProperty("git_revision", currentGoCDVersion.gitRevision());
    return gson.toJson(object);
}
Also used : CurrentGoCDVersion(com.thoughtworks.go.CurrentGoCDVersion) JsonObject(com.google.gson.JsonObject)

Aggregations

CurrentGoCDVersion (com.thoughtworks.go.CurrentGoCDVersion)2 JsonObject (com.google.gson.JsonObject)1 ServerConfig (com.thoughtworks.go.config.ServerConfig)1 Test (org.junit.jupiter.api.Test)1