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();
}
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();
}
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();
}
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();
}
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());
}
Aggregations