Search in sources :

Example 26 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class SetParentIT method setParent.

@Test
public void setParent() throws Exception {
    String parent = createProject("parent", null, true).get();
    RestResponse r = adminRestSession.put("/projects/" + project.get() + "/parent", newParentInput(parent));
    r.assertOK();
    r.consume();
    r = adminRestSession.get("/projects/" + project.get() + "/parent");
    r.assertOK();
    String newParent = newGson().fromJson(r.getReader(), String.class);
    assertThat(newParent).isEqualTo(parent);
    r.consume();
    // When the parent name is not explicitly set, it should be
    // set to "All-Projects".
    r = adminRestSession.put("/projects/" + project.get() + "/parent", newParentInput(null));
    r.assertOK();
    r.consume();
    r = adminRestSession.get("/projects/" + project.get() + "/parent");
    r.assertOK();
    newParent = newGson().fromJson(r.getReader(), String.class);
    assertThat(newParent).isEqualTo(AllProjectsNameProvider.DEFAULT);
    r.consume();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 27 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class SetParentIT method setInvalidParent_Conflict.

@Test
public void setInvalidParent_Conflict() throws Exception {
    RestResponse r = adminRestSession.put("/projects/" + project.get() + "/parent", newParentInput(project.get()));
    r.assertConflict();
    r.consume();
    Project.NameKey child = createProject("child", project, true);
    r = adminRestSession.put("/projects/" + project.get() + "/parent", newParentInput(child.get()));
    r.assertConflict();
    r.consume();
    String grandchild = createProject("grandchild", child, true).get();
    r = adminRestSession.put("/projects/" + project.get() + "/parent", newParentInput(grandchild));
    r.assertConflict();
    r.consume();
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) RestResponse(com.google.gerrit.acceptance.RestResponse) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 28 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class SetParentIT method setNonExistingParent_UnprocessibleEntity.

@Test
public void setNonExistingParent_UnprocessibleEntity() throws Exception {
    RestResponse r = adminRestSession.put("/projects/" + project.get() + "/parent", newParentInput("non-existing"));
    r.assertUnprocessableEntity();
    r.consume();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 29 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class SetParentIT method setParent_Forbidden.

@Test
public void setParent_Forbidden() throws Exception {
    String parent = createProject("parent", null, true).get();
    RestResponse r = userRestSession.put("/projects/" + project.get() + "/parent", newParentInput(parent));
    r.assertForbidden();
    r.consume();
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 30 with RestResponse

use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.

the class EmailIT method getEmails.

private Set<String> getEmails() throws Exception {
    RestResponse r = adminRestSession.get("/accounts/self/emails");
    r.assertOK();
    List<EmailInfo> emails = newGson().fromJson(r.getReader(), new TypeToken<List<EmailInfo>>() {
    }.getType());
    return emails.stream().map(e -> e.email).collect(toSet());
}
Also used : List(java.util.List) TypeToken(com.google.gson.reflect.TypeToken) EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) RestResponse(com.google.gerrit.acceptance.RestResponse) Set(java.util.Set) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) Collectors.toSet(java.util.stream.Collectors.toSet) EmailInfo(com.google.gerrit.extensions.common.EmailInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken) EmailInfo(com.google.gerrit.extensions.common.EmailInfo)

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