use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class AgreementsIT method signAgreementNoAutoVerify.
@Test
public void signAgreementNoAutoVerify() throws Exception {
assume().that(isContributorAgreementsEnabled()).isTrue();
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.accounts().self().signAgreement(caNoAutoVerify.getName()));
assertThat(thrown).hasMessageThat().contains("cannot enter a non-autoVerify agreement");
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class PluginOperatorsIT method getChangeWithIsOperator.
@Test
public void getChangeWithIsOperator() throws Exception {
QueryChanges queryChanges = queryChangesProvider.get();
queryChanges.addQuery("is:changeNumberEven_myplugin");
String oddChangeId = createChange().getChangeId();
String evenChangeId = createChange().getChangeId();
BadRequestException exception = assertThrows(BadRequestException.class, () -> getChanges(queryChanges));
assertThat(exception).hasMessageThat().isEqualTo("Unrecognized value: changeNumberEven_myplugin");
try (AutoCloseable ignored = installPlugin("myplugin", IsOperatorModule.class)) {
List<?> changes = getChanges(queryChanges);
assertThat(changes).hasSize(1);
ChangeInfo c = (ChangeInfo) changes.get(0);
String outputChangeId = c.changeId;
assertThat(outputChangeId).isEqualTo(evenChangeId);
assertThat(outputChangeId).isNotEqualTo(oddChangeId);
}
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class PrivateChangeIT method cannotSetMergedChangePrivate.
@Test
public void cannotSetMergedChangePrivate() throws Exception {
PushOneCommit.Result result = createChange();
approve(result.getChangeId());
merge(result);
String changeId = result.getChangeId();
assertThat(gApi.changes().id(changeId).get().isPrivate).isNull();
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.changes().id(changeId).setPrivate(true));
assertThat(thrown).hasMessageThat().contains("cannot set merged change to private");
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class SuggestReviewersIT method suggestReviewersTooManyQueryTerms.
@Test
@GerritConfig(name = "index.maxTerms", value = "10")
public void suggestReviewersTooManyQueryTerms() throws Exception {
String changeId = createChange().getChangeId();
// Do a query which doesn't exceed index.maxTerms succeeds (add only 9 terms, since on
// 'inactive:1' term is implicitly added) and assert that a result is returned
StringBuilder query = new StringBuilder();
for (int i = 1; i <= 9; i++) {
query.append(name("u")).append(" ");
}
assertThat(suggestReviewers(changeId, query.toString())).isNotEmpty();
// Do a query which exceed index.maxTerms succeeds (10 terms plus 'inactive:1' term which is
// implicitly added).
query.append(name("u"));
BadRequestException exception = assertThrows(BadRequestException.class, () -> suggestReviewers(changeId, query.toString()));
assertThat(exception).hasMessageThat().isEqualTo("too many terms in query");
}
use of com.google.gerrit.extensions.restapi.BadRequestException in project gerrit by GerritCodeReview.
the class HashtagsIT method addInvalidHashtag.
@Test
public void addInvalidHashtag() throws Exception {
PushOneCommit.Result r = createChange();
BadRequestException thrown = assertThrows(BadRequestException.class, () -> addHashtags(r, "invalid,hashtag"));
assertThat(thrown).hasMessageThat().contains("hashtags may not contain commas");
}
Aggregations