use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ChangeEditIT method files.
@Test
public void files() throws Exception {
createEmptyEditFor(changeId);
gApi.changes().id(changeId).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
Optional<EditInfo> edit = getEdit(changeId);
assertThat(edit).isPresent();
String editCommitId = edit.get().commit.commit;
RestResponse r = adminRestSession.getJsonAccept(urlRevisionFiles(changeId, editCommitId));
Map<String, FileInfo> files = readContentFromJson(r, new TypeToken<Map<String, FileInfo>>() {
});
assertThat(files).containsKey(FILE_NAME);
r = adminRestSession.getJsonAccept(urlRevisionFiles(changeId));
files = readContentFromJson(r, new TypeToken<Map<String, FileInfo>>() {
});
assertThat(files).containsKey(FILE_NAME);
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class ChangeEditIT method updateMessageRest.
@Test
public void updateMessageRest() throws Exception {
adminRestSession.get(urlEditMessage(changeId, false)).assertNotFound();
EditMessage.Input in = new EditMessage.Input();
in.message = String.format("New commit message\n\n" + CONTENT_NEW2_STR + "\n\nChange-Id: %s\n", changeId);
adminRestSession.put(urlEditMessage(changeId, false), in).assertNoContent();
RestResponse r = adminRestSession.getJsonAccept(urlEditMessage(changeId, false));
r.assertOK();
assertThat(readContentFromJson(r)).isEqualTo(in.message);
String commitMessage = gApi.changes().id(changeId).edit().getCommitMessage();
assertThat(commitMessage).isEqualTo(in.message);
in.message = String.format("New commit message2\n\nChange-Id: %s\n", changeId);
adminRestSession.put(urlEditMessage(changeId, false), in).assertNoContent();
String updatedCommitMessage = gApi.changes().id(changeId).edit().getCommitMessage();
assertThat(updatedCommitMessage).isEqualTo(in.message);
r = adminRestSession.getJsonAccept(urlEditMessage(changeId, true));
try (Repository repo = repoManager.openRepository(project);
RevWalk rw = new RevWalk(repo)) {
RevCommit commit = rw.parseCommit(ObjectId.fromString(ps.getRevision().get()));
assertThat(readContentFromJson(r)).isEqualTo(commit.getFullMessage());
}
PublishChangeEditInput publishInput = new PublishChangeEditInput();
publishInput.notify = NotifyHandling.NONE;
gApi.changes().id(changeId).edit().publish(publishInput);
assertChangeMessages(changeId, ImmutableList.of("Uploaded patch set 1.", "Uploaded patch set 2.", "Patch Set 3: Commit message was updated."));
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class BanCommitIT method banCommit.
@Test
public void banCommit() throws Exception {
RevCommit c = commitBuilder().add("a.txt", "some content").create();
RestResponse r = adminRestSession.put("/projects/" + project.get() + "/ban/", BanCommit.Input.fromCommits(c.name()));
r.assertOK();
BanResultInfo info = newGson().fromJson(r.getReader(), BanResultInfo.class);
assertThat(Iterables.getOnlyElement(info.newlyBanned)).isEqualTo(c.name());
assertThat(info.alreadyBanned).isNull();
assertThat(info.ignored).isNull();
RemoteRefUpdate u = pushHead(testRepo, "refs/heads/master", false).getRemoteUpdate("refs/heads/master");
assertThat(u).isNotNull();
assertThat(u.getStatus()).isEqualTo(REJECTED_OTHER_REASON);
assertThat(u.getMessage()).startsWith("contains banned commit");
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class CheckMergeabilityIT method assertBadRequest.
private void assertBadRequest(String targetBranch, String source, String strategy, String errMsg) throws Exception {
String url = "/projects/" + project.get() + "/branches/" + targetBranch;
url += "/mergeable?source=" + source;
if (!Strings.isNullOrEmpty(strategy)) {
url += "&strategy=" + strategy;
}
RestResponse r = userRestSession.get(url);
r.assertBadRequest();
assertThat(r.getEntityContent()).isEqualTo(errMsg);
}
use of com.google.gerrit.acceptance.RestResponse in project gerrit by GerritCodeReview.
the class CacheOperationsIT method flush_UnprocessableEntity.
@Test
public void flush_UnprocessableEntity() throws Exception {
RestResponse r = adminRestSession.getOK("/config/server/caches/projects");
CacheInfo cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
r = adminRestSession.post("/config/server/caches/", new PostCaches.Input(FLUSH, Arrays.asList("projects", "unprocessable")));
r.assertUnprocessableEntity();
r.consume();
r = adminRestSession.getOK("/config/server/caches/projects");
cacheInfo = newGson().fromJson(r.getReader(), CacheInfo.class);
assertThat(cacheInfo.entries.mem).isGreaterThan((long) 0);
}
Aggregations