use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.
the class RefOperationValidationIT method rejectRefCreation.
@Test
public void rejectRefCreation() throws Exception {
try (Registration registration = testValidator(CREATE)) {
RestApiException expected = assertThrows(RestApiException.class, () -> gApi.projects().name(project.get()).branch(TEST_REF).create(new BranchInput()));
assertThat(expected).hasMessageThat().contains(CREATE.name());
}
}
use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.
the class AbstractSubmit method submit.
protected void submit(String changeId, SubmitInput input, @Nullable Class<? extends RestApiException> expectedExceptionType, String expectedExceptionMsg) throws Throwable {
approve(changeId);
if (expectedExceptionType == null) {
assertSubmittable(changeId);
} else {
requireNonNull(expectedExceptionMsg);
}
ThrowingRunnable submit = () -> gApi.changes().id(changeId).current().submit(input);
if (expectedExceptionType != null) {
RestApiException thrown = assertThrows(expectedExceptionType, submit);
assertThat(thrown).hasMessageThat().isEqualTo(expectedExceptionMsg);
return;
}
submit.run();
ChangeInfo change = gApi.changes().id(changeId).info();
assertMerged(change.changeId);
}
use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.
the class CreateBranchIT method assertCreateFails.
private void assertCreateFails(BranchNameKey branch, String revision, Class<? extends RestApiException> errType, String errMsg) throws Exception {
BranchInput in = new BranchInput();
in.revision = revision;
RestApiException thrown = assertThrows(errType, () -> branch(branch).create(in));
if (errMsg != null) {
assertThat(thrown).hasMessageThat().contains(errMsg);
}
}
Aggregations