use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class CorsIT method check.
private RestResponse check(String url, boolean accept, String origin) throws Exception {
Header hdr = new BasicHeader(ORIGIN, origin);
RestResponse r = adminRestSession.getWithHeader(url, hdr);
r.assertOK();
checkCors(r, accept, origin);
return r;
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class CreateChangeIT method setSignedOffByFooter.
// TODO(davido): Expose setting of account preferences in the API
private void setSignedOffByFooter() throws Exception {
RestResponse r = adminRestSession.get("/accounts/" + admin.email + "/preferences");
r.assertOK();
GeneralPreferencesInfo i = newGson().fromJson(r.getReader(), GeneralPreferencesInfo.class);
i.signedOffBy = true;
r = adminRestSession.put("/accounts/" + admin.email + "/preferences", i);
r.assertOK();
GeneralPreferencesInfo o = newGson().fromJson(r.getReader(), GeneralPreferencesInfo.class);
assertThat(o.signedOffBy).isTrue();
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class GetRelatedIT method getRelated.
private List<ChangeAndCommit> getRelated(Change.Id changeId, int ps) throws Exception {
String url = String.format("/changes/%d/revisions/%d/related", changeId.get(), ps);
RestResponse r = adminRestSession.get(url);
r.assertOK();
return newGson().fromJson(r.getReader(), RelatedInfo.class).changes;
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class RevisionIT method contentType.
@Test
public void contentType() throws Exception {
PushOneCommit.Result r = createChange();
String endPoint = "/changes/" + r.getChangeId() + "/revisions/" + r.getCommit().name() + "/files/" + FILE_NAME + "/content";
RestResponse response = adminRestSession.head(endPoint);
response.assertOK();
assertThat(response.getContentType()).startsWith("text/plain");
assertThat(response.hasContent()).isFalse();
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ChangeEditIT method getFileContentRest.
@Test
public void getFileContentRest() throws Exception {
Put.Input in = new Put.Input();
in.content = RawInputUtil.create(CONTENT_NEW);
adminRestSession.putRaw(urlEditFile(changeId, FILE_NAME), in.content).assertNoContent();
gApi.changes().id(changeId).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW2));
RestResponse r = adminRestSession.getJsonAccept(urlEditFile(changeId, FILE_NAME));
r.assertOK();
assertThat(readContentFromJson(r)).isEqualTo(new String(CONTENT_NEW2, UTF_8));
r = adminRestSession.getJsonAccept(urlEditFile(changeId, FILE_NAME, true));
r.assertOK();
assertThat(readContentFromJson(r)).isEqualTo(new String(CONTENT_OLD, UTF_8));
}
Aggregations