TeamCityRestRequest { public Build fetchBuildStatus(int buildId) throws IOException { String urlEndpoint = buildServerUrl + PATH_BUILD + Integer.toString(buildId); JsonElement json = RestRequest.fetchJson(username, password, urlEndpoint); System.out.println("Rest Response: " + json.toString()); Gson gson = new Gson(); return gson.fromJson(json, Build.class); } @SuppressWarnings("unused") private  TeamCityRestRequest();  TeamCityRestRequest(String buildServerUrl, String buildServerUsername, String buildServerPassword); Build fetchBuildStatus(int buildId);  }
@Test public void testRestRequestSuccess() throws IOException { String serverUrl = "http: String username = github.getUsername(); String password = github.getPassword(); int buildId = 299; TeamCityRestRequest rest = new TeamCityRestRequest(serverUrl, username, password); Build build = rest.fetchBuildStatus(buildId); Assert.assertNotNull(build); Assert.assertTrue(build.getStatus().contains("SUCC")); }
@Test public void testRestRequestFailure() throws IOException { String serverUrl = "http: String username = github.getUsername(); String password = github.getPassword(); int buildId = 490; TeamCityRestRequest rest = new TeamCityRestRequest(serverUrl, username, password); Build build = rest.fetchBuildStatus(buildId); Assert.assertNotNull(build); Assert.assertTrue(build.getStatus().contains("FAIL")); }