protected HttpResponse programStatus(Id.Program program) throws Exception { String path = String.format( "apps/%s/%s/%s/status", program.getApplicationId(), program.getType().getCategoryName(), program.getId()); return doGet(getVersionedAPIPath(path, program.getNamespaceId())); }
/** * Tries to start the given program with the given runtime arguments and expect the call completed * with the status. */ protected void startProgram(Id.Program program, Map<String, String> args, int expectedStatusCode) throws Exception { String path = String.format( "apps/%s/%s/%s/start", program.getApplicationId(), program.getType().getCategoryName(), program.getId()); HttpResponse response = doPost(getVersionedAPIPath(path, program.getNamespaceId()), GSON.toJson(args)); Assert.assertEquals(expectedStatusCode, response.getStatusLine().getStatusCode()); }
protected void stopProgram(Id.Program program, int expectedStatusCode, String runId) throws Exception { String path; if (runId == null) { path = String.format( "apps/%s/%s/%s/stop", program.getApplicationId(), program.getType().getCategoryName(), program.getId()); } else { path = String.format( "apps/%s/%s/%s/runs/%s/stop", program.getApplicationId(), program.getType().getCategoryName(), program.getId(), runId); } HttpResponse response = doPost(getVersionedAPIPath(path, program.getNamespaceId())); Assert.assertEquals(expectedStatusCode, response.getStatusLine().getStatusCode()); }
protected List<RunRecord> getProgramRuns(Id.Program program, String status) throws Exception { String path = String.format( "apps/%s/%s/%s/runs?status=%s", program.getApplicationId(), program.getType().getCategoryName(), program.getId(), status); HttpResponse response = doGet(getVersionedAPIPath(path, program.getNamespaceId())); Assert.assertEquals(200, response.getStatusLine().getStatusCode()); String json = EntityUtils.toString(response.getEntity()); return GSON.fromJson(json, LIST_RUNRECORD_TYPE); }