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());
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class EmailIT method createEmail.
private void createEmail(String email) throws Exception {
EmailInput input = new EmailInput();
input.noConfirmation = true;
RestResponse r = adminRestSession.put("/accounts/self/emails/" + email, input);
r.assertCreated();
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ExternalIdIT method getExternalIds.
@Test
public void getExternalIds() throws Exception {
Collection<ExternalId> expectedIds = accountCache.get(user.getId()).getExternalIds();
List<AccountExternalIdInfo> expectedIdInfos = toExternalIdInfos(expectedIds);
RestResponse response = userRestSession.get("/accounts/self/external.ids");
response.assertOK();
List<AccountExternalIdInfo> results = newGson().fromJson(response.getReader(), new TypeToken<List<AccountExternalIdInfo>>() {
}.getType());
Collections.sort(expectedIdInfos);
Collections.sort(results);
assertThat(results).containsExactlyElementsIn(expectedIdInfos);
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class CapabilitiesIT method capabilitiesAdmin.
@Test
public void capabilitiesAdmin() throws Exception {
RestResponse r = adminRestSession.get("/accounts/self/capabilities");
r.assertOK();
CapabilityInfo info = (new Gson()).fromJson(r.getReader(), new TypeToken<CapabilityInfo>() {
}.getType());
for (String c : GlobalCapability.getAllNames()) {
if (BATCH_CHANGES_LIMIT.equals(c)) {
// It does not have default value for any user as it can override the
// 'receive.batchChangesLimit'. It needs to be granted explicitly.
assertThat(info.batchChangesLimit).isNull();
} else if (PRIORITY.equals(c)) {
assertThat(info.priority).isFalse();
} else if (QUERY_LIMIT.equals(c)) {
assert_().withFailureMessage("missing queryLimit").that(info.queryLimit).isNotNull();
assertThat(info.queryLimit.min).isEqualTo((short) 0);
assertThat(info.queryLimit.max).isEqualTo((short) DEFAULT_MAX_QUERY_LIMIT);
} else if (ACCESS_DATABASE.equals(c)) {
assertThat(info.accessDatabase).isFalse();
} else if (RUN_AS.equals(c)) {
assertThat(info.runAs).isFalse();
} else {
assert_().withFailureMessage(String.format("capability %s was not granted", c)).that((Boolean) CapabilityInfo.class.getField(c).get(info)).isTrue();
}
}
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method removingReviewerRemovesTheirVote.
@Test
public void removingReviewerRemovesTheirVote() throws Exception {
String crLabel = "Code-Review";
PushOneCommit.Result r = createChange();
ReviewInput input = ReviewInput.approve().reviewer(admin.email);
ReviewResult addResult = review(r.getChangeId(), r.getCommit().name(), input);
assertThat(addResult.reviewers).isNotNull();
assertThat(addResult.reviewers).hasSize(1);
Map<String, LabelInfo> changeLabels = getChangeLabels(r.getChangeId());
assertThat(changeLabels.get(crLabel).all).hasSize(1);
RestResponse deleteResult = deleteReviewer(r.getChangeId(), admin);
deleteResult.assertNoContent();
changeLabels = getChangeLabels(r.getChangeId());
assertThat(changeLabels.get(crLabel).all).isNull();
// Check that the vote is gone even after the reviewer is added back
addReviewer(r.getChangeId(), admin.email);
changeLabels = getChangeLabels(r.getChangeId());
assertThat(changeLabels.get(crLabel).all).isNull();
}
Aggregations