Search in sources :

Example 36 with RestResponse

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;
}
Also used : Header(org.apache.http.Header) BasicHeader(org.apache.http.message.BasicHeader) RestResponse(com.google.gerrit.acceptance.RestResponse) BasicHeader(org.apache.http.message.BasicHeader)

Example 37 with RestResponse

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();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) GeneralPreferencesInfo(com.google.gerrit.extensions.client.GeneralPreferencesInfo)

Example 38 with RestResponse

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;
}
Also used : RelatedInfo(com.google.gerrit.server.change.GetRelated.RelatedInfo) RestResponse(com.google.gerrit.acceptance.RestResponse)

Example 39 with RestResponse

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();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 40 with RestResponse

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));
}
Also used : AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput) TestProjectInput(com.google.gerrit.acceptance.TestProjectInput) PublishChangeEditInput(com.google.gerrit.extensions.api.changes.PublishChangeEditInput) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) RestResponse(com.google.gerrit.acceptance.RestResponse) Put(com.google.gerrit.server.change.ChangeEdits.Put) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

RestResponse (com.google.gerrit.acceptance.RestResponse)79 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)67 Test (org.junit.Test)67 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)17 TypeToken (com.google.gson.reflect.TypeToken)15 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)9 CacheInfo (com.google.gerrit.server.config.ListCaches.CacheInfo)6 TaskInfo (com.google.gerrit.server.config.ListTasks.TaskInfo)6 ReviewResult (com.google.gerrit.extensions.api.changes.ReviewResult)5 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)5 Result (com.google.gerrit.acceptance.PushOneCommit.Result)4 AccountExternalIdInfo (com.google.gerrit.extensions.common.AccountExternalIdInfo)4 LabelInfo (com.google.gerrit.extensions.common.LabelInfo)4 ArrayList (java.util.ArrayList)4 ApprovalInfo (com.google.gerrit.extensions.common.ApprovalInfo)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 TestProjectInput (com.google.gerrit.acceptance.TestProjectInput)2 EmailInput (com.google.gerrit.extensions.api.accounts.EmailInput)2 AddReviewerInput (com.google.gerrit.extensions.api.changes.AddReviewerInput)2 PublishChangeEditInput (com.google.gerrit.extensions.api.changes.PublishChangeEditInput)2