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));
}
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);
}
Aggregations